geodezyx.utils_xtra package
Submodules
geodezyx.utils_xtra.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 LGPL v3 License
Copyright (C) 2019 Pierre Sakic et al. (IPGP, sakic@ipgp.fr) GitHub repository : https://github.com/GeodeZYX/geodezyx-toolbox
- geodezyx.utils_xtra.pandas_utils.diff_pandas(DF, col_name, use_np_diff=False)
Differentiate a Pandas DataFrame, if index is time.
This function calculates the difference between consecutive elements in a specified column of a DataFrame. The difference is divided by the difference in time (seconds) between the corresponding indices. This is essentially a derivative operation, assuming the index represents time.
- Parameters:
DF (pandas.DataFrame) – The input DataFrame. The index should represent time.
col_name (str) – The name of the column in the DataFrame that you want to differentiate.
use_np_diff (bool, optional) – If True, use Numpy’s diff. Default is False. This option has a (much) faster execution speed.
- Returns:
The differentiated column of the input DataFrame. The type of the return value depends on the ‘return_array’ parameter. If ‘return_array’ is False (default), a DataFrame is returned. If ‘return_array’ is True, a numpy array is returned.
- Return type:
pandas.DataFrame or numpy.array
- geodezyx.utils_xtra.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] `
Source :
- geodezyx.utils_xtra.pandas_utils.pandas_DF_print(DFin)
- geodezyx.utils_xtra.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_xtra.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_xtra.pandas_utils.weighted_average(df, data_col, weight_col, by_col)
Source
https://stackoverflow.com/questions/31521027/groupby-weighted-average-and-sum-in-pandas-dataframe
geodezyx.utils_xtra.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 LGPL v3 License
Copyright (C) 2019 Pierre Sakic et al. (IPGP, sakic@ipgp.fr) GitHub repository : https://github.com/GeodeZYX/geodezyx-toolbox
- geodezyx.utils_xtra.plot_utils.axis_data_coords_sys_transform(axis_obj_in, xin, yin, inverse=False)
inverse = False : Axis => Data = True : Data => Axis
- geodezyx.utils_xtra.plot_utils.color_list(L, colormap='jet')
- geodezyx.utils_xtra.plot_utils.colors_from_colormap_getter(ncolors, colormap='viridis')
- geodezyx.utils_xtra.plot_utils.figure_saver(figobjt_in, outdir, outname, outtype=('.png', '.pdf', '.figpik'), formt=None, dpi=200, transparent=False)
This function provides a front end to export pretty-print plots
- Parameters:
figobjt_in (matplotlib Figure object) – input matplotlib Figure object. use for instance plt.gcf() to get it.
outdir (str) – the output directory.
outname (str) – output prefix filename.
outtype (tuple, optional) – the output formats. The default is (‘.png’,’.pdf’,’.figpik’).
formt (2-tuple or string , optional) – the format (size) of the plot. if string: a Ax format (A4, A3 etc…) if tuple: size of the plot in inches. The default is None.
dpi (int, optional) – DPI of the figure. The default is 200.
transparent (bool, optional) – make the plot transparent. The default is False.
- Returns:
outpath_stk – output paths of the plots.
- Return type:
string or list of string
- geodezyx.utils_xtra.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_xtra.plot_utils.get_figure(figin=0)
- geodezyx.utils_xtra.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_xtra.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_xtra.plot_utils.symbols_list(L=None)
- geodezyx.utils_xtra.plot_utils.ylim_easy(Lin, delta=0.1, min_null_if_neg=False)