Experiment data and execution manager.
An Experiment is an object which keeps tracks of all the parts which compose an actual measurement, including instruments, the actions performed on them, the data returned by them, and real-time graphs of the data.
The main driver class of an experiment.
The Experiment class is responsible for managing instruments; the actions those instruments should perform; and the collection, storage, saving, and graphing of data.
Methods
Create a temporary buffer for simultaneous blocks.
Create a temporary buffer, with the same keys as the main column dictionary, for storing data while running a simultaneous block. This alleviates the danger of getting goofy garbage in the data file due to, e.g., race conditions. The principal problem this averts is writing data to the file prematurely, which would happen if the actions return in the wrong order.
Add a graph to the experiment.
Store graph in the list, and bind it to the columns which will supply its data.
Parameters : | graph : Graph
|
---|
Add an instrument to this experiment.
Parameters : | instrument : Instrument
|
---|
Add a Postprocessor action to be executed after the experiment.
Parameters : | action : ActionPostprocessor
|
---|
Check the syntactic validity of the supplied expression.
Substitute numeric values for columns, constants, and parameters and attempt to evaluate the given expression to determine whether the syntax of the expression is correct.
Parameters : | expr : str
|
---|---|
Returns : | bool :
|
Save the data from the temporary buffer, then destroy the buffer.
Take the data stored in the temporary buffer while running the simultaneous block. If the same amount of data has been added for each column, add them to the appropriate column bins. Otherwise, save them as a separate file in the same folder as the data. Then destroy the temporary buffer.
Evaluate a given expression.
Substitute all defined constants and the most recent values of all columns and parameters into expr, evaluate it, and return the outcome.
This is mainly used by the Calculate action from the System class.
Parameters : | expr : str
conditional : bool
|
---|---|
Returns : | float or bool :
|
Return the root of the action tree.
Returns : | ActionContainer :
|
---|
Return a copy of the constants dictionary.
Returns : | dict :
|
---|
Return a formatted string containing a list of column details.
Returns : | str :
|
---|
Return the value of the named constant.
Parameters : | name : str
|
---|---|
Returns : | float :
|
Return a list of instruments which implement the given action.
Sometimes, the user may want to change the instrument which carries out a particular action. However, in order to change the instrument, it is necessary that the new instrument should have the ability to carry out the action.
This method returns a list of dictionaries with information about the instruments (and their respective actions) which could potentially be used as a replacement for the instrument associated with the specified action.
Parameters : | action : Action
|
---|---|
Returns : | list of dict :
|
Notes
Two Action objects are said to be “equal enough” if they have the same description and the same parameters. Two Parameter objects are said to be the same if they are identical in all immutable aspects (that is, they have the same name, the same description, and the same format string).
Return a list of all files used so far in the experiment.
Returns : | list of tuple of str :
|
---|
Return the graph at the specified index.
Parameters : | index : int
|
---|---|
Returns : | Graph :
|
Return a list of the names of the experiment’s graphs.
Returns : | list of str :
|
---|
Return the names of graphs and whether each graph is enabled.
Returns : | str :
bool :
|
---|
Return the instrument at the specified index.
Parameters : | index : int
|
---|---|
Returns : | Instrument :
|
Return the names of the instruments in this experiment.
Returns : | list of str :
|
---|
Get the names of all data storage bins.
Returns : | list of str :
list of str :
list of str :
|
---|
Return a formatted string representing the storage bin names.
Returns : | str :
|
---|
Return an XML string representing the experiment.
Returns : | str :
|
---|
Automatically handle the addition, removal, or renaming of a bin.
If the new name is None or ‘’, delete the old bin. If the old name is None or ‘’, create the new bin. If the old name and the new name are are both non-trivial, the old name is changed to the new name, and the types are switched if necessary.
Parameters : | oldName : str
oldType : str
newName : str
newType : str
|
---|
Return whether the next loop should be interrupted.
Returns : | bool :
|
---|
Return whether the experiment has been paused.
Returns : | bool :
|
---|
Return whether the experiment is running.
Returns : | Whether the experiment is running. : |
---|
Delete a defined constant.
Parameters : | name : str
|
---|
Remove a graph from the experiment
First, remove graph from all columns which reference it. Then delete it from the list of graphs.
Parameters : | graph : Graph
|
---|
Remove an instrument from this experiment.
Parameters : | instrument : Instrument
|
---|
Rename the specified constant.
Rename a constant and update all expressions in conditional loops and calculations to reflect the name change.
Parameters : | oldName : str
newName : str
|
---|
Perform the pre-sequence actions and begin the experiment.
Parameters : | errorCheck : bool
|
---|---|
Raises : | GeneralExperimentError :
|
Add data returned from actions to the appropriate dictionary.
Take the input from the execute commands bound to an Action object and add it to the data column dictionary, the parameter dictionary, or the temporary buffer as appropriate.
Parameters : | binType : str
binName : str
value : str
|
---|
Set the value of a constant, creating it if necessary.
Parameters : | name : str
value : float
|
---|
Set the filenames and open the files.
Use the supplied baseName to generate names for the data and parameter files, as well as the graph image file if applicable, by appending the appropriate extensions. Then open the files. Write the column headers to the data file and dump the parameter buffer into the parameter file.
Important: All folders in the path to the files must already exist.
Parameters : | basePath : str
|
---|
Set how the experiment should communicate with the outside.
These parameters can be set only using keyword arguments.
Any parameter which takes a list can be disabled by setting it to an empty list. Any parameter which takes something else can be disabled by setting it to None.
Parameters : | parentFrame : Frame
graphManagerClass : GraphManager
graphManager : GraphManager
preSequenceCommands : list of Command
postSequenceCommands : list of Command
statusMonitor : statusMonitor
loopEnterCommands : list of Command
loopExitCommands : list of Command
|
---|
Fix the column dictionary so that the graph is in the right slots.
Remove the graph from the list (which includes unbinding it from the old columns), and then add it back, automatically placing the graph in the slots for the newly-specified columns.
Parameters : | graph : Graph
|
---|