Data parsing

deareis.parse_data(path, file_format='', **kwargs)

Wrapper for pyimpspec.parse_data.

Parse experimental data and return a list of DataSet instances. One or more specific sheets can be specified by name when parsing spreadsheets (e.g., .xlsx or .ods) to only return DataSet instances for those sheets. If no sheets are specified, then all sheets will be processed and the data from successfully parsed sheets will be returned as DataSet instances.

Parameters:
  • path (Union[str, pathlib.Path]) – The path to a file containing experimental data that is to be parsed.

  • file_format (str, optional) – The file format (or extension) that should be assumed when parsing the data. If no file format is specified, then the file format will be determined based on the file extension. If there is no file extension, then attempts will be made to parse the file as if it was one of the supported file formats.

  • **kwargs – Keyword arguments are passed to the parser.

Return type:

List[|DataSet|]

class deareis.DataSet(frequencies, impedances, mask=None, path='', label='', uuid='')

Extends pyimpspec.DataSet to implement data minimization when writing to disk and to recreate the data when loading from disk. Equality checks between DataSet instances is also modified.

Parameters:
  • frequencies (Frequencies) – A 1-dimensional array of frequencies in hertz.

  • impedances (ComplexImpedances) – A 1-dimensional array of complex impedances in ohms.

  • mask (Dict[int, bool], optional) – A mapping of integer indices to boolean values where a value of True means that the data point is to be omitted.

  • path (str, optional) – The path to the file that has been parsed to generate this DataSet instance.

  • label (str, optional) – The label assigned to this DataSet instance.

  • uuid (str, optional) – The universivally unique identifier assigned to this DataSet instance. If empty, then one will be automatically assigned.

classmethod average(data_sets, label='Average')

Create a DataSet by averaging the impedances of multiple DataSet instances.

Parameters:
  • data_sets (List[DataSet]) – The DataSet instances to average.

  • label (str, optional) – The label that the new DataSet should have.

Return type:

DataSet

classmethod duplicate(data, label=None)

Create a duplicate of an existing DataSet but assign another universally unique identifier (UUID) to the copy.

Parameters:
  • data (DataSet) – The existing DataSet to duplicate.

  • label (Optional[str], optional) – The label that the copy should have.

Return type:

DataSet

classmethod from_dict(dictionary)

Return a DataSet instance that has been created based off of a dictionary.

Parameters:

dictionary (dict) – Create an instance from a dictionary.

Return type:

DataSet

get_bode_data(masked=False)

Get the data necessary to plot this DataSet as a Bode plot: the frequencies, the absolute magnitudes of the impedances, and the negative phase angles/shifts of the impedances in degrees.

Parameters:

masked (Optional[bool], optional) – None means that all impedances are returned. True means that only impedances that are to be omitted are returned. False means that only impedances that are to be included are returned.

Return type:

Tuple[Frequencies, Impedances, Phases]

get_frequencies(masked=False)

Get the frequencies in this DataSet.

Parameters:

masked (Optional[bool], optional) – None means that all frequencies are returned. True means that only frequencies that are to be omitted are returned. False means that only frequencies that are to be included are returned.

Return type:

Frequencies

get_impedances(masked=False)

Get the complex impedances in this DataSet.

Parameters:

masked (Optional[bool], optional) – None means that all impedances are returned. True means that only impedances that are to be omitted are returned. False means that only impedances that are to be included are returned.

Return type:

ComplexImpedances

get_label()

Get the label assigned to this DataSet.

Return type:

str

get_magnitudes(masked=False)

Get the absolute magnitudes of the impedances in this DataSet.

Parameters:

masked (Optional[bool], optional) – None means that all impedances are returned. True means that only impedances that are to be omitted are returned. False means that only impedances that are to be included are returned.

Return type:

Impedances

get_mask()

Get the mask for this DataSet. True means that the data point is to be omitted and False means that the data point is to be included. The keys are zero-based integer indices and the values are booleans.

Return type:

Dict[int, bool]

get_num_points(masked=False)

Get the number of data points in this DataSet

Parameters:

masked (Optional[bool], optional) – None means that all impedances are returned. True means that only impedances that are to be omitted are returned. False means that only impedances that are to be included are returned.

Return type:

int

get_nyquist_data(masked=False)

Get the data necessary to plot this DataSet as a Nyquist plot: the real and the negative imaginary parts of the impedances.

Parameters:

masked (Optional[bool], optional) – None means that all impedances are returned. True means that only impedances that are to be omitted are returned. False means that only impedances that are to be included are returned.

Return type:

Tuple[Impedances, Impedances]

get_path()

Get the path to the file that was parsed to generate this DataSet.

Return type:

str

get_phases(masked=False)

Get the phase angles/shifts of the impedances in this DataSet in degrees.

Parameters:

masked (Optional[bool], optional) – None means that all impedances are returned. True means that only impedances that are to be omitted are returned. False means that only impedances that are to be included are returned.

Return type:

Phases

high_pass(cutoff)

Mask data points by applying a high-pass filter with the provided cutoff frequency.

Parameters:

cutoff (float) – The cutoff frequency to use. Data points with frequencies lower than this cutoff frequency are masked.

low_pass(cutoff)

Mask data points by applying a low-pass filter with the provided cutoff frequency.

Parameters:

cutoff (float) – The cutoff frequency to use. Data points with frequencies higher than this cutoff frequency are masked.

set_label(label)

Set the label assigned to this DataSet.

Parameters:

label (str) – The new label.

set_mask(mask)

Set the mask for this DataSet.

Parameters:

mask (Dict[int, bool]) – The new mask that determines which data points are omitted. True means that the data point is to be omitted and False means that the data point is to be included. The keys must be zero-based integer indices and the values must be boolean values.

set_path(path)

Set the path to the file that was parsed to generate this DataSet.

Parameters:

path (str) – The path.

subtract_impedances(impedances)

Subtract either the same complex value from all data points or a unique complex value for each data point in this DataSet.

Parameters:

impedances (ComplexImpedances) – The complex value(s) to subtract from this DataSet’s impedances.

to_dataframe(masked=False, columns=None, negative_imaginary=False, negative_phase=False)

Create a `pandas.DataFrame`_ instance from this DataSet.

Parameters:
  • masked (Optional[bool], optional) – None means that all impedances are returned. True means that only impedances that are to be omitted are returned. False means that only impedances that are to be included are returned.

  • columns (Optional[List[str]], optional) – The column headers to use.

  • negative_imaginary (bool, optional) – Whether or not the sign of the imaginary part of the impedance data should be inverted. Note that this does not automatically add a minus sign in front of the column label.

  • negative_phase (bool, optional) – Whether or not the sign of the phase of the impedance data should be inverted. Note that this does not automatically add a minus sign in front of the column label.

Return type:

`pandas.DataFrame`_

to_dict(session=True)

Return a dictionary that can be used to recreate an instance.

Parameters:

session (bool, optional) – If False, then a minimal dictionary is generated to reduce file size.

Return type:

dict