qtcad.device.io module
Functions to save and load simulation results.
- qtcad.device.io.load(path, var_name=None, fmt=None, asarray=False)
Loads a .json or .hdf5 file.
- Parameters:
path (str) – The path to the data file.
fmt (string, optional) – Format of the data file. “json”, “hdf5” or None. If None, guesses from extension. Default: None.
var_name (string, optional) – Name of the variable to load. In hdf5, default name that will be used is “var”.
asarray (bool, optional) – Force to load Fields as numpy arrays. Default: False.
- Returns:
dict – The contents of the file.
Note
For json files, the data is stored in a dictionary by default, unless a specific variable name is specified, in which case this variable is loaded. For hdf5 files, specifying the variable name is mandatory.
- qtcad.device.io.save(path, out_dict, mesh=None, fmt=None, compression_opts=4, var_name='data', length_unit='nm', verbose=True)
Saves a dictionary of arrays or a single array into a .json, .hdf5, or .vtu file.
- Parameters:
path (str) – The path to the data file.
out_dict (dict) – A dictionary of numpy arrays or fields to save.
fmt (string) – Format of the data file. “json”, “hdf5”, “vtu”, or None. If None, guesses from extension. Default: None.
compression_opts (int, optional) – Compression level to use in hdf5 file, from 0 to 9. Default: 4.
mesh (Mesh, optional) – The mesh to use when saving under vtu format.
var_name (str, optional) – The variable name to use when exporting a variable in vtu format.
length_unit (str) – Units of length to use when exporting into vtu format. Default: “nm”. Other choices are: “um”, “mm”, and “m”.
verbose (bool, optional) – Whether messages regarding the file path and size are printed. Default: True.
- qtcad.device.io.save_device(path, device, attrs=None, fmt=None, compression_opts=4)
Saves a device into an hdf5 or json file.
- Parameters:
path (string) – The path to the file in which to save the device.
device (device) – The device to save.
attrs (list of str or None) – Attributes to save in the .json file. If None, save all of them.
fmt (string) – Format of the data file. “json”, “hdf5” or None. If None, guesses from extension. Default: None.
compression_opts (int, optional) – Compression level to use in hdf5 file, from 0 to 9. Default: 4.