instrumentserver.serialize#
instrumentserver.serialize#
Serializing and de-serializing instruments and parameters. The tools in here can be used to perform the following tasks:
Store instrument and parameter information to json.
Load instrument and parameter information from json.
The main utility of the methods here is to have a relatively simple representation of the state of the system (by system we mean: either a qcodes station, or simply a collection of qcodes instruments and parameters). All of this information is also provided by the qcodes snaphot. This module is currently intended to supplement that with a format that is easier to read and contains only state information (such as values).
The main methods here are toParamDict() and fromParamDict(), which allow
extracting instrument parameters to JSON and load parameters from JSON.
The main format for the JSON objects we work with follows this scheme:
paramDict = {
"parameter_name": {
"value": value,
"unit": "unit of this parameter",
[...]
},
"instrument.instrument_parameter": {
"value": value,
"unit": "the unit of this parameter",
[...]
},
"another_instrument.a_submodule.some_parameter": {
"value": value,
[...]
}
}
Only “value” is required as key for each parameter, but arbitrary additional meta data can be added in principle. The naming of the parameters is the same way in which they would be addressed inside a qcodes station. I.e., if the parameter is called using:
station.[parent object(s)].parameter()
Then the name in paramDict is “[parent objects(s)].parameter”.
In case the only property of each parameter is value, then it is also possible to use a simplified format which looks like this:
paramDict = {
"parameter_name": value,
"instrument.instrument_parameter": value,
"another_instrument.a_submodule.some_parameter": value,
}
This format is sufficient to store/load parameter values, but not to create parameters that are not present yet.
Functions
|
Load parameter values from JSON. |
|
Checks if the supplied paramDict is in the simplified format. |
|
Make a pandas data frame from the parameters. |
|
Create a dictionary that holds parameter values, and optionally additional information about them. |
|
- instrumentserver.serialize.fromParamDict(paramDict: Dict[str, Any], target: Station | List[InstrumentBase | Parameter]) None[source]#
Load parameter values from JSON.
- Parameters:
paramDict – The parameter dictionary in a valid JSON format (may be simple or regular format).
target – Object(s) holding the parameters to load.
- instrumentserver.serialize.isSimpleFormat(paramDict: Dict[str, Any]) bool[source]#
Checks if the supplied paramDict is in the simplified format.
We identify the simple format by the fact that otherwise all item values are a dictionary with a least the key value in it.
- instrumentserver.serialize.toDataFrame(input: Station | List[InstrumentBase | Parameter]) DataFrame[source]#
Make a pandas data frame from the parameters. Mainly useful for printing overviews in notebooks.
- instrumentserver.serialize.toParamDict(input: Station | List[InstrumentBase | Parameter], get: bool = False, includeMeta: List[str] = [], excludeParameters: List[str] = [], simpleFormat: bool = True) Dict[source]#
Create a dictionary that holds parameter values, and optionally additional information about them.
- Parameters:
input – qcodes station or list of instruments/parameters.
get – Whether to call get on the parameters. If not, use the values from the current snapshot. Note: Parameters that are not included in the snapshot are never included.
includeMeta – List of parameter attributes to include besides value. All keys occurring in snapshots are valid.
excludeParameters – List of parameters we don’t include in the return.
simpleFormat – If
Trueand no additional metadata is included, then the output format will be simplified such that the the value for each parameter key is simply value, rather than a dictionary of multiple properties.
- Returns:
Dictionary. If not simple format, conforms to instrumentserver/schemas/parameters.json