slitflow.tbl.math module

class EvalOneCol(info_path=None)[source]

Bases: Table

Apply 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:

Table

set_info(param={})[source]

Modify column information and add params.

static process(reqs, param)[source]

Apply eval() calculation to columns.

If you want to calculate multiple columns in one Table object, , use EvalTwoCols and 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:

pandas.DataFrame

class EvalTwoCols(info_path=None)[source]

Bases: Table

Apply 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["calc_cols"] (list of str) – Column names of [x, 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:

Table

set_reqs(reqs, param)[source]

Drop elements that exist only in one required data.

set_info(param={})[source]

Set new column information and add params.

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["calc_cols"] (list of str) – Column names of [x, y].

  • param["index_cols"] (list of str) – Column names of index.

  • 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:

Table

class Centering(info_path=None)[source]

Bases: Table

Shift column values using center values.

Parameters:
  • reqs[0] (Table) – Table to shift column values.

  • param["calc_cols"] (list of str) – Coordinate column names to shift.

  • param["group_depth"] (int) – Data split depth.

  • param["split_depth"] (int) – File split depth number.

Returns:

Table containing shifted columns

Return type:

Table

set_info(param={})[source]

Copy info from reqs[0] and add params.

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.

  • param["index_cols"] (list of str) – Column names for index.

Returns:

Table containing shifted columns

Return type:

pandas.DataFrame

centering_by_edge(df, calc_cols)[source]

Shift column value by center position.

Parameters:
  • df (pandas.DataFrame) – Table containing columns to shift.

  • calc_cols (list of str) – Column names to shift values.

Returns:

Table containing shifted columns

Return type:

pandas.DataFrame

class AddGauss(info_path=None)[source]

Bases: Table

Add 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:

Table

set_info(param={})[source]

Copy info from reqs[0] and add params.

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:

numpy.ndarray