slitflow.tbl.math module
- class EvalOneCol(info_path=None)[source]
Bases:
TableApply
eval()calculation to columns.- Parameters:
reqs[0] (Table) – Table containing columns for calculation.
param["calc_cols"] (list of str, optional) – Column names to calculate. If not provided, all columns are calculated.
param["split_depth"] (int) – File split depth number.
param["type"] (str, optional) – Preset calculation type. Select from “log10”, “standardize” or user defined. type is also used as new column name headers.
param["eval"] (str, optional) – Calculation eval string such as ‘__import__(“numpy”).log10(x)’. eval is needed if type is not defined. The input values should be x in eval string.
- Returns:
Calculated Table object
- Return type:
- static process(reqs, param)[source]
Apply
eval()calculation to columns.If you want to calculate multiple columns in one Table object, , use
EvalTwoColsand select the same Table object for reqs[0] and reqs[1].- Parameters:
reqs[0] (pandas.DataFrame) – Table containing columns for calculation.
param["calc_cols"] (list of str) – Column names to calculate.
param["new_cols"] (list of str) – Column names of calculated columns.
param["eval"] (str) – Calculation eval string such as ‘__import__(“numpy”).log10(x)’. The input values should be x in eval string.
- Returns:
Table containing calculated columns
- Return type:
- class EvalTwoCols(info_path=None)[source]
Bases:
TableApply
eval()between two columns from different Tables.- Parameters:
reqs[0] (Table) – Table containing a column for calculation as x.
reqs[1] (Table) – The second table containing a column for calculation as y.
param["eval"] (str) – String of equation with column1=x and column2=y. Ex. “x*y”.
param["new_col_info"] (tuple of str) – Information of new columns. This should be (“name”, “type”, “unit”, “description”).
param["keep_cols"] (list of bool or list of list of str) – If True, keep all columns. If False, delete all columns except calc_cols. If list of str, keep columns in the list.
param["split_depth"] (int) – File split depth number.
- Returns:
Calculated column data
- Return type:
- static process(reqs, param)[source]
Apply
eval()between two columns from different Tables.- Parameters:
reqs[0] (pandas.DataFrame) – Table containing a column for calculation as x.
reqs[1] (pandas.DataFrame) – The second table containing a column for calculation as y.
param["eval"] (str) – String of equation with column1=x and column2=y. Ex. “x*y”.
param["keep_cols"] (list of list of str) – List of column names to keep.
param["col_name"] (str) – Name string of calculated column.
- Returns:
Calculated column data
- Return type:
- class Centering(info_path=None)[source]
Bases:
TableShift column values using center values.
- Parameters:
- Returns:
Table containing shifted columns
- Return type:
- static process(reqs, param)[source]
Shift column values using center values.
- Parameters:
reqs[0] (pandas.DataFrame) – Table to shift column values.
param["calc_cols"] (list of str) – Coordinate column names to shift.
- Returns:
Table containing shifted columns
- Return type:
- centering_by_edge(df, calc_cols)[source]
Shift column value by center position.
- Parameters:
df (pandas.DataFrame) – Table containing columns to shift.
- Returns:
Table containing shifted columns
- Return type:
- class AddGauss(info_path=None)[source]
Bases:
TableAdd Gaussian random values to Table.
- Parameters:
reqs[0] (Table) – Table to add Gauss value.
param["name"] (str) – Column name of Gauss value.
param["unit"] (str) – Column unit of Gauss value.
param["description"] (str) – Column description of Gauss value.
param["sigmas"] (float) – Standard deviation of Gauss values.
param["baselines"] (float) – Baseline value of Gauss values.
param["ratio"] (float) – Ratio of Gauss fraction.
param["seed"] (int, optional) – Random seed.
param["split_depth"] (int) – File split depth number.
- Returns:
Table with Gauss values
- Return type:
- static process(reqs, param)[source]
Add Gaussian random values to table.
- Parameters:
reqs[0] (numpy.ndarray) – Table to add Gauss value.
param["name"] (str) – Column name of Gauss value.
param["sigmas"] (float) – Standard deviation of Gauss values.
param["baselines"] (float) – Baseline value of Gauss values.
param["ratio"] (float) – Ratio of Gauss fraction.
- Returns:
Table with Gauss values
- Return type: