prsctrl.data.prsdata.PrsData#
- class PrsData(data_path: str | None = None, data: dict | None = None, metadata: dict | None = None, data_name: str | None = None, file_mode='r', exp_mode=None)[source]#
Bases:
DataClass managing data and metadata. Can be initialized from data directly, or from a file or directory path.
- data is a dictionary with:
key: wavelength as int or float, or “offset_<name>”
- value: dictionary with:
key: quantity as string: [“lock-in-R_raw”, “lock-in-theta”, “slock-in-theta”, “lock-in-aux_raw”, … ]
value: quantity value, or array if “_raw”
- Keys for a given wavelength/offset:
dI: delta I, the change in reflectance/transmittance/absorbance. (This is the signal amplitude “R” from the lock-in)
I: the baseline reflectivity. (DC signal measured using Aux In of the lock-in)
theta: phase
theta-corr: theta between [-90, 90], assuming |theta| > 90 simply means lock-in-R is negative
lock-in-R: magnitude value of lock-in
lock-in-theta: phase value of lock-in
lock-in-aux: value if lock-in aux port
<qty>_raw: The raw measurement data (all individual samples)
s<qty>: Standard error of the quantity
Methods
get_column_colorget_column_labelget_column_label_with_unitget_column_scaleget_column_tex_labelget_column_tex_label_with_unitget_column_tex_label_with_unit_and_scaleget_column_tex_unitget_column_unitget_csvReturn the value for <key> at a given wavelength <wl> (in nanometers)
Return the spectral data for the specified keys and wavelengths as numpy array :param wavelengths: List of wavelengths, range of wavelenthgs (as tuple, with at least (min, max)), or None to use all wavelengths.
has_AChas_DChas_wavelengthsLoads data from a single csv file.
Load prs data from a directory path.
Loads data from a single pkl file. If the file is compressed with gzip, it must end with '.gz' extension. Parameters ---------- :param filepath Path to the file. :return data 2D numpy array with shape (n, 4) where n is the number of data points. metadata Dictionary with metadata.
Plot raw data against index (time) for a particular wavelength.
Delete all calculated data values
save_csvsave_csv_atReturn a csv of the spectrum data as csv :param sep: csv separator :param columns: List of column names.
update_wavelengthsWrite the entire data to a single pickle file in the data directory.
write_metadatawrite_partial_fileAttributes
CALC_KEYSOLD_KEYSdefault_spectrum_columnsspectrum_columns_absspectrum_columns_referenceAbsolute path to the data file or directory
Absolute path to the data directory
Name of the data directory
- data_path#
Absolute path to the data file or directory
- dir_name: str#
Name of the data directory
- dir_path: str#
Absolute path to the data directory
- get_for_wl(wl, key) float[source]#
Return the value for <key> at a given wavelength <wl> (in nanometers)
- Parameters:
wl – Wavelength in nm
key – Key of the quantity to return.
- if relative_time:
I: the DC signal (measured by lock-in aux port and calculated from the “lock-in-aux_raw” values)
dI: sqrt(dI-X^2 + dI-Y^2)
dI-X: delta I = I * cos(theta) where I is the I value from the lock-in (peak-peak, calculated from the “lock-in-R_raw” values)
dI-Y: delta I = I * sin(theta) where I is the I value from the lock-in (peak-peak, calculated from the “lock-in-R_raw” values)
theta: the phase (calculated from the “lock-in-theta_raw” values)
dI_I, dI-X_I, dI-Y_I: dI/I each
lock-in-<key>: mean (error) value calculated from the “lock-in-<key>_raw” values
- Returns:
float, or np.ndarray if a _raw value was requested
- get_spectrum_data(wavelengths=None, columns=None, Es=None, transforms: list[Callable[[ndarray[tuple[Any, ...], dtype[_ScalarT]], list[str]], tuple[ndarray[tuple[Any, ...], dtype[_ScalarT]], list[str]]]] | None = None) tuple[ndarray[tuple[Any, ...], dtype[_ScalarT]], list[str]][source]#
Return the spectral data for the specified keys and wavelengths as numpy array :param wavelengths: List of wavelengths, range of wavelenthgs (as tuple, with at least (min, max)), or None to use all wavelengths. Conflicts with Es. :param Es: List of energies (eV), range of energies (as tuple, with at least (min, max)), or None to use all wavelengths. Conflicts with wavelengths :param columns: List of column keys, or None to use default_spectrum_columns. :param transforms: List of transformations to apply to the data :return: numpy.ndarray where the first index is the wavelength/index and the second is the keys/columns. (wavelength=0, <keys>…=1…)
- static load_data_from_csv(filepath: str, mode=None, **csv_kw) tuple[dict, dict][source]#
Loads data from a single csv file. :param filepath: Path to the csv file.
- static load_data_from_dir(dirpath: str) tuple[dict, dict][source]#
Load prs data from a directory path. If PREFER_LOAD_FROM_FULL_FILE is True, the data is loaded from the FULL_DATA_FILENAME, if it exists. Otherwise all data files with the PARTIAL_PREFIX are loaded and combined.
:param dirpath Path to the data directory :return data, metadata
- classmethod load_data_from_pkl(filepath: str) tuple[dict, dict][source]#
Loads data from a single pkl file. If the file is compressed with gzip, it must end with ‘.gz’ extension. Parameters ———- :param filepath Path to the file. :return
- data
2D numpy array with shape (n, 4) where n is the number of data points.
- metadata
Dictionary with metadata.
- plot_raw_for_wl(wl, what=['lock-in-R', 'lock-in-aux', 'lock-in-theta'], fig=None, axs=None, **plot_kw)[source]#
Plot raw data against index (time) for a particular wavelength.