cohesivm.experiment
This module contains the Experiment class which is responsible for packaging the multiple components of an
experiment together. Further, it handles the worker process which executes the measurements in the background.
- class ExperimentState(value)[source]
Bases:
EnumAn Enumeration of the different states an
Experimentcan be in.- INITIAL = 1
- READY = 2
- RUNNING = 3
- FINISHED = 4
- ABORTED = 5
- class Experiment(database: Database, device: Device, measurement: Measurement, interface: Interface, sample_id: str, selected_contacts: List[str] | None = None, data_stream: Queue | None = None)[source]
Bases:
objectA statemachine which packages the components of an experiment (
Device,InterfaceandMeasurement), checks their compatibility, executes the measurements in a separate process and keeps track of the progress. Creates during initialization a newmultiprocessing.Valuewhich holds the current state of the experiment.- Parameters:
database – The database where the data is stored.
device – The measurement device which is used to run the experiment.
interface – The contacting hardware which establishes the electronic connection on the sample.
measurement – The routine which is run for each contact on the interface.
sample_id – The string identifier of the sample which should be unique in the database.
selected_contacts – List of selected contact ids which should be measured. The default are all available contacts on the
interface.data_stream – A
multiprocessing.Queue-like object where the measurement results can be sent to, e.g., for real-time plotting of the measurement.
- Raises:
CompatibilityError – If the provided components are not compatible with each other.
- property state: ExperimentState
The current state of the experiment stored in a
multiprocessing.Value.
- property measurement: Measurement
The routine which is run for each contact on the interface.
- property interface: Interface
The contacting hardware which establishes the electronic connection on the sample.
- property sample_id: str
The string identifier of the sample which should be unique in the database.
- property selected_contacts: List[str]
List of selected contact ids which should be measured. The default is all available contacts on the
interface.
- property current_contact_idx: int | None
List index of the currently measured contact from the
selected_contacts. Stored asmultiprocessing.Valuewhile thestateisRUNNING.
- property data_stream: Queue
A
multiprocessing.Queue-like object where the measurement results can be sent to, e.g., for real-time plotting of the measurement.
- property dataset: str
The dataset path in the database which should be obtained from the dataset initialization.
- property process: Process
The process which runs the measurements in the background.
- preview(contact_id: str) None[source]
Starts a preview measurement on the specified contact which is executed by a separate worker process. Sends the data to the
data_streambut does not store it in the database.Changes the
stateproperty toRUNNING. Resets thestateto the previous one if completed.- Parameters:
contact_id – The id of the contact for which the preview measurement should be run.
- Raises:
StateError – If the
stateisRUNNING.
- setup() None[source]
Generates the
Metadataobject and initializes the dataset in the database. Populates thedataset.- Raises:
StateError – If the
stateis none ofINITIAL,FINISHEDorABORTED.
- start() None[source]
Starts the experiment which is executed by a separate worker process. Selects the contact on the interface, generates/updates the
current_contact_idxwhich is amultiprocessing.Value, runs the measurement and stores the result in the database.Changes the
statetoRUNNINGwhile running. Changes thestatetoFINISHEDafter completion.- Raises:
StateError – If the
stateis notREADY.