Data

The main entry point for the data is the Measurement class. These can be loaded from a .pssession file or directly returned as a result from an expirement.

These classes are wrappers for the underlying .NET code. Each Python wrapper in this module holds a reference to the underlying .NET SDK object, usually prefixed ps... like Measurement.psmeasurement. These .NET classes are instantiated by the measurement or data loading code. These wrappers are intended to be used for data processing and exploration and not to be directly instantiated.

The raw data is stored in a DataSet under Measurement.dataset. A dataset in turn consist of a series of `DataArray’`s. These would be analogous to the ’Data’ tab in the PSTrace software. A data array would be the equivalent of a column, with a title, array type, and units.

The Curve objects (retrieved via Measurement.curves) are interpretations of the data, much like the plots in the PSTrace software. These can be used for plots or data processing like smoothing the data and peak finding.

pypalmsens.data

This module contains the public api for classes representing measurement data.

Classes:

  • ArrayType – Data array type for standard arrays.

  • DataArray – Python wrapper for .NET DataArray class.

  • Peak – Python wrapper for .NET Peak class.

  • DeviceInfo – Dataclass for device information.

  • Curve – Python wrapper for .NET Curve class.

  • Measurement – Python wrapper for .NET Measurement class.

  • DataSet – Python wrapper for .NET DataSet class.

  • EISData – Python wrapper for .NET EISdata class.

ArrayType

Data array type for standard arrays.

Attributes:

Unspecified

Unspecified = -1

Unspecified

Time

Time = 0

Time / s

Potential

Potential = 1

Potential / V

Current

Current = 2

Current / μA

Charge

Charge = 3

Charge

ExtraValue

ExtraValue = 4

ExtraValue

Frequency

Frequency = 5

Frequency

Phase

Phase = 6

Phase

ZRe

ZRe = 7

Z real

ZIm

ZIm = 8

Z imaginary

Iac

Iac = 9

I AC values

Z

Z = 10

Z

Y

Y = 11

Y

YRe

YRe = 12

Y real

YIm

YIm = 13

Y imaginary

Cs

Cs = 14

Cs

CsRe

CsRe = 15

Cs real

CsIm

CsIm = 16

Cs imaginary

Index

Index = 17

Index

Admittance

Admittance = 18

Admittance

Concentration

Concentration = 19

Concentration

Signal

Signal = 20

Signal

Func

Func = 21

Func

Integral

Integral = 22

Integral

AuxInput

AuxInput = 23

Auxillary input

BipotCurrent

BipotCurrent = 24

Bipot current

BipotPotential

BipotPotential = 25

Bipot potential

ReverseCurrent

ReverseCurrent = 26

Reverse current

CEPotential

CEPotential = 27

CE potential

DCCurrent

DCCurrent = 28

DC current

ForwardCurrent

ForwardCurrent = 29

Forward current

PotentialExtraRE

PotentialExtraRE = 30

Potential setpoint measured back on RE

CurrentExtraWE

CurrentExtraWE = 31

Current setpoint measured back on WE

InverseDerative_dtdE

InverseDerative_dtdE = 32

Inverse derivative dt/dE

mEdc

mEdc = 33

Measured applied DC

Eac

Eac = 34

E AC values

MeasuredStepStartIndex

MeasuredStepStartIndex = 35

MeasuredStepStartIndex

miDC

miDC = 36

Measured I DC values

SE2vsXPotential

SE2vsXPotential = 37

SE2 vs XPotential

DataArray

DataArray(*, psarray)

Python wrapper for .NET DataArray class.

Parameters:

  • psarray – Reference to .NET DataArray object.

Functions:

  • copy – Return a copy of the array.

  • min – Return min value.

  • max – Return max value.

  • savitsky_golay – Smooth the array using a Savitsky-Golay filter with the window size.

  • to_numpy – Export data array to numpy.

  • to_list – Export data array to list.

Attributes:

name

name: str

Name of the array.

type

type: ArrayType

ArrayType enum.

unit

unit: str

Unit for array.

quantity

quantity: str

Quantity for array.

ocp_value

ocp_value: float

OCP Value.

copy

copy()

Return a copy of the array.

min

min()

Return min value.

max

max()

Return max value.

savitsky_golay

savitsky_golay(window_size=3)

Smooth the array using a Savitsky-Golay filter with the window size.

(i.e. window size 2 will filter points based on the values of the next/previous 2 points)

Parameters:

  • window_size (int) – Size of the window

to_numpy

to_numpy()

Export data array to numpy.

to_list

to_list()

Export data array to list.

Peak

Peak(*, pspeak)

Python wrapper for .NET Peak class.

Parameters:

  • pspeak (Peak) – Reference to .NET Peak object.

Attributes:

curve

curve: Curve

Parent curve associated with Peak.

curve_title

curve_title: str

Title of parent curve.

x_unit

x_unit: str

Units of X axis

y_unit

y_unit: str

Units for Y axis

analyte_name

analyte_name: str

Name of analyte.

area

area: float

Area of the peak.

label

label: str

Formatted label for the peak value.

left_index

left_index: int

Left side of the peaks baseline as index number of the curve.

left_x

left_x: float

X of the left side of the peak baseline.

left_y

left_y: float

Y of the left side of the peak baseline.

maximum_of_derivative_neg

maximum_of_derivative_neg: float

Maximum derivative of the negative slope of the peak.

maximum_of_derivative_pos

maximum_of_derivative_pos: float

Maximum derivative of the positive slope of the peak.

maximum_of_derivative_sum

maximum_of_derivative_sum: float

Sum of the absolute values for both the positive and negative maximum derivative.

notes

notes: str

User notes stored on this peak.

y_offset

y_offset: float

Offset of Y.

index

index: int

Location of the peak as index number of the curve.

type

type: str

Used to determine if a peak is auto found.

value

value: float

Value of the peak in units of the curve. This is the value of the peak height relative to the baseline of the peak.

x

x: float

X value of the peak.

y

y: float

Y value of the peak.

right_index

right_index: int

Left side of the peaks baseline as index number of the curve.

right_x

right_x: float

X of the right side of the peak baseline.

right_y

right_y: float

Returns the Y of the right side of the peak baseline.

width

width: float

Full width at half-height of the peak.

DeviceInfo

DeviceInfo(type, firmware, serial, id)

Dataclass for device information.

Attributes:

type

type: str

Device type

firmware

firmware: str

Firmware version

serial

serial: str

Serial number

id

id: int

Device ID

Curve

Curve(*, pscurve)

Python wrapper for .NET Curve class.

Parameters:

  • pscurve (Curve) – Reference to .NET curve object.

Functions:

  • copy – Return a copy of this curve.

  • smooth – Smooth the .y_array using a Savitsky-Golay filter with the specified smooth

  • savitsky_golay – Smooth the .y_array using a Savitsky-Golay filter with the specified window

  • find_peaks – Find peaks in a curve in all directions.

  • find_peaks_semiderivative – Find peaks in a curve using the semi-derivative algorithm.

  • clear_peaks – Clear peaks stored on object.

  • linear_slope – Calculate linear line parameters for this curve between two indexes.

  • plot – Generate simple plot for this curve using matplotlib.

Attributes:

  • max_x (float) – Maximum X value found in this curve.

  • max_y (float) – Maximum Y value found in this curve.

  • min_x (float) – Minimum X value found in this curve.

  • min_y (float) – Minimum Y value found in this curve.

  • mux_channel (int) – The corresponding MUX channel number with the curve starting at 0.

  • n_points (int) – Number of points for this curve.

  • ocp_value (float) – OCP value for curve.

  • reference_electrode_name (link:#typing.Union[None, link:#str]) – The name of the reference electrode. Return None if not set.

  • reference_electrode_potential (link:#typing.Union[None, link:#str]) – The reference electrode potential offset. Return None if not set.

  • x_unit (str) – Units for X dimension.

  • x_label (str) – Label for X dimension.

  • y_unit (str) – Units for Y dimension.

  • y_label (str) – Label for Y dimension.

  • z_unit (link:#typing.Union[None, link:#str]) – Units for Z dimension. Returns None if not set.

  • z_label (link:#typing.Union[None, link:#str]) – Units for Z dimension. Returns None if not set.

  • title (str) – Title for the curve.

  • peaks (link:#list[link:#pypalmsens._data.peak.Peak]) – Return peaks stored on object.

  • x_array (DataArray) – Y data for the curve.

  • y_array (DataArray) – Y data for the curve.

max_x

max_x: float

Maximum X value found in this curve.

max_y

max_y: float

Maximum Y value found in this curve.

min_x

min_x: float

Minimum X value found in this curve.

min_y

min_y: float

Minimum Y value found in this curve.

mux_channel

mux_channel: int

The corresponding MUX channel number with the curve starting at 0. Return -1 when no MUX channel used.

n_points

n_points: int

Number of points for this curve.

ocp_value

ocp_value: float

OCP value for curve.

reference_electrode_name

reference_electrode_name: Union[None, str]

The name of the reference electrode. Return None if not set.

reference_electrode_potential

reference_electrode_potential: Union[None, str]

The reference electrode potential offset. Return None if not set.

x_unit

x_unit: str

Units for X dimension.

x_label

x_label: str

Label for X dimension.

y_unit

y_unit: str

Units for Y dimension.

y_label

y_label: str

Label for Y dimension.

z_unit

z_unit: Union[None, str]

Units for Z dimension. Returns None if not set.

z_label

z_label: Union[None, str]

Units for Z dimension. Returns None if not set.

title

title: str

Title for the curve.

peaks

peaks: list[Peak]

Return peaks stored on object.

x_array

x_array: DataArray

Y data for the curve.

y_array

y_array: DataArray

Y data for the curve.

copy

copy()

Return a copy of this curve.

smooth

smooth(smooth_level=0)

Smooth the .y_array using a Savitsky-Golay filter with the specified smooth level.

Parameters:

  • smooth_level (int) – The smooth level to be used. -1 = none, 0 = no smooth (spike rejection only), 1 = 5 points, 2 = 9 points, 3 = 15 points, 4 = 25 points

savitsky_golay

savitsky_golay(window_size=3)

Smooth the .y_array using a Savitsky-Golay filter with the specified window size.

(i.e. window size 2 will filter points based on the values of the next/previous 2 points)

Parameters:

  • window_size (int) – Size of the window

find_peaks

find_peaks(min_peak_width=0.1, min_peak_height=0.0, peak_shoulders=False, merge_overlapping_peaks=True)

Find peaks in a curve in all directions.

CV can have 1 or 2 direction changes.

Parameters:

  • min_peak_width (float) – Minimum width of the peak in V

  • min_peak_height (float) – Minimum height of the peak in uA

  • peak_shoulders (bool) – Use alternative peak search algorithm optimized for finding peaks on slopes

  • merge_overlapping_peaks (bool) – Two or more peaks that overlap will be identified as a single base peak and as shoulder peaks on the base peak.

Returns:

  • peak_list (link:#list[link:#pypalmsens._data.peak.Peak]) –

find_peaks_semiderivative

find_peaks_semiderivative(min_peak_height=0.0)

Find peaks in a curve using the semi-derivative algorithm.

Used for detecting non-overlapping peaks in LSV and CV curves. The peaks are also assigned to the curve, updating Curve.peaks. Existing peaks are overwritten.

For more info, see this Wikipedia page.

Parameters:

  • min_peak_height (float) – Minimum height of the peak in uA

Returns:

  • peak_list (link:#list[link:#pypalmsens._data.peak.Peak]) –

clear_peaks

clear_peaks()

Clear peaks stored on object.

linear_slope

linear_slope(start=None, stop=None)

Calculate linear line parameters for this curve between two indexes.

current = a + b * x

Parameters:

  • start (int) – begin index

  • stop (int) – end index

Returns:

  • a (float) –

  • b (float) –

  • coefdet (float) – Coefficient of determination (R2)

plot

plot(ax=None, legend=True, **plot_kwargs)

Generate simple plot for this curve using matplotlib.

Parameters:

  • ax (link:#typing.Optional[link:#matplotlib.axes.Axes]) – Add plot to this ax if specified.

  • legend (bool) – If True, add legend.

  • plot_kwargs – These keyword arguments are passed to ax.plot.

Returns:

  • fig (Figure) – Matplotlib figure. Use fig.show() to render plot.

Measurement

Measurement(*, psmeasurement)

Python wrapper for .NET Measurement class.

Parameters:

  • psmeasurement (Measurement) – Reference to .NET measurement object.

Attributes:

  • title (str) – Title for the measurement.

  • timestamp (str) – Date and time of the start of this measurement..

  • device (DeviceInfo) – Return dataclass with measurement device information.

  • blank_curve (Curve | None) – Blank curve.

  • has_blank_subtracted_curves (bool) – Return True if the curve collection contains a blank subtracted curve.

  • has_eis_data (bool) – Return True if EIS data are is available.

  • dataset (DataSet) – Dataset containing multiple arrays of values.

  • eis_data (link:#list[link:#pypalmsens._data.eisdata.EISData]) – EIS data in measurement.

  • method (Method) – Method related with this Measurement.

  • channel (float) – Get the channel that the measurement was measured on.

  • ocp_value (float) – First OCP Value from either curves or EISData.

  • n_curves (int) – Number of curves that are part of the Measurement class.

  • n_eis_data (int) – Number of EISdata curves (channels) that are part of the Measurement class.

  • peaks (link:#list[link:#pypalmsens._data.peak.Peak]) – Get peaks from all curves.

  • eis_fit (link:#list[link:#pypalmsens._fitting.FitResult]) – Get all EIS fits from measurement

  • curves (link:#list[link:#pypalmsens._data.curve.Curve]) – Get all curves in measurement.

title

title: str

Title for the measurement.

timestamp

timestamp: str

Date and time of the start of this measurement..

device

device: DeviceInfo

Return dataclass with measurement device information.

blank_curve

blank_curve: Curve | None

Blank curve.

if Blank curve is present (not null) a new curve will be added after each measurement containing the result of the measured curve subtracted with the Blank curve.

has_blank_subtracted_curves

has_blank_subtracted_curves: bool

Return True if the curve collection contains a blank subtracted curve.

has_eis_data

has_eis_data: bool

Return True if EIS data are is available.

dataset

dataset: DataSet

Dataset containing multiple arrays of values.

All values are related by means of their indices. Data arrays in a dataset should always have an equal amount of entries.

eis_data

eis_data: list[EISData]

EIS data in measurement.

method

method: Method

Method related with this Measurement.

The information from the Method is used when saving Curves.

channel

channel: float

Get the channel that the measurement was measured on.

ocp_value

ocp_value: float

First OCP Value from either curves or EISData.

n_curves

n_curves: int

Number of curves that are part of the Measurement class.

n_eis_data

n_eis_data: int

Number of EISdata curves (channels) that are part of the Measurement class.

peaks

peaks: list[Peak]

Get peaks from all curves.

Returns:

  • peaks (link:#list[link:#pypalmsens._data.peak.Peak]) – List of peaks

eis_fit

eis_fit: list[FitResult]

Get all EIS fits from measurement

Returns:

  • eis_fits (link:#list[link:#EISFitResults]) – Return list of EIS fits

curves

curves: list[Curve]

Get all curves in measurement.

Returns:

  • curves (link:#list[link:#pypalmsens._data.curve.Curve]) – List of curves

DataSet

DataSet(*, psdataset)

Python wrapper for .NET DataSet class.

Parameters:

  • psdataset (DataSet) – Reference to .NET DataSet object.

Functions:

Attributes:

  • array_types (link:#set[link:#pypalmsens._data._shared.ArrayType]) – Return unique set of array type (enum) for arrays in dataset.

  • array_names (link:#set[link:#str]) – Return unique set of names for arrays in dataset.

  • array_quantities (link:#set[link:#str]) – Return unique set of quantities for arrays in dataset.

array_types

array_types: set[ArrayType]

Return unique set of array type (enum) for arrays in dataset.

array_names

array_names: set[str]

Return unique set of names for arrays in dataset.

array_quantities

array_quantities: set[str]

Return unique set of quantities for arrays in dataset.

curve

curve(x, y, title=None)

Construct a custom curve from x and y keys.

Parameters:

  • x (str) – Key identifying the x array

  • y (str) – Key identifying the y array

  • title (str) – Set the title. If None, use the \(x-\)y as title

Returns:

  • curve (Curve) – New Curve with plotting x against y

arrays

arrays()

Return list of all arrays. Alias for .to_list()

hidden_arrays

hidden_arrays()

Return ‘hidden’ arrays used for debugging.

arrays_by_name

arrays_by_name(name)

Get arrays by name.

Parameters:

  • name (str) – Name of the array.

Returns:

  • arrays (link:#list[link:#pypalmsens._data.data_array.DataArray]) –

arrays_by_quantity

arrays_by_quantity(quantity)

Get arrays by quantity.

Parameters:

  • quantity (str) – Quantity of the array.

Returns:

  • arrays (link:#list[link:#pypalmsens._data.data_array.DataArray]) –

arrays_by_type

arrays_by_type(array_type)

Get arrays by data type.

Parameters:

  • array_type (str) – Type of the array.

Returns:

  • arrays (link:#list[link:#pypalmsens._data.data_array.DataArray]) –

current_arrays

current_arrays()

Return all Current arrays.

potential_arrays

potential_arrays()

Return all Potential arrays.

time_arrays

time_arrays()

Return all Time arrays.

freq_arrays

freq_arrays()

Return all Frequency arrays.

zre_arrays

zre_arrays()

Return all ZRe arrays.

zim_arrays

zim_arrays()

Return all ZIm arrays.

aux_input_arrays

aux_input_arrays()

Return all AuxInput arrays.

current_range

current_range()

Return current range as list of strings.

reading_status

reading_status()

Return reading status as list of strings.

timing_status

timing_status()

Return timing status as list of strings.

to_dataframe

to_dataframe()

Return dataset as pandas dataframe.

EISData

EISData(*, pseis)

Python wrapper for .NET EISdata class.

Parameters:

  • pseis – Reference to .NET EISdata object.

Functions:

Attributes:

title

title: str

Tite for EIS data.

frequency_type

frequency_type: str

Frequency type.

scan_type

scan_type: str

Scan type.

dataset

dataset: DataSet

Dataset which contains multiple arrays of values.

subscans

subscans: list[EISData]

Get list of subscans.

n_points

n_points: int

Number of points (including subscans).

n_frequencies

n_frequencies: int

Number of frequencies.

n_subscans

n_subscans: int

Number of subscans.

x_unit

x_unit: str

Unit for array.

x_quantity

x_quantity: str

Quantity for array.

ocp_value

ocp_value: float

OCP Value.

has_subscans

has_subscans: bool

Return True if data contains subscans.

mux_channel

mux_channel: int

Mux channel.

cdc

cdc: str

Gets the CDC circuit for fitting.

cdc_values

cdc_values: list[float]

Return values for circuit description code (CDC).

get_data_for_frequency

get_data_for_frequency(frequency)

Returns dictionary with data per frequency.

Parameters:

  • frequency (int) – Index of the frequency to retrieve the data for.

Returns:

  • [link:#str">str, link:#pypalmsens._data.data_array.DataArray] – Data are returned as a dictionary keyed by the data type.

arrays

arrays()

Complete list of data arrays.

current_range

current_range()

Current ranges for the measurement.