loader module

Define functions to prepare data for MultipactorTest.

TRIGGER_POLICIES

How consecutive-same power points should be treated.

  • "keep_all": keep all data (default)

  • "trim": remove trailing points

  • "average": average the data on the same point

  • "first": only consider first point (least conditionned)

  • "last": only consider last point (most conditionned)

  • "max": retain maximum value

  • "min": retain minimum value

alias of Literal[‘keep_all’, ‘trim’, ‘average’, ‘first’, ‘last’, ‘max’, ‘min’]

load(filepath, sep='\\t', trigger_policy='keep_all', index_col='Sample index', remove_metadata_columns=False, **kwargs)[source]

Load the LabViewer file.

If trigger_policy is set, perform operations to select the desired trigger. These operations do not preserve original sample indexes.

Parameters:
  • filepath (Path) – LabViewer file to be loaded.

  • sep (str, default: '\\t') – Column separator.

  • trigger_policy (Literal['keep_all', 'trim', 'average', 'first', 'last', 'max', 'min'], default: 'keep_all') – How consecutive measures at the same power should be treated.

  • index_col (str, default: 'Sample index') – Name of the column holding indexes.

  • remove_metadata_columns (bool, default: False) – Remove the rightmost columns holding metadata.

  • kwargs – Other kwargs passed to _load_file().

Return type:

tuple[DataFrame, list[str]]

Returns:

  • pandas.DataFrame – Holds data.

  • list[str] – The comments, without their comment character, line by line. If loading a XLSX, an empty list is returned.

_load_file(filepath, index_col='Sample index', comment='#', **kwargs)[source]

Load the data file.

Todo

Allow for TXT or XLSX input files.

Parameters:
  • filepath (Path) – File to load.

  • index_col (str, default: 'Sample index') – Name of the index column.

  • comment (str, default: '#') – Comment character.

  • kwargs – Other keyword arguments passed to the loading function. Holds "sep" key-value pair, which is removed if loading a XLSX.

Return type:

tuple[DataFrame, list[str]]

Returns:

  • pandas.DataFrame – Holds data.

  • list[str] – The comments, without their comment character, line by line. If loading a XLSX, an empty list is returned.

_apply_trigger_filtering(trigger_policy, data, dbm_column='NI9205_dBm', tol=1e-10)[source]

Apply desired trigger policy.

Original indexes are not preserved.

Parameters:
  • trigger_policy (Literal['keep_all', 'trim', 'average', 'first', 'last', 'max', 'min'])

  • data (DataFrame)

  • dbm_column (str, default: 'NI9205_dBm')

  • tol (float, default: 1e-10)

Return type:

DataFrame

_group_consecutive_equal_power(power, tol=1e-10)[source]

Gather measurements with the same power (consecutive).

Parameters:
Return type:

ndarray[tuple[Any, ...], dtype[intc]]

Returns:

An array of group labels of the same length as power.

save(filepath, data, info=None, verbose=True, **kwargs)[source]

Save the dataframe as a new LabViewer results file.

Parameters:
Return type:

None