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
-
Time – Time / s
-
Potential – Potential / V
-
Current – Current / μA
-
Charge – Charge
-
ExtraValue – ExtraValue
-
Frequency – Frequency
-
Phase – Phase
-
ZRe – Z real
-
ZIm – Z imaginary
-
Iac – I AC values
-
Z – Z
-
Y – Y
-
YRe – Y real
-
YIm – Y imaginary
-
Cs – Cs
-
CsRe – Cs real
-
CsIm – Cs imaginary
-
Index – Index
-
Admittance – Admittance
-
Concentration – Concentration
-
Signal – Signal
-
Func – Func
-
Integral – Integral
-
AuxInput – Auxillary input
-
BipotCurrent – Bipot current
-
BipotPotential – Bipot potential
-
ReverseCurrent – Reverse current
-
CEPotential – CE potential
-
DCCurrent – DC current
-
ForwardCurrent – Forward current
-
PotentialExtraRE – Potential setpoint measured back on RE
-
CurrentExtraWE – Current setpoint measured back on WE
-
InverseDerative_dtdE – Inverse derivative dt/dE
-
mEdc – Measured applied DC
-
Eac – E AC values
-
MeasuredStepStartIndex – MeasuredStepStartIndex
-
miDC – Measured I DC values
-
SE2vsXPotential – SE2 vs XPotential
DataArray
DataArray(*, psarray)
Python wrapper for .NET DataArray class.
Parameters:
-
psarray – Reference to .NET DataArray object.
Functions:
Attributes:
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
Peak
Peak(*, pspeak)
Python wrapper for .NET Peak class.
Parameters:
-
pspeak (Peak) – Reference to .NET Peak object.
Attributes:
-
curve_title (str) – Title of parent curve.
-
analyte_name (str) – Name of analyte.
-
left_index (int) – Left side of the peaks baseline as index number of the curve.
-
maximum_of_derivative_neg (float) – Maximum derivative of the negative slope of the peak.
-
maximum_of_derivative_pos (float) – Maximum derivative of the positive slope of the peak.
-
maximum_of_derivative_sum (float) – Sum of the absolute values for both the positive and negative maximum derivative.
-
index (int) – Location of the peak as index number of the curve.
-
right_index (int) – Left side of the peaks baseline as index number of the curve.
-
right_y (float) – Returns the Y of the right 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.
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:
-
mux_channel (int) – The corresponding MUX channel number with the curve starting at 0.
-
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.
-
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.
-
peaks (link:#list[link:#pypalmsens._data.peak.Peak]) – Return peaks stored on object.
mux_channel
mux_channel: int
The corresponding MUX channel number with the curve starting at 0. Return -1 when no MUX channel used.
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.
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]) –
linear_slope
linear_slope(start=None, stop=None)
Calculate linear line parameters for this curve between two indexes.
current = a + b * x
Parameters:
Returns:
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:
-
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.
-
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.
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.
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.
method
method: Method
Method related with this Measurement.
The information from the Method is used when saving Curves.
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
DataSet
DataSet(*, psdataset)
Python wrapper for .NET DataSet class.
Parameters:
-
psdataset (DataSet) – Reference to .NET DataSet object.
Functions:
-
curve – Construct a custom curve from x and y keys.
-
arrays – Return list of all arrays. Alias for
.to_list()
-
hidden_arrays – Return ‘hidden’ arrays used for debugging.
-
arrays_by_name – Get arrays by name.
-
arrays_by_quantity – Get arrays by quantity.
-
arrays_by_type – Get arrays by data type.
-
current_arrays – Return all Current arrays.
-
potential_arrays – Return all Potential arrays.
-
time_arrays – Return all Time arrays.
-
freq_arrays – Return all Frequency arrays.
-
zre_arrays – Return all ZRe arrays.
-
zim_arrays – Return all ZIm arrays.
-
aux_input_arrays – Return all AuxInput arrays.
-
current_range – Return current range as list of strings.
-
reading_status – Return reading status as list of strings.
-
timing_status – Return timing status as list of strings.
-
to_dataframe – Return dataset as pandas dataframe.
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.
curve
curve(x, y, title=None)
Construct a custom curve from x and y keys.
Parameters:
Returns:
-
curve (Curve) – New Curve with plotting x against y
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]) –
EISData
EISData(*, pseis)
Python wrapper for .NET EISdata class.
Parameters:
-
pseis – Reference to .NET EISdata object.
Functions:
-
get_data_for_frequency – Returns dictionary with data per frequency.
-
arrays – Complete list of data arrays.
-
current_range – Current ranges for the measurement.
Attributes:
-
frequency_type (str) – Frequency type.
-
dataset (DataSet) – Dataset which contains multiple arrays of values.
-
subscans (link:#list[link:#pypalmsens._data.eisdata.EISData]) – Get list of subscans.
-
n_frequencies (int) – Number of frequencies.
-
n_subscans (int) – Number of subscans.
-
x_quantity (str) – Quantity for array.
-
has_subscans (bool) – Return True if data contains subscans.
-
mux_channel (int) – Mux channel.
-
cdc_values (link:#list[link:#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.