exmecheva.common package
Submodules
exmecheva.common.analyze module
Analyzing functionality.
@author: MarcGebhardt
- exmecheva.common.analyze.Geo_curve_TBC(func, params, length, outopt='signed_curvature')[source]
Determines the radius or curvature of a circle through three points. The sign indicates the direction (positve=left turn/curvature downwards).
- Parameters
func (TYPE) – DESCRIPTION.
params (TYPE) – DESCRIPTION.
length (TYPE) – DESCRIPTION.
outopt (string, optional) –
Option for output. Possible are:
[‘signed_radius’,’sr’]: signed radius
[‘signed_curvature’,’sc’]: signed curvature
…: all values (Center of circle, radius, sign, quadrant to mid)
The default is ‘signed_curvature’.
- Returns
r – Radius, curvature or all outputs.
- Return type
float or tuple
- exmecheva.common.analyze.Inter_Lines(r1, c1, r2, c2, out='x')[source]
Determine intersection point of two lines.
- Parameters
r1 (float) – Rise of first line.
c1 (float) – Constant part of first line.
r2 (float) – Rise of second line.
c2 (float) – Constant part of second line.
out (string, optional) – Option for output (‘x’, ‘y’, or ‘xy’). The default is ‘x’.
- Returns
Output values.
- Return type
float or tuple of float
- exmecheva.common.analyze.Line_from2P(P1, P2)[source]
Determine line from two points (1st argument is x)
- exmecheva.common.analyze.TP_circle(p1, p2, p3)[source]
Returns the center and radius of the circle passing the given 3 points. In case the 3 points form a line, returns (None, infinity).
- exmecheva.common.analyze.TP_radius(pts, outopt='signed_curvature')[source]
Determines the radius or curvature of a circle through three points. The sign indicates the direction (positve=left turn/curvature downwards).
- Parameters
pts (np.array or pd.DataFrame of shape (2=[x,y],3=[left,mid,right])) – Array of point coordinates.
outopt (string, optional) –
Option for output. Possible are:
[‘signed_radius’,’sr’]: signed radius
[‘signed_curvature’,’sc’]: signed curvature
…: all values (Center of circle, radius, sign, quadrant to mid)
The default is ‘signed_curvature’.
- Returns
Radius, curvature or all outputs.
- Return type
float or tuple
- exmecheva.common.analyze.normalize(pdo, axis=0, norm='absmax', normadd=0.5, pdo_n=None, warn_excl=['x_sc', 'dx_sc'])[source]
Normalize an array in respect to given option.
- Parameters
pdo (pandas.Series or pandas.DataFrame) – Input values.
axis ({0 or ‘index’, 1 or ‘columns’},, optional) – Axis to apply normalizing. The default is 0.
norm (string, optional) –
Apllied option for normalizing. Possible are:
’absmax’: Normalize to maximum of absolut input values.
’absmin’: Normalize to minimum of absolut input values.
’absqua’: Normalize to Quantile of absolut input values (specified with normadd).
’max’: Normalize to maximum of input values.
’min’: Normalize to minimum of input values.
’qua’: Normalize to Quantile of input values (specified with normadd).
’val’: Normalize to given value (specified with normadd).
None: No normalization (return input values).
The default is ‘absmax’.
normadd (int or float, optional) – Additional parameter for option ‘qua’(to set quantile value), or ‘val’(to set norm parameter directly). The default is 0.5.
pdo_n (pandas.Series or pandas.DataFrame or None, optional) – Additional values to get normalizing parameter. If None use input values. If type is Dataframe, same shape required. The default is None.
warn_excl (list) – Defines exclusions of ZeroDivisionError-prevention-warnings. The default is [‘x_sc’,’dx_sc’].
- Raises
NotImplementedError – Option not implemented.
- Returns
o – Normalized output values.
- Return type
pandas.Series or pandas.DataFrame
- exmecheva.common.analyze.normalize_th(pdo, axis=0, pdo_n=None, norm='absmax', normadd=0.5, th=None, th_option='abs', th_set_val='th', warn_excl=['x_sc', 'dx_sc'])[source]
- exmecheva.common.analyze.sign_n_change(y)[source]
Computes sign and sign change of an array.
- Parameters
y (pandas.Series of float) – Array which should analyzed.
- Returns
y_sign (pandas.Series of integer) – Signs of y.
y_signchange (pandas.Series of boolean) – Sign changes of y.
- exmecheva.common.analyze.sign_n_changeth(y, axis=0, norm=None, normadd=0.5, th=None, th_option='abs', th_set_val=0, rename=True, opt_out='Tuple')[source]
Computes sign and sign change of an array.
- Parameters
y (pandas.Series of float) – Array which should analyzed.
- Returns
y_sign (pandas.Series of integer) – Signs of y.
y_signchange (pandas.Series of boolean) – Sign changes of y.
exmecheva.common.eva_opt_hand module
Contains functionality for evaluation options.
@author: MarcGebhardt
- exmecheva.common.eva_opt_hand.com_option_file_read(file, check_OPT=True)[source]
Reads common options file with json and return as pandas dataframe.
- Parameters
file (path object or string) – Common options file location.
check_OPT (bool, optional) – Check if variable name starts with ‘OPT_’. If it is true, then use for options dataframe. The default is True.
- Returns
co – Common options dataframe.
- Return type
pd.DataFrame
- exmecheva.common.eva_opt_hand.com_option_file_write(file, co, indent=1)[source]
Writes coomon options dataframe to file with json.
- Parameters
file (path object or string) – Common options file location.
co (pd.DataFrame) – Common options dataframe.
indent (int, optional) – Indent for json builder. The default is 1.
- Return type
None.
- exmecheva.common.eva_opt_hand.option_presetter(opt, mtype, preset, stype=None)[source]
Presets option by value and types.
- Parameters
opt (object) – Option value.
mtype (string) – Main type (see set_type_by_string for available types and additional “Array” with stype).
preset (object) – Preset value.
stype (string or None, optional) – Sub types, used if mtype == “Array” (see set_type_by_string for available types). The default is None.
- Returns
opt – Presetted option value.
- Return type
object
- exmecheva.common.eva_opt_hand.option_reader_sel(prot_ser, paths, search_inds=['Number', 'Designation', 'name'], variant='', option='JFile+Prot', sheet_name='Eva_Options', re_rkws={'header': 3, 'index_col': 0, 'skiprows': range(4, 5)})[source]
Reads in evaluation options with different methods.
- Parameters
prot_ser (pd.Series) – Protocoll series for measurement.
paths (pd.Series) –
- Series with paths (need to have indexes ‘opts’ for common options and
’prot’ if option contains ‘Sheet’).
search_inds (list, optional) – List of strings to build search strings in index of option sheet in protocoll excel table (excecuted in given order). Search strings have to be in prot_ser as variable name or an attribute of prot_ser (only ‘name’ implemented’). The default is [].
variant (string or str() callable, optional) – Additional addendum on search strings. Search will be exceuted after other search strings (see search_inds). The default is [‘Number’,’Designation’,’name’].
option (string, optional) –
Implemented options for option_reader_sel. Implemented are:
- ’JFile+Prot’: Json file (loaded from paths[‘opts’] location) and
direct load of evaluation options from protocoll series of measurement
- ’JFile+Sheet’: Json file (loaded from paths[‘opts’] location) and
load of evaluation options from protocoll option sheet (see sheet_name). Search order by search_inds and combination of search_inds and variant.
The default is ‘JFile+Prot’.
sheet_name (string, optional) – Name of evalutaion options sheet in protocoll excel table. The default is “Eva_Options”.
re_rkws (dict, optional) – Keyword arguments for loading evalutaion options from sheet in protocoll excel table (see paths and sheet_name). The default is dict(header=3, skiprows=range(4,5), index_col=0).
- Raises
ValueError – The search string is neither in the index nor an attribute.
NotImplementedError – Option for selecting options not implemented.
- Returns
opts_out – Evaluation options.
- Return type
pd.Series
- exmecheva.common.eva_opt_hand.set_type_by_string(o, t)[source]
Create new object by given determiner.
- Parameters
o (object) – Object to convert.
t (string) –
- Determiner for conversion. Implemented are:
”String”: String object
”Int”: Integer object
”Bool”: Boolean object
”Float”: Float precision object
”Json”: Json object (uses json.loads)
”Free”: No conversion
Combination of formantioned, split by ‘_’ in descending order
- Raises
NotImplementedError – Given determiner/type is not implemented.
- Returns
o – Converted object.
- Return type
object
exmecheva.common.fitting module
Created on Mon Dec 4 17:43:14 2023
@author: mgebhard
- exmecheva.common.fitting.Refit_YM_vals(m_df, YM, VIP, n_strain='Strain', n_stress='Stress', n_loBo=['F3'], n_upBo=['F4'], option='range', outopt='Series')[source]
Refits line values for given rising (i.e. absolute value and R² vor given elastic modulus)
- Parameters
m_df (pd.DataFrame) – Measured data.
YM (float) – Youngs Modulus (fixed rising of line).
VIP (pd.Series) – Important points corresponding to measured data.
n_strain (string) – Name of used strain (have to be in measured data).
n_stress (string) – Name of used stress (have to be in measured data).
n_loBo ([string]) – List of lower borders for determination (have to be in VIP). The default is [‘F3’].
n_upBo ([string]) – List of upper borders for determination (have to be in VIP). The default is [‘F4’].
option (string, optional) – Determination range. The default is ‘range’.
outopt (string, optional) – Switch for outupt (Series or list). The default is ‘Series’.
- Returns
out – Line values and firt parameters for fixed rising.
- Return type
list or pd.Series
- exmecheva.common.fitting.Rquad(y_true, y_predicted, nan_policy='omit')[source]
Returns coefficient of determination.
- Parameters
y_true (array of float) – True values.
y_predicted (array of float) – Predicted values.
nan_policy (bool, optional) – NaN policy (omit, raise or propagate). The default is ‘omit’.
- Raises
ValueError – NaN values during Rquad detected (nan_policy is raise).
NotImplementedError – NaN policy type not implemented.
- Returns
r2_score – Coefficient of determination.
- Return type
TYPE
- exmecheva.common.fitting.YM_eva_com_sel(stress_ser, strain_ser, comp=True, name='A', det_opt='incremental', **kws)[source]
Calculates Young’s Modulus over defined range with definable method.
- Parameters
stress_ser (pd.Series) – Series with stress values corresponding strain_ser.
strain_ser (pd.Series) – Series with strain values corresponding stress_ser.
comp (boolean, optional) – Compression mode. The default is True.
name (string, optional) – Name of operation. The default is ‘A’.
det_opt (TYPE, optional) – Definable method for determination. Ether incremental or leastsq. The default is ‘incremental’.
**kws (dict) – Keyword dict for least-square determination.
- Returns
det_opt == “incremental” –
- YM_serpd.Series
Series of Young’s Moduli.
or
det_opt == “leastsq” –
- YMfloat
Youngs Modulus (corresponds to slope of linear fit).
- YM_absfloat
Stress value on strain origin (corresponds to interception of linear fit).
- YM_Rquadfloat
Coefficient of determination.
- YM_fitlmfit.model.ModelResult
Fitting result from lmfit (use with fit.fit_report() for report).
- exmecheva.common.fitting.YM_sigeps_lin(stress_ser, strain_ser, method='leastsq', nan_policy='omit', ind_S=None, ind_E=None)[source]
Calculates Youngs Modulus of a stress-strain-curve with linear approach using non linear least squares curve fitting.
- Parameters
strain_col (pd.Series) – Strain curve.
stress_col (pd.Series) – Stress_curve.
ind_S (integer) – First used index in df.
ind_E (integer) – Last used index in df.
- Returns
E (float) – Youngs Modulus (corresponds to slope of linear fit).
Eabs (float) – Stress value on strain origin (corresponds to interception of linear fit).
Rquad (float) – Coefficient of determination.
fit (lmfit.model.ModelResult) – Fitting result from lmfit (use with fit.fit_report() for report).
- exmecheva.common.fitting.fit_report_adder(fit, Var, Varname='R-square', show_correl=False)[source]
Adds a statistical entry to the fit report of lmfit (p.e. coefficient of determination).
- Parameters
fit (string or lmfit.model.ModelResult) – Fit report.
Var (float) – Value of addional statistics entry.
Varname (string, optional) – Name of addional statistics entry. The default is ‘R-square’.
show_correl (bool, optional) – Show or hide correlation. The default is False.
- Raises
TypeError – Fit has wrong type.
- Returns
txt – Fit report with additional statistics value.
- Return type
string
- exmecheva.common.fitting.func_exp(x, a, b, c)[source]
Return values from a general exponential function.
- exmecheva.common.fitting.func_exp_str(xl, yl, a, b, c, t_form='{a:.3e},{b:.3e},{c:.3e}')[source]
Return string from a general exponential function.
- exmecheva.common.fitting.func_lin_str(xl, yl, a, b, t_form='{a:.3e},{b:.3e}')[source]
Return string from a general linear function.
- exmecheva.common.fitting.func_pow_str(xl, yl, a, b, c, t_form='{a:.3e},{b:.3e},{c:.3e}')[source]
Return string from a general power function.
- exmecheva.common.fitting.regfitret(pdo, x, y, name='linear', guess={'a': 0.01, 'b': 0.1}, xl='$X$', yl='$Y$', t_form='{a:.3e},{b:.3e}', xt=None, yt=None, max_nfev=1000, nan_policy='omit', outtype='Series')[source]
Performs a least square regression fit according given function type.
- Parameters
pdo (pd.DataFrame) – Input data.
x (str) – Column name for abscissa data.
y (str) – Column name for ordinate data.
name (str, optional) –
Type and name of function to adjust. Implemented are:
’linear’: linear and constant function (see func_lin)
’power’: power and constant function (see func_pow)
’exponential’: exponantial and constant function (see func_exp)
- additional endings:
’_nc’: no constant value
’_x0’: fixed to zero
The default is ‘linear’.
guess (dictionary, optional) – First guess for fitting. The default is dict(a=0.01, b=0.1).
xl (str, optional) – Variable name for abscissa. The default is r’$X$’.
yl (str, optional) – Variable name for ordinate. The default is r’$Y$’.
t_form (str, optional) – String of dictionary with variables and format strings. The default is ‘{a:.3e},{b:.3e}’.
xt (str, optional) – Variable string for description. The default is None.
yt (str, optional) – Variable string for description. The default is None.
max_nfev (int, optional) – Maximum number of evaluations. The default is 1000.
nan_policy (string, optional) – NaN policy (omit, raise or propagate). The default is ‘omit’.
outtype (string, optional) – Type for output (dictionary or pd.Series). The default is ‘Series’.
- Raises
NotImplementedError – Function type not implemented.
- Returns
out – Output data.
- Return type
pd:series or dict
- exmecheva.common.fitting.regfitret_restring_func(reg_res, xl='$X$', yl='$Y$', t_form='{a:.3e},{b:.3e}', rquad_add=True, rq_form='{:.3f}')[source]
Rebuild equation string for regfit result.
- Parameters
reg_res (pd.Series) – Result of regfitret.
xl (str, optional) – Variable name for abscissa. The default is r’$X$’.
yl (str, optional) – Variable name for ordinate. The default is r’$Y$’.
t_form (str, optional) – String of dictionary with variables and format strings. The default is ‘{a:.3e},{b:.3e}’.
rquad_add (bool, optional) – Switch for adding coefficent of determination. The default is True.
rq_form (string, optional) – Format string for coefficent of determination. The default is ‘{:.3f}’.
- Raises
NotImplementedError – Function type not implemented.
- Returns
out – Equation string.
- Return type
string
- exmecheva.common.fitting.strain_linfit(stress_ser, YM, YM_abs, strain_offset=0.002)[source]
Linearised strain fit corresponding Youngs Modulus and stress
exmecheva.common.helper module
Contains test and basic numeric functionality.
@author: MarcGebhardt
- exmecheva.common.helper.check_empty(x, empty_str=['', ' ', ' ', ' ', '#NVNaN', 'nan', 'NA'])[source]
Tests if given variable (string or float) can interpreted as empty.
- Parameters
x (None or string or float) – Given variable to test.
empty_str (list of strings) – Strings determining if variable can interpreted as empty.
- Returns
t – Test result.
- Return type
bool
- exmecheva.common.helper.round_to_sigdig(x, sd=3)[source]
Round a floating number to a number of significant digits.
- Parameters
x (float) – Number.
sd (int, optional) – Significant digits. The default is 3.
- Returns
xr – Rounded number to significant digits.
- Return type
float
- exmecheva.common.helper.sigdig(x, sd=3)[source]
Returns the significant digits of a floating number.
- Parameters
x (float) – Number.
sd (int, optional) – Significant digits. The default is 3.
- Returns
xr – Rounded number to significant digits.
- Return type
float
- exmecheva.common.helper.str_to_bool(x, str_true=['True', 'true', 'Yes', '1', 'On'])[source]
Interpretes a given string as boolean value
- Parameters
x (string or bool) – Value to be interpreted.
str_true (list of strings) – List of strings interpreted as True.
- Returns
t – Boolean value result.
- Return type
bool
- exmecheva.common.helper.type_str_return(obj)[source]
Tests type of given object and return an identifying string.
- Parameters
obj (object) –
Input object to check type. Implemented are:
Standard: None, bool, str, int and float
- Numpy array of shape:
unknown shape -> npAu
single row -> npAr
single column -> npAc
frame -> npAF
- Pandas:
Index -> pdIN
Series -> pdSe
DataFrame-> pdDF
- Raises
NotImplementedError – Type of object not implemented.
- Returns
t – String of derived type.
- Return type
str
exmecheva.common.list_ops module
List manipulation and interpretation functionality.
@author: MarcGebhardt
- exmecheva.common.list_ops.Failure_code_bool_df(list_ser, sep=',', level=1, strength=[1, 2, 3], drop_duplicates=True, sort_values=True, exclude=['nan'], replace_whitespaces=True, as_int=True)[source]
- exmecheva.common.list_ops.Failure_code_checker(fc_ser, exclude=['nan'], pattern='[A-Z][0-9][0-9][.][0-3]')[source]
- exmecheva.common.list_ops.Failure_code_lister(_list, level=1, strength=[1, 2, 3], drop_duplicates=True, replace_whitespaces=True)[source]
Shortens List of Failure-codes (Version 3.1) to levels and optional strength Level: 0=Procedure, 1=Procedure Failure_Type, 2=Porcedure.Failure_Type.Strength
‘P’=Procedure, ‘F’=Failure_Type
- exmecheva.common.list_ops.ICD_bool_df(series, sep=',', level=1, drop_duplicates=True, sort_values=True, exclude=[], replace_whitespaces=True, as_int=True)[source]
- exmecheva.common.list_ops.ICD_lister(_list, level=1, drop_duplicates=True, replace_whitespaces=True)[source]
Shortens List of ICD-codes to levels
exmecheva.common.loadnsave module
Contains functionality for loading and saving files.
@author: MarcGebhardt
- exmecheva.common.loadnsave.comb_logs(in_paths, out_path)[source]
Generates a combined log-file of a series of log-files.
- Parameters
in_paths (pd.DataFrame with columns ['prot','out']) – Path for finding protocol and evaluation data.
out_path (string) – Output path of combined log-file (without extension).
- Return type
None.
- exmecheva.common.loadnsave.file_namer(fstr, svars='>', svare='<', sform='#')[source]
Names a file according given string (sub module of File_namer_interpreter).
- Parameters
fstr (string) – String with replaceable tokens.
svars (string, optional) – Start character for token. The default is ‘>’.
svare (string, optional) – End character for token. The default is ‘<’.
sform (string, optional) – Form determinator at end of token. The default is ‘#’.
- Returns
vardf – DESCRIPTION.
- Return type
TYPE
Examples
- >Number#02<>Variant<.xlsx:
with Number = 05 (from protocol) and Variant = C (from call) -> 05C.xlsx
- >Designation<_>Variant<_foo.csv:
with (from protocol) Designation = Test_1 and Variant = B -> Test_1_B_foo.csv
- exmecheva.common.loadnsave.file_namer_interpreter(fstr, prot_ser, path, variant='', expext='.xlsx', svars='>', svare='<', sform='#')[source]
Builds a file location according given string (with repleacable tokens).
- Parameters
fstr (string) – String with replaceable tokens.
prot_ser (pd.Series) – Series form protocoll dataframe with tokens as index.
path (string) – Path addendum (will be added before adjusted filename).
variant (string, optional) – Variant (special string for token ‘Variant’). The default is ‘’.
expext (string, optional) – Expected extension of file. The default is ‘.xlsx’.
svars (string, optional) – Start character for token. The default is ‘>’.
svare (string, optional) – End character for token. The default is ‘<’.
sform (string, optional) – Form determinator at end of token. The default is ‘#’.
- Raises
ValueError – Token not found in protocoll.
- Returns
fname – Adjusted file name.
- Return type
string
Examples
- >Number#02<>Variant<.xlsx:
with Number = 05 (from protocol) and Variant = C (from call) -> 05C.xlsx
- >Designation<_>Variant<_foo.csv:
with (from protocol) Designation = Test_1 and Variant = B -> Test_1_B_foo.csv
- exmecheva.common.loadnsave.pack_hdf(in_paths, out_path, hdf_naming='Designation', var_suffix=[''], h5_conc='Material_Parameters', h5_data='Measurement', prot_rkws={'header': 11, 'index_col': 0, 'skiprows': range(12, 13)}, opt_pd_out=True, opt_hdf_save=True)[source]
Packs specimenwise evaluated measurements (HDF-files, *.h5) to a HDF-database containing material parameters (key is ‘Summary’) and evaluated measurements (key is ‘Test_Data’).
- Parameters
in_paths (pd.DataFrame with columns ['prot','hdf']) – Path for finding protocol and evaluation data.
out_path (string) – Output path of created database.
hdf_naming (string, optional) – Naming rule of evaluated measurements (*.h5). The default is ‘Designation’.
var_suffix (list of strings, optional) – Suffix of hdf naming rule. The default is [“”].
h5_conc (str, optional) – Identifier of material parameters conclusion in evaluated measurements (*.h5). The default is ‘Material_Parameters’.
h5_data (str, optional) – Identifier of measured and evaluated curves in evaluated measurements (*.h5). The default is ‘Measurement’.
prot_rkws (dict, optional) – Dictionary for reading protocol. Must be keyword in pandas.read_excel. The default is dict(header=11, skiprows=range(12,13), index_col=0).
opt_pd_out (bool, optional) – Option for pandas object output. The default is True.
opt_hdf_save (bool, optional) – Option for hdf saving. The default is True.
- Returns
dfc (pd.DataFrame) – Summary of protocol and material data.
dfd (pd.DataFrame) – Summary of test data.
- exmecheva.common.loadnsave.pack_hdf_mul(in_paths, out_path, hdf_naming='Designation', var_suffix=[''], h5_conc='Material_Parameters', h5_data='all', prot_rkws={'header': 11, 'index_col': 0, 'skiprows': range(12, 13)}, opt_pd_out=True, opt_hdf_save=True)[source]
Packs specimenwise evaluated measurements (HDF-files, *.h5) to a HDF-database containing material parameters key is ‘Summary’ and other included data (key starting with ‘Add_’). Only all keys in single hdf-files are implemented. (High storage requirements!)
- Parameters
in_paths (pd.DataFrame with columns ['prot','hdf']) – Path for finding protocol and evaluation data.
out_path (string) – Output path of created database.
hdf_naming (string, optional) – Naming rule of evaluated measurements (*.h5). The default is ‘Designation’.
var_suffix (list of strings, optional) – Suffix of hdf naming rule. The default is [“”].
h5_conc (str, optional) – Identifier of material parameters conclusion in evaluated measurements (*.h5). The default is ‘Material_Parameters’.
h5_data (str, optional) – Identifier for additional packaging. Only ‘all’ (packing all keys from input hfd’s)implemented. The default is ‘all’.
prot_rkws (dict, optional) – Dictionary for reading protocol. Must be keyword in pandas.read_excel. The default is dict(header=11, skiprows=range(12,13), index_col=0).
opt_pd_out (bool, optional) – Option for pandas object output. The default is True.
opt_hdf_save (bool, optional) – Option for hdf saving. The default is True.
- Returns
dfc (pd.DataFrame) – Summary of protocol and material data.
dfd (pd.DataFrame) – Summary of test data.
exmecheva.common.mc_char module
Created on Tue Dec 5 12:25:34 2023
@author: mgebhard
- exmecheva.common.mc_char.Diff_Quot(meas_curve_A, meas_curve_B, smoothbool, smooth_lvl, opt_shift=False)[source]
Computes difference quotient (1st[rise] and 2nd-grade[curvature]) to find points of inconstancy in measured curves.
- Parameters
meas_curve_A (pd.Series of float) – Abscissa of the curve for which the difference quotient is to be determined.
meas_curve_B (pd.Series of float) – Ordinate of the curve for which the difference quotient is to be determined.
smoothbool (bool) – Controles determination of rolling mean.
smooth_lvl (positv integer) – Width of rolling mean determination.
opt_shift (bool) – Shifting returned values to pointed input values. If False it points to the index before. Leading to a difficult to handle shift, ingreasing with difference quotient grade. Optional. The defalut is False.
Test –
------- –
t=pd.DataFrame([[0 – [5,2.5],[6,2],[7,2]], columns=[‘x’,’y’])
0] – [5,2.5],[6,2],[7,2]], columns=[‘x’,’y’])
[1 – [5,2.5],[6,2],[7,2]], columns=[‘x’,’y’])
0] – [5,2.5],[6,2],[7,2]], columns=[‘x’,’y’])
[1.5 – [5,2.5],[6,2],[7,2]], columns=[‘x’,’y’])
1] – [5,2.5],[6,2],[7,2]], columns=[‘x’,’y’])
[2.5 – [5,2.5],[6,2],[7,2]], columns=[‘x’,’y’])
2] – [5,2.5],[6,2],[7,2]], columns=[‘x’,’y’])
[3.5 – [5,2.5],[6,2],[7,2]], columns=[‘x’,’y’])
3] – [5,2.5],[6,2],[7,2]], columns=[‘x’,’y’])
[4 – [5,2.5],[6,2],[7,2]], columns=[‘x’,’y’])
3.5] – [5,2.5],[6,2],[7,2]], columns=[‘x’,’y’])
:param : [5,2.5],[6,2],[7,2]], columns=[‘x’,’y’]) :param DQ_df = pd.concat(Diff_Quot(t.x:
- ” DQ1 DQ1_signchange DQ2 DQ2_signchange DQ3 DQ3_signchange
0 NaN True NaN True NaN True 1 0.0 True NaN True NaN True 2 2.0 False 4.0 True NaN True 3 1.0 False -1.0 True -5.0 True 4 1.0 False 0.0 False 1.0 True 5 1.0 True 0.0 True 0.0 True 6 -1.0 False -2.0 True -2.0 True 7 -0.5 True 0.5 False 2.5 True 8 0.0 NaN 0.5 NaN 0.0 NaN”
- Parameters
t.y –
- ” DQ1 DQ1_signchange DQ2 DQ2_signchange DQ3 DQ3_signchange
0 NaN True NaN True NaN True 1 0.0 True NaN True NaN True 2 2.0 False 4.0 True NaN True 3 1.0 False -1.0 True -5.0 True 4 1.0 False 0.0 False 1.0 True 5 1.0 True 0.0 True 0.0 True 6 -1.0 False -2.0 True -2.0 True 7 -0.5 True 0.5 False 2.5 True 8 0.0 NaN 0.5 NaN 0.0 NaN”
False –
- ” DQ1 DQ1_signchange DQ2 DQ2_signchange DQ3 DQ3_signchange
0 NaN True NaN True NaN True 1 0.0 True NaN True NaN True 2 2.0 False 4.0 True NaN True 3 1.0 False -1.0 True -5.0 True 4 1.0 False 0.0 False 1.0 True 5 1.0 True 0.0 True 0.0 True 6 -1.0 False -2.0 True -2.0 True 7 -0.5 True 0.5 False 2.5 True 8 0.0 NaN 0.5 NaN 0.0 NaN”
2 –
- ” DQ1 DQ1_signchange DQ2 DQ2_signchange DQ3 DQ3_signchange
0 NaN True NaN True NaN True 1 0.0 True NaN True NaN True 2 2.0 False 4.0 True NaN True 3 1.0 False -1.0 True -5.0 True 4 1.0 False 0.0 False 1.0 True 5 1.0 True 0.0 True 0.0 True 6 -1.0 False -2.0 True -2.0 True 7 -0.5 True 0.5 False 2.5 True 8 0.0 NaN 0.5 NaN 0.0 NaN”
True) –
- ” DQ1 DQ1_signchange DQ2 DQ2_signchange DQ3 DQ3_signchange
0 NaN True NaN True NaN True 1 0.0 True NaN True NaN True 2 2.0 False 4.0 True NaN True 3 1.0 False -1.0 True -5.0 True 4 1.0 False 0.0 False 1.0 True 5 1.0 True 0.0 True 0.0 True 6 -1.0 False -2.0 True -2.0 True 7 -0.5 True 0.5 False 2.5 True 8 0.0 NaN 0.5 NaN 0.0 NaN”
axis=1) –
- ” DQ1 DQ1_signchange DQ2 DQ2_signchange DQ3 DQ3_signchange
0 NaN True NaN True NaN True 1 0.0 True NaN True NaN True 2 2.0 False 4.0 True NaN True 3 1.0 False -1.0 True -5.0 True 4 1.0 False 0.0 False 1.0 True 5 1.0 True 0.0 True 0.0 True 6 -1.0 False -2.0 True -2.0 True 7 -0.5 True 0.5 False 2.5 True 8 0.0 NaN 0.5 NaN 0.0 NaN”
- Returns
DQ1 (pd.Series of float) – Differential quotient 1st grade (rise) of meas_curve_B to meas_curve_A.
DQ1_signchange (pd.Series of bool) – Indicates sign changes of DQ1.
DQ2 (pd.Series of float) – Differential quotient 2nd grade (curvature) of meas_curve_B to meas_curve_A.
DQ2_signchange (pd.Series of bool) – Indicates sign changes of DQ2.
DQ3 (pd.Series of float) – Differential quotient 3rd grade of meas_curve_B to meas_curve_A.
DQ3_signchange (pd.Series of bool) – Indicates sign changes of DQ3.
- exmecheva.common.mc_char.Diff_Quot2(x, y, smooth_bool=False, smooth_type='SMA', smooth_opts={'window_length': 3}, smooth_snip=False, sc_kwargs={'norm': 'absmax', 'normadd': 0.5, 'th': 0.05, 'th_option': 'abs', 'th_set_val': 0}, opt_shift=False, opt_out='Tuple')[source]
Computes difference quotient of input arrays (1st[rise], 2nd[curvature] and 3rd-grade) to find points of inconstancy in measured curves.
- Parameters
x (pd.Series of float) – Abscissa of the curve for which the difference quotient is to be determined.
y (pd.Series of float) – Ordinate of the curve for which the difference quotient is to be determined.
smoothbool (bool or string) – Controles determination of rolling mean.
smooth_type (string, case-sensitive, optional) –
Choosen smoothing type. Optional. The defalut is ‘SMA’. Possible are:
’SMA’: Moving average based on numpy.convolve.
’SMA_f1d’: Moving average based scipy.ndimage.filters.uniform_filter1d.
’SavGol’: Savitzky-Golay filter based on scipy.signal.savgol_filter.
smooth_opts (dict, optional) – Keywords and values to pass to smoothing method. For further informations see smooth_type and linked methods. Optional. The defalut is {‘window_length’:3, ‘mode’:’same’}.
smooth_snip (bool or integer, optional) – Trimming of output. Either, if True with window_length in smooth_opts, none if False, or with inserted distance. The default is False.
opt_shift (bool) – Shifting returned values to pointed input values. If False it points to the index before. Leading to a difficult to handle shift. Optional. The defalut is False.
opt_out (string) – Type of Output. Either Tuple or pandas dataframe. Optional. The defalut is ‘Tuple’.
Test –
------- –
t=pd.DataFrame([[0 – [5,2.5],[6,2],[7,2]], columns=[‘x’,’y’])
0] – [5,2.5],[6,2],[7,2]], columns=[‘x’,’y’])
[1 – [5,2.5],[6,2],[7,2]], columns=[‘x’,’y’])
0] – [5,2.5],[6,2],[7,2]], columns=[‘x’,’y’])
[1.5 – [5,2.5],[6,2],[7,2]], columns=[‘x’,’y’])
1] – [5,2.5],[6,2],[7,2]], columns=[‘x’,’y’])
[2.5 – [5,2.5],[6,2],[7,2]], columns=[‘x’,’y’])
2] – [5,2.5],[6,2],[7,2]], columns=[‘x’,’y’])
[3.5 – [5,2.5],[6,2],[7,2]], columns=[‘x’,’y’])
3] – [5,2.5],[6,2],[7,2]], columns=[‘x’,’y’])
[4 – [5,2.5],[6,2],[7,2]], columns=[‘x’,’y’])
3.5] – [5,2.5],[6,2],[7,2]], columns=[‘x’,’y’])
:param : [5,2.5],[6,2],[7,2]], columns=[‘x’,’y’]) :param DQ_df = pd.concat(Diff_Quot(t.x:
- ” DQ1 DQ1_signchange DQ2 DQ2_signchange DQ3 DQ3_signchange
0 NaN True NaN True NaN True 1 0.0 True NaN True NaN True 2 2.0 False 4.0 True NaN True 3 1.0 False -1.0 True -5.0 True 4 1.0 False 0.0 False 1.0 True 5 1.0 True 0.0 True 0.0 True 6 -1.0 False -2.0 True -2.0 True 7 -0.5 True 0.5 False 2.5 True 8 0.0 False 0.5 False 0.0 False”
- Parameters
t.y –
- ” DQ1 DQ1_signchange DQ2 DQ2_signchange DQ3 DQ3_signchange
0 NaN True NaN True NaN True 1 0.0 True NaN True NaN True 2 2.0 False 4.0 True NaN True 3 1.0 False -1.0 True -5.0 True 4 1.0 False 0.0 False 1.0 True 5 1.0 True 0.0 True 0.0 True 6 -1.0 False -2.0 True -2.0 True 7 -0.5 True 0.5 False 2.5 True 8 0.0 False 0.5 False 0.0 False”
False –
- ” DQ1 DQ1_signchange DQ2 DQ2_signchange DQ3 DQ3_signchange
0 NaN True NaN True NaN True 1 0.0 True NaN True NaN True 2 2.0 False 4.0 True NaN True 3 1.0 False -1.0 True -5.0 True 4 1.0 False 0.0 False 1.0 True 5 1.0 True 0.0 True 0.0 True 6 -1.0 False -2.0 True -2.0 True 7 -0.5 True 0.5 False 2.5 True 8 0.0 False 0.5 False 0.0 False”
2 –
- ” DQ1 DQ1_signchange DQ2 DQ2_signchange DQ3 DQ3_signchange
0 NaN True NaN True NaN True 1 0.0 True NaN True NaN True 2 2.0 False 4.0 True NaN True 3 1.0 False -1.0 True -5.0 True 4 1.0 False 0.0 False 1.0 True 5 1.0 True 0.0 True 0.0 True 6 -1.0 False -2.0 True -2.0 True 7 -0.5 True 0.5 False 2.5 True 8 0.0 False 0.5 False 0.0 False”
True) –
- ” DQ1 DQ1_signchange DQ2 DQ2_signchange DQ3 DQ3_signchange
0 NaN True NaN True NaN True 1 0.0 True NaN True NaN True 2 2.0 False 4.0 True NaN True 3 1.0 False -1.0 True -5.0 True 4 1.0 False 0.0 False 1.0 True 5 1.0 True 0.0 True 0.0 True 6 -1.0 False -2.0 True -2.0 True 7 -0.5 True 0.5 False 2.5 True 8 0.0 False 0.5 False 0.0 False”
axis=1) –
- ” DQ1 DQ1_signchange DQ2 DQ2_signchange DQ3 DQ3_signchange
0 NaN True NaN True NaN True 1 0.0 True NaN True NaN True 2 2.0 False 4.0 True NaN True 3 1.0 False -1.0 True -5.0 True 4 1.0 False 0.0 False 1.0 True 5 1.0 True 0.0 True 0.0 True 6 -1.0 False -2.0 True -2.0 True 7 -0.5 True 0.5 False 2.5 True 8 0.0 False 0.5 False 0.0 False”
- Returns
DQ1 (pd.Series of float) – Differential quotient 1st grade (rise) of y to x.
DQ1_si (pd.Series of bool) – Signs of DQ1.
DQ1_sc (pd.Series of bool) – Indicates sign changes of DQ1.
DQ2 (pd.Series of float) – Differential quotient 2nd grade (curvature) of y to x.
DQ2_si (pd.Series of bool) – Signs of DQ2.
DQ2_sc (pd.Series of bool) – Indicates sign changes of DQ2.
DQ3 (pd.Series of float) – Differential quotient 3rd grade (curvature change) of y to x.
DQ3_si (pd.Series of bool) – Signs of DQ3.
DQ3_sc (pd.Series of bool) – Indicates sign changes of DQ3.
- exmecheva.common.mc_char.Diff_Quot3(y, x=None, deep=3, ex_bool=True, ex_kwargs={'polydeg': 1}, smooth_bool=False, smooth_type='SMA', smooth_opts={'window_length': 3}, sc_kwargs={'norm': 'absmax', 'normadd': 0.5, 'th': 0.05, 'th_option': 'abs', 'th_set_val': 0}, shift_value=False, opt_out='DataFrame')[source]
Computes difference quotient of input arrays (nth-grade) and their signs, as well as sign changes to find points of inconstancy in measured curves.
- Parameters
y (pd.Series of float) – Ordinate of the curve for which the difference quotient is to be determined.
x (pd.Series of float or None, optional) – Abscissa of the curve for which the difference quotient is to be determined. The default is None.
deep (int, optional) – Number of differential quotients to determine. The default is 3.
ex_bool (bool, optional) – Switch for extending data with Extend_Series_n_setter and afterwards retrim them with Retrim_Series. The default is True.
ex_kwargs (dict, optional) – Keyword arguments for Extend_Series_n_setter. The default is {‘polydeg’:1}.
smooth_bool (bool or string, optional) – Switch for smoothing of data. Must ether be True or False or in [‘Input’,’x-only’,’y-only’,’yandDQ’,’DQ’]. The default is False.
smooth_type (string, optional) – Type of smoothing methode (see Smoothsel for further information). The default is ‘SMA’.
smooth_opts (dict, optional) – Smoothing option for choosen method (see Smoothsel for further information). The default is {‘window_length’:3}.
sc_kwargs (dict, optional) –
Keyword arguments for sign and sign change determination (normalization and thresholding, for further information see ./analyze.sign_n_changeth). The default is {‘norm’:’absmax’, ‘normadd’:0.5,
’th’:0.05, ‘th_option’:’abs’, ‘th_set_val’:0}.
shift_value (bool or int, optional) – Shifting of values. The default is False.
opt_out (string, optional) – Output option (only DataFrame or DF implemented yet). The default is ‘DataFrame’.
- Raises
TypeError – Determination length of smooth_opts seems to be wrong.
NotImplementedError – Output option not implemented.
- Returns
out – Differnece quotients, signs and sign changes of given input data.
- Return type
pd.DataFrame
- exmecheva.common.mc_char.YM_eva_range_refine(m_df, VIP, n_strain, n_stress, n_loBo='S', n_upBo='U', d_loBo=0.05, d_max=0.75, rise_det=[True, 4], n_Outlo='F3', n_Outmi='FM', n_Outhi='F4')[source]
Refines the Youngs Modulus determinition range according to “Keuerleber, M. (2006) - Bestimmung des Elastizitätsmoduls von Kunststoffen bei hohen Dehnraten am Beispiel von PP. Von der Fakultät Maschinenbau der Universität Stuttgart zur Erlangung der Würde eines Doktor-Ingenieurs (Dr.-Ing.) genehmigte Abhandlung. Doktorarbeit. Universität Stuttgart, Stuttgart”
- Parameters
m_df (pd.DataFrame) – Measured data.
VIP (pd.Series) – Important points corresponding to measured data.
n_strain (string) – Name of used strain (have to be in measured data).
n_stress (string) – Name of used stress (have to be in measured data).
n_loBo (string) – Lower border for determination (have to be in VIP). The default is ‘S’.
n_upBo (string) – Upper border for determination (have to be in VIP). The default is ‘U’.
d_loBo (float/str, optional) – When float: Percentage of range between n_upBo and n_loBo as start distance to n_loBo. When str starting with ‘S’, followed by integer: Distance in steps to n_loBo. The default is 0.05.
d_max (float, optional) – Percentage of . The default is 0.75.
rise_det ([bool, int], optional) – Determination options for stress rising ([smoothing, smoothing factor]).
n_Outlo (string, optional) – Name of new lower border. The default is ‘F3’.
n_Outmi (string, optional) – Name of maximum differential quotient. The default is ‘FM’.
n_Outhi (string, optional) – Name of new upper border. The default is ‘F4’.
- Yields
VIP_new (pd.Series) – Important points corresponding to measured data.
txt (string) – Documantation string.
- exmecheva.common.mc_char.curve_characterizer(x, y, ex_bool=True, ex_kwargs={'polydeg': 1}, smooth_bool=True, smooth_type='SMA', smooth_opts={'window_length': 3}, shift_value=-1, sc_kwargs={'norm': 'absmax', 'normadd': 0.5, 'th': 0.05, 'th_option': 'abs', 'th_set_val': 0}, peak_norm='absmax', peak_kwargs={'height': 0.1, 'prominence': 0.1}, cc_snip=3, cc_threshold=0.01, cc_norm='abs_max_ref', cc_refine=True, ccr_threshold=0.75, ccr_norm='abs_mid', nan_policy='omit')[source]
Characterize a measured curve. To plot results please see curve_char_plotter in ./plotting.py.
- Parameters
x (pandas Series of float, or pandas.DataFrame) – Abscissa or difference quotient dataframe of input.
y (pandas Series of float) – Ordinate of input.
smooth_bool (bool or string, optional) – Smoothing behavior. The default is True.
smooth_type (string, case-sensitive, optional) –
Choosen smoothing type. Optional. The defalut is ‘SMA’. Possible are:
’SMA’: Moving average based on numpy.convolve.
’SMA_f1d’: Moving average based scipy.ndimage.filters.uniform_filter1d.
’SavGol’: Savitzky-Golay filter based on scipy.signal.savgol_filter.
smooth_opts (dict, optional) – Keywords and values to pass to smoothing method. For further informations see smooth_type and linked methods. Optional. The defalut is {‘window_length’:3, ‘mode’:’same’}.
smooth_snip (bool or integer, optional) – Trimming of output. Either, if True with window_length in smooth_opts, none if False, or with inserted distance. The default is False.
opt_shift (bool) – Shifting returned values to pointed input values. If False it points to the index before. Leading to a difficult to handle shift. Optional. The defalut is False.
peak_norm (string, optional) – Normalization method. The default is ‘absmax’.
peak_kwargs (dict, optional) – Keyword arguments to pass to scipy.signal.find_peaks. The default is {‘prominence’:0.1, ‘height’:0.1}.
cc_snip (corresponding type of index, optional) – Determination distance to start and end for characterization of section. The default is 3.
cc_threshold (float, optional) – Determination threshold for characterization of section. The default is 0.01.
cc_norm (string, optional) – Nomralization method for characterization of section. The default is ‘abs_max_ref’.
cc_refine (bool, optional) – Turn refinement by curvature of curve section on. The default is True.
ccr_threshold (float, optional) – Determination threshold of refinement. The default is 0.75.
ccr_norm (string, optional) – Nomralization method of refinement. The default is ‘abs_mid’.
- Returns
pandas Dataframe –
- Characterization of input (for linear parts: linearisation and
intersection to previous included).
pandas Series – Points of first characteriation(S=Start,E=End, I=Increase, D=Decrease).
pandas Dataframe – Maxima and minima of input, as well as differential quotients.
pandas Dataframe – Input, as well as differential quotients.
- exmecheva.common.mc_char.curve_merger(cps1, cps2, how='1stMax', option='nearest')[source]
Finds time offset between two measured curves.
- Parameters
cps1 (pandas Dataframe (result of curve_characterizer)) – First curve characterization.
cps2 (pandas Dataframe (result of curve_characterizer)) – Second curve characterization.
how (string, optional) –
- Switch for how to determine time offset. Possible are:
’1stMax’: first maximum
’wo_1st+last’: without first and last relevant positions
’complete’: all relevant positions
’list;[x,x,…]’: list of relevant positions
’int;x’: one relevant position
’fix;x’: fixed time offset
The default is ‘1stMax’.
option (string, optional) – Switch for offset determination. The default is ‘nearest’ (merging nearest positions found in both frames).
- Raises
NotImplementedError – Method not implemented.
- Returns
t_off (float) – Offset to apply on first to merge second.
t1 (float or pd.Series) – Timestamp/-s of first curve characterization.
t2 (float or pd.Series) – Timestamp/-s of second curve characterization.
- exmecheva.common.mc_char.curvecar_refine(i_start, i_mid, i_end, ref_ser, threshold=0.5, norm='abs_mid', out_vals=['', 'Pos', 'Neg'])[source]
Determine type, as well as new start and end points, of a refined section by comparing a reference series to a given threshold.
- Parameters
i_start (corresponding type of index) – Start index of first section.
i_mid (corresponding type of index) – Index between sections.
i_end (corresponding type of index) – End index of second section.
ref_ser (pands Series) – Reference series.
threshold (float, optional) – Determination threshold. The default is 0.5.
norm (string, optional) – Nomralization method. The default is ‘abs_mid’.
out_vals (array of strings, optional) – Strings for determination type. The default is [‘’,’Pos’,’Neg’].
- Returns
string – Determined type of curve section.
corresponding type of index – New start point of refined curve section.
corresponding type of index – New end point of refined curve section.
float – Mean value over range of reference series.
- exmecheva.common.mc_char.curvecar_section(i_start, i_end, ref_ser, sm_w_length=0, threshold=0.01, norm='abs_max_ref', out_vals=['', 'Const', 'Rise', 'Fall'], kind='median')[source]
Determine type of section by comparing a reference series to a given threshold.
- Parameters
i_start (corresponding type of index) – Start index of section.
i_end (corresponding type of index) – End index of section.
ref_ser (pands Series) – Reference series.
sm_w_length (corresponding type of index, optional) – Determination distance to start and end. The default is 0.
threshold (float, optional) – Determination threshold. The default is 0.01.
norm (string, optional) – Nomralization method. The default is ‘abs_max_ref’.
out_vals (array of strings, optional) – Strings for determination type. The default is [‘’,’Const’,’Rise’,’Fall’].
- Returns
string – Determined type of curve section.
float – Mean value over range of reference series.
- exmecheva.common.mc_char.find_SandE(Val, Val2, drop_op, drop_val)[source]
Computes first and last indices which fullfill the choosen condition.
- Parameters
Val (pd.Series([],dtype='float64')) – Input value.
Val2 (pd.Series([],dtype='float64')) – Testing value.
drop_op (string, case-sensitive) – Condition name (abV_self,pgm_self,pgm_other,qua_self),
drop_val (float64) – Value for condition.
- Returns
iS (TYPE) – First index which fullfill the choosen condition.
iE (TYPE) – Last index which fullfill the choosen condition.
- exmecheva.common.mc_char.peaky_finder(df, cols='all', norm='absmax', fp_kwargs={'height': 0.1, 'prominence': 0.1}, out_opt='valser-loc')[source]
Find peaks in passed input data.
- Parameters
df (pandas DataFrame) – Input data.
cols (string or array of strings or boolean, optional) – Columns (axis=1) of data to use. The default is ‘all’.
norm (string, optional) – Normalization method. The default is ‘absmax’.
fp_kwargs (dict, optional) – Keyword arguments to pass to scipy.signal.find_peaks. The default is {‘prominence’:0.1, ‘height’:0.1}.
out_opt (string, optional) – Output options. The default is ‘valser-loc’.
- Raises
NotImplementedError – Option not implemented.
- Returns
o – Series with input-columns as index and array of input index as values.
- Return type
Series of arrays
- exmecheva.common.mc_char.peaky_finder_MM(df, cols='all', norm='absmax', fp_kwargs={'height': 0.1, 'prominence': 0.1}, out_opt='valser-loc')[source]
Pacckage method of peaky_finder to find maxima and minima.
- exmecheva.common.mc_char.poi_det_plh(x, y, cps, z=None, dft=None, det_dist=2, det_r='RF', refineP=True)[source]
Automatically determines high and low points, as well of points with with changing rise based on a given curve.
- Parameters
x (pd.Series) – Input data on abcissa, p.e. time.
y (pd.Series) – Input data on ordinate, p.e. force.
cps (pandas Dataframe (first result of curve_characterizer)) – Measurement curve characterization.
z (pd.Series, optional) – Additional input data on ordinate, p.e. displacement. The default is None.
dft (pandas Dataframe (last result of curve_characterizer), optional) – Input, as well as differential quotients. Used if refineP is True. The default is None.
det_dist (int, optional) – Determination distance. The default is 2.
det_r (string, optional) – Determination range selection keyword to search in cps. The default is ‘RF’.
refineP (bool, optional) – Switch for refinement. The default is True.
- Returns
cip (pd.Series) – Points of interest, with index by names and value by index of input. data. Labels are ‘H’-high point, ‘L’-low point, ‘Pl’-rise change on loading and ‘Pu’-rise change on unloading.
c (int) – Number of cyclic loadings.
Example
- if ((‘preload’ in _opts[‘OPT_Testtype’])
or (‘cyclic’ in _opts[‘OPT_Testtype’])):
- Vt, cycles = poi_det_plh(x=messu.Time, y=messu.Force,
cps=cps_t, z=messu.Way, dft=df_t, det_dist=_opts[‘OPT_Determination_Distance’], det_r=’RF’, refineP=True)
VIP_messu = Vt.combine_first(VIP_messu).sort_values().astype(int)
- exmecheva.common.mc_char.poi_fixeva(pds, p, iS=None, iE=None, range_sub='min', norm='max', option='abs', check_irr=False, irr=None, irr_opt='nearest')[source]
Determine points for start and end of fixed range determination (by ratios to given value).
- Parameters
pds (pd.Series) – Input values, p.e. measured stress data.
p (list of two floats) – Lower (first) and upper (second) border of determination range.
iS (TYPE, optional) – DESCRIPTION. The default is None.
iE (TYPE, optional) – DESCRIPTION. The default is None.
range_sub (TYPE, optional) – DESCRIPTION. The default is ‘min’.
norm (TYPE, optional) – DESCRIPTION. The default is ‘max’.
option (TYPE, optional) – DESCRIPTION. The default is ‘abs’.
check_irr (TYPE, optional) – DESCRIPTION. The default is False.
irr (TYPE, optional) – DESCRIPTION. The default is None.
irr_opt (TYPE, optional) – DESCRIPTION. The default is ‘nearest’.
- Raises
NotImplementedError – DESCRIPTION.
- Returns
TYPE – DESCRIPTION.
TYPE – DESCRIPTION.
TYPE – DESCRIPTION.
Example
- for cc in np.arange(1,cycles+1):
- tmp_iS=poi_vip_namer(VIP=VIP_messu,ttype=_opts[‘OPT_Testtype’],
key=_opts[‘OPT_YM_Determination_range’][-2], cc=cc,mc=cycles,lu=’l’)
- tmp_iE=poi_vip_namer(VIP=VIP_messu,ttype=_opts[‘OPT_Testtype’],
key=_opts[‘OPT_YM_Determination_range’][-1], cc=cc,mc=cycles,lu=’l’)
- tmp,_,_ = poi_fixeva(pds=messu.Stress,
p=_opts[‘OPT_YM_Determination_range’][0:2], iS=VIP_messu[tmp_iS], iE=VIP_messu[tmp_iE], range_sub=’min’, norm=’max’, option=’abs’, check_irr=True, irr=messu[messu.driF_schg].index.values, irr_opt=’nearest’)
VIP_messu[‘FlA’+str(cc)],VIP_messu[‘FlB’+str(cc)]=tmp if not ((‘destructive’ in _opts[‘OPT_Testtype’]) and cc==cycles):
- tmp_iS=poi_vip_namer(VIP=VIP_messu,ttype=_opts[‘OPT_Testtype’],
key=_opts[‘OPT_YM_Determination_range’][-1], cc=cc,mc=cycles,lu=’u’)
- tmp_iE=poi_vip_namer(VIP=VIP_messu,ttype=_opts[‘OPT_Testtype’],
key=_opts[‘OPT_YM_Determination_range’][-2], cc=cc,mc=cycles,lu=’u’)
- tmp,_,_ = poi_fixeva(pds=messu.Stress,
p=_opts[‘OPT_YM_Determination_range’][0:2], iS=VIP_messu[tmp_iS], iE=VIP_messu[tmp_iE], range_sub=’min’, norm=’max’, option=’abs’, check_irr=True, irr=messu[messu.driF_schg].index.values, irr_opt=’nearest’)
VIP_messu[‘FuB’+str(cc)],VIP_messu[‘FuA’+str(cc)]=tmp
- exmecheva.common.mc_char.poi_refinement(DQ, B_ser, s_range, B_ind=None, names=['F3', 'M', 'F4'], Blp=0.15, Bup=0.95, Maxp=0.75, trimsch=True)[source]
Refine elastic modulus determination range according to a method described by Keuerleber [1]. ([1]: Keuerleber, M. (2006). Bestimmung des Elastizitätsmoduls von Kunststoffen bei hohen Dehnraten am Beispiel von PP. Von der Fakultät Maschinenbau der Universität Stuttgart zur Erlangung der Würde eines Doktor-Ingenieurs (Dr.-Ing.) genehmigte Abhandlung. Doktorarbeit. Universität Stuttgart, Stuttgart.)
- Parameters
DQ (pd.DataFrame) – Stress-strain-curve differential quotients and sign changes. Generated by Diff_Quot.
B_ser (pd.Series) – Input data, p.e. stress, to search for given lower limit ratio (Blp) und upper limit ratio (Bup) for refined range.
s_range (list) – Start and end of step range to search for refined range.
B_ind (int, optional) – Index for B_ser. The default is None. Not implemented yet (using absolute maximum of given B_ser values instead).
names (list of string, optional) – Output names for lower limit, maximum of differental quotient and upper limit. The default is [‘F3’,’M’,’F4’].
Blp (float, optional) – Lower limit ratio to identified B_ser value (p.e. maximum stress). The default is 0.15.
Bup (float, optional) – Upper limit ratio to identified B_ser value (p.e. maximum stress). The default is 0.95.
Maxp (float, optional) – Lowest value to include in refined range. The default is 0.75. (i.e. 75 % of the maximum differntail quotient)
trimsch (bool, optional) – Switch for trimming step range of differential quotients. The default is True.
- Returns
VIP (pd.Series) – Determined points of interest as series of steps indexed by given names.
DQs (pd.DataFrame) – Differential quotients limitet to range.
Example
DQcons=None DQopts=None for cc in np.arange(1,cycles+1):
- tmp_iS=poi_vip_namer(VIP=VIP_messu,ttype=_opts[‘OPT_Testtype’],
key=_opts[‘OPT_YM_Determination_refinement’][2], cc=cc,mc=cycles,lu=’l’)
- tmp_iE=poi_vip_namer(VIP=VIP_messu,ttype=_opts[‘OPT_Testtype’],
key=_opts[‘OPT_YM_Determination_refinement’][3], cc=cc,mc=cycles,lu=’l’)
- tmp,DQcont = poi_refinement(DQ=DQcon, B_ser=messu.loc(axis=1)[‘Stress’],
s_range=[VIP_messu[tmp_iS],VIP_messu[tmp_iE]], names=[‘RlA’+str(cc),’RlM’+str(cc),’RlB’+str(cc)], Blp=_opts[‘OPT_YM_Determination_refinement’][0], Bup=1.0-_opts[‘OPT_YM_Determination_refinement’][0], Maxp=_opts[‘OPT_YM_Determination_refinement’][1])
VIP_messu=tmp.combine_first(VIP_messu).sort_values().astype(int) if DQcons is None:
DQcons = DQcont
- else:
DQcons=pd.concat([DQcons,DQcont],axis=0)
- tmp,DQoptt = poi_refinement(DQ=DQopt, B_ser=messu.loc(axis=1)[‘Stress’],
s_range=[VIP_messu[tmp_iS],VIP_messu[tmp_iE]], names=[‘RlA’+str(cc),’RlM’+str(cc),’RlB’+str(cc)], Blp=_opts[‘OPT_YM_Determination_refinement’][0], Bup=1.0-_opts[‘OPT_YM_Determination_refinement’][0], Maxp=_opts[‘OPT_YM_Determination_refinement’][1])
VIP_dicu=tmp.combine_first(VIP_dicu).sort_values().astype(int) if DQopts is None:
DQopts = DQoptt
- else:
DQopts=pd.concat([DQopts,DQoptt],axis=0)
- if not ((‘destructive’ in _opts[‘OPT_Testtype’]) and cc==cycles):
- tmp_iS=poi_vip_namer(VIP=VIP_messu,ttype=_opts[‘OPT_Testtype’],
key=_opts[‘OPT_YM_Determination_refinement’][3], cc=cc,mc=cycles,lu=’u’)
- tmp_iE=poi_vip_namer(VIP=VIP_messu,ttype=_opts[‘OPT_Testtype’],
key=_opts[‘OPT_YM_Determination_refinement’][2], cc=cc,mc=cycles,lu=’u’)
- tmp,DQcont = poi_refinement(DQ=DQcon, B_ser=messu.loc(axis=1)[‘Stress’],
s_range=[VIP_messu[tmp_iS],VIP_messu[tmp_iE]], names=[‘RuA’+str(cc),’RuM’+str(cc),’RuB’+str(cc)], Blp=_opts[‘OPT_YM_Determination_refinement’][0], Bup=1.0-_opts[‘OPT_YM_Determination_refinement’][0], Maxp=_opts[‘OPT_YM_Determination_refinement’][1])
VIP_messu=tmp.combine_first(VIP_messu).sort_values().astype(int) if DQcons is None:
DQcons = DQcont
- else:
DQcons=pd.concat([DQcons,DQcont],axis=0)
- tmp,DQoptt = poi_refinement(DQ=DQopt, B_ser=messu.loc(axis=1)[‘Stress’],
s_range=[VIP_messu[tmp_iS],VIP_messu[tmp_iE]], names=[‘RuA’+str(cc),’RuM’+str(cc),’RuB’+str(cc)], Blp=_opts[‘OPT_YM_Determination_refinement’][0], Bup=1.0-_opts[‘OPT_YM_Determination_refinement’][0], Maxp=_opts[‘OPT_YM_Determination_refinement’][1])
VIP_dicu=tmp.combine_first(VIP_dicu).sort_values().astype(int) if DQopts is None:
DQopts = DQoptt
- else:
DQopts=pd.concat([DQopts,DQoptt],axis=0)
- exmecheva.common.mc_char.poi_rel_finder(cip, cycles, xser, df, dx=None, POI_start='P', POI_sec=['l', 'u'], comp_dfx='x', rel_df='DQ2', ascending=True)[source]
Finds the relevant point from several given points. For example, if there are several rise changes (e.g. due to measurement deviation), an attempt is made to find the actual one.
- Parameters
cip (pd.Series ((interim-)result of poi_det_plh)) – Points of interest, with index by names and value by index of input. data. Labels are ‘H’-high point, ‘L’-low point, ‘Pl’-rise change on loading and ‘Pu’-rise change on unloading.
cycles (int) – Number of cyclic loadings.
xser (pd.Series) – Input data on abcissa, p.e. time.
df (pandas Dataframe (last result of curve_characterizer), optional) – Input, as well as differential quotients.
dx (float or None, optional) – Test range. The default is None.
POI_start (str, optional) – Start of point of interest name. The default is ‘P’.
POI_sec (list of strings, optional) – Second part of point of interest name. The default is [‘l’,’u’].
comp_dfx (string, optional) – Comparision data on df. The default is ‘x’.
rel_df (string, optional) – Relevant data on df for testing (DQ1=ris and DQ2=curve). The default is ‘DQ2’.
ascending (bool, optional) – Switch for ascending or descending. The default is True.
- Returns
Vren – Renamer for relevant points.
- Return type
pd.Series
Example
- Vren=poi_rel_finder(cip=cip, cycles=cycles, xser=x,
df=dft, dx=x.diff().mean()*(det_dist), POI_start=’P’, POI_sec=[‘l’,’u’], comp_dfx=’x’, rel_df=’DQ2’, ascending=True)
cip.index=cip.index.to_series().replace(Vren).values
- exmecheva.common.mc_char.poi_vip_namer(VIP, ttype, key, cc=1, mc=1, lu='l')[source]
Automatic naming of points of interest to use before poi_fixeva and poi_refinement. Replaces given string by its equivalent for current cycle. For example if key is ‘P’ (may be lower edge of elastic modulus determination range) and lu=’l’ it will find ‘Pl1’ for the first cycle and ‘L3’ for the third cycle.
- Parameters
VIP (pd.Series) – Identified points of interest. Index by name and value by index of measurement dataframe.
ttype (string) – Test type, i.e. type of applied loading. Searches only for ‘cyclic’ and ‘destructive’.
key (string) – Label for naming, possible are ‘H’-high point, ‘L’-low point, ‘P’-rise change and ‘S’-start.
cc (int, optional) – Current cycle. The default is 1.
mc (int, optional) – maximum applied cycles. The default is 1.
lu (string, optional) – Loading (‘l’) or unloading (‘u’). The default is ‘l’.
- Returns
Found name of point of interest.
- Return type
string
Example
- for cc in np.arange(1,cycles+1):
- tmp_iS=poi_vip_namer(VIP=VIP_messu,ttype=_opts[‘OPT_Testtype’],
key=_opts[‘OPT_YM_Determination_range’][-2], cc=cc,mc=cycles,lu=’l’)
- tmp_iE=poi_vip_namer(VIP=VIP_messu,ttype=_opts[‘OPT_Testtype’],
key=_opts[‘OPT_YM_Determination_range’][-1], cc=cc,mc=cycles,lu=’l’)
- tmp,_,_ = poi_fixeva(pds=messu.Stress,
p=_opts[‘OPT_YM_Determination_range’][0:2], iS=VIP_messu[tmp_iS], iE=VIP_messu[tmp_iE], range_sub=’min’, norm=’max’, option=’abs’, check_irr=True, irr=messu[messu.driF_schg].index.values, irr_opt=’nearest’)
VIP_messu[‘FlA’+str(cc)],VIP_messu[‘FlB’+str(cc)]=tmp if not ((‘destructive’ in _opts[‘OPT_Testtype’]) and cc==cycles):
- tmp_iS=poi_vip_namer(VIP=VIP_messu,ttype=_opts[‘OPT_Testtype’],
key=_opts[‘OPT_YM_Determination_range’][-1], cc=cc,mc=cycles,lu=’u’)
- tmp_iE=poi_vip_namer(VIP=VIP_messu,ttype=_opts[‘OPT_Testtype’],
key=_opts[‘OPT_YM_Determination_range’][-2], cc=cc,mc=cycles,lu=’u’)
- tmp,_,_ = poi_fixeva(pds=messu.Stress,
p=_opts[‘OPT_YM_Determination_range’][0:2], iS=VIP_messu[tmp_iS], iE=VIP_messu[tmp_iE], range_sub=’min’, norm=’max’, option=’abs’, check_irr=True, irr=messu[messu.driF_schg].index.values, irr_opt=’nearest’)
VIP_messu[‘FuB’+str(cc)],VIP_messu[‘FuA’+str(cc)]=tmp
- exmecheva.common.mc_char.rise_curve(meas_curve, smoothbool, smooth_lvl)[source]
Computes partial integration (1st[rise] and 2nd-grade[curvature]) to find points of inconstancy in measured curves
- exmecheva.common.mc_char.test_pdmon(df, cols, m, dist)[source]
Test of monotonic de-/increasing in dataframe columns.
- Parameters
df (pd.DataFrame) – Dataframe which includes cols as Column-names.
cols (string or array of strings) – Column-names for monotonic test.
m (np.int) – Kind of monotoni (1=increasing, -1=decreasing).
dist (np.int) – test distance of monotonic creasing.
- Returns
d – Series with index ‘cols’ of last ‘df.index’ with monotonic de-/increasing of ‘dist’-length.
- Return type
pd.Series([],dtype=’float64’)
exmecheva.common.mc_man module
Adds functionality to temporary manipulate measurement curves.
@author: MarcGebhardt
- exmecheva.common.mc_man.DetFinSSC(mdf, YM, iS, iLE=None, StressN='Stress', StrainN='Strain', addzero=True, izero=None, option='YM')[source]
Determine final stress-strain curve (moved to strain offset from elastic modulus).
- Parameters
mdf (pd.DataFrame) – Original stress-strain curve data.
YM (dict or pd.Series or float) – Elastic modulus (float) or elastic modulus (key=E) and intersection on strain=0 (key=Eabs) or direct input of strain offset (if option is in [‘strain_offset’,’SO’,’so’]).
iS (index of mdf) – Start of linear behavior (all values befor will dropped).
iLE (TYPE, optional) – End of linear behavior (if None, strain offset will determined only with iS). The default is None.
StressN (string, optional) – Column name for stress variable. The default is ‘Stress’.
StrainN (TYPE, optional) – Column name for strain variable. The default is ‘Strain’.
addzero (bool, optional) – Switch to adding Zero value (index,StressN,StrainN=0). The default is True.
izero (index of mdf, optional) – Index for zero value line (p.e. to match old start index)
option (string, optional) –
- Option for strain offset. Possible:
’YM’: Strain offset determined by elastic modulus.
[‘strain_offset’,’SO’,’so’]: Direct input of strain offset.
The default is ‘YM’.
- Returns
out (pd.DataFrame) – Moved stress-strain curve data.
so (float) – Strain offset.
- exmecheva.common.mc_man.Diff_ext(x, periods=1, axis=0, pfunc=<function Extend_Series_Poly>, pkwargs={}, shift_value=0, fill_value=None)[source]
Calculates the difference of input values after extension and retrims.
- Parameters
x (pd.Series or pd. DataFrame) – Input values.
periods (int, optional) – Periods to shift (see pandas diff). The default is 1.
axis (integer, optional) – Axis to apply. The default is 0.
pfunc (function, optional) – Extension function. The default is Extend_Series_Poly.
pkwargs (dict, optional) –
- Keyword arguments passed to extening funtion (pfunc).
The default is {}.
shift_value (int, optional) – Value for shifting. The default is 0.
fill_value (int or None, optional) –
- Value for filling free values after shifting.
The default is None, which apply self.dtype.na_value.
- Raises
TypeError – DESCRIPTION.
- Returns
xout – Output values.
- Return type
pd.Series or pd. DataFrame
- exmecheva.common.mc_man.Extend_Series_Poly(y, n=3, polydeg=1, kind='fb')[source]
Extend an Array or series with polynomial values.
- Parameters
y (numpy.array or pandas.Series) – Input values.
n (int or list of or dict of kind{'f':int,'b':int}) – Number of points to extend. Must be at least equal to the order of the polynomial. Could be 0 (skipping extension).
polydeg (int or list of or dict of kind{'f':int,'b':int}, optional) – Order of polynom. The default is 1.
kind (str, optional) – Kind of extension (‘f’-forward, ‘b’-backward and ‘fb’-both). The default is ‘fb’.
- Raises
TypeError – DESCRIPTION.
- Returns
yout – Extended input values.
- Return type
numpy.array or pandas.Series
- exmecheva.common.mc_man.Extend_Series_n_setter(ffunctype='Smooth', ffuncargs=(), ffunckwargs={})[source]
Sets window length for extending of series by given aspiired function.
- Parameters
ffunctype (function, optional) – Function to use after extension. The default is ‘Smooth’.
ffuncargs (list, optional) – Arguments for function. The default is ().
ffunckwargs (dict, optional) – Keyword arguments for function. The default is {}.
- Raises
ValueError – No valid value found for extension length.
- Returns
ntmp – Extension length.
- Return type
integer
- exmecheva.common.mc_man.Predict_apply_retrim(x, afunc=None, pfunc=<function Extend_Series_Poly>, aargs=[], akwargs={}, pargs=[], pkwargs={'kind': 'fb', 'n': 3, 'polydeg': 1}, shift_value=0, fill_value=None)[source]
Predict input over their boundary values, apply a function and retrim to original size.
- Parameters
x (numpy.array or pandas.Series) – Input values.
afunc (function, optional) –
- Function for manipulation to apply after extending the input values.
The default is None.
pfunc (function, optional) –
- Function for extending the input values.
The default is Extend_Series_Poly.
aargs (list, optional) –
- Arguments passed to manipulation funtion (afunc).
The default is [].
akwargs (dict, optional) –
- Keyword arguments passed to manipulation funtion (afunc).
The default is {}.
pargs (list, optional) –
- Arguments passed to extening funtion (pfunc).
The default is [].
pkwargs (dict, optional) –
- Keyword arguments passed to extening funtion (pfunc).
The default is {‘n’:1, ‘polydeg’:1, ‘kind’:’fb’}.
shift_value (int, optional) – Value for shifting. The default is 0.
fill_value (int or None, optional) –
- Value for filling free values after shifting.
The default is None, which apply self.dtype.na_value.
- Raises
TypeError – Not expected data type.
- Returns
xout – Manipualted output values.
- Return type
numpy.array or pandas.Series
- exmecheva.common.mc_man.Retrim_Series(y, axis=0, n=0, kind='fb')[source]
Retrim an Array or series after extension.
- Parameters
y (numpy.array or pandas.Series or pandas.DataFrame) – Input values.
n (int or list of or dict of kind{'f':int,'b':int}) – Number of points which are extend. Could be 0 (skip retrimming).
kind (str, optional) – Kind of extension (‘f’-front, ‘b’-back and ‘fb’-both). The default is ‘fb’.
- Raises
TypeError – DESCRIPTION.
- Returns
yout – Extended input values.
- Return type
numpy.array or pandas.Series
- exmecheva.common.mc_man.Smoothsel(x, smooth_type='SMA', smooth_opts={'mode': 'nearest', 'window_length': 3}, snip=False, conv_method='scipy')[source]
Computes a smoothed version of an input array, according to different smoothing types.
- Parameters
x (array or pandas.Series of float) – Input values.
smooth_type (string, case-sensitive, optional) –
Choosen smoothing type. Optional. The defalut is ‘SMA’. Possible are:
’SMA’: Simple moving average based on numpy.convolve.
’BMA’: Moving average with binomial coefficents based on numpy.convolve.
’SMA_f1d’: Simple moving average based scipy.ndimage.filters.uniform_filter1d.
’SavGol’: Savitzky-Golay filter based on scipy.signal.savgol_filter.
smooth_opts (dict, optional) – Keywords and values to pass to smoothing method. For further informations see smooth_type and linked methods. Optional. The defalut is {‘window_length’:3, ‘mode’:’nearest’}.
snip (bool or integer, optional) – Trimming of output. Either, if True with (window_length-1)//2 in smooth_opts, none if False, or with inserted distance. The default is False.
conv_method (string, optional) –
- Convolve method to use (‘numpy’ for numpy.convolve,
’scipy’ for scipy.ndimage.convolve1d)
The default is ‘scipy’.
- Raises
TypeError – Type not expected.
NotImplementedError – Not implemented.
- Returns
out – Output values.
- Return type
array or pandas.Series of float
- exmecheva.common.mc_man.Smoothsel_ext(x, axis=0, smooth_type='SMA', smooth_opts={'mode': 'nearest', 'window_length': 3}, snip=False, conv_method='scipy', pfunc=<function Extend_Series_Poly>, pkwargs={}, shift_value=0, fill_value=None, so_idks=['window_length', 'size', 'box', 'box_pts'])[source]
Smoothes extended data and retrimes afterwards.
- Parameters
x (pd.Series or pd.DataFrame) – Input data.
axis (int, optional) – 2D axis to apply. The default is 0.
smooth_type (string, case-sensitive, optional) –
Choosen smoothing type. Optional. The defalut is ‘SMA’. Possible are:
’SMA’: Simple moving average based on numpy.convolve.
’BMA’: Moving average with binomial coefficents based on numpy.convolve.
’SMA_f1d’: Simple moving average based scipy.ndimage.filters.uniform_filter1d.
’SavGol’: Savitzky-Golay filter based on scipy.signal.savgol_filter.
smooth_opts (dict, optional) – Keywords and values to pass to smoothing method. For further informations see smooth_type and linked methods. Optional. The defalut is {‘window_length’:3, ‘mode’:’nearest’}.
snip (bool or integer, optional) – Trimming of output. Either, if True with (window_length-1)//2 in smooth_opts, none if False, or with inserted distance. The default is False.
conv_method (string, optional) –
- Convolve method to use (‘numpy’ for numpy.convolve,
’scipy’ for scipy.ndimage.convolve1d)
The default is ‘scipy’.
pfunc (function, optional) – Function for extension. The default is Extend_Series_Poly.
pkwargs (dict, optional) – Keywords for extension function (pfunc). The default is {}.
shift_value (int, optional) – Value for shifting. The default is 0.
fill_value (int or None, optional) –
- Value for filling free values after shifting.
The default is None, which apply self.dtype.na_value.
so_idks (list of string, optional) – Smoothing options Keywords to search for extension length. The default is [‘window_length’,’size’,’box’,’box_pts’].
- Raises
TypeError – Input type error.
ValueError – No extension length found.
- Returns
xout – Output data.
- Return type
pd.Series or pd.DataFrame
- exmecheva.common.mc_man.check_params(test_val, test_var='n', func=<function Extend_Series_Poly>, args=(), kwargs={'polydeg': 1})[source]
Checkes if tested values merge with given function.
- Parameters
test_val (TYPE) – Variable value to test.
test_var (TYPE, optional) – Variable name. The default is ‘n’.
func (function, optional) –
- Function to test. Implemented are:
Extend_Series_Poly
The default is Extend_Series_Poly.
args (list, optional) – Arguments for function. The default is ().
kwargs (dict, optional) – Keyword arguments for function. The default is {‘polydeg’:1}.
- Raises
NotImplementedError – Function not implemented.
- Returns
leg_val (bool) – Indicates if the input value is legitimate.
adj_val (TYPE) – Adjusted value.
leg_str (TYPE) – Output string.
- exmecheva.common.mc_man.mc_resampler(mdf, t_col='Time', resample=True, res_frequ=4, move_ave=True, ma_sampler='data_rf', rel_time_digs=2)[source]
Resample measured data to aspired frequancy, with or without moving average. Only tested with downsampling and integer frequency; fixed time format ‘s’ and 3 digits for resampling. TODO: Implement mc_smoothing.Smoothsel_ext
(extending, smoothing and retrimming).
- Parameters
mdf (pd.DataFrame) – Time depend measured data.
t_col (string, optional) – Name of time column. The default is ‘Time’.
resample (bool, optional) – Resampling switch. The default is True.
res_frequ (int, optional) – Aspired output frequency. The default is 4.
move_ave (bool, optional) – Switch for moving average. The default is True.
ma_sampler (string or int, optional) – Sampler for moving average. Can ether be option ‘data_rf’ (sampler derived from quotient of present to aspired frequency) or integer number. The default is ‘data_rf’.
rel_time_digs (int, optional) – Relevant digits for time variable. The default is 2.
- Returns
mdf – Resampled measured data.
- Return type
pd.DataFrame
exmecheva.common.mc_yield module
Created on Tue Dec 5 12:36:27 2023
@author: mgebhard
- exmecheva.common.mc_yield.Find_intg2p(gsl, gin, pdo, i1=None, i2=None, x='Strain', y='Stress', so=0, n_yield='Y')[source]
Determine intersection of line and point (usefull to find yield point)
- exmecheva.common.mc_yield.YM_eva_range_refine(m_df, VIP, n_strain, n_stress, n_loBo='S', n_upBo='U', d_loBo=0.05, d_max=0.75, rise_det=[True, 4], n_Outlo='F3', n_Outmi='FM', n_Outhi='F4')[source]
Refines the Youngs Modulus determinition range according to “Keuerleber, M. (2006) - Bestimmung des Elastizitätsmoduls von Kunststoffen bei hohen Dehnraten am Beispiel von PP. Von der Fakultät Maschinenbau der Universität Stuttgart zur Erlangung der Würde eines Doktor-Ingenieurs (Dr.-Ing.) genehmigte Abhandlung. Doktorarbeit. Universität Stuttgart, Stuttgart”
- Parameters
m_df (pd.DataFrame) – Measured data.
VIP (pd.Series) – Important points corresponding to measured data.
n_strain (string) – Name of used strain (have to be in measured data).
n_stress (string) – Name of used stress (have to be in measured data).
n_loBo (string) – Lower border for determination (have to be in VIP). The default is ‘S’.
n_upBo (string) – Upper border for determination (have to be in VIP). The default is ‘U’.
d_loBo (float/str, optional) – When float: Percentage of range between n_upBo and n_loBo as start distance to n_loBo. When str starting with ‘S’, followed by integer: Distance in steps to n_loBo. The default is 0.05.
d_max (float, optional) – Percentage of . The default is 0.75.
rise_det ([bool, int], optional) – Determination options for stress rising ([smoothing, smoothing factor]).
n_Outlo (string, optional) – Name of new lower border. The default is ‘F3’.
n_Outmi (string, optional) – Name of maximum differential quotient. The default is ‘FM’.
n_Outhi (string, optional) – Name of new upper border. The default is ‘F4’.
- Yields
VIP_new (pd.Series) – Important points corresponding to measured data.
txt (string) – Documantation string.
- exmecheva.common.mc_yield.Yield_redet(m_df, VIP, n_strain, n_stress, n_loBo, n_upBo, n_loBo_int, YM, YM_abs, strain_offset=0.002, rise_det=[True, 4], n_yield='Y')[source]
Redetermine yield point to different conditions (intersection with linearised strain offset (ones after), zero rising, fixed endpoint).
- Parameters
m_df (pd.DataFrame) – Measured data.
VIP (pd.Series) – Important points corresponding to measured data.
n_strain (string) – Name of used strain (have to be in measured data).
n_stress (string) – Name of used stress (have to be in measured data).
n_loBo ([string]) – List of lower borders for determination (have to be in VIP).
n_upBo ([string]) – List of upper borders for determination (have to be in VIP).
n_loBo_int ([string]) – List of lower borders for interseption (have to be in VIP).
YM (float) – Youngs Modulus.
YM_abs (float) – Absolut value of Youngs Modulus.
strain_offset (float, optional) – Strain offset (eq. plastic strain). The default is -0.002.
rise_det ([bool, int], optional) – Determination options for stress rising ([smoothing, smoothing factor]). The default is [True,4].
n_yield (string, optional) – Name of yield point (have to be in VIP). The default is ‘Y’.
- Returns
VIP_new (pd.Series) – Important points corresponding to measured data.
txt (string) – Documantation string.
- exmecheva.common.mc_yield.Yield_redet2(m_df, VIP, n_strain, n_stress, n_loBo, n_upBo, n_loBo_int, YM, YM_abs, strain_offset=0.002, use_rd=True, rise_det=[True, 4], n_yield='Y', ywhere='n')[source]
Redetermine yield point to different conditions (intersection with linearised strain offset (ones after), zero rising, fixed endpoint).
- Parameters
m_df (pd.DataFrame) – Measured data.
VIP (pd.Series) – Important points corresponding to measured data.
n_strain (string) – Name of used strain (have to be in measured data).
n_stress (string) – Name of used stress (have to be in measured data).
n_loBo ([string]) – List of lower borders for determination (have to be in VIP).
n_upBo ([string]) – List of upper borders for determination (have to be in VIP).
n_loBo_int ([string]) – List of lower borders for interseption (have to be in VIP).
YM (float) – Youngs Modulus.
YM_abs (float) – Absolut value of Youngs Modulus.
strain_offset (float, optional) – Strain offset (eq. plastic strain). The default is -0.002.
use_rd (bool, optional) – Switch for using change in stress rising. The default is True.
rise_det ([bool, int], optional) – Determination options for stress rising ([smoothing, smoothing factor]). The default is [True,4].
n_yield (string, optional) – Name of yield point (have to be in VIP). The default is ‘Y’.
ywhere (string, optional) – Which point should be choosen (n-next, a-after, b-before). The default is ‘n’.
- Returns
VIP_new (pd.Series) – Important points corresponding to measured data.
txt (string) – Documantation string.
- exmecheva.common.mc_yield.Yield_redet2_Multi(m_df, VIP, YM, YM_abs, strain_osd={'Y': 0.002, 'Y0': 0.0, 'Y1': 7.000000000000001e-05, 'YK': 0.0}, strain_osdf={'YK': 'F4'}, n_strain='Strain', n_stress='Stress', n_loBo=['F3'], n_upBo=['U'], n_loBo_int=['F3'], use_rd=True, rise_det=[True, 2], ywhere='n')[source]
exmecheva.common.output module
Functions for output data generation.
@author: MarcGebhardt
- exmecheva.common.output.Otvalgetter_Multi(mdf, Vs=['Y', 'YK', 'Y0', 'Y1', 'U', 'B'], datasep=['con', 'opt'], VIPs={'con': None, 'opt': None}, exacts={'con': None, 'opt': None}, orders={'con': ['f', 'e', 'U'], 'opt': ['e', 'U']}, add_esufs={'con': '_con', 'opt': '_opt'}, n_strains={'con': 'Strain', 'opt': 'DStrain'}, n_stresss={'con': 'Stress', 'opt': 'Stress'}, use_exacts=True)[source]
Wrapper for Outvalgetter.
- Parameters
mdf (TYPE) – DESCRIPTION.
Vs (list of strings, optional) – Relevant VIPs (have to be in VIP). The default is [‘Y’,’YK’,’Y0’,’Y1’,’U’,’B’].
datasep (list of strings, optional) – Data seperation by strain/displacement relation. The default is [‘con’,’opt’].
VIPs (dict, optional) – ‘Very important points’. The default is {‘con’:None,’opt’:None}.
exacts (dict of pd.DataFrame, optional) –
Exact values (p.e. for yield point) seperated by strain/displacement relation. Need to have special format (see common.analyze.Yield_redet2_Multi):
index: VIP
columns: [‘strain_os’,’ind’,’ind_ex’,n_strain,n_stress]
The default is None.
orders (dict of lists of strings, optional) –
- Output order seperated to datasep. Implemented are:
’f’: stress
’F’: force
’e’: strain
’s’: displacement
’U’: strain energy / -density
’W’: deformation energy
The default is {‘con’:[‘f’,’e’,’U’],’opt’:[‘e’,’U’]}.
add_esufs (dict of strings, optional) – Suffixes for strain/displacement relation acc. to measurement method. The default is {‘con’:’_con’,’opt’:’_opt’}.
n_strains (dict of strings, optional) – Column name in mdf for strain values. The default is {‘con’:’Strain’,’opt’:’DStrain’}.
n_stresss (TYPE, optional) – Column name in mdf for stress values. The default is {‘con’:’Stress’,’opt’:’Stress’}.
use_exacts (bool, optional) – Switch to use exact values if applicable. The default is True.
- Returns
out – Evaluated values.
- Return type
pd.Series
Examples
- Otvalgetter_Multi(messu_FP, Vs=relVS,
datasep=[‘con’,’opt’], VIPs={‘con’:VIP_messu,’opt’:VIP_dicu}, exacts={‘con’:yield_df_con,’opt’:yield_df_opt}, orders={‘con’:[‘f’,’e’,’U’],’opt’:[‘e’,’U’]}, add_esufs={‘con’:’_con’,’opt’:’_opt’}, n_strains={‘con’:’Strain’,’opt’:dic_used_Strain}, n_stresss={‘con’:’Stress’,’opt’:’Stress’}, use_exacts=True)
- exmecheva.common.output.Outvalgetter(mdf, V, VIP, exacts=None, order=['f', 'e', 'U'], add_esuf='_con', n_strain='Strain', n_stress='Stress', use_exacts=True)[source]
Get output values from given data and options.
- Parameters
mdf (pd.DataFrame) – DESCRIPTION.
V (string) – Relevant VIP (have to be in VIP).
VIP (list of string) – ‘Very important point’.
exacts (pd.DataFrame, optional) –
Exact values (p.e. for yield point). Need to have special format (see common.analyze.Yield_redet2_Multi):
index: VIP
columns: [‘strain_os’,’ind’,’ind_ex’,n_strain,n_stress]
The default is None.
order (list of string, optional) –
- Output order. Implemented are:
’f’: stress (no suffix)
’F’: force (no suffix)
’e’: strain
’s’: displacement
’U’: strain energy / -density
’W’: deformation energy
The default is [‘f’,’e’,’U’].
add_esuf (string, optional) – Suffix for strain/displacement relation acc. to measurement method. The default is ‘_con’.
n_strain (string, optional) – Column name in mdf for strain values. The default is ‘Strain’.
n_stress (string, optional) – Column name in mdf for stress values. The default is ‘Stress’.
use_exacts (bool, optional) – Switch to use exact values if applicable. The default is True.
- Returns
out – Evaluated values.
- Return type
pd.Series
- exmecheva.common.output.str_indent(po, indent=3)[source]
Adds indentation to str at each new line.
- Parameters
po (string or str callable) – String to manipulate.
indent (int, optional) – Number of spaces for indentation. The default is 3.
- Returns
poo – Output string with indentation.
- Return type
string
- exmecheva.common.output.str_log(s, logfp, output_lvl=1, logopt=True, printopt=True)[source]
Write lines to log and/or console. TODO: add functionality for different backends! (Console/window object)
- Parameters
s (string) – String to write or print.
logfp (string or path) – Open log file.
output_lvl (positiv integer) – Output level (0=none, 1=only text, 2=additional diagramms). The default is 1.
logopt (bool) – Wriet in log file (logfp). The default is True.
printopt (bool) – Display on terminal. The default is True.
exmecheva.common.pd_ext module
Contains extensions to pandas functionality (mostly indexing and NaN-handling).
@author: MarcGebhardt
- exmecheva.common.pd_ext.Find_closest(pds, val, iS=None, iE=None, option='abs')[source]
Returns the index of the closest value of a Series to a value
- exmecheva.common.pd_ext.Find_closest_perc(pds, p, iS=None, iE=None, range_sub='min', norm='max', option='abs')[source]
Returns the index of the closest value of a Series to a percentage value in a range of this series
- exmecheva.common.pd_ext.Find_closestv(pds1, pds2, val1, val2, iS=None, iE=None, option='quad')[source]
Returns the index of the closest value of two corresponding Series to a pair of values
- exmecheva.common.pd_ext.Find_first_sc(pds, val, iS=None, iE=None, direction='normal', option='after', exclude_1st=True, nan_policy='omit')[source]
Returns the index of the first value of a Series with change in sign to a value
- exmecheva.common.pd_ext.deal_dupl_index(df, deal_dupl_ind='raise')[source]
Deal with dupliceted index values according option.
- Parameters
df (pandas.Series or pandas.DataFrame) – Data input.
deal_dupl_ind (string, optional) –
Option to deal with duplicated index entries. Possible are:
’raise’: raises IndexError when finding duplicates.
’keep’: keep unchanged and give no error.
’keep-first’: drop all duplicated entries except first one.
’keep-last’: drop all duplicated entries except first one.
Aggratable function or string accapted by pd.agg: Aggregate duplicated index entries by function.
The default is ‘raise’.
- Raises
IndexError – Index has duplicates and option set to ‘raise’.
ValueError – option (deal_dupl_ind) is not aggregatable.
- Returns
dft – Data output.
- Return type
pandas.Series or pandas.DataFrame
- exmecheva.common.pd_ext.pd_axischange(axis)[source]
Change axis (use for pandas object). Index will return columns, 0 will return 1 and in visa versa.
- Parameters
axis (int in [0,1] or string in [index,columns]) – Axis determiner.
- Returns
a – Oposite axis of axis.
- Return type
int or string
- exmecheva.common.pd_ext.pd_combine_index(pd1, pd2, option='dropna')[source]
Returns a combined index of two pandas objects (series or dataframe) with valide values in both.
- exmecheva.common.pd_ext.pd_limit(self, iS=None, iE=None)[source]
Limit a pandas Series or Dataframe to given indexes
- Parameters
iS (matching type of self.index, optional) – Start index. The default is None.
iE (matching type of self.index, optional) – End index. The default is None.
- Returns
Limited pandas object.
- Return type
pandas.Series or pandas.DataFrame
- exmecheva.common.pd_ext.pd_nan_handler(pdo, ind=None, axis=0, nan_policy='omit')[source]
Handles NaN in pandas object according to NaN-policy.
- Parameters
pdo (pandas.Series or pandas.DataFrame) – Input Value.
ind ((same as corresponding axis), optional) – Index limitation on not scanned axis. The default is None.
axis ([0,1]/["index","columns"], optional) – Scanned axis. The default is 0.
nan_policy (string, optional) – Policy to handle NaN. Implemented: omit, raise, interpolate. The default is ‘omit’.
- Raises
ValueError – Raise error if nan_policy is raise and NaN’s detected.
- Returns
pds – Output value with NaN handled acc. NaN-policy.
- Return type
pandas.Series or pandas.DataFrame
- exmecheva.common.pd_ext.pd_outsort(data, outsort='ascending')[source]
Sorts pandas object by given string.
- Parameters
data (pd.Series or pd.DataFrame) – Data to be sorted.
outsort (str, optional) – Option for sorting. Implemented: - ascending: [‘A’,’a’,’ascending’,True,’r’,’rising’,’rise’] - descending: [‘D’,’d’,’descending’,’f’,’falling’,’fall’] The default is ‘ascending’.
- Returns
dout – Sortted data.
- Return type
pd.Series or pd.DataFrame
- exmecheva.common.pd_ext.pd_slice_index(index, vals, option='range')[source]
Slice an index by given values and option.
- Parameters
index (pd.Index) – Index.
vals (range or list) – Slicing values (list or, lower and upper limits).
option (string, optional) – Option for slicing (range or list). The default is ‘range’.
- Raises
NotImplementedError – Option not implemented.
- Returns
ind_new – New index.
- Return type
pd.Index
- exmecheva.common.pd_ext.pd_trapz(pdo, y=None, x=None, axis=0, nan_policy='omit')[source]
Extends usage of np.trapz for pandas with nan policy.
- Parameters
pdo (pd.DataFrame or pd.Series) – Pandas object containing data.
y (string, optional) – Determiner for y-values. Have to be in index or columns (see axis). The default is None.
x (string, optional) – Determiner for x-values. Have to be in index or columns (see axis). The default is None.
axis (int in [0,1] or string in [index,columns], optional) – Axis determiner to perform action. The default is 0.
nan_policy (string, optional) – Option for handling NaN-values. The default is ‘omit’.
- Raises
ValueError – NaN handling.
NotImplementedError – Option for nan_policy not implemented.
- Returns
out – DESCRIPTION.
- Return type
float or series of float
- exmecheva.common.pd_ext.pd_valid_index(val, pdo, opt='ba', na_hand='Value', na_out=None, add_ind=None)[source]
Returning valid index of pandas object in respect to defined option. (b=before,a=after,n=nearest,ba=before and after,bna=before, nearest and after) Filling not available values according a handler (na_hand) with standard value (na_out) or a part of an additional index (add_ind).
exmecheva.common.plotting module
Plotting functionality.
@author: MarcGebhardt
- exmecheva.common.plotting.curve_char_plotter(cps, cip, dfp, df, head=None, xlabel=None, ylabel_l=None, ylabel_r=None, cco={'y': 'm'}, cco_sc={}, ccd={'DQ1': 'b', 'DQ2': 'g', 'DQ3': 'y'}, ccd_sc={'DQ1_sc': 'b', 'DQ2_sc': 'g', 'DQ3_sc': 'y'}, cc={'Const': 'b', 'Fall': 'r', 'Neg': 'y', 'Pos': 'm', 'Rise': 'g'}, disp_opt_DQ='Normalized', do_kwargs={'norm': 'absmax', 'normadd': 0.5, 'th': 0.05, 'th_option': 'abs', 'th_set_val': 0}, limDQ=False, limDQvals=[-1.1, 1.1])[source]
Plotting method for mc_char.curve_characterizer results.
- Parameters
cps (pd.Dataframe (mc_char.curve_characterizer output)) –
- Characterization of input (for linear parts: linearisation and
intersection to previous included).
cip (pd.Series (mc_char.curve_characterizer output)) – Points of first characteriation (S=Start, E=End, I=Increase, D=Decrease).
dfp (pd.Dataframe (mc_char.curve_characterizer output)) – Maxima and minima of input, as well as differential quotients.
df (pd.Dataframe (mc_char.curve_characterizer output)) – Input, as well as differential quotients.
head (string or None, optional) – Figure title. The default is None.
xlabel (string or None, optional) – Label on x-axis. The default is None.
ylabel_l (string or None, optional) – Label on left y-axis. The default is None.
ylabel_r (string or None, optional) – Label on right y-axis. The default is None.
cco (dict, optional) – Color codes for Max and Min markers in accordance with dfp column name. The default is {‘y’:’m’}.
cco_sc (dict, optional) – Color codes for changes in sign markers in accordance with dfp column name. The default is {}.
ccd (dict, optional) – Color codes for differential quotient plotting. The default is {‘DQ1’:’b’,’DQ2’:’g’,’DQ3’:’y’}.
ccd_sc (dict, optional) – Color codes for plotting of differential quotient sign changes. The default is {‘DQ1_sc’:’b’,’DQ2_sc’:’g’,’DQ3_sc’:’y’}.
cc (ict, optional) – Color codes for plotting of curve description in cps. The default is {‘Const’:’b’,’Rise’:’g’,’Fall’:’r’,’Pos’:’m’,’Neg’:’y’}.
disp_opt_DQ (string, optional) – Normalization of differential quotients. The default is ‘Normalized’.
do_kwargs (dict, optional) –
Keyword arguments for normalization of differential quotients. The default is {‘norm’:’absmax’, ‘normadd’:0.5,
’th’:0.05, ‘th_option’:’abs’, ‘th_set_val’:0}.
limDQ (bool, optional) – Limit plot on y-axis to limDQvals. The default is False.
limDQvals (list of float, optional) – Lower and upper limits on y-axis for limDQ. The default is [-1.1,1.1].
- Raises
NotImplementedError – DESCRIPTION.
- Return type
None.
- exmecheva.common.plotting.plt_add_DaAnno(mdf, x_n, y_n, VIP, ax=None, xy_standard=(-6, 6), xy_ded={1: (1, 1), 2: (-1, 1), 3: (-1, -1), 4: (1, -1)}, pkwargs={'color': 'red', 'label': 'Points of interest', 'linestyle': '', 'marker': 'x'}, akwargs={'ha': 'center', 'textcoords': 'offset points', 'va': 'center', 'xycoords': 'data'})[source]
Adds data annotations to curve.
- Parameters
mdf (pd.DataFrame) – DataFrame of measured data.
x_n (string) – Column name of data to plot on x-axis.
y_n (string) – Column name of data to plot on y-axis.
VIP (pd.Series) – Points of interest (name as index and index of mdf as values).
ax (plt.subplot axis, optional) – Matplotlib axis object to plot. The default is None.
xy_standard (tuple of int, optional) – Standard position of text, coordinates related to data. The default is (-6,6).
xy_ded (dict, optional) – Dictionary with positiioning multipliers to apply to xy_standard. The default is {1:(1,1),2:(-1,1),3:(-1,-1),4:(1,-1)}.
pkwargs (dict, optional) –
Keyword arguments for plt.plot. The default is {‘marker’:’x’, ‘linestyle’:’’,’color’:’red’,
’label’:’Points of interest’}.
akwargs (TYPE, optional) –
Keyword arguments for plt.annotate. The default is {‘xycoords’:’data’, ‘textcoords’:’offset points’,
’ha’:”center”, ‘va’:”center”}.
- Returns
Combined postion and text (for control purposes).
- Return type
pd.DataFrame
- exmecheva.common.plotting.plt_ax_regfit(pdo, x, y=None, fit={}, ax=None, plt_d=False, label_d='Data', label_f=False, xlabel=None, ylabel=None, title=None, legend=True, skws={}, lkws={}, t_form={})[source]
Plots a regression (done by fitting.regfitret) and data (optional). Optional legend entry with fitting function.
- Parameters
pdo (pd.DataFrame) – Input data.
x (str) – Column name for abscissa data.
y (str or None) – Column name for ordinate data or none, if plt_d is False. The default is None.
fit (pd.DataFrame (result of fitting.regfitret), optional) – Least square regression fit results. The default is {}.
ax (plt.axis or None, optional) – Axis to plote result. The default is None.
plt_d (bool, optional) – Switch for plotting data. The default is False.
label_d (string, optional) – Label for data plot. The default is ‘Data’.
label_f (bool, optional) – Label for function plot. The default is False.
xlabel (string, optional) – label for x-axis. The default is None.
ylabel (string, optional) – Label for y-axis. The default is None.
title (string, optional) – Axis title. The default is None.
skws (dict, optional) – Dictionary for scatter plot (data). The default is {}.
lkws (dict, optional) – Dictionary for lineplot (function). The default is {}.
legend (bool, optional) – Switch for showing legend. The default is True.
- Return type
None.
- exmecheva.common.plotting.plt_handle_suffix(fig, path='foo', tight=True, show=True, save=True, s_types=['pdf', 'png'], clear=True, close=True)[source]
Handler for end of plotting procedure.
- Parameters
fig (matplotlib.pyplot.figure) – Figure instance.
path (str, optional) – Save path. The default is ‘foo’.
tight (bool, optional) – Tight the layout. The default is True.
show (bool, optional) – Show figure. The default is True.
save (bool, optional) – Save figure. The default is True.
s_types (list of str, optional) – Types in which the figure is saved. The default is [“pdf”,”png”].
clear (bool, optional) – Clear figure instance. The default is True.
close (bool, optional) – Close figure window. The default is True.
- Return type
None.
- exmecheva.common.plotting.sns_pointplot_MMeb(ax, data, x, y, hue=None, dodge=0.2, join=False, palette=None, markers=['o', 'P'], scale=1, barsabove=True, capsize=4, controlout=False)[source]
Generate Pointplot with errorbars marking minimum and maximum instead of CI.
- exmecheva.common.plotting.tick_label_inserter(ax, pos=0, ins='', axis='both')[source]
Inserts a string to tick labels on axis (can be switched [‘both’,’x’,’y’]).
exmecheva.common.stat_ext module
Created on Mon Dec 4 17:54:05 2023
@author: mgebhard
- exmecheva.common.stat_ext.CD_rep(pdo, groupby='Series', var='DEFlutoB', det_met='SM-RRT', outtype='txt', tnform='{:.3e}')[source]
Calculate critical differences and compare to given mean difference. Can provide information on the comparability and/or repeatability of two test series.
- Parameters
pdo (pd.DataFrame) – Dataframe with groups and values as columns for test.
groupby (str) – Name of groups for statistical test.
var (str) – Name of variable for statistical test.
det_met (string, optional) –
Determination method for deriving critical differences (CD). The default is ‘SM-RRT’. Implemented are (all only implemented for 95 % confidence):
’SM-RRT’: CD by standard deviation and size
(see https://www.methodensammlung-bvl.de/resource/blob/208066/e536126ed1723145e51fc90b12736f5e/planung-und-statistische-auswertung-data.pdf) - ‘CV-DC’: CD by coefficient of variation and maximum (see https://flexikon.doccheck.com/de/Kritische_Differenz) - ‘CV’: CD by coefficient of variation (see https://link.springer.com/chapter/10.1007/978-3-662-48986-4_887) - ‘SD’: CD by standard deviation (see https://edoc.hu-berlin.de/bitstream/handle/18452/11713/cclm.1982.20.11.817.pdf?sequence=1
outtype (string, optional) –
Switch for output. The default is ‘txt’. Implemented are:
’Ser_all’: pd.Series with all derived results
’Tuple_all’: tuple of all derived results
’txt’: single line text output showing results acc. repeatability
’Series’: pd.Series with important resulzs
tnform (formatcode, optional) – Format for float in sttestual output. The default is ‘{:.3e}’.
- Raises
NotImplementedError – Method not implemented.
- Returns
out – Output according to switch (see outtype).
- Return type
pd.Series or tuple or string
- exmecheva.common.stat_ext.CD_test_multi(df, group_main='Series', group_sub=['A'], ano_Var=['WC_vol'], det_met='SM-RRT', Transpose=True)[source]
Calculate critical differences and compare to given mean difference for groups and subgroups. Can provide information on the comparability and/or repeatability of two test series.
- Parameters
df (pd.DataFrame) – Dataframe with groups, subgroups and values as columns for test.
group_main (str, optional) – Main group for statistical test. The default is ‘Series’.
group_sub (list of str, optional) – Sub-groups for statistical test (p.e. variants). The default is [‘A’].
ano_Var (list of str, optional) – Names of variables for statistical test.The default is [‘WC_vol’].
det_met (string, optional) –
Determination method for deriving critical differences (CD). The default is ‘SM-RRT’. Implemented are (all only implemented for 95 % confidence):
’SM-RRT’: CD by standard deviation and size
(see https://www.methodensammlung-bvl.de/resource/blob/208066/e536126ed1723145e51fc90b12736f5e/planung-und-statistische-auswertung-data.pdf) - ‘CV-DC’: CD by coefficient of variation and maximum (see https://flexikon.doccheck.com/de/Kritische_Differenz) - ‘CV’: CD by coefficient of variation (see https://link.springer.com/chapter/10.1007/978-3-662-48986-4_887) - ‘SD’: CD by standard deviation (see https://edoc.hu-berlin.de/bitstream/handle/18452/11713/cclm.1982.20.11.817.pdf?sequence=1
Transpose (bool, optional) – Switch for transposing result. The default is False.
- Returns
df_out – Derived test results (pd.Series({‘MD’:grs_MD,’CD’:CD, ‘eta’:eta, ‘H0’: MD_l_CD})).
- Return type
pd.DataFrame
- exmecheva.common.stat_ext.CImax(data, confidence=0.95, method='Seaborn_Bootstrap', func=<function nanmean>, n_boot=1000, axis=None, units=None, seed=0)[source]
Return only maximum of confidence interval. (Use same seed and n_boot!)
- exmecheva.common.stat_ext.CImin(data, confidence=0.95, method='Seaborn_Bootstrap', func=<function nanmean>, n_boot=1000, axis=None, units=None, seed=0)[source]
Return only minimum of confidence interval. (Use same seed and n_boot!)
- exmecheva.common.stat_ext.Corr_ext(df, method='spearman', sig_level={0.001: '$^a$', 0.01: '$^b$', 0.05: '$^c$', 0.1: '$^d$'}, corr_round=2)[source]
Performs correlation according to method and significance levels.
- Parameters
df (pd.DataFrame) – Input data.
method (string, optional) –
- Correlation method, implemented are:
Pearson: [‘pearson’,’Pearson’,’P’]
Spearman: [‘spearman’, ‘Spearman’,’S’]
Kendalltau: [‘kendall’, ‘kendalltau’, ‘Kendall’, ‘Kendalltau’, ‘K’]
The default is ‘spearman’.
sig_level (list or dict, optional) – Significance level for anotation, if list: ascending number of *´s, if dict: dictionary values. The default is {0.001:’$^a$’,0.01:’$^b$’,0.05:’$^c$’,0.10:’$^d$’}.
corr_round (int or None, optional) – Number of digits for rounding of annotation of correlation. The default is 2.
- Raises
NotImplementedError – Method fpr correlation not implemented.
- Returns
Output dataframes (Correlation, Annotation strings with significance levels).
- Return type
pd.DataFrame, pd.DataFrame
- exmecheva.common.stat_ext.Dist_test(pds, alpha=0.05, mcomp='Shapiro', mkws={}, skipna=True, add_out=False)[source]
Distribution test of data to Hypothesis sample looks Gaussian (reject, if p<=alpha).
- Parameters
pds (pd.Series) – Series of data.
alpha (float, optional) – Test criterion to reject zero hypothesis (normal distribution). The default is 0.05.
mcomp (str, optional) – Test method. The default is ‘Shapiro’.
mkws (dict, optional) – Keyword arguments for used test. The default is {}.
skipna (bool, optional) – Switch for skipping NaNs in data. The default is True.
add_out (bool or str, optional) – Switch for output. The default is False.
- Raises
NotImplementedError – Method not implemented.
- Returns
Output of test results, depending on add_out.
- Return type
str, Dict, Series, [Series, Series, str]
- exmecheva.common.stat_ext.Dist_test_multi(pdo, axis=0, alpha=0.05, mcomps=['Shapiro', 'DAgostino'], mkws={}, skipna=True, add_out='DF')[source]
Performs multiple distribution tests.
- exmecheva.common.stat_ext.Hypo_test(df, groupby, ano_Var, group_str=None, ano_str=None, alpha=0.05, group_ren={}, mcomp='TukeyHSD', mkws={}, rel=False, rel_keys=[], deal_dupl_ind='raise', group_ord=None, add_T_ind=3, add_out=False)[source]
Performs hypothesis test of given data according to selected method. Returns results acc. to selected output switch.
- Parameters
df (pd.DataFrame) – Dataframe with groups and values as columns for statistical test.
groupby (str) – Name of groups for statistical test.
ano_Var (str) – Name of variable for statistical test.
group_str (str, optional) – String for output implementation of group names. The default is None.
ano_str (str, optional) – String for output implementation of value names. The default is None.
alpha (float, optional) – Test criterion to reject zero hypothesis (all means are equal). The default is 0.05.
group_ren (dict, optional) – Renaming of groups in df. The default is {}.
mcomp (TYPE, optional) –
Method for hypothesis test. The default is ‘TukeyHSD’. Implemented are:
’TukeyHSD’: Tukey HSD test (see scipy.stats.tukey_hsd)
’ttest_ind’: Independend t-test (see scipy.stats.ttest_ind)
’ttest_rel’: Related t-test (see scipy.stats.ttest_rel)
’mannwhitneyu’: Mann-Whittney-U-test (see scipy.stats.mannwhitneyu)
’wilcoxon’: Wilcoxon signed rank test (see scipy.stats.wilcoxon)
mkws (dict, optional) – Keyword arguments for used hypothesis test. p.e.: {‘equal_var’: False, ‘nan_policy’: ‘omit’} The default is {}.
rel (bool, optional) – Switch for relation of samples (True= related). The default is False.
rel_keys (list, optional) – Variabel/column names for determining relation. The default is [].
deal_dupl_ind (string, optional) – Behavior with duplicated indices (see deal_dupl_index). The default is ‘raise’.
group_ord (None or list, optional) – Selected groups. None will use all columns. The default is None.
add_T_ind (int, optional) – Additional indentation of level in textual output. The default is 3.
add_out (TYPE, optional) –
Switch for output. The default is False. Implemented are:
False: only text output
True: text output (str) and test result (statistic, pvalue as float)
’Series’: pd.Series of degrees of freedom, statistics, p-value
and zero hypothesis test result to alpha - ‘Test’: complete output
- Raises
ValueError – More than two groups identified.
NotImplementedError – Method not implemented.
- Returns
Output of hypothesis test acc. to selected switch(see add_out).
- Return type
str or (str, float) or pd.Series or (pd.DataFrame, pd.Series, string)
- exmecheva.common.stat_ext.Hypo_test_multi(df, group_main='Series', group_sub=['A'], ano_Var=['WC_vol'], mcomp='mannwhitneyu', alpha=0.05, mkws={}, rel=False, rel_keys=[], deal_dupl_ind='raise', group_ord=None, Transpose=True)[source]
Performs hypothesis tests for given variable, in respect to given groups according to selected method. Returns results acc. to selected output switch.
- Parameters
df (pd.DataFrame) – Dataframe with groups and values as columns for statistical test.
group_main (str) – Main group for statistical test. The default is ‘Series’.
group_sub (list of str) – Sub-groups for statistical test (p.e. variants). The default is [‘A’].
ano_Var (list of str) – Names of variables for statistical test. The default is [‘WC_vol’].
mcomp (TYPE, optional) –
Method for hypothesis test. The default is ‘TukeyHSD’. Implemented are:
’TukeyHSD’: Tukey HSD test (see scipy.stats.tukey_hsd)
’ttest_ind’: Independend t-test (see scipy.stats.ttest_ind)
’ttest_rel’: Related t-test (see scipy.stats.ttest_rel)
’mannwhitneyu’: Mann-Whittney-U-test (see scipy.stats.mannwhitneyu)
’wilcoxon’: Wilcoxon signed rank test (see scipy.stats.wilcoxon)
alpha (float, optional) – Test criterion to reject zero hypothesis (all means are equal). The default is 0.05.
mkws (dict, optional) – Keyword arguments for used hypothesis test. p.e.: {‘equal_var’: False, ‘nan_policy’: ‘omit’} The default is {}.
rel (bool, optional) – Switch for relation of samples (True= related). The default is False.
rel_keys (list, optional) – Variabel/column names for determining relation. The default is [].
deal_dupl_ind (string, optional) – Behavior with duplicated indices (see deal_dupl_index). The default is ‘raise’.
group_ord (None or list, optional) – Changing of order of groups not implemented. The default is None.
Transpose (bool, optional) – Switch for transposing result. The default is False.
- Returns
df_out – Dataframe of test results indexed variable name and group.
- Return type
pd.DataFrame
- exmecheva.common.stat_ext.MComp_interpreter(T_Result)[source]
Interprets a test result from statsmodels multicomparision (Zero hypothesis reject). Returns identified higher order groups in relation to original groups.
- Parameters
T_Result (statsmodels.iolib.table.SimpleTable) – Simple table result from statsmodels.
- Returns
dict2 (dict) – Dictionary of results.
txt (str) – Textual output.
- exmecheva.common.stat_ext.Multi_conc(df, group_main='Donor', anat='VA', met='Kruskal', alpha=0.05, stdict={'DEFlutoB': ['C', 'G', 'L'], 'DHAntoB': ['C', 'G', 'L'], 'Hyst_An': ['B'], 'WC_vol': ['A', 'B', 'L'], 'WC_vol_rDA': ['B', 'C', 'L'], 'lu_F_mean': ['B']}, rel=False, rel_keys=[], kws={})[source]
Multiple conclusion of statistical tests (variance analysis, hyphotesis test or critical differences)
- Parameters
df (pd.DataFrame) – Dataframe.
group_main (str, optional) – Main group name. The default is ‘Donor’.
anat (str, optional) –
Type of test. Implemented are:
VA: variance analysis
VAwoSg: variance analysis without subgrouping
HT: hyphotesis test
CD: critical differences
The default is ‘VA’.
met (str, optional) – Methode of test. The default is ‘Kruskal’.
alpha (float, optional) – Test criterion to reject zero hypothesis. The default is 0.05.
stdict (dict, optional) –
Dictionary of value and list of variants to evaluate. The default is {‘WC_vol’:[‘A’,’B’,’L’],’WC_vol_rDA’:[‘B’,’C’,’L’],
’lu_F_mean’:[‘B’],’DEFlutoB’:[‘C’,’G’,’L’], ‘Hyst_An’:[‘B’],’DHAntoB’:[‘C’,’G’,’L’]}.
rel (bool, optional) – Switch for relation of samples (True= related). The default is False.
rel_keys (list, optional) – Variabel/column names for determining relation. The default is [].
kws (dict, optional) – Dictionarie of additional Keyword arguments for selected test. The default is {}.
- Returns
out – Dataframe of results.
- Return type
pd.DataFrame
- exmecheva.common.stat_ext.NaN_stat_outliers(df, numeric_only=True, option='IQR', span=1.5, out='all', outsort=None)[source]
Determine statistical outliers with respect to NaN values. Optional selects numerical data only.
- Parameters
df (pd.DataFrame) – Input data.
numeric_only (bool, optional) – Numerical columns only. The default is True.
option (str, optional) – Determination option. Only ‘IQR’: interquartile-range-rule implemented. The default is ‘IQR’.
span (float, optional) – Span for inclusion (p.e.: ‘IQr’ and 1.5 leads to standard 1.5-interquartile-range-rule). The default is 1.5.
out (str, optional) –
- Output option. Implemented are:
’all’: all data points outside range (all statistical outliers)
’lower’: data points lower then range
’higher’: data points higher then range
’inner’: data points inside range (exclusion of statistical outliers)
The default is ‘all’.
outsort (str, optional) – Sorting of output. Implemented are ‘ascending’ and ‘descending’. All other values will return data unsorted. The default is None.
- Returns
dfout – Statistical outlier data acc. to options.
- Return type
pd.DataFrame
- exmecheva.common.stat_ext.agg_add_ci(pdo, agg_funcs=['mean', 'std', 'min', 'max'])[source]
Adds confidence interval to pandas aggregate function
- exmecheva.common.stat_ext.coefficient_of_variation(data, outsort=None, optmeanabs=True)[source]
Determine coefficient of determination (standard deviation to mean value).
- Parameters
data (pd.Series or pd.DataFrame) – Input data.
outsort (str, optional) – Sorting of output. Implemented are None ‘ascending’ and ‘descending’. The default is None.
optmeanabs (bool, optional) – Option for using absolute mean value (if False and mean is negative, coefficient of variation will be negative). The default is True.
- Returns
dout – Coefficient of variation value/-s of input data.
- Return type
float or pd.Series
- exmecheva.common.stat_ext.coefficient_of_variation_woso(data, option='IQR', span=1.5, out='inner', outsort=None, optmeanabs=True)[source]
Determine coefficient of variation of input data without statistical outliers.(see stat_outliers for more information)
- Parameters
data (pd.Series or pd.DataFrame) – Input data.
option (str, optional) – Determination option. Only ‘IQR’: interquartile-range-rule implemented. The default is ‘IQR’.
span (float, optional) – Span for inclusion (p.e.: ‘IQr’ and 1.5 leads to standard 1.5-interquartile-range-rule). The default is 1.5.
out (str, optional) –
Output option. Only option inner makes sense. Implemented are:
’all’: all data points outside range (all statistical outliers)
’lower’: data points lower then range
’higher’: data points higher then range
’inner’: data points inside range (exclusion of statistical outliers)
The default is ‘inner’.
outsort (str, optional) – Sorting of output. Implemented are ‘ascending’ and ‘descending’. All other values will return data unsorted. The default is None.
optmeanabs (bool, optional) – Option for using absolute mean value (if False and mean is negative, coefficient of variation will be negative). The default is True.
- Returns
dout – Coefficient of variation value/-s of input data without statistical outliers.
- Return type
float or pd.Series
- exmecheva.common.stat_ext.confidence_interval(data, confidence=0.95, method='Seaborn_Bootstrap', func=<function nanmean>, n_boot=1000, axis=None, units=None, seed=0, outtype='List')[source]
Calculates the confidence interval of given data.
- Parameters
data (pandas.Series of float) – Series of values to be analysed.
confidence (float, optional) – Confidence value. The default is 0.95.
method (string, optional) –
Method to use. Implemented are:
Seaborn_Bootstrap: Seaborn Bootstrapping (Compare Seaborn barplot)
Wald: Wald-Confidence-Interval
The default is “Seaborn_Bootstrap”.
func (string or callable, optional) – DESCRIPTION. The default is “nanmean”.
n_boot (int, optional) – Number of iterations. The default is 1000.
axis (int, optional) – Applied axis. The default is None.
units (array, optional) – Sampling units (see seaborn.algorithms). The default is None.
seed (Generator | SeedSequence | RandomState | int | None, optional) – Seed for rondom number generator. The default is 0.
outtype (str, optional) – Switch for output (List, Dict, Min, Max). The default is List.
- Raises
NotImplementedError – Error to raise if option not implemented.
- Returns
CI – Confidence interval values [lower, higher].
- Return type
list or or dict or value
- exmecheva.common.stat_ext.cv(data, outsort=None, optmeanabs=True)[source]
Short naming of funciton coefficient_of_variation. Readability improved by usage of pandas aggregate function (pd.agg).
- exmecheva.common.stat_ext.cvwoso(data, option='IQR', span=1.5, out='inner', outsort=None, optmeanabs=True)[source]
Short naming of funciton coefficient_of_variation_woso. Readability improved by usage of pandas aggregate function (pd.agg).
- exmecheva.common.stat_ext.group_ANOVA_MComp(df, groupby, ano_Var, group_str=None, ano_str=None, mpop='ANOVA', alpha=0.05, group_ren={}, do_mcomp_a=1, mcomp='TukeyHSD', mpadj='bonf', Ffwalpha=2, mkws={}, nan_policy='omit', check_resnorm=False, add_T_ind=3, add_out=False)[source]
Performs an one way variance analysis and multi comparision test for given variable, in respect to given groups. Returns an output string with summary and optional additional test outputs.
- Parameters
df (pd.DataFrame) – Dataframe with groups and values as columns for statistical test.
groupby (str) – Name of groups for statistical test.
ano_Var (str) – Name of variable for statistical test.
group_str (str, optional) – String for output implementation of group names. The default is None.
ano_str (str, optional) – String for output implementation of value names. The default is None.
mpop (str, optional) – Method for population test. Implemented are ANOVA and Kruskal-Wallis H-test. The default is ANOVA.
alpha (float, optional) – Test criterion to reject zero hypothesis (all means are equal). The default is 0.05.
group_ren (dict, optional) – Renaming of groups in df. The default is {}.
do_mcomp_a (int, optional) – Performance level of tukey test (0 - never, 1 - only if p of ANOVA lower alpha, 2 - allways). The default is 1.
mcomp (str, optional) – Method for multi comparison. Implemented are TukeyHSD, ttest_ind, ttest_rel, mannwhitneyu. The default is TukeyHSD.
mpadj (str, optional) – Method for testing and adjustment of pvalues. For further information see: statsmodels.stats.multitest.multipletests The default is bonf.
Ffwalpha (float, optional) – Factor for family-wise error in comparision to alpha. The default is 2.
mkws (dict, optional) – Keyword arguments for used multi comparision test. p.e.: {‘equal_var’: False, ‘nan_policy’: ‘omit’} The default is {}.
nan_policy (str, optional) – Handling of NaN values. The default is ‘omit’.
add_T_ind (int, optional) – Additional indentation of lines in txt for Tukey HSD. The default is 3.
add_out (bool, optional) – Additional output request. The default is False.
- Returns
txt (str) – Text output with ANOVA and optional Tukey-HSD results.
[F,p] ([float,float], optional) – ANOVA results
t (statsmodels.iolib.table.SimpleTable, optional) – Results of multi comaprison test.
- exmecheva.common.stat_ext.group_ANOVA_MComp_multi(df, group_main='Series', group_sub=['A'], ano_Var=['WC_vol'], mpop='ANOVA', alpha=0.05, group_ren={}, do_mcomp_a=0, mcomp='TukeyHSD', mpadj='bonf', Ffwalpha=1, mkws={}, check_resnorm=False, Transpose=True)[source]
Performs an one way ANOVA and multi comparision test for given variable, in respect to given groups and sub-groups. Returns an output string with summary and optional additional test outputs.
- Parameters
df (pd.DataFrame) – Dataframe with groups and values as columns for statistical test.
group_main (str) – Main group for statistical test.
group_sub (list of str) – Sub-groups for statistical test (p.e. variants).
ano_Var (list of str) – Names of variables for statistical test.
group_str (str, optional) – String for output implementation of group names. The default is None.
mpop (str, optional) – Method for population test. Implemented are ANOVA and Kruskal-Wallis H-test. The default is ANOVA.
alpha (float, optional) – Test criterion to reject zero hypothesis (all means are equal). The default is 0.05.
group_ren (dict, optional) – Renaming of groups in df. The default is {}.
do_mcomp_a (int, optional) – Performance level of tukey test (0 - never, 1 - only if p of ANOVA lower alpha, 2 - allways). The default is 1.
mcomp (str, optional) – Method for multi comparison. Implemented are TukeyHSD, ttest_ind, ttest_rel, mannwhitneyu. The default is TukeyHSD.
mpadj (str, optional) – Method for testing and adjustment of pvalues. For further information see: statsmodels.stats.multitest.multipletests The default is bonf.
Ffwalpha (float, optional) – Factor for family-wise error in comparision to alpha. The default is 2.
mkws (dict, optional) – Keyword arguments for used multi comparision test. p.e.: {‘equal_var’: False, ‘nan_policy’: ‘omit’} The default is {}.
Transpose (bool, optional) – Switch for transposing result. The default is False.
- Returns
df_out – DataFrame output with variance analyses and additional results.
- Return type
pd.DataFrame
- exmecheva.common.stat_ext.group_Anova(df, groupby, ano_Var, group_str=None, ano_str=None, alpha=0.05)[source]
Performs an one way ANOVA -> depricated (use group_ANOVA_MComp)
- exmecheva.common.stat_ext.meanwoso(data, option='IQR', span=1.5, out='inner', outsort=None)[source]
Determine mean value of input data without statistical outliers. (see stat_outliers for more information)
- Parameters
data (pd.Series or pd.DataFrame) – Input data.
option (str, optional) – Determination option. Only ‘IQR’: interquartile-range-rule implemented. The default is ‘IQR’.
span (float, optional) – Span for inclusion (p.e.: ‘IQr’ and 1.5 leads to standard 1.5-interquartile-range-rule). The default is 1.5.
out (str, optional) –
Output option. Only option inner makes sense. Implemented are:
’all’: all data points outside range (all statistical outliers)
’lower’: data points lower then range
’higher’: data points higher then range
’inner’: data points inside range (exclusion of statistical outliers)
The default is ‘inner’.
outsort (str, optional) – Sorting of output. Implemented are ‘ascending’ and ‘descending’. All other values will return data unsorted. The default is None.
- Returns
dout – Mean value/-s of input data without statistical outliers.
- Return type
float or pd.Series
- exmecheva.common.stat_ext.pd_agg(pd_o, agg_funcs=['mean', 'median', 'std', 'max', 'min'], numeric_only=False)[source]
Aggregate pandas object with defined functions.
- exmecheva.common.stat_ext.pd_agg_custom(pdo, agg_funcs=['mean', <function meanwoso>, 'median', 'std', <function coefficient_of_variation>, <function stdwoso>, <function coefficient_of_variation_woso>, 'min', 'max', <function confidence_interval>], numeric_only=False, af_ren={'coefficient_of_variation': 'CV', 'coefficient_of_variation_woso': 'CVwoso'}, af_unp={'confidence_interval': ['CImin', 'CImax']})[source]
Aggregate pandas object with defined functions, including unpacked multi-value functions.
- Parameters
pdo (pd.DataFrame or pd.Series) – Pandas object (DataFrame or Series).
agg_funcs (list of functions, optional) –
List of aggregatable functions (pandas aggregate accepted). The default is [‘mean’,meanwoso,’median’,
’std’,coefficient_of_variation,stdwoso, coefficient_of_variation_woso, ‘min’,’max’,confidence_interval].
numeric_only (bool, optional) – Switch for consideration of numerical values only (int and float). The default is False.
af_ren (dict, optional) –
Dictionary for renaming of aggregate function names. The default is {‘coefficient_of_variation_woso’:’CVwoso’,
’coefficient_of_variation’:’CV’}.
af_unp (dict, optional) – Dictionary for unpacking of aggregate function. The default is {‘confidence_interval’: [‘CImin’,’CImax’]}.
- Returns
Aggregation values depending on given functions.
- Return type
pd.DataFrame or pd.Series
- exmecheva.common.stat_ext.reg_stats_multi(df, lRd, var_ren={}, var_sym={}, ftype='linear', guess={'a': 0.01, 'b': 0.1}, t_form='{a:.3e},{b:.3e}', max_nfev=1000, nan_policy='omit', ind=3, addind=3)[source]
Performs multiple regression fits (according fitting.regfitret) on given data. Returns a DataFrame and textual output.
- Parameters
df (pd.DataFrame) – Input data.
lRd (list) – List of compared variables (must be column names in df). Example [[‘Density_app’,’Age’]]
var_ren (dict, optional) – Renamer for given variables (description). Example dict(‘Density_app’=’apparent density’,’Age’=’donor age’) The default is {}.
var_sym (dict, optional) – Renamer for given variables (symbols). Example dict(‘Density_app’=’rho_{app}’,’Age’=’age’) The default is {}.
ftype (str, optional) –
Type and name of function to adjust. Implemented are:
’linear’: linear and constant function (see func_lin)
’power’: power and constant function (see func_pow)
’exponential’: exponantial and constant function (see func_exp)
- additional endings:
’_nc’: no constant value
’_x0’: fixed to zero
The default is ‘linear’.
guess (dictionary, optional) – Dictionary for first guess. The default is dict(a=0.01, b=0.1).
t_form (str, optional) – String of dictionary with variables and format strings. The default is ‘{a:.3e},{b:.3e}’.
max_nfev (int, optional) – Maximum number of evaluations. The default is 1000.
nan_policy (string, optional) – NaN policy (omit, raise or propagate). The default is ‘omit’.
ind (TYPE, optional) – Indentation for text output. The default is 3.
addind (int, optional) – Additional indentation for text output. The default is 3.
- Returns
reg_df (pd.Dataframe) – Results of regressions.
txt (str) – Textual output.
- exmecheva.common.stat_ext.relative_deviation(a, b, axis=0)[source]
Calculates the relative deviation from second argument to first.
\[RD_{b-a} = (b-a)/a\]- Parameters
a (int or float or pd.Series or pd.DataFrame) – Base value.
b (pd.Series or pd.DataFrame) – Calculation value.
axis (int, optional) – Identifyier for performing calculation. The default is 0.
- Raises
NotImplementedError – Combination of types not implemented.
- Returns
out – Relative deviation result (type depends on input types).
- Return type
int or float or pd.Series or pd.DataFrame
- exmecheva.common.stat_ext.stat_box_vals(data, option='IQR', span=1.5)[source]
Determine values of typical boxplot values (1st quantile, 3rd qhuantile)
- datapd.Series or pd.DataFrame
Input data.
- optionstr, optional
Determination option. Only ‘IQR’: interquartile-range-rule implemented. The default is ‘IQR’.
- spanfloat, optional
Span for inclusion (p.e.: ‘IQr’ and 1.5 leads to standard 1.5-interquartile-range-rule). The default is 1.5.
- Raises
NotImplementedError – Option not implemented.
- Returns
box_vals (dict) – DESCRIPTION. - ‘lBo’: lower boarder of 1.5-IQR - ‘minin’: minimal value inside range - ‘dQ1’: first quartile - ‘med’: Median - ‘dQ3’: third quartile - ‘maxin’: maximal value inside range - ‘uBo’: upper boarder of 1.5-IQR
inner_vals (pd.Series or pd.DataFrame (like input data)) – Index of values inside range (not statistical outlier).
outer_vals (pd.Series or pd.DataFrame (like input data)) – Index of values outside range (statistical outlier).
- exmecheva.common.stat_ext.stat_outliers(data, option='IQR', span=1.5, out='all', outsort='ascending')[source]
Determine statistical outliers.
- Parameters
data (pd.Series or pd.DataFrame) – Input data.
option (str, optional) – Determination option. Only ‘IQR’: interquartile-range-rule implemented. The default is ‘IQR’.
span (float, optional) – Span for inclusion (p.e.: ‘IQr’ and 1.5 leads to standard 1.5-interquartile-range-rule). The default is 1.5.
out (str, optional) –
- Output option. Implemented are:
’all’: all data points outside range (all statistical outliers)
’lower’: data points lower then range
’higher’: data points higher then range
’inner’: data points inside range (exclusion of statistical outliers)
The default is ‘all’.
outsort (str, optional) – Sorting of output. Implemented are ‘ascending’ and ‘descending’. All other values will return data unsorted. The default is ‘ascending’.
- Raises
NotImplementedError – Option not implemented.
- Returns
stol – Statistical outlier data acc. to options.
- Return type
pd.Series or pd.DataFrame (like input data)
- exmecheva.common.stat_ext.stdwoso(data, option='IQR', span=1.5, out='inner', outsort=None)[source]
Determine standard deviation of input data without statistical outliers. (see stat_outliers for more information)
- Parameters
data (pd.Series or pd.DataFrame) – Input data.
option (str, optional) – Determination option. Only ‘IQR’: interquartile-range-rule implemented. The default is ‘IQR’.
span (float, optional) – Span for inclusion (p.e.: ‘IQr’ and 1.5 leads to standard 1.5-interquartile-range-rule). The default is 1.5.
out (str, optional) –
Output option. Only option inner makes sense. Implemented are:
’all’: all data points outside range (all statistical outliers)
’lower’: data points lower then range
’higher’: data points higher then range
’inner’: data points inside range (exclusion of statistical outliers)
The default is ‘inner’.
outsort (str, optional) – Sorting of output. Implemented are ‘ascending’ and ‘descending’. All other values will return data unsorted. The default is None.
- Returns
dout – Standard deviation value/-s of input data without statistical outliers.
- Return type
float or pd.Series
Module contents
Common functionality for exmecheva.