Measure
This module contains the base classes for making measurements with a device.
ATTRIBUTE | DESCRIPTION |
---|---|
MAX_LEN |
maximum length of data buffer
TYPE:
|
CLASS | DESCRIPTION |
---|---|
Measurer |
Base class for maker tools |
Program |
Base Program template |
ProgramDetails |
ProgramDetails dataclass represents the set of inputs, default values, truncated docstring and tooltip of a program class |
Documentation last updated: 2025-02-22
Measurer
Base class for maker tools.
ATTRIBUTE | DESCRIPTION |
---|---|
buffer |
data buffer for the device
TYPE:
|
buffer_df |
data buffer as a DataFrame
TYPE:
|
records |
records for the device
TYPE:
|
records_df |
records as a DataFrame
TYPE:
|
record_event |
event for recording data
TYPE:
|
program |
program to run
TYPE:
|
runs |
dictionary of runs
TYPE:
|
n_runs |
number of runs
TYPE:
|
connection_details |
connection details for the device
TYPE:
|
device |
device object that communicates with physical tool
TYPE:
|
flags |
flags for the class
TYPE:
|
is_busy |
whether the device is busy
TYPE:
|
is_connected |
whether the device is connected
TYPE:
|
verbose |
verbosity of class
TYPE:
|
METHOD | DESCRIPTION |
---|---|
connect |
connect to the device |
disconnect |
disconnect from the device |
resetFlags |
reset all flags to class attribute _default_flags |
shutdown |
shutdown procedure for tool |
Initialize Measurer class
PARAMETER | DESCRIPTION |
---|---|
verbose
|
verbosity of class. Defaults to False.
TYPE:
|
getData
Get data from the device
PARAMETER | DESCRIPTION |
---|---|
query
|
query to device. Defaults to None.
TYPE:
|
RETURNS | DESCRIPTION |
---|---|
Any | None
|
Any|None: data from device |
getDataframe
Get dataframe of data collected
PARAMETER | DESCRIPTION |
---|---|
data_store
|
data store
TYPE:
|
RETURNS | DESCRIPTION |
---|---|
DataFrame
|
pd.DataFrame: dataframe of data collected |
loadProgram
loadProgram(
program: Program,
docstring_parser: Callable[[Any, bool], ProgramDetails]
| None = None,
)
Load a program to the Measurer
PARAMETER | DESCRIPTION |
---|---|
program
|
program to load
TYPE:
|
measure
measure(
*args,
parameters: dict | None = None,
blocking: bool = True,
**kwargs,
) -> DataFrame | None
Run the measurement program
args: positional arguments parameters (dict, optional): dictionary of kwargs. Defaults to None. blocking (bool, optional): whether to block until completion. Defaults to True. *kwargs: keyword arguments
RETURNS | DESCRIPTION |
---|---|
DataFrame | None
|
pd.DataFrame|None: dataframe of data collected |
record
record(
on: bool,
show: bool = False,
clear_cache: bool = False,
*,
callback: Callable | None = None,
**kwargs,
)
Record data from the device
PARAMETER | DESCRIPTION |
---|---|
on
|
whether to record data
TYPE:
|
show
|
whether to show data. Defaults to False.
TYPE:
|
clear_cache
|
whether to clear the cache. Defaults to False.
TYPE:
|
callback
|
callback function to process data. Defaults to None.
TYPE:
|
saveData
Save data to file
PARAMETER | DESCRIPTION |
---|---|
filepath
|
path to save file
TYPE:
|
stream
Stream data from the device
PARAMETER | DESCRIPTION |
---|---|
on
|
whether to stream data
TYPE:
|
show
|
whether to show data. Defaults to False.
TYPE:
|
callback
|
callback function to process data. Defaults to None.
TYPE:
|
Program
Program(
instrument: Measurer | None = None,
parameters: dict | None = None,
verbose: bool = False,
**kwargs,
)
Base Program template
ATTRIBUTE | DESCRIPTION |
---|---|
data |
data collected from device when running the program
TYPE:
|
instrument |
Measurer object
TYPE:
|
parameters |
dictionary of kwargs
TYPE:
|
verbose |
verbosity of class
TYPE:
|
data_df |
dataframe of data collected
TYPE:
|
METHOD | DESCRIPTION |
---|---|
getDataframe |
get dataframe of data collected |
run |
measurement program to run |
saveData |
save data to file |
==========
Initialize Program class
PARAMETER | DESCRIPTION |
---|---|
instrument
|
Measurer object. Defaults to None.
TYPE:
|
parameters
|
dictionary of kwargs. Defaults to None.
TYPE:
|
verbose
|
verbosity of class. Defaults to False.
TYPE:
|
getDataframe
Get dataframe of data collected
PARAMETER | DESCRIPTION |
---|---|
data_store
|
data store
TYPE:
|
RETURNS | DESCRIPTION |
---|---|
DataFrame
|
pd.DataFrame: dataframe of data collected |
parseDocstring
staticmethod
parseDocstring(
program_class: Program, verbose: bool = False
) -> ProgramDetails
Get the input fields and defaults
PARAMETER | DESCRIPTION |
---|---|
program_class
|
program class of interest
TYPE:
|
verbose
|
whether to print out truncated docstring. Defaults to False.
TYPE:
|
RETURNS | DESCRIPTION |
---|---|
ProgramDetails
|
details of program class
TYPE:
|
run
Measurement program to run
RETURNS | DESCRIPTION |
---|---|
DataFrame
|
pd.DataFrame: Dataframe of data collected |
ProgramDetails
dataclass
ProgramDetails(
signature: Signature,
description: str = "",
parameter_descriptions: dict[str, str] = dict(),
return_descriptions: dict[tuple[str], str] = dict(),
)
ProgramDetails dataclass represents the set of inputs, default values, truncated docstring and tooltip of a program class
Constructor:
inputs (list[str]): list of input field names
defaults (dict[str, Any]): dictionary of kwargs and default values
short_doc (str): truncated docstring of the program
tooltip (str): descriptions of input fields