pyUSID.io.array_translator.ArrayTranslator¶
- class pyUSID.io.array_translator.ArrayTranslator(*args, **kwargs)[source]¶
Bases:
Translator
Translator that writes numeric arrays (already in memory) that describe a USID dataset to a HDF5 file
- Return type:
Translator object
Methods
Checks whether the provided file can be read by this translator.
Writes the provided datasets and parameters to an h5 file
- static is_valid_file(file_path, *args, **kwargs)¶
Checks whether the provided file can be read by this translator.
This basic function compares the file extension against the “extension” keyword argument. If the extension matches, this function returns True
- translate(h5_path, data_name, raw_data, quantity, units, pos_dims, spec_dims, translator_name='ArrayTranslator', parm_dict=None, extra_dsets=None, **kwargs)[source]¶
Writes the provided datasets and parameters to an h5 file
- Parameters:
h5_path (str) – Absolute path of the h5 file to be written
data_name (str) – Name of the scientific data type. Example - ‘SEM’
raw_data (
np.ndarray
ordask.array.core.Array
) – 2D matrix formatted as [position, spectral]quantity (str) – Name of the physical quantity stored in the dataset. Example - ‘Current’
units (str) – Name of units for the quantity stored in the dataset. Example - ‘A’ for amperes
pos_dims (
Dimension
or array-like ofDimension
) – objects Sequence ofDimension
objects that provides all necessary instructions for constructing the indices and values datasets Object specifying the instructions necessary for building the Position indices and values datasetsspec_dims (
Dimension
or array-like ofDimension
) – objects Sequence ofDimension
objects that provides all necessary instructions for constructing the indices and values datasets Object specifying the instructions necessary for building the Spectroscopic indices and values datasetstranslator_name (str, Optional) – Name of the translator. Example - ‘HitachiSEMTranslator’
parm_dict (dict, Optional) – Dictionary of parameters that will be written under the group ‘Measurement_000’
extra_dsets (dict, Optional) – Dictionary whose values will be written into individual HDF5 datasets and whose corresponding keys provide the names of the datasets. You are recommended to limit these to simple and small datasets.
kwargs (dict, Optional.) – Additional keyword arguments that will be passed onto
pyUSID.hdf_utils.write_main_dset()
which will in turn will be passed onto the creation of the dataset. Please pass chunking, compression, dtype, and other arguments this way
- Returns:
h5_path – Absolute path of the written h5 file
- Return type: