MethodSCRIPT
This page documents the MethodSCRIPT (MS) method.
pypalmsens.MethodScript
Create a MethodSCRIPT method.
With the MethodSCRIPT scripting language, you can write code that runs on-device. This enables custom measurements and makes it possible to combine different measurements and other tasks.
This class uses the PyPalmSens machinery to send your MethodSCRIPT script directly to the potentiostat.
See the MethodSCRIPT documentation for more information and script examples.
Examples:
Return hello world:
>>> import pypalmsens as ps
>>> from textwrap import dedent
>>> method = ps.MethodScript(
... script=dedent('''\
... wait 100m
... if 1 < 2
... send_string "Hello world"
... endif
... ''')
... )
Chronoamperometry measurement loop example:
>>> method = ps.MethodScript(
... script=dedent('''\
... var potential
... var current
... set_pgstat_chan 0
... set_pgstat_mode 2
... cell_on
... meas_loop_ca potential current 100m 200m 1000m
... pck_start
... pck_add potential
... pck_add current
... pck_end
... endloop
... ''')
... )
Methods:
-
to_dict–Return the technique instance as a new key/value dictionary mapping.
-
from_dict–Structure technique instance from dict.
-
from_method_id–Create new instance of appropriate technique from method ID.
-
from_file–Load methodscript from file.
-
to_file–Save script to file.
-
from_url–Download script over http.
Attributes:
-
id(Literal['ms']) –Unique method identifier.
-
version(Literal['1.10'] | None) –MethodSCRIPT language version.
-
script(str) –Script to run.
-
custom_units(dict[Literal['as', 'at', 'au'], CustomUnits]) –Define custom quantities and units for 'as', 'at', 'au' variable types.
version
class-attribute
instance-attribute
version: Literal['1.10'] | None = '1.10'
MethodSCRIPT language version.
Determines the version of the MethodSCRIPT parser to use for validating
the syntax of script. Set to None to skip script validation.
script
class-attribute
instance-attribute
script: str = 'wait 100m\nif 1 < 2\n send_string "Hello world"\nendif\n'
Script to run.
For more info on MethodSCRIPT, see: https://www.palmsens.com/methodscript/ for more information.
custom_units
class-attribute
instance-attribute
Define custom quantities and units for 'as', 'at', 'au' variable types.
Use this to override the quantities for analog inputs (0, 1, and 2). These default to Voltage / V. Defining custum units is purely cosmetic. The values are used for labeling curves and axes.
to_dict
Return the technique instance as a new key/value dictionary mapping.
Source code in src/pypalmsens/_methods/base.py
47 48 49 | |
from_dict
classmethod
from_dict(obj: dict[str, Any]) -> MethodType
Structure technique instance from dict.
Opposite of .to_dict()
Source code in src/pypalmsens/_methods/base.py
51 52 53 54 55 56 | |
from_method_id
classmethod
from_method_id(id: str) -> MethodType
Create new instance of appropriate technique from method ID.
Source code in src/pypalmsens/_methods/base.py
58 59 60 61 62 | |
from_file
classmethod
from_file(path: str | Path = 'methodscript.mscr') -> MethodScript
Load methodscript from file.
Parameters:
Returns:
-
method(MethodScript) –
Source code in src/pypalmsens/_methods/techniques.py
2699 2700 2701 2702 2703 2704 2705 2706 2707 2708 2709 2710 2711 2712 2713 2714 2715 | |
to_file
Save script to file.
Parameters:
Source code in src/pypalmsens/_methods/techniques.py
2717 2718 2719 2720 2721 2722 2723 2724 2725 2726 | |
from_url
classmethod
from_url(url: str) -> MethodScript
Download script over http.
Parameters:
-
(urlurl) –URL to download methodscript file from.
Returns:
-
method(MethodScript) –
Source code in src/pypalmsens/_methods/techniques.py
2728 2729 2730 2731 2732 2733 2734 2735 2736 2737 2738 2739 2740 2741 2742 2743 2744 | |