geodezyx.utils package¶
Submodules¶
geodezyx.utils.dict_utils module¶
@author: psakic
This sub-module of geodezyx.utils contains functions for operations related to Python’s dictionary manipulations.
it can be imported directly with: from geodezyx import utils
The GeodeZYX Toolbox is a software for simple but useful functions for Geodesy and Geophysics under the GNU GPL v3 License
Copyright (C) 2019 Pierre Sakic et al. (GFZ, pierre.sakic@gfz-postdam.de) GitHub repository : https://github.com/GeodeZYX/GeodeZYX-Toolbox_v4
- geodezyx.utils.dict_utils.dic_key_for_vals_list_finder(dic_in, value_in)¶
- dic_in is a dict like :
dic_in[key1] = [val1a , val1b] dic_in[key2] = [val2a , val2b , val2c]
E.g. if value_in = val2b then the function returns key2
- NBthe function returns the first value found, then
dic_in has to be injective !!
- geodezyx.utils.dict_utils.dicts_merge(*dict_args)¶
Given any number of dicts, shallow copy and merge into a new dict, precedence goes to key value pairs in latter dicts.
WARN : first values will be erased if the same key is present in following dicts !!!
- geodezyx.utils.dict_utils.dicts_of_list_merge(*dict_args)¶
- geodezyx.utils.dict_utils.dicts_of_list_merge_mono(dol1, dol2)¶
https://stackoverflow.com/questions/1495510/combining-dictionaries-of-lists-in-python
geodezyx.utils.list_utils module¶
@author: psakic
This sub-module of geodezyx.utils contains functions for operations related to Python’s list manipulations.
it can be imported directly with: from geodezyx import utils
The GeodeZYX Toolbox is a software for simple but useful functions for Geodesy and Geophysics under the GNU GPL v3 License
Copyright (C) 2019 Pierre Sakic et al. (GFZ, pierre.sakic@gfz-postdam.de) GitHub repository : https://github.com/GeodeZYX/GeodeZYX-Toolbox_v4
- geodezyx.utils.list_utils.chunkIt(seq, num)¶
make num sublists of a list
- geodezyx.utils.list_utils.consecutive_groupIt(data, only_start_end=False)¶
Identify groups of continuous numbers in a list
Useful for time period with a prealable conversion to MJD
Source : https://stackoverflow.com/questions/2154249/identify-groups-of-continuous-numbers-in-a-list
- geodezyx.utils.list_utils.decimateIt(listin, n)¶
n so as np.mod(i,n) == 0
- geodezyx.utils.list_utils.df_sel_val_in_col(DF, col_name, col_val)¶
Return a selected value of a column in a DataFrame i.e. return DF[DF[col_name] == col_val]
- geodezyx.utils.list_utils.dicofdic(mat, names)¶
- geodezyx.utils.list_utils.duplicates_finder(seq)¶
from http://stackoverflow.com/questions/9835762/find-and-list-duplicates-in-python-list moooeeeep solution
- geodezyx.utils.list_utils.find_common_elts(*lists)¶
Find common elements in different lists
- geodezyx.utils.list_utils.find_index_multi_occurences(L, elt)¶
- geodezyx.utils.list_utils.find_interval_bound(listin, val, outindexes=True)¶
trouve les bornes d’un intervalle (listin est supposé triée)
- geodezyx.utils.list_utils.find_nearest(listin, value)¶
- Returns
value of the nearest , index of the nearest
- geodezyx.utils.list_utils.find_regex_in_list(regex, L, only_first_occurence=False, line_number=False)¶
- geodezyx.utils.list_utils.find_surrounding(L, v)¶
find the surrounding values
- Parameters
L (Iterable) – Input list/array.
- Returns
surrounding_values (tuple) – surounding values.
surrounding_index (tuple) – surounding indexes.
- geodezyx.utils.list_utils.get_interval(start, end, delta)¶
- geodezyx.utils.list_utils.groups_near_central_values(A, tol, B=None)¶
beta … bug if tol is bad tol : absolute tolerance 170514 : B is an annex list
- geodezyx.utils.list_utils.identical_consecutive_eltsIt(Lin)¶
- geodezyx.utils.list_utils.identical_groupIt(data)¶
- geodezyx.utils.list_utils.is_listoflist(inp)¶
check if inp is a list of list [[…] , […] , … ,[…]]
- geodezyx.utils.list_utils.median_improved(L)¶
manage the case where len(L) is even in this case, doesn’t return the mean of the 2 medians, but the nearest value
- geodezyx.utils.list_utils.middle(Lin)¶
- geodezyx.utils.list_utils.minmax(L)¶
- geodezyx.utils.list_utils.most_common(lst)¶
http://stackoverflow.com/questions/1518522/python-most-common-element-in-a-list
- geodezyx.utils.list_utils.occurence(L, tolerence=None, pretty_output=False)¶
- Input :
- tolerencetolerence to find close elements of L
if no tolerence is given then a set() is used
- Returns :
- if pretty_output = False :
return a list of 2-tuples : (element of the list, number of occurence of this element in the list)
if pretty_output 0 True :
- Notapretty_output is implemented because the first mode is not really useful (180612)
the equal test is also replaced by is close
- geodezyx.utils.list_utils.second_smallest(numbers)¶
- geodezyx.utils.list_utils.shrink_listoflist(lin)¶
if lin (list in) is a list of list and contains only one element then returns the sublist, e.g. : [[a,b,c]] => [a,b,c]
- geodezyx.utils.list_utils.sliceIt(seq, num)¶
make sublist of num elts of a list
- geodezyx.utils.list_utils.sort_binom_list(X, Y, array_out=False)¶
sort Y according to X and sort X
- geodezyx.utils.list_utils.sort_multinom_list(X, *Y)¶
sort Y according to X and sort X
- geodezyx.utils.list_utils.sort_table(table, col)¶
sort a table by multiple columns table: a list of lists (or tuple of tuples) where each inner list
represents a row
cols: specifying the column numbers to sort by
- geodezyx.utils.list_utils.sublistsIt(seq, lenofsublis_lis, output_array=False)¶
make sublists of seq , accoding to len of the sublist in lenofsublis_lis ex lenofsublis_lis = [2,3,4,2]
if output_array : output list of array , else list of list
(fct perso)
- geodezyx.utils.list_utils.trio_lists_2_tab(Xlis, Ylis, Vlis)¶
From a trio of lists Xlis => parameter you want in columns Ylis => parameter you want in rows Vlis => data(X,Y)
make a tab compatible with mabular module tabulate(Finalis, headers=”firstrow”)
NB : very dirty research of the elements …
- geodezyx.utils.list_utils.uniq_and_sort(L, natural_sort=True)¶
In a list, remove duplicates and sort the list
- geodezyx.utils.list_utils.uniq_set_list(setlis, frozen=True)¶
uniqify a list of sets
- geodezyx.utils.list_utils.uniqify_list(seq, idfun=None)¶
order preserving uniq function based on https://www.peterbe.com/plog/uniqifiers-benchmark
- geodezyx.utils.list_utils.uniqify_list_of_lists(L)¶
source http://stackoverflow.com/questions/3724551/python-uniqueness-for-list-of-lists
- geodezyx.utils.list_utils.uniquetol(A, tol)¶
tol : absolute tolerance source http://stackoverflow.com/questions/37847053/uniquify-an-array-list-with-a-tolerance-in-python-uniquetol-equivalent
- geodezyx.utils.list_utils.uniquetol2(A, tol=1e-06)¶
This one is faster https://stackoverflow.com/questions/5426908/find-unique-elements-of-floating-point-array-in-numpy-with-comparison-using-a-d
geodezyx.utils.pandas_utils module¶
@author: psakic
This sub-module of geodezyx.utils contains functions for operations related to Python’s Pandas object manipulations.
it can be imported directly with: from geodezyx import utils
The GeodeZYX Toolbox is a software for simple but useful functions for Geodesy and Geophysics under the GNU GPL v3 License
Copyright (C) 2019 Pierre Sakic et al. (GFZ, pierre.sakic@gfz-postdam.de) GitHub repository : https://github.com/GeodeZYX/GeodeZYX-Toolbox_v4
- geodezyx.utils.pandas_utils.diff_pandas(DF, col_name)¶
Differentiate a Pandas DataFrame, if index is time
- Parameters
DF (Pandas DataFrame) – input DataFrame
col_name (str) – the column of the DataFrame you want to differentiate
- Returns
DSout – Differenciated column of the input DataFrame
- Return type
Pandas DataFrame
- geodezyx.utils.pandas_utils.pandas_DF_2_tuple_serie(DFin, columns_name_list, reset_index_first=False)¶
This function is made to solve the multiple columns selection problem the idea is :
S1 = pandas_DF_2_tuple_serie(DF1 , columns_name_list) S2 = pandas_DF_2_tuple_serie(DF2 , columns_name_list) BOOL = S1.isin(S2) DF1[BOOL]
- geodezyx.utils.pandas_utils.pandas_DF_print(DFin)¶
- geodezyx.utils.pandas_utils.pandas_column_rename_dic(*inpnames)¶
wrapper of renamedic_fast_4_pandas
EXEMPLE : rnamedic = utils.renamedic_fast_4_pandas(*[“zmax”,”ang”,”zsmooth”,”smoothtype”,”xgrad”,”ygrad”,
‘r_eiko’,’z_eiko’,’pt_eiko_x’,’pt_eiko_y’,”t_eiko”, ‘r_sd’, ‘z_sd’, ‘pt_sd_x’ ,’pt_sd_y’ ,’t_sd’, ‘diff_x’,’diff_y’,’diff’,’diff_t’])
pda = pda.rename(columns = rnamedic)
- geodezyx.utils.pandas_utils.renamedic_fast_4_pandas(*inpnames)¶
EXEMPLE : rnamedic = utils.renamedic_fast_4_pandas(*[“zmax”,”ang”,”zsmooth”,”smoothtype”,”xgrad”,”ygrad”,
‘r_eiko’,’z_eiko’,’pt_eiko_x’,’pt_eiko_y’,”t_eiko”, ‘r_sd’, ‘z_sd’, ‘pt_sd_x’ ,’pt_sd_y’ ,’t_sd’, ‘diff_x’,’diff_y’,’diff’,’diff_t’])
pda = pda.rename(columns = rnamedic)
- geodezyx.utils.pandas_utils.weighted_average(df, data_col, weight_col, by_col)¶
geodezyx.utils.plot_utils module¶
@author: psakic
This sub-module of geodezyx.utils contains functions for operations related to Python’s plot operations.
it can be imported directly with: from geodezyx import utils
The GeodeZYX Toolbox is a software for simple but useful functions for Geodesy and Geophysics under the GNU GPL v3 License
Copyright (C) 2019 Pierre Sakic et al. (GFZ, pierre.sakic@gfz-postdam.de) GitHub repository : https://github.com/GeodeZYX/GeodeZYX-Toolbox_v4
- geodezyx.utils.plot_utils.axis_data_coords_sys_transform(axis_obj_in, xin, yin, inverse=False)¶
inverse = False : Axis => Data = True : Data => Axis
- geodezyx.utils.plot_utils.color_list(L, colormap='jet')¶
- geodezyx.utils.plot_utils.colors_from_colormap_getter(ncolors, colormap='viridis')¶
- geodezyx.utils.plot_utils.figure_saver(figobjt_in, outdir, outname, outtype=('.png', '.pdf', '.figpik'), formt=None, dpi=200, transparent=False)¶
- geodezyx.utils.plot_utils.gaussian_for_plot(D, density=False, nbins=500, nsigma=3.5)¶
generate a gaussian curve for histogram plot
- Parameters
D (iterable) – data vector.
density (bool, optional) – Adapted curve for desity mode. The default is False.
nbins (int, optional) – number of bins. The default is 500.
nsigma (TYPE, optional) – n sigmas for the x axis. The default is 3.5.
- Returns
Xpdf (array) – gaussian curve x.
Ypdf_out (TYPE) – gaussian curve x.
- geodezyx.utils.plot_utils.get_figure(figin=0)¶
- geodezyx.utils.plot_utils.id2val(value_lis, id_lis, idin)¶
from a value list and a id pointer list return the good val from the good id replace dico bc. set is not supproted as key
- geodezyx.utils.plot_utils.set_size_for_pub(width=418.25368, fraction=1, subplot=[1, 1])¶
Set aesthetic figure dimensions to avoid scaling in latex.
- Parameters
width (float) – Width in pts
fraction (float) – Fraction of the width which you wish the figure to occupy
- Returns
fig_dim – Dimensions of figure in inches
- Return type
tuple
- geodezyx.utils.plot_utils.symbols_list(L=None)¶
- geodezyx.utils.plot_utils.ylim_easy(Lin, delta=0.1, min_null_if_neg=False)¶
geodezyx.utils.shell_like module¶
@author: psakic
- This sub-module of geodezyx.utils contains functions for Shell-like
operations in Python.
it can be imported directly with: from geodezyx import utils
The GeodeZYX Toolbox is a software for simple but useful functions for Geodesy and Geophysics under the GNU GPL v3 License
Copyright (C) 2019 Pierre Sakic et al. (GFZ, pierre.sakic@gfz-postdam.de) GitHub repository : https://github.com/GeodeZYX/GeodeZYX-Toolbox_v4
- geodezyx.utils.shell_like.cat(outfilename, *infilenames)¶
Is for concatenating files … For just a print, use cat_print ! http://stackoverflow.com/questions/11532980/reproduce-the-unix-cat-command-in-python
kindall response
- geodezyx.utils.shell_like.cat_print(inpfile)¶
- geodezyx.utils.shell_like.cat_remove_header(infilepath, outfilepath, header='', header_included=False)¶
- geodezyx.utils.shell_like.check_regex(filein, regex)¶
verfie si un fichier contient une regex retourne un booleen
- geodezyx.utils.shell_like.create_dir(directory)¶
- geodezyx.utils.shell_like.egrep_big_string(regex, bigstring, only_first_occur=False)¶
perform a regex grep on a big string sepatated with
NB : must be improved with regular pattern matching, wo regex
- geodezyx.utils.shell_like.empty_file_check(fpath)¶
Check if a file is empty or not. NB : Also check if the file exists
- Parameters
fpath (str) – the file path
- Returns
True – if the file is empty
False – if the file is not empty
Source
——
http (//stackoverflow.com/questions/2507808/python-how-to-check-file-empty-or-not)
- geodezyx.utils.shell_like.fileprint(output, outfile)¶
- geodezyx.utils.shell_like.find_recursive(parent_folder, pattern, sort_results=True, case_sensitive=True, extended_file_stats=False, warn_if_empty=True)¶
Find files in a folder and his sub-folders in a recursive way
- Parameters
parent_folder (str) – the parent folder path
pattern (str) – the researched files pattern name (can manage wildcard or regex) * wildcard (only * and ?) for case_sensitive = True * regex for case_sensitive = False
sort_results (bool) – Sort results
case_sensitive (bool) – Case sensitve or not
extended_file_stats (bool) –
if True, returns the stats of the files the outputed matches list will be a list of tuples (file_path,stat_object), where stat_object has the following attributes
st_mode - protection bits,
st_ino - inode number,
st_dev - device,
st_nlink - number of hard links,
st_uid - user id of owner,
st_gid - group id of owner,
st_size - size of file, in bytes,
st_atime - time of most recent access,
st_mtime - time of most recent content modification,
- st_ctime - platform dependent; time of most recent metadata
change on Unix, or the time of creation on Windows)
- Returns
matches (list) – Found files
Source
——
https (//stackoverflow.com/questions/2186525/use-a-glob-to-find-files-recursively-in-python)
https (//stackoverflow.com/questions/15652594/how-to-find-files-with-specific-case-insensitive-extension-names-in-python)
(for the case unsensitive case)
- geodezyx.utils.shell_like.glob_smart(dir_path, file_pattern=None, verbose=True)¶
- geodezyx.utils.shell_like.grep(file_in, search_string, only_first_occur=False, invert=False, regex=False, line_number=False, col=(None, None), force_list_output=False)¶
if nothing is found returns a empty string : “” (and NOT a singleton list with an empty string inside)
- Args :
- colDefine the columns where the grep is executed
(Not delimited columns , one character = a new column) from 1st col. / until last col. : use None as index
force_list_output : if the output is an unique element, it will be returned in a list anyway
search_string can be a list (150721 change)
- geodezyx.utils.shell_like.grep_boolean(file_in, search_string)¶
- geodezyx.utils.shell_like.head(filename, count=1)¶
This one is fairly trivial to implement but it is here for completeness.
- geodezyx.utils.shell_like.insert_lines_in_file(file_path, text_values, lines_ids)¶
- geodezyx.utils.shell_like.insert_str_in_file_if_line_contains(file_path, str_to_insert, line_pattern_tup, position=None, only_first_occur=False)¶
NB : position is not implemented
- geodezyx.utils.shell_like.regex2filelist(dossier, regex, outtype='file')¶
a partir d’un chemin de dossier et d’une regex, donne les éléments du dossier correspondant à la regex
OUTTYPE : file : juste les fichiers
- geodezyx.utils.shell_like.regex_OR_from_list(listin)¶
- geodezyx.utils.shell_like.remove_dir(directory)¶
- geodezyx.utils.shell_like.replace(file_path, pattern, subst)¶
Replace a string in a file with a substitute
- Parameters
file_path (str) – path of the file.
pattern (str) – string to be replaced.
subst (str) – string which will be substituted.
- Returns
- Return type
None.
- geodezyx.utils.shell_like.tail(filename, count=1, offset=1024)¶
A more efficent way of getting the last few lines of a file. Depending on the length of your lines, you will want to modify offset to get better performance.
- geodezyx.utils.shell_like.uncompress(pathin, dirout='', opts='-f')¶
- geodezyx.utils.shell_like.walk_dir(parent_dir)¶
from a main parent_dir returns files_list & dirs_list all the files and all the dirs in the parent_dir
- geodezyx.utils.shell_like.write_in_file(string_to_write, outdir, outname, ext='.txt', encoding='utf8')¶
encoding : utf8, latin_1 https://docs.python.org/3/library/codecs.html#standard-encodings
check the following commented old version if troubles
geodezyx.utils.utils_core module¶
@author: psakic
This sub-module of geodezyx.utils contains functions for misc. low level function
it can be imported directly with: from geodezyx import utils
The GeodeZYX Toolbox is a software for simple but useful functions for Geodesy and Geophysics under the GNU GPL v3 License
Copyright (C) 2019 Pierre Sakic et al. (GFZ, pierre.sakic@gfz-postdam.de) GitHub repository : https://github.com/GeodeZYX/GeodeZYX-Toolbox_v4
- geodezyx.utils.utils_core.Aformat(A, landscape=True)¶
- class geodezyx.utils.utils_core.Tee(*files)¶
Bases:
object
Internal class for Tee_frontend
based on http://stackoverflow.com/questions/11325019/output-on-the-console-and-file-using-python Secondary links http://stackoverflow.com/questions/616645/how-do-i-duplicate-sys-stdout-to-a-log-file-in-python http://stackoverflow.com/questions/2996887/how-to-replicate-tee-behavior-in-python-when-using-subprocess
- flush()¶
- pause()¶
- restart()¶
- stop()¶
- write(obj)¶
- geodezyx.utils.utils_core.Tee_frontend(dir_in, logname_in, suffix='', ext='log', print_timestamp=True)¶
Write in a file the console output
- Parameters
dir_in (str) – directory path.
logname_in (str) – logfile name.
suffix (str, optional) – An optional suffix. The default is ‘’.
ext (str, optional) – file extension. The default is ‘log’.
print_timestamp (bool, optional) – print a timestamp in the filename. The default is True.
- Returns
F_tee – Object controling the output
- Return type
F_tee object
Note
It is recommended to stop the writing at the end of the script with F_tee.stop()
- geodezyx.utils.utils_core.alphabet(num=None)¶
- geodezyx.utils.utils_core.array_from_lists(*listsin)¶
fonction pour arreter de galerer avec les conversions de lists => matrices
- geodezyx.utils.utils_core.boolean_dict(list_of_keywords)¶
- geodezyx.utils.utils_core.clear_all()¶
Clears all the variables from the workspace of the spyder application.
- geodezyx.utils.utils_core.contains_word(s, w)¶
- geodezyx.utils.utils_core.dday()¶
- geodezyx.utils.utils_core.diagonalize(x, n=10)¶
- geodezyx.utils.utils_core.docstring_generic()¶
prints and returns an prototype generic docstring. Based on Numpy docstring convention
- geodezyx.utils.utils_core.eval_a_dict(dictin, where, verbose=True)¶
where is most of time globals() WARN : doesnt work in a function !!! use instead : for k,v in booldic.items():
globals()[k] = v locals()[k] = v
- geodezyx.utils.utils_core.extract_text_between_elements(file_path, elt_start, elt_end)¶
- geodezyx.utils.utils_core.extract_text_between_elements_2(file_path, elt_start, elt_end, return_string=False, nth_occur_elt_start=0, nth_occur_elt_end=0, invert=False, verbose=False)¶
This function is based on REGEX (elt_start , elt_end are REGEX) and can manage several blocks in the same file
return_string = True : returns a string of the matched lines return_string = False : returns a list of the matched lines invert : exclude text between the pattern
- NBin SINEX context, with “+MARKER”, use backslash i.e.
“+MARKER”
NB2 : think about StingIO for a Pandas DataFrame Handeling https://docs.python.org/2/library/stringio.html
- geodezyx.utils.utils_core.get_computer_name()¶
- geodezyx.utils.utils_core.get_function_name()¶
- geodezyx.utils.utils_core.get_specific_locals(prefix)¶
get locals params with ‘prefix’ in the name can actually be a suffix
- geodezyx.utils.utils_core.get_timestamp(outstring=True)¶
frontend to get easily a timestamp
- geodezyx.utils.utils_core.get_type_smart(obj_in)¶
get type of an object, to convert easily another one to this type for instance type(np.array(A)) doesn’t return a constructor
- geodezyx.utils.utils_core.get_username()¶
- geodezyx.utils.utils_core.globals_filtered()¶
Filter globals() varirables with only compatible variables for pickle.
- Returns
data_out – filtered globals() variables.
- Return type
dict
- geodezyx.utils.utils_core.greek_alphabet(num=None, maj=False)¶
- geodezyx.utils.utils_core.indice_printer(i, print_every=10, text_before='')¶
print an index every N iteration
- geodezyx.utils.utils_core.is_iterable(inp, consider_str_as_iterable=False)¶
Test if the input is an iterable like a list or a numpy array or not
- Parameters
inp (list, numpy.array, ...) –
consider_str_as_iterable (bool) – string are considered as iterable by Python per default This boolean will avoid True as return if you test a string
- Returns
out – True if inp is iterable, False either
- Return type
bool
- geodezyx.utils.utils_core.is_lambda(v)¶
Check if v is lambda
https://stackoverflow.com/questions/3655842/how-can-i-test-whether-a-variable-holds-a-lambda
- geodezyx.utils.utils_core.is_not_iterable(inp, consider_str_as_iterable=False)¶
Simple negation of is_iterable()
- geodezyx.utils.utils_core.join_improved(strseparat, *varsin)¶
- geodezyx.utils.utils_core.line_count(filein)¶
- geodezyx.utils.utils_core.line_in_file_checker(file_path, string)¶
- geodezyx.utils.utils_core.mdot(*args)¶
- geodezyx.utils.utils_core.mdotr(*args)¶
- geodezyx.utils.utils_core.memmap_from_array(arrin)¶
- geodezyx.utils.utils_core.mmpa(arrin)¶
- geodezyx.utils.utils_core.multidot(tupin)¶
- geodezyx.utils.utils_core.patterns_in_string_checker(string, *patterns)¶
recipe to the famous problem of pattern in string from http://stackoverflow.com/questions/3389574/check-if-multiple-strings-exist-in-another-string
- geodezyx.utils.utils_core.pickle_loader(pathin)¶
Load a Python object saved as a Pickle file (wrapper of pickle.load)
- Parameters
pathin (str) – the input pickle file path.
- Returns
outdata – Data which will be loaded from the a pickle..
- Return type
generic
- geodezyx.utils.utils_core.pickle_saver(datain, outdir=None, outname=None, ext='.pik', timestamp=False, full_path=None)¶
Save a Python object in a Pickle file (wrapper of pickle.dump)
- Parameters
datain (generic) – Data which will be saved as a pickle.
outdir (str, optional) – output directory. The default is None.
outname (str, optional) – pickle output name. The default is None.
ext (str, optional) – pickle file extension. The default is ‘.pik’.
timestamp (bool, optional) – add the timestamp in the pickle’s filename. The default is False.
full_path (str, optional) – gives the full path where to save the pickle. if full_path is given, override outdir and outname. The default is None.
- Returns
outpath – the output pickle file path.
- Return type
str
- geodezyx.utils.utils_core.read_comments(filein, comment='#')¶
- geodezyx.utils.utils_core.read_mat_file(pathin, full=False)¶
low level reader of a MATLAB mat file
- geodezyx.utils.utils_core.replace_in_file(file_in, str_before, str_after)¶
https://stackoverflow.com/questions/17140886/how-to-search-and-replace-text-in-a-file
- geodezyx.utils.utils_core.save_array_fast(arrin, outname='', outdir='/home/psakicki/aaa_FOURBI', txt=True)¶
- geodezyx.utils.utils_core.save_obj_as_file(objin, pathin, prefix, ext='.exp', suffix='')¶
OLD proto-version of pickle saver DISCONTINUED
- geodezyx.utils.utils_core.split_improved(strin, sep_left, sep_right)¶
- geodezyx.utils.utils_core.spyder_run_check()¶
Check if the code is run inside Spyder IDE
- geodezyx.utils.utils_core.str2float_smart(str_in)¶
- geodezyx.utils.utils_core.str2int_float_autodetect(str_list_in)¶
- geodezyx.utils.utils_core.str2int_smart(str_in)¶
- geodezyx.utils.utils_core.str_2_float_line(line, sep=' ', out_type=<class 'float'>)¶
convert a line of number (in str) to a list of float (or other out_type)
- geodezyx.utils.utils_core.stringizer(tupin, separ=' ', eol=True)¶
transform elts of a tuple in a string line, ready for write in a file
- geodezyx.utils.utils_core.timeout(func, args=(), kwargs={}, timeout_duration=1, default=None)¶
This function will spwan a thread and run the given function using the args, kwargs and return the given default value if the timeout_duration is exceeded
http://stackoverflow.com/questions/366682/how-to-limit-execution-time-of-a-function-call-in-python
- geodezyx.utils.utils_core.transpose_vector_array(X)¶
transpose a Nx3 array to a 3xN array if necessary (necessary for some usages)
- Parameters
X (iterable) –
- Returns
X – X transposed if necessary.
- Return type
iterable
- geodezyx.utils.utils_core.trunc(f, n)¶
Truncates/pads a float f to n decimal places without rounding
- geodezyx.utils.utils_core.vectorialize(array_in)¶
redondant avec .flat ???