Methods

Supported methods

Setting up a method

This example creates a method for a square-wave voltammetry measurement versus the open circuit potential:

>>> import pypalmsens

>>> method = pypalmsens.SquareWaveVoltammetry(
...    conditioning_potential = 2.0,  # V
...    conditioning_time = 2,  # seconds
...    versus_ocp_mode = 3,  # versus begin and end potential
...    versus_ocp_max_ocp_time = 1,  # seconds
...    begin_potential = -0.5,  # V
...    end_potential = 0.5,  # V
...    step_potential = 0.01,  # V
...    amplitude = 0.08,  # V
...    frequency = 10,  # Hz
...)

Because methods are attrs dataclasses, all attributes can be modified afterwards:

>>> method.begin_potential = -1.0
>>> method.end_potential = 1.0
>>> method.step_potential = 0.02

Dataclasses can be serialized to and from a dictionary:

>>> from attrs import asdict
>>> d = asdict(method)
>>> d
{'equilibration_time': 0.0,
 'begin_potential': -1.0,
 'end_potential': 1.0,
 'step_potential': 0.02,
 'frequency': 10,
 'amplitude': 0.08,
 ...}
>>> method2 == pypalmsens.SquareWaveVoltammetry(**d)
>>> method == method2
True

It can be updated like a dataclass:

>>> from attrs import evolve
>>> method2 = evolve(method, equilibration_time=10.0)
>>> method == method2
False

The VSCode Debug Console or another Python REPL environment like IPython will auto complete on the properties and functions.

Debug console in VSCode

Common settings

Many settings are shared between methods. For a full listing, see Method settings.

If you don’t specify any arguments, the default values are loaded. These are accessible via attributes on the methods.

For example:

>>> cv = pypalmsens.CyclicVoltammetry()
>>> cv.current_range
CurrentRange(
    max=<CURRENT_RANGE.cr_10_mA: 8>,
    min=<CURRENT_RANGE.cr_1_uA: 4>,
    start=<CURRENT_RANGE.cr_100_uA: 6>,
)

There are two ways to modify the current ranges, for example, if we want so set the start current at 10 μA.

  1. By passing current ranges as an argument during initialization

    >>> cv = pypalmsens.CyclicVoltammetry(
    ...     current_range=pypalmsens.settings.current_range(
    ...         start=pypalmsens.settings.CURRENT_RANGE.cr_10_uA
    ...     )
    ... )
    >>> cv.current_range
    CurrentRange(
        max=<CURRENT_RANGE.cr_10_mA: 8>,
        min=<CURRENT_RANGE.cr_1_uA: 4>,
        start=<CURRENT_RANGE.cr_10_uA: 5>, (1)
    )
    1 We only gave the start value, so the min/max are populated with the defaults.
  2. By updating the attributes (after initialization)

    >>> cv = pypalmsens.CyclicVoltammetry()
    >>> cv.current_range.start = pypalmsens.settings.CURRENT_RANGE.cr_10_uA
Fixed ranges

If you want to use a fixed current (or potential) range, you can save yourself some typing by passing CURRENT_RANGE directly. This automatically expands into the CurrentRange object with min, max, and start equal.

>>> cv = pypalmsens.CyclicVoltammetry(
...    current_range=pypalmsens.settings.CURRENT_RANGE.cr_10_uA
... )
>>> cv.current_range
CurrentRange(
    max=<CURRENT_RANGE.cr_10_uA: 5>,
    min=<CURRENT_RANGE.cr_10_uA: 5>,
    start=<CURRENT_RANGE.cr_10_uA: 5>,
)

Starting a measurement

For further information on how to run a measurement: