Skip to content

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.

  • CallbackData

    Data returned by the new data callback.

  • CallbackDataEIS

    Data returned by the EIS new data callback.

  • CurrentReading

    Current reading data class.

  • Curve

    Python wrapper for .NET Curve class.

  • DataArray

    Python wrapper for .NET DataArray class.

  • DataSet

    Python wrapper for .NET DataSet class.

  • DeviceInfo

    Dataclass for device information.

  • EISData

    Python wrapper for .NET EISdata class.

  • Measurement

    Python wrapper for .NET Measurement class.

  • Peak

    Python wrapper for .NET Peak class.

  • PotentialReading

    Potential reading data class.

  • Status

    Device Status class.

ArrayType


              flowchart TD
              pypalmsens.data.ArrayType[ArrayType]

              

              click pypalmsens.data.ArrayType href "" "pypalmsens.data.ArrayType"
            

Data array type for standard arrays.

Attributes:

Admittance class-attribute instance-attribute

Admittance = 18

Admittance.

AuxInput class-attribute instance-attribute

AuxInput = 23

Auxillary input.

BipotCurrent class-attribute instance-attribute

BipotCurrent = 24

Bipot current.

BipotPotential class-attribute instance-attribute

BipotPotential = 25

Bipot potential.

CEPotential class-attribute instance-attribute

CEPotential = 27

CE potential.

Charge class-attribute instance-attribute

Charge = 3

Charge.

Concentration class-attribute instance-attribute

Concentration = 19

Concentration.

Cs class-attribute instance-attribute

Cs = 14

Cs.

CsIm class-attribute instance-attribute

CsIm = 16

Cs imaginary.

CsRe class-attribute instance-attribute

CsRe = 15

Cs real.

Current class-attribute instance-attribute

Current = 2

Current / μA.

CurrentExtraWE class-attribute instance-attribute

CurrentExtraWE = 31

Current setpoint measured back on WE.

DCCurrent class-attribute instance-attribute

DCCurrent = 28

DC current.

Eac class-attribute instance-attribute

Eac = 34

E AC values.

ExtraValue class-attribute instance-attribute

ExtraValue = 4

ExtraValue.

ForwardCurrent class-attribute instance-attribute

ForwardCurrent = 29

Forward current.

Frequency class-attribute instance-attribute

Frequency = 5

Frequency.

Func class-attribute instance-attribute

Func = 21

Func.

Iac class-attribute instance-attribute

Iac = 9

I AC values.

Index class-attribute instance-attribute

Index = 17

Index.

Integral class-attribute instance-attribute

Integral = 22

Integral.

InverseDerative_dtdE class-attribute instance-attribute

InverseDerative_dtdE = 32

Inverse derivative dt/dE.

MeasuredStepStartIndex class-attribute instance-attribute

MeasuredStepStartIndex = 35

MeasuredStepStartIndex.

Phase class-attribute instance-attribute

Phase = 6

Phase.

Potential class-attribute instance-attribute

Potential = 1

Potential / V.

PotentialExtraRE class-attribute instance-attribute

PotentialExtraRE = 30

Potential setpoint measured back on RE.

ReverseCurrent class-attribute instance-attribute

ReverseCurrent = 26

Reverse current.

SE2vsXPotential class-attribute instance-attribute

SE2vsXPotential = 37

SE2 vs XPotential.

Signal class-attribute instance-attribute

Signal = 20

Signal.

Time class-attribute instance-attribute

Time = 0

Time / s.

Unspecified class-attribute instance-attribute

Unspecified = -1

Unspecified.

Y class-attribute instance-attribute

Y = 11

Y.

YIm class-attribute instance-attribute

YIm = 13

Y imaginary.

YRe class-attribute instance-attribute

YRe = 12

Y real.

Z class-attribute instance-attribute

Z = 10

Z.

ZIm class-attribute instance-attribute

ZIm = 8

Z imaginary.

ZRe class-attribute instance-attribute

ZRe = 7

Z real.

mEdc class-attribute instance-attribute

mEdc = 33

Measured applied DC.

miDC class-attribute instance-attribute

miDC = 36

Measured I DC values.

CallbackData dataclass

CallbackData(x_array: DataArray, y_array: DataArray, start: int)

Data returned by the new data callback.

Methods:

Attributes:

index property

index: int

Index of last point.

start instance-attribute

start: int

Start index for the new data.

x_array instance-attribute

x_array: DataArray

Data array for the x variable.

y_array instance-attribute

y_array: DataArray

Data array for the y variable.

last_datapoint

last_datapoint() -> dict[str, float]

Return last measured data point.

Source code in src/pypalmsens/_instruments/callback.py
41
42
43
44
45
46
47
def last_datapoint(self) -> dict[str, float]:
    """Return last measured data point."""
    return {
        'index': self.index,
        'x': self.x_array[-1],
        'y': self.y_array[-1],
    }

new_datapoints

new_datapoints() -> Generator[dict[str, float]]

Return new data points since last callback.

Source code in src/pypalmsens/_instruments/callback.py
49
50
51
52
53
54
55
56
def new_datapoints(self) -> Generator[dict[str, float]]:
    """Return new data points since last callback."""
    for i in range(self.start, self.index + 1):
        yield {
            'x': self.x_array[i],
            'y': self.y_array[i],
            'index': i,
        }

CallbackDataEIS dataclass

CallbackDataEIS(data: DataSet, start: int)

Data returned by the EIS new data callback.

Methods:

Attributes:

data instance-attribute

data: DataSet

EIS dataset.

index property

index: int

Index of last point.

start instance-attribute

start: int

Start index for the new data.

last_datapoint

last_datapoint() -> dict[str, float]

Return last measured data point.

Source code in src/pypalmsens/_instruments/callback.py
78
79
80
81
82
def last_datapoint(self) -> dict[str, float]:
    """Return last measured data point."""
    ret = {array.name: array[-1] for array in self.data.arrays()}
    ret['index'] = self.index
    return ret

new_datapoints

new_datapoints() -> Generator[dict[str, float]]

Return new data points since last callback.

Source code in src/pypalmsens/_instruments/callback.py
84
85
86
87
88
89
def new_datapoints(self) -> Generator[dict[str, float]]:
    """Return new data points since last callback."""
    for i in range(self.start, self.index + 1):
        ret = {array.name: array[i] for array in self.data.arrays()}
        ret['index'] = i
        yield ret

CurrentReading dataclass

CurrentReading(current_range: AllowedCurrentRanges, current: float, current_in_range: float, timing_status: AllowedTimingStatus, reading_status: AllowedReadingStatus)

Current reading data class.

Attributes:

current instance-attribute

current: float

current in μA.

current_in_range instance-attribute

current_in_range: float

Raw current value expressed in the active current range.

current_range instance-attribute

current_range: AllowedCurrentRanges

Active current range for this data point.

reading_status instance-attribute

reading_status: AllowedReadingStatus

Status of the current reading.

timing_status instance-attribute

timing_status: AllowedTimingStatus

Status of the current timing.

Curve

Curve(*, pscurve: Curve)

Python wrapper for .NET Curve class.

Parameters:

  • pscurve

    (Curve) –

    Reference to .NET curve object.

Methods:

  • clear_peaks

    Clear peaks stored on object.

  • copy

    Return a copy of this curve.

  • find_peaks

    Find peaks in a curve in all directions.

  • find_peaks_semiderivative

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

  • linear_slope

    Calculate linear line parameters for this curve between two indexes.

  • plot

    Generate simple plot for this curve using matplotlib.

  • savitsky_golay

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

  • smooth

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

Attributes:

Source code in src/pypalmsens/_data/curve.py
27
28
def __init__(self, *, pscurve: PSCurve):
    self._pscurve = pscurve

max_x property

max_x: float

Maximum X value found in this curve.

max_y property

max_y: float

Maximum Y value found in this curve.

min_x property

min_x: float

Minimum X value found in this curve.

min_y property

min_y: float

Minimum Y value found in this curve.

mux_channel property

mux_channel: int

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

n_points property

n_points: int

Number of points for this curve.

ocp_value property

ocp_value: float

OCP value for curve.

peaks property

peaks: list[Peak]

Return peaks stored on object.

reference_electrode_name property

reference_electrode_name: None | str

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

reference_electrode_potential property

reference_electrode_potential: None | str

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

title property writable

title: str

Title for the curve.

x_array property

x_array: DataArray

Y data for the curve.

x_label property

x_label: str

Label for X dimension.

x_unit property

x_unit: str

Units for X dimension.

y_array property

y_array: DataArray

Y data for the curve.

y_label property

y_label: str

Label for Y dimension.

y_unit property

y_unit: str

Units for Y dimension.

z_label property

z_label: None | str

Units for Z dimension. Returns None if not set.

z_unit property

z_unit: None | str

Units for Z dimension. Returns None if not set.

clear_peaks

clear_peaks()

Clear peaks stored on object.

Source code in src/pypalmsens/_data/curve.py
240
241
242
def clear_peaks(self):
    """Clear peaks stored on object."""
    self._pscurve.ClearPeaks()

copy

copy() -> Curve

Return a copy of this curve.

Source code in src/pypalmsens/_data/curve.py
34
35
36
def copy(self) -> Curve:
    """Return a copy of this curve."""
    return Curve(pscurve=PSCurve(self._pscurve, cloneData=True))

find_peaks

Find peaks in a curve in all directions.

CV can have 1 or 2 direction changes.

Parameters:

  • min_peak_width
    (float, default: 0.1 ) –

    Minimum width of the peak in V

  • min_peak_height
    (float, default: 0.0 ) –

    Minimum height of the peak in uA

  • peak_shoulders
    (bool, default: False ) –

    Use alternative peak search algorithm optimized for finding peaks on slopes

  • merge_overlapping_peaks
    (bool, default: True ) –

    Two or more peaks that overlap will be identified as a single base peak and as shoulder peaks on the base peak.

Returns:

Source code in src/pypalmsens/_data/curve.py
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
def find_peaks(
    self,
    min_peak_width: float = 0.1,
    min_peak_height: float = 0.0,
    peak_shoulders: bool = False,
    merge_overlapping_peaks: bool = True,
) -> list[Peak]:
    """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, optional
        Use alternative peak search algorithm optimized for finding peaks on slopes
    merge_overlapping_peaks : bool, optional
        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 : list[Peak]
    """
    pspeaks = self._pscurve.FindPeaks(
        minPeakWidth=min_peak_width,
        minPeakHeight=min_peak_height,
        peakShoulders=peak_shoulders,
        mergeOverlappingPeaks=merge_overlapping_peaks,
    )

    peaks_list = [Peak(pspeak=peak) for peak in pspeaks]

    return peaks_list

find_peaks_semiderivative

find_peaks_semiderivative(min_peak_height: float = 0.0) -> list[Peak]

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, default: 0.0 ) –

    Minimum height of the peak in uA

Returns:

Source code in src/pypalmsens/_data/curve.py
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
def find_peaks_semiderivative(
    self,
    min_peak_height: float = 0.0,
) -> list[Peak]:
    """
    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](https://en.wikipedia.org/wiki/Neopolarogram).

    Parameters
    ----------
    min_peak_height : float
        Minimum height of the peak in uA

    Returns
    -------
    peak_list : list[Peak]
    """
    dct = System.Collections.Generic.Dictionary[PSCurve, System.Double]()
    dct[self._pscurve] = min_peak_height

    pd = PSAnalysis.SemiDerivativePeakDetection()
    pd.GetNonOverlappingPeaks(dct)

    return self.peaks

linear_slope

linear_slope(start: None | int = None, stop: None | int = None) -> tuple[float, float, float]

Calculate linear line parameters for this curve between two indexes.

current = a + b * x

Parameters:

  • start
    (int, default: None ) –

    begin index

  • stop
    (int, default: None ) –

    end index

Returns:

  • a ( float ) –
  • b ( float ) –
  • coefdet ( float ) –

    Coefficient of determination (R2)

Source code in src/pypalmsens/_data/curve.py
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
def linear_slope(
    self, start: None | int = None, stop: None | int = None
) -> tuple[float, float, float]:
    """Calculate linear line parameters for this curve between two indexes.

    current = a + b * x

    Parameters
    ----------
    start : int, optional
        begin index
    stop : int, optional
        end index

    Returns
    -------
    a : float
    b : float
    coefdet : float
        Coefficient of determination (R2)
    """
    if start and stop:
        return self._pscurve.LLS(start, stop)
    else:
        return self._pscurve.LLS()

plot

plot(ax: None | Axes = None, legend: bool = True, **plot_kwargs) -> Figure | SubFigure

Generate simple plot for this curve using matplotlib.

Parameters:

  • ax
    (Optional[Axes], default: None ) –

    Add plot to this ax if specified.

  • legend
    (bool, default: True ) –

    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.

Source code in src/pypalmsens/_data/curve.py
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
def plot(
    self,
    ax: None | axes.Axes = None,
    legend: bool = True,
    **plot_kwargs,
) -> figure.Figure | figure.SubFigure:
    """Generate simple plot for this curve using matplotlib.

    Parameters
    ----------
    ax : Optional[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 : fig.Figure
        Matplotlib figure. Use `fig.show()` to render plot.
    """
    import matplotlib.pyplot as plt

    if not ax:
        fig, ax = plt.subplots()

    _ = ax.plot(self.x_array, self.y_array, label=self.title, **plot_kwargs)
    _ = ax.set_xlabel(f'{self.x_label} ({self.x_unit})')
    _ = ax.set_ylabel(f'{self.y_label} ({self.y_unit})')

    if peaks := self.peaks:
        x, y = list(zip(*((peak.x, peak.y) for peak in peaks)))
        _ = ax.scatter(x, y, label='Peaks')

    if legend:
        _ = ax.legend()

    return ax.figure

savitsky_golay

savitsky_golay(window_size: int = 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, default: 3 ) –

    Size of the window

Source code in src/pypalmsens/_data/curve.py
52
53
54
55
56
57
58
59
60
61
62
63
def savitsky_golay(self, window_size: int = 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
    """
    self._pscurve.SavitskyGolay(windowSize=window_size)

smooth

smooth(smooth_level: int = 0)

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

Parameters:

  • smooth_level
    (int, default: 0 ) –

    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

Source code in src/pypalmsens/_data/curve.py
38
39
40
41
42
43
44
45
46
47
48
49
50
def smooth(self, smooth_level: int = 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
    """
    success = self._pscurve.Smooth(smoothLevel=smooth_level)
    if not success:
        raise ValueError('Something went wrong.')

DataArray

DataArray(*, psarray: DataArray)

              flowchart TD
              pypalmsens.data.DataArray[DataArray]

              

              click pypalmsens.data.DataArray href "" "pypalmsens.data.DataArray"
            

Python wrapper for .NET DataArray class.

Parameters:

  • psarray

    (DataArray) –

    Reference to .NET DataArray object.

Methods:

  • as_current_range

    Return current range as list of strings.

  • as_reading_status

    Return reading status as list of strings.

  • as_timing_status

    Return timing status as list of strings.

  • copy

    Return a copy of the array.

  • max

    Return max value.

  • min

    Return min value.

  • savitsky_golay

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

  • to_list

    Export data array to list.

  • to_numpy

    Export data array to numpy.

Attributes:

Source code in src/pypalmsens/_data/data_array.py
32
33
def __init__(self, *, psarray: PSDataArray):
    self._psarray: PSDataArray = psarray

name property

name: str

Name of the array.

ocp_value property

ocp_value: float

OCP Value.

quantity property

quantity: str

Quantity for array.

type property

type: ArrayType

ArrayType enum.

unit property

unit: str

Unit for array.

as_current_range

as_current_range() -> list[AllowedCurrentRanges]

Return current range as list of strings.

Source code in src/pypalmsens/_data/data_array.py
125
126
127
128
129
130
131
132
133
def as_current_range(self) -> list[AllowedCurrentRanges]:
    """Return current range as list of strings."""
    if self.type is not ArrayType.Current:
        raise ValueError(f'Invalid array type: {self.type}, expected: {ArrayType.Current}')

    clr_type = clr.GetClrType(CurrentReading)
    field_info = clr_type.GetField('CurrentRange')

    return [cr_enum_to_string(field_info.GetValue(val)) for val in self._psarray]

as_reading_status

as_reading_status() -> list[AllowedReadingStatus]

Return reading status as list of strings.

Source code in src/pypalmsens/_data/data_array.py
135
136
137
138
139
140
141
142
143
def as_reading_status(self) -> list[AllowedReadingStatus]:
    """Return reading status as list of strings."""
    if self.type is not ArrayType.Current:
        raise ValueError(f'Invalid array type: {self.type}, expected: {ArrayType.Current}')

    clr_type = clr.GetClrType(CurrentReading)
    field_info = clr_type.GetField('ReadingStatus')

    return [field_info.GetValue(val).ToString() for val in self._psarray]

as_timing_status

as_timing_status() -> list[AllowedTimingStatus]

Return timing status as list of strings.

Source code in src/pypalmsens/_data/data_array.py
145
146
147
148
149
150
151
152
153
def as_timing_status(self) -> list[AllowedTimingStatus]:
    """Return timing status as list of strings."""
    if self.type is not ArrayType.Current:
        raise ValueError(f'Invalid array type: {self.type}, expected: {ArrayType.Current}')

    clr_type = clr.GetClrType(CurrentReading)
    field_info = clr_type.GetField('TimingStatus')

    return [field_info.GetValue(val).ToString() for val in self._psarray]

copy

copy() -> DataArray

Return a copy of the array.

Source code in src/pypalmsens/_data/data_array.py
64
65
66
def copy(self) -> DataArray:
    """Return a copy of the array."""
    return DataArray(psarray=self._psarray.Clone())

max

max() -> float

Return max value.

Source code in src/pypalmsens/_data/data_array.py
72
73
74
def max(self) -> float:
    """Return max value."""
    return self._psarray.MaxValue

min

min() -> float

Return min value.

Source code in src/pypalmsens/_data/data_array.py
68
69
70
def min(self) -> float:
    """Return min value."""
    return self._psarray.MinValue

savitsky_golay

savitsky_golay(window_size: int = 3) -> DataArray

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, default: 3 ) –

    Size of the window

Source code in src/pypalmsens/_data/data_array.py
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
def savitsky_golay(self, window_size: int = 3) -> DataArray:
    """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
    """
    new = self.copy()
    success = new._psarray.Smooth(window_size, False)
    if not success:
        raise ValueError('Something went wrong.')
    return new

to_list

to_list() -> list[float]

Export data array to list.

Source code in src/pypalmsens/_data/data_array.py
101
102
103
def to_list(self) -> list[float]:
    """Export data array to list."""
    return list(self._psarray.GetValues())

to_numpy

to_numpy() -> ndarray

Export data array to numpy.

Source code in src/pypalmsens/_data/data_array.py
97
98
99
def to_numpy(self) -> np.ndarray:
    """Export data array to numpy."""
    return np.array(self._psarray.GetValues())

DataSet

DataSet(*, psdataset: DataSet)

              flowchart TD
              pypalmsens.data.DataSet[DataSet]

              

              click pypalmsens.data.DataSet href "" "pypalmsens.data.DataSet"
            

Python wrapper for .NET DataSet class.

Parameters:

  • psdataset

    (DataSet) –

    Reference to .NET DataSet object.

Methods:

Attributes:

Source code in src/pypalmsens/_data/dataset.py
54
55
56
def __init__(self, *, psdataset: PSDataSet):
    self._psdataset = psdataset
    self._mapping = _dataset_to_mapping_with_unique_keys(psdataset)

array_names property

array_names: set[str]

Return unique set of names for arrays in dataset.

array_quantities property

array_quantities: set[str]

Return unique set of quantities for arrays in dataset.

array_types property

array_types: set[ArrayType]

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

n_points property

n_points: int

Number of points in arrays.

arrays

arrays() -> list[DataArray]

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

Source code in src/pypalmsens/_data/dataset.py
119
120
121
def arrays(self) -> list[DataArray]:
    """Return list of all arrays. Alias for `.to_list()`"""
    return list(self.values())

arrays_by_name

arrays_by_name(name: str) -> list[DataArray]

Get arrays by name.

Parameters:

  • name
    (str) –

    Name of the array.

Returns:

Source code in src/pypalmsens/_data/dataset.py
127
128
129
130
131
132
133
134
135
136
137
138
139
def arrays_by_name(self, name: str) -> list[DataArray]:
    """Get arrays by name.

    Parameters
    ----------
    name : str
        Name of the array.

    Returns
    -------
    arrays : list[DataArray]
    """
    return self._filter(key=lambda array: array.name == name)

arrays_by_quantity

arrays_by_quantity(quantity: str) -> list[DataArray]

Get arrays by quantity.

Parameters:

  • quantity
    (str) –

    Quantity of the array.

Returns:

Source code in src/pypalmsens/_data/dataset.py
141
142
143
144
145
146
147
148
149
150
151
152
153
def arrays_by_quantity(self, quantity: str) -> list[DataArray]:
    """Get arrays by quantity.

    Parameters
    ----------
    quantity : str
        Quantity of the array.

    Returns
    -------
    arrays : list[DataArray]
    """
    return self._filter(key=lambda array: array.quantity == quantity)

arrays_by_type

arrays_by_type(array_type: ArrayType) -> list[DataArray]

Get arrays by data type.

Parameters:

  • array_type
    (str) –

    Type of the array.

Returns:

Source code in src/pypalmsens/_data/dataset.py
155
156
157
158
159
160
161
162
163
164
165
166
167
def arrays_by_type(self, array_type: ArrayType) -> list[DataArray]:
    """Get arrays by data type.

    Parameters
    ----------
    array_type : str
        Type of the array.

    Returns
    -------
    arrays : list[DataArray]
    """
    return self._filter(key=lambda array: array.type == array_type)

aux_input_arrays

aux_input_arrays() -> list[DataArray]

Return all AuxInput arrays.

Source code in src/pypalmsens/_data/dataset.py
208
209
210
def aux_input_arrays(self) -> list[DataArray]:
    """Return all AuxInput arrays."""
    return self.arrays_by_type(ArrayType.AuxInput)

current_arrays

current_arrays() -> list[DataArray]

Return all Current arrays.

Source code in src/pypalmsens/_data/dataset.py
184
185
186
def current_arrays(self) -> list[DataArray]:
    """Return all Current arrays."""
    return self.arrays_by_type(ArrayType.Current)

current_range

current_range() -> list[AllowedCurrentRanges]

Return current range as list of strings.

Source code in src/pypalmsens/_data/dataset.py
212
213
214
215
def current_range(self) -> list[AllowedCurrentRanges]:
    """Return current range as list of strings."""
    array = self.current_arrays()[-1]
    return array.as_current_range()

curve

curve(x: str, y: str, title: str | None = None) -> Curve

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, default: None ) –

    Set the title. If None, use the $x-$y as title

Returns:

  • curve ( Curve ) –

    New Curve with plotting x against y

Source code in src/pypalmsens/_data/dataset.py
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
def curve(self, x: str, y: str, title: str | None = None) -> Curve:
    """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
    """
    xarray = self[x]
    yarray = self[y]

    if not title:
        title = f'{x}-{y}'

    pscurve = PSCurve(xarray._psarray, yarray._psarray, title=title)

    return Curve(pscurve=pscurve)

freq_arrays

freq_arrays() -> list[DataArray]

Return all Frequency arrays.

Source code in src/pypalmsens/_data/dataset.py
196
197
198
def freq_arrays(self) -> list[DataArray]:
    """Return all Frequency arrays."""
    return self.arrays_by_type(ArrayType.Frequency)

hidden_arrays

hidden_arrays() -> list[DataArray]

Return 'hidden' arrays used for debugging.

Source code in src/pypalmsens/_data/dataset.py
123
124
125
def hidden_arrays(self) -> list[DataArray]:
    """Return 'hidden' arrays used for debugging."""
    return [DataArray(psarray=psarray) for psarray in self._psdataset if psarray.Hidden]

potential_arrays

potential_arrays() -> list[DataArray]

Return all Potential arrays.

Source code in src/pypalmsens/_data/dataset.py
188
189
190
def potential_arrays(self) -> list[DataArray]:
    """Return all Potential arrays."""
    return self.arrays_by_type(ArrayType.Potential)

reading_status

reading_status() -> list[AllowedReadingStatus]

Return reading status as list of strings.

Source code in src/pypalmsens/_data/dataset.py
217
218
219
220
def reading_status(self) -> list[AllowedReadingStatus]:
    """Return reading status as list of strings."""
    array = self.current_arrays()[-1]
    return array.as_reading_status()

time_arrays

time_arrays() -> list[DataArray]

Return all Time arrays.

Source code in src/pypalmsens/_data/dataset.py
192
193
194
def time_arrays(self) -> list[DataArray]:
    """Return all Time arrays."""
    return self.arrays_by_type(ArrayType.Time)

timing_status

timing_status() -> list[AllowedTimingStatus]

Return timing status as list of strings.

Source code in src/pypalmsens/_data/dataset.py
222
223
224
225
def timing_status(self) -> list[AllowedTimingStatus]:
    """Return timing status as list of strings."""
    array = self.current_arrays()[-1]
    return array.as_timing_status()

to_dataframe

to_dataframe() -> DataFrame

Return dataset as pandas dataframe.

Requires pandas.

Returns:

  • df ( DataFrame ) –

    pandas dataframe with all arrays in dataset

Source code in src/pypalmsens/_data/dataset.py
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
def to_dataframe(self) -> pd.DataFrame:
    """Return dataset as pandas dataframe.

    Requires pandas.

    Returns
    -------
    df : pd.DataFrame
        pandas dataframe with all arrays in dataset
    """
    import pandas as pd

    cols, arrays = zip(*[(key, arr.to_list()) for key, arr in self.items() if len(arr)])

    arrays_list = list(arrays)
    arrays_list.append(self.current_range())
    arrays_list.append(self.reading_status())

    cols_list = list(cols)
    cols_list.append('CR')
    cols_list.append('ReadingStatus')

    df = pd.DataFrame(arrays_list, index=cols_list).T

    return df

zim_arrays

zim_arrays() -> list[DataArray]

Return all ZIm arrays.

Source code in src/pypalmsens/_data/dataset.py
204
205
206
def zim_arrays(self) -> list[DataArray]:
    """Return all ZIm arrays."""
    return self.arrays_by_type(ArrayType.ZIm)

zre_arrays

zre_arrays() -> list[DataArray]

Return all ZRe arrays.

Source code in src/pypalmsens/_data/dataset.py
200
201
202
def zre_arrays(self) -> list[DataArray]:
    """Return all ZRe arrays."""
    return self.arrays_by_type(ArrayType.ZRe)

DeviceInfo dataclass

DeviceInfo(type: str, firmware: str, serial: str, id: int)

Dataclass for device information.

Attributes:

firmware instance-attribute

firmware: str

Firmware version.

id instance-attribute

id: int

Device ID.

serial instance-attribute

serial: str

Serial number.

type instance-attribute

type: str

Device type.

EISData

EISData(*, pseis: EISData)

Python wrapper for .NET EISdata class.

Parameters:

  • pseis

    (EISData) –

    Reference to .NET EISdata object.

Methods:

Attributes:

Source code in src/pypalmsens/_data/eisdata.py
79
80
def __init__(self, *, pseis: PSEISData):
    self._pseis = pseis

cdc property

cdc: str

Gets the CDC circuit for fitting.

cdc_values property

cdc_values: list[float]

Return values for circuit description code (CDC).

dataset property

dataset: DataSet

Dataset which contains multiple arrays of values.

frequency_type property

frequency_type: str

Frequency type.

has_subscans property

has_subscans: bool

Return True if data contains subscans.

mux_channel property

mux_channel: int

Mux channel.

n_frequencies property

n_frequencies: int

Number of frequencies.

n_points property

n_points: int

Number of points (including subscans).

n_subscans property

n_subscans: int

Number of subscans.

ocp_value property

ocp_value: float

OCP Value.

scan_type property

scan_type: str

Scan type.

subscans property

subscans: list[EISData]

Get list of subscans.

title property

title: str

Tite for EIS data.

x_quantity property

x_quantity: str

Quantity for array.

x_unit property

x_unit: str

Unit for array.

arrays

arrays() -> list[DataArray]

Complete list of data arrays.

Source code in src/pypalmsens/_data/eisdata.py
181
182
183
def arrays(self) -> list[DataArray]:
    """Complete list of data arrays."""
    return list(self.dataset.values())

current_range

current_range() -> list[AllowedCurrentRanges]

Current ranges for the measurement.

Source code in src/pypalmsens/_data/eisdata.py
185
186
187
188
189
def current_range(self) -> list[AllowedCurrentRanges]:
    """Current ranges for the measurement."""
    return [
        cr_enum_to_string(self._pseis.GetCurrentRange(val)) for val in range(self.n_points)
    ]

get_data_for_frequency

get_data_for_frequency(frequency: int) -> dict[str, DataArray]

Returns dictionary with data per frequency.

Parameters:

  • frequency
    (int) –

    Index of the frequency to retrieve the data for.

Returns:

  • dict[str, DataArray]

    Data are returned as a dictionary keyed by the data type.

Source code in src/pypalmsens/_data/eisdata.py
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
def get_data_for_frequency(self, frequency: int) -> dict[str, DataArray]:
    """Returns dictionary with data per frequency.

    Parameters
    ----------
    frequency : int
        Index of the frequency to retrieve the data for.

    Returns
    -------
    dict[str, DataArray]
        Data are returned as a dictionary keyed by the data type.
    """
    if not (0 <= frequency < self.n_frequencies):
        raise ValueError(f'Frequency must be between 0 and {self.n_frequencies}')

    return {
        str(row.Key): DataArray(psarray=row.Value)
        for row in self._pseis.GetDataArrayVsX(frequency)
    }

Measurement

Measurement(*, psmeasurement: Measurement)

Python wrapper for .NET Measurement class.

Parameters:

  • psmeasurement

    (Measurement) –

    Reference to .NET measurement object.

Attributes:

Source code in src/pypalmsens/_data/measurement.py
53
54
def __init__(self, *, psmeasurement: PSMeasurement):
    self._psmeasurement = psmeasurement

blank_curve property

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.

channel property

channel: float

Get the channel that the measurement was measured on.

curves property

curves: list[Curve]

Get all curves in measurement.

Returns:

dataset property

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.

device property

device: DeviceInfo

Return dataclass with measurement device information.

eis_data property

eis_data: list[EISData]

EIS data in measurement.

eis_fit property

eis_fit: list[FitResult]

Get all EIS fits from measurement

Returns:

  • eis_fits ( list[EISFitResults] ) –

    Return list of EIS fits

has_blank_subtracted_curves property

has_blank_subtracted_curves: bool

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

has_eis_data property

has_eis_data: bool

Return True if EIS data are is available.

method property

method: Method

Method related with this Measurement.

The information from the Method is used when saving Curves.

n_curves property

n_curves: int

Number of curves that are part of the Measurement class.

n_eis_data property

n_eis_data: int

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

ocp_value property

ocp_value: float

First OCP Value from either curves or EISData.

peaks property

peaks: list[Peak]

Get peaks from all curves.

Returns:

  • peaks ( list[Peak] ) –

    List of peaks

timestamp property

timestamp: str

Date and time of the start of this measurement.

title property

title: str

Title for the measurement.

Peak

Peak(*, pspeak: Peak)

Python wrapper for .NET Peak class.

Parameters:

  • pspeak

    (Peak) –

    Reference to .NET Peak object.

Attributes:

Source code in src/pypalmsens/_data/peak.py
23
24
25
26
def __init__(self, *, pspeak: PSPeak):
    self._pspeak = pspeak

    self._curve: Curve | None = None

analyte_name property writable

analyte_name: str

Name of analyte.

area property

area: float

Area of the peak.

curve property

curve: Curve

Parent curve associated with Peak.

curve_title property

curve_title: str

Title of parent curve.

index property

index: int

Location of the peak as index number of the curve.

label property

label: str

Formatted label for the peak value.

left_index property

left_index: int

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

left_x property

left_x: float

X of the left side of the peak baseline.

left_y property

left_y: float

Y of the left side of the peak baseline.

maximum_of_derivative_neg property

maximum_of_derivative_neg: float

Maximum derivative of the negative slope of the peak.

maximum_of_derivative_pos property

maximum_of_derivative_pos: float

Maximum derivative of the positive slope of the peak.

maximum_of_derivative_sum property

maximum_of_derivative_sum: float

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

notes property

notes: str

User notes stored on this peak.

right_index property

right_index: int

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

right_x property

right_x: float

X of the right side of the peak baseline.

right_y property

right_y: float

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

type property

type: str

Used to determine if a peak is auto found.

value property

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.

width property

width: float

Full width at half-height of the peak.

x property

x: float

X value of the peak.

x_unit property

x_unit: str

Units of X axis.

y property

y: float

Y value of the peak.

y_offset property

y_offset: float

Offset of Y.

y_unit property

y_unit: str

Units for Y axis.

PotentialReading dataclass

PotentialReading(potential_range: AllowedPotentialRanges, potential: float, potential_in_range: float, timing_status: AllowedTimingStatus, reading_status: AllowedReadingStatus)

Potential reading data class.

Attributes:

potential instance-attribute

potential: float

Potential in V.

potential_in_range instance-attribute

potential_in_range: float

Raw potential value expressed in the active potential range.

potential_range instance-attribute

potential_range: AllowedPotentialRanges

Active potential range for this data point.

reading_status instance-attribute

reading_status: AllowedReadingStatus

Status of the potential reading.

timing_status instance-attribute

timing_status: AllowedTimingStatus

Status of the potential timing.

Status dataclass

Status(_status: Status, device_state: AllowedDeviceState = 'Unknown')

Device Status class.

Attributes:

aux_input property

aux_input: float

Raw aux input.

aux_input_as_voltage property

aux_input_as_voltage: float

Aux input as V.

corrected_bipot_current property

corrected_bipot_current: float

Corrected bipot current in the current range.

current property

current: float

Current value in µA.

current_reading property

current_reading: CurrentReading

Current reading dataclass.

current_reading_we2 property

current_reading_we2: CurrentReading

Current reading dataclass for WE2.

current_we2 property

current_we2: float

Current WE2 value.

device_state class-attribute instance-attribute

device_state: AllowedDeviceState = 'Unknown'

Device state.

noise property

noise: float

Measured

potential property

potential: float

Potential in V

potential_reading property

potential_reading: PotentialReading

Potential reading dataclass.

pretreatment_phase property

pretreatment_phase: Literal['None', 'Conditioning', 'Depositing', 'Equilibrating']

Pretreatment phase.