Utils#
- baecon.utils.arg_parser()#
Argument parser for command line interface.
-c,--config_file: Full measurement configuration file.-g,--gen_file: File listing invididual config files for use
-e,--engine: Measurementengineto use.currently not implemented but there could a standard engine, OptBayes engine, and others
-o,--output: Output file for saving data, or for saving agenerated config file.
- Returns
parsed arguements
- Return type
dict
- baecon.utils.dump_config(config: dict, file: str, options=None) None#
- Saves configuration dictionary into
file. File type may be
.toml,.yml, or.json.
- Parameters
config (dict) – Configuration dictionary to load
file (str) – Configuration file to load.
options (optional) – Can be used in the future if functionality need extendsion, like encoding type.
- Saves configuration dictionary into
- baecon.utils.generate_measurement_config_from_file(config_list_file: str, out_file: str) None#
- Generates measurement configuration from list of indiviual files, yielding
a single file for the measurement.
The config_list_file is a list of files of seperate configurations, e.g., configuration for individual scans, devices etc.This function loads each individual file into a
Measurement_Settingsobject, then measurement configuration file. config_list_file will be a dict like file (e.g., json, yaml, toml) with structure:{'acquisition_devices': {'device_name': configuration_file_name, ...}, 'scan_devices': {'device_name': configuration_file_name, ...}, 'scan_collections': {'scan_name': configuration_file_name, ...} 'averages': (int)}
- Parameters
config_list_file (str) – Name of list file to load.
out_file (str) – Name of file for saving the configuration of the generated
Measurement_Settings. –
- baecon.utils.json_dump(config: dict, file: str, options=None) None#
Write configuration dictionary (
config) to ajsonfile.- Parameters
config (dict) – Configuration dictionary to save.
file (str) – path of
tomlfile.options (optional) – Can be used in the future if functionality need extendsion, like encoding type
- baecon.utils.json_load(file: str, options=None) dict#
Reads
jsonfile and returnsdict.- Parameters
file (str) – path of
jsonfile.options (optional) – Can be used in the future if functionality need extendsion, like encoding type
- Returns
Dictionary of
jsonfile contents.- Return type
dict
- baecon.utils.load_config(file: str, options=None) dict#
- Loads configuration file
fileand returns dictionary of configurations. File type may be
.toml,.yml, or.json.
- Parameters
file (str) – Configuration file to load.
options (optional) – Can be used in the future if functionality
extendsion (need) –
type. (like encoding) –
- Returns
Configuration dictionary
- Return type
dict
- Loads configuration file
- baecon.utils.load_module_from_path(file_path: str)#
- Loads module from specified path.
This is used to load specific
Deviceanalysis file fordata.
- Parameters
file_path (str) – String or path to file of module.
- Returns
Module that was loaded
- Return type
(python module)
- baecon.utils.save_baecon_data(md: baecon.data.Measurement_Data, file_name: str, format: str = '.zarr', options=None) None#
- Saves measurement data to choice of
format. The default format is a Zarr group file. Possible formats:
zarr,netcdf,hdf5, andcsv.
zarrandnetcdfplay well withxarray. For the other formats data is covertedpandasthen saved.Todo
Need to check settings saved as metadata correctly
Possible formats to implement in the future: parquet, feather.
- Parameters
md (
Measurement_Data) – Configuration of measurement.file_name (str) – File name for saving data.
format (str, optional) – File format to use, defaults to ‘.zarr’
options (optional) – Options for extension in the future, likely
compression. (chunking and) –
- Saves measurement data to choice of
- baecon.utils.save_measurement_config(ms: baecon.base.Measurement_Settings, out_file: str) None#
- Generatres configuration dictioary from Measurement_Settings object
and saves to specified file.
- Parameters
ms (Measurement_Settings) – Measurement settings to save.
out_file (str) – Name of file to save.
- baecon.utils.set_device_directory(Devices_directory: str)#
- Sets default devices directory in
Deviceto the input directory.
- Parameters
Devices_directory (str) – New directory for the devices.
- Sets default devices directory in
- baecon.utils.toml_dump(config: dict, file: str, options=None) None#
Write configuration dictionary (
config) to atomlfile.- Parameters
config (dict) – Configuration dictionary to save.
file (str) – path of
tomlfile.options (optional) – Can be used in the future if functionality need extendsion, like encoding type
- baecon.utils.toml_load(file: str, options=None) dict#
Reads
tomlfile and returnsdict.- Parameters
file (str) – path of
tomlfile.options (optional) – Can be used in the future if functionality need extendsion, like encoding type.
- Returns
Dictionary of
tomlfile contents.- Return type
dict
- baecon.utils.yaml_dump(config: dict, file: str, options=None) None#
Write configuration dictionary (
config) to ayamlfile.- Parameters
config (dict) – Configuration dictionary to save.
file (str or path) – name or path of
yamlfile.options (optional) – Can be used in the future if functionality need extendsion, like encoding type
- baecon.utils.yaml_load(file: str, options=None) dict#
Reads
yamlfile and returnsdict.- Parameters
file (str) – path of
yamlfile.options (optional) – Can be used in the future if functionality need extendsion, like encoding type
- Returns
Dictionary of
yamlfile contents.- Return type
dict