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
Return 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.
Loads 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
Return a csv of the spectrum data as csv :param sep: csv separator :param columns: List of column names.
Write the entire data to a single pickle file in the data directory.
Attributes
Absolute path to the data file or directory
Absolute path to the data directory
Name of the data directory
- CALC_KEYS = ['I', 'dI', 'dI-X', 'dI-Y', 'dI_I', 'dI-X_I', 'dI-Y_I', 'theta', 'theta-corr', 'lock-in-theta', 'lock-in-R', 'lock-in-aux', 'dI-Q', 'dI_I-Q', 'plot-theta', 'real-theta']#
- OLD_KEYS = ['dI-Q', 'dI_I-Q', 'plot-theta', 'real-theta']#
- _COLUMN_DATA = {'*': {'color': {'I': '#1f78b4', 'L': 'purple', 'dI': '#33a02c', 'dI-X': '#43802c', 'dI-X_I': '#c34a0c', 'dI-Y': '#43802c', 'dI-Y_I': '#c34a0c', 'dI_I': '#e31a1c', 'lock-in-R': '#b2df8a', 'lock-in-aux': '#a6cee3', 'lock-in-theta': '#fdbf6f', 'sI': '#1f78b4', 'sL': 'purple', 'sdI': '#33a02c', 'sdI-X': '#43802c', 'sdI-X_I': '#c34a0c', 'sdI-Y': '#43802c', 'sdI-Y_I': '#c34a0c', 'sdI_I': '#e31a1c', 'slock-in-R': '#b2df8a', 'slock-in-aux': '#a6cee3', 'slock-in-theta': '#fdbf6f', 'stheta': '#fdbf6f', 'stheta-corr': '#ff7f00', 'theta': '#fdbf6f', 'theta-corr': '#ff7f00'}, 'label': {'E': 'Energy [eV]', 'lock-in-R': 'lock-in-R', 'slock-in-R': 'sigma(lock-in-R)', 'stheta': 'sigma(theta) [°]', 'stheta-corr': 'sigma(theta_corr) [°]', 'theta': 'theta [°]', 'theta-corr': 'theta_corr [°]', 'wl': 'Wavelength [nm]'}, 'label-tex': {'E': '$E$', 'L': '$L$', 'dI-X_I': '$\\Delta I_X/I$', 'dI-Y_I': '$\\Delta I_Y/I$', 'dI_I': '$\\Delta I/I$', 'stheta': '$\\sigma(\\theta)$', 'stheta-corr': '$\\sigma(\\theta_\\text{corr})$', 'theta': '$\\theta$', 'theta-corr': '$\\theta_\\text{corr}$', 'wl': '$\\lambda$'}, 'scale': {'L': 1e-05, 'dI': 1e-06, 'dI-X': 1e-06, 'dI-X_I': 1e-05, 'dI-Y': 1e-06, 'dI-Y_I': 1e-05, 'dI_I': 1e-05, 'lock-in-R': 1e-06}, 'unit-tex': {'E': 'eV', 'I': 'V', 'dI': 'V', 'dI-X': 'V', 'dI-Y': 'V', 'lock-in-R': 'V', 'lock-in-aux': 'V', 'lock-in-theta': '°', 'sI': 'V', 'sdI': 'V', 'sdI-X': 'V', 'sdI-Y': 'V', 'stheta': '°', 'stheta-corr': '°', 'theta': '°', 'theta-corr': '°', 'wl': 'nm'}}, 'abs': {'label': {'I': 'A [V]', 'dI': 'dA [V]', 'dI-X': 'dA_X [V]', 'dI-X_I': 'dA_X/A', 'dI-Y': 'dA_Y [V]', 'dI-Y_I': 'dA_Y/A', 'dI_I': 'dA/A', 'sI': 'sigma(A) [V]', 'sdI': 'sigma(dA) [V]', 'sdI-X': 'sigma(dA_X) [V]', 'sdI-X_I': 'sigma(dA_X/A)', 'sdI-Y': 'sigma(dA_Y) [V]', 'sdI-Y_I': 'sigma(dA_Y/A)', 'sdI_I': 'sigma(dA/A)'}, 'label-tex': {'I': '$A$', 'dI': '$\\Delta A$', 'dI-X': '$\\Delta A_X$', 'dI-X_I': '$\\Delta A_X/A$', 'dI-Y': '$\\Delta A_Y$', 'dI-Y_I': '$\\Delta A_Y/A$', 'dI_I': '$\\Delta A/A$', 'sdI': '$\\sigma(\\Delta A$)', 'sdI-X': '$\\sigma(\\Delta A_X$)', 'sdI-X_I': '$\\sigma(\\Delta A_X/A$)', 'sdI-Y': '$\\sigma(\\Delta A_Y$)', 'sdI-Y_I': '$\\sigma(\\Delta A_Y/A$)', 'sdI_I': '$\\sigma(\\Delta A/A$)'}}, 'ref': {'label': {'I': 'R [V]', 'dI': 'dR [V]', 'dI-X': 'dR_X [V]', 'dI-X_I': 'dR_X/R', 'dI-Y': 'dR_Y [V]', 'dI-Y_I': 'dR_Y/R', 'dI_I': 'dR/R', 'sI': 'sigma(R) [V]', 'sdI': 'sigma(dR) [V]', 'sdI-X': 'sigma(dR_X) [V]', 'sdI-X_I': 'sigma(dR_X/R)', 'sdI-Y': 'sigma(dR_Y) [V]', 'sdI-Y_I': 'sigma(dR_Y/R)', 'sdI_I': 'sigma(dR/R)'}, 'label-tex': {'I': '$R$', 'dI': '$\\Delta R$', 'dI-X': '$\\Delta R_X$', 'dI-X_I': '$\\Delta R_X/R$', 'dI-Y': '$\\Delta R_Y$', 'dI-Y_I': '$\\Delta R_Y/R$', 'dI_I': '$\\Delta R/R$', 'sdI': '$\\sigma(\\Delta R$)', 'sdI-X': '$\\sigma(\\Delta R_X$)', 'sdI-X_I': '$\\sigma(\\Delta R_X/R$)', 'sdI-Y': '$\\sigma(\\Delta R_Y$)', 'sdI-Y_I': '$\\sigma(\\Delta R_Y/R$)', 'sdI_I': '$\\sigma(\\Delta R/R$)'}}, 'tra': {'label': {'I': 'T [V]', 'dI': 'dT [V]', 'dI-X': 'dT_X [V]', 'dI-X_I': 'dT_X/T', 'dI-Y': 'dT_Y [V]', 'dI-Y_I': 'dT_Y/T', 'dI_I': 'dT/T', 'sI': 'sigma(T) [V]', 'sdI': 'sigma(dT) [V]', 'sdI-X': 'sigma(dT_X) [V]', 'sdI-X_I': 'sigma(dT_X/T)', 'sdI-Y': 'sigma(dT_Y) [V]', 'sdI-Y_I': 'sigma(dT_Y/T)', 'sdI_I': 'sigma(dT/T)'}, 'label-tex': {'I': '$T$', 'dI': '$\\Delta T$', 'dI-X': '$\\Delta T_X$', 'dI-X_I': '$\\Delta T_X/T$', 'dI-Y': '$\\Delta T_Y$', 'dI-Y_I': '$\\Delta T_Y/T$', 'dI_I': '$\\Delta T/T$', 'sdI': '$\\sigma(\\Delta T$)', 'sdI-X': '$\\sigma(\\Delta T_X$)', 'sdI-X_I': '$\\sigma(\\Delta T_X/T$)', 'sdI-Y': '$\\sigma(\\Delta T_Y$)', 'sdI-Y_I': '$\\sigma(\\Delta T_Y/T$)', 'sdI_I': '$\\sigma(\\Delta T/T$)'}}}#
- _EQUALITY_CHECKS = {'endswith': <function Data.<lambda>>, 'equal': <function Data.<lambda>>, 'startswith': <function Data.<lambda>>}#
- __annotations__ = {'data': 'dict'}#
- __dict__ = mappingproxy({'__module__': 'prsctrl.data.prsdata', '__firstlineno__': 48, '__doc__': '\nClass managing data and metadata.\nCan be initialized from data directly, or from a file or directory path.\n\n\ndata is a dictionary with:\n - key: wavelength as int or float, or "offset_<name>"\n - value: dictionary with:\n - key: quantity as string: ["lock-in-R_raw", "lock-in-theta", "slock-in-theta", "lock-in-aux_raw", ... ]\n - value: quantity value, or array if "_raw"\n\nKeys for a given wavelength/offset:\n - dI: delta I, the change in reflectance/transmittance/absorbance. (This is the signal amplitude "R" from the lock-in)\n - I: the baseline reflectivity. (DC signal measured using Aux In of the lock-in)\n - theta: phase\n - theta-corr: theta between [-90, 90], assuming |theta| > 90 simply means lock-in-R is negative\n - lock-in-R: magnitude value of lock-in\n - lock-in-theta: phase value of lock-in\n - lock-in-aux: value if lock-in aux port\n - <qty>_raw: The raw measurement data (all individual samples)\n - s<qty>: Standard error of the quantity\n', '__init__': <function PrsData.__init__>, '__setitem__': <function PrsData.__setitem__>, '__getitem__': <function PrsData.__getitem__>, '_check_has_wavelength': <function PrsData._check_has_wavelength>, 'update_wavelengths': <function PrsData.update_wavelengths>, 'get_for_wl': <function PrsData.get_for_wl>, '_remove_calculated_offsets': <function PrsData._remove_calculated_offsets>, '_get_time_sorted_measurement_keys': <function PrsData._get_time_sorted_measurement_keys>, '_get_time_sorted_offset_keys': <function PrsData._get_time_sorted_offset_keys>, '_get_time_sorted_wavelenth_keys': <function PrsData._get_time_sorted_wavelenth_keys>, '_calc_offsets': <function PrsData._calc_offsets>, '_calc_offset': <function PrsData._calc_offset>, '_get_theta_offset': <function PrsData._get_theta_offset>, '_get_dI_offset': <function PrsData._get_dI_offset>, '_get_I_offset': <function PrsData._get_I_offset>, '_calculate_I_for_wl': <function PrsData._calculate_I_for_wl>, '_calculate_theta_for_wl': <function PrsData._calculate_theta_for_wl>, '_calculate_theta_corr_for_wl': <function PrsData._calculate_theta_corr_for_wl>, '_calculate_dI_for_wl': <function PrsData._calculate_dI_for_wl>, '_calculate_dIX_for_wl': <function PrsData._calculate_dIX_for_wl>, '_calculate_dIY_for_wl': <function PrsData._calculate_dIY_for_wl>, '_calculate_dI_I_for_wl': <function PrsData._calculate_dI_I_for_wl>, '_calculate_dIX_I_for_wl': <function PrsData._calculate_dIX_I_for_wl>, '_calculate_dIY_I_for_wl': <function PrsData._calculate_dIY_I_for_wl>, 'CALC_KEYS': ['I', 'dI', 'dI-X', 'dI-Y', 'dI_I', 'dI-X_I', 'dI-Y_I', 'theta', 'theta-corr', 'lock-in-theta', 'lock-in-R', 'lock-in-aux', 'dI-Q', 'dI_I-Q', 'plot-theta', 'real-theta'], 'OLD_KEYS': ['dI-Q', 'dI_I-Q', 'plot-theta', 'real-theta'], 'remove_calculated_values': <function PrsData.remove_calculated_values>, 'default_spectrum_columns': ['wl', 'E', 'dI_I', 'dI-X_I', 'dI-Y_I', 'sdI_I', 'sdI-X_I', 'sdI-Y_I', 'dI', 'dI-X', 'dI-Y', 'sdI', 'sdI-X', 'sdI-Y', 'I', 'sI', 'theta-corr', 'stheta-corr', 'theta', 'stheta', 'lock-in-theta', 'slock-in-theta', 'lock-in-R', 'slock-in-R', 'lock-in-aux', 'slock-in-aux'], 'spectrum_columns_abs': ['wl', 'E', 'dI_I', 'dI-X_I', 'dI-Y_I', 'sdI_I', 'sdI-X_I', 'sdI-Y_I', 'dI', 'dI-X', 'dI-Y', 'sdI', 'sdI-X', 'sdI-Y', 'I', 'sI', 'theta-corr', 'stheta-corr'], 'spectrum_columns_reference': ['wl', 'E', 'I', 'sI', 'lock-in-aux', 'slock-in-aux'], 'get_spectrum_data': <function PrsData.get_spectrum_data>, 'to_csv': <function PrsData.to_csv>, 'save_csv_at': <function PrsData.save_csv_at>, 'save_csv': <function PrsData.save_csv>, '_assert_write_mode': <function PrsData._assert_write_mode>, '_assert_directory_exists': <function PrsData._assert_directory_exists>, 'write_partial_file': <function PrsData.write_partial_file>, 'write_full_file': <function PrsData.write_full_file>, 'write_metadata': <function PrsData.write_metadata>, 'get_csv': <staticmethod(<function PrsData.get_csv>)>, 'load_data_from_csv': <staticmethod(<function PrsData.load_data_from_csv>)>, '_spectrum_data_to_internal_data': <staticmethod(<function PrsData._spectrum_data_to_internal_data>)>, 'load_data_from_pkl': <classmethod(<function PrsData.load_data_from_pkl>)>, 'load_data_from_dir': <staticmethod(<function PrsData.load_data_from_dir>)>, 'plot_raw_for_wl': <function PrsData.plot_raw_for_wl>, 'has_DC': <function PrsData.has_DC>, 'has_AC': <function PrsData.has_AC>, 'has_wavelengths': <function PrsData.has_wavelengths>, '_COLUMN_DATA': {'*': {'label': {'wl': 'Wavelength [nm]', 'E': 'Energy [eV]', 'theta': 'theta [°]', 'stheta': 'sigma(theta) [°]', 'theta-corr': 'theta_corr [°]', 'stheta-corr': 'sigma(theta_corr) [°]', 'lock-in-R': 'lock-in-R', 'slock-in-R': 'sigma(lock-in-R)'}, 'label-tex': {'wl': '$\\lambda$', 'E': '$E$', 'theta': '$\\theta$', 'stheta': '$\\sigma(\\theta)$', 'theta-corr': '$\\theta_\\text{corr}$', 'stheta-corr': '$\\sigma(\\theta_\\text{corr})$', 'L': '$L$', 'dI_I': '$\\Delta I/I$', 'dI-X_I': '$\\Delta I_X/I$', 'dI-Y_I': '$\\Delta I_Y/I$'}, 'unit-tex': {'wl': 'nm', 'E': 'eV', 'dI': 'V', 'dI-X': 'V', 'dI-Y': 'V', 'I': 'V', 'theta': '°', 'theta-corr': '°', 'sdI': 'V', 'sdI-X': 'V', 'sdI-Y': 'V', 'sI': 'V', 'stheta': '°', 'stheta-corr': '°', 'lock-in-R': 'V', 'lock-in-aux': 'V', 'lock-in-theta': '°'}, 'scale': {'dI_I': 1e-05, 'dI-X_I': 1e-05, 'dI-Y_I': 1e-05, 'L': 1e-05, 'dI': 1e-06, 'dI-X': 1e-06, 'dI-Y': 1e-06, 'lock-in-R': 1e-06}, 'color': {'dI_I': '#e31a1c', 'dI': '#33a02c', 'dI-X_I': '#c34a0c', 'dI-X': '#43802c', 'dI-Y_I': '#c34a0c', 'dI-Y': '#43802c', 'lock-in-R': '#b2df8a', 'I': '#1f78b4', 'lock-in-aux': '#a6cee3', 'theta-corr': '#ff7f00', 'theta': '#fdbf6f', 'lock-in-theta': '#fdbf6f', 'L': 'purple', 'sdI_I': '#e31a1c', 'sdI': '#33a02c', 'sdI-X_I': '#c34a0c', 'sdI-X': '#43802c', 'sdI-Y_I': '#c34a0c', 'sdI-Y': '#43802c', 'slock-in-R': '#b2df8a', 'sI': '#1f78b4', 'slock-in-aux': '#a6cee3', 'stheta-corr': '#ff7f00', 'stheta': '#fdbf6f', 'slock-in-theta': '#fdbf6f', 'sL': 'purple'}}, 'ref': {'label': {'dI_I': 'dR/R', 'dI-X_I': 'dR_X/R', 'dI-Y_I': 'dR_Y/R', 'dI': 'dR [V]', 'dI-X': 'dR_X [V]', 'dI-Y': 'dR_Y [V]', 'I': 'R [V]', 'sdI_I': 'sigma(dR/R)', 'sdI-X_I': 'sigma(dR_X/R)', 'sdI-Y_I': 'sigma(dR_Y/R)', 'sdI': 'sigma(dR) [V]', 'sdI-X': 'sigma(dR_X) [V]', 'sdI-Y': 'sigma(dR_Y) [V]', 'sI': 'sigma(R) [V]'}, 'label-tex': {'dI_I': '$\\Delta R/R$', 'dI-X_I': '$\\Delta R_X/R$', 'dI-Y_I': '$\\Delta R_Y/R$', 'dI': '$\\Delta R$', 'dI-X': '$\\Delta R_X$', 'dI-Y': '$\\Delta R_Y$', 'I': '$R$', 'sdI_I': '$\\sigma(\\Delta R/R$)', 'sdI-X_I': '$\\sigma(\\Delta R_X/R$)', 'sdI-Y_I': '$\\sigma(\\Delta R_Y/R$)', 'sdI': '$\\sigma(\\Delta R$)', 'sdI-X': '$\\sigma(\\Delta R_X$)', 'sdI-Y': '$\\sigma(\\Delta R_Y$)'}}, 'tra': {'label': {'dI_I': 'dT/T', 'dI-X_I': 'dT_X/T', 'dI-Y_I': 'dT_Y/T', 'dI': 'dT [V]', 'dI-X': 'dT_X [V]', 'dI-Y': 'dT_Y [V]', 'I': 'T [V]', 'sdI_I': 'sigma(dT/T)', 'sdI-X_I': 'sigma(dT_X/T)', 'sdI-Y_I': 'sigma(dT_Y/T)', 'sdI': 'sigma(dT) [V]', 'sdI-X': 'sigma(dT_X) [V]', 'sdI-Y': 'sigma(dT_Y) [V]', 'sI': 'sigma(T) [V]'}, 'label-tex': {'dI_I': '$\\Delta T/T$', 'dI-X_I': '$\\Delta T_X/T$', 'dI-Y_I': '$\\Delta T_Y/T$', 'dI': '$\\Delta T$', 'dI-X': '$\\Delta T_X$', 'dI-Y': '$\\Delta T_Y$', 'I': '$T$', 'sdI_I': '$\\sigma(\\Delta T/T$)', 'sdI-X_I': '$\\sigma(\\Delta T_X/T$)', 'sdI-Y_I': '$\\sigma(\\Delta T_Y/T$)', 'sdI': '$\\sigma(\\Delta T$)', 'sdI-X': '$\\sigma(\\Delta T_X$)', 'sdI-Y': '$\\sigma(\\Delta T_Y$)'}}, 'abs': {'label': {'dI_I': 'dA/A', 'dI-X_I': 'dA_X/A', 'dI-Y_I': 'dA_Y/A', 'dI': 'dA [V]', 'dI-X': 'dA_X [V]', 'dI-Y': 'dA_Y [V]', 'I': 'A [V]', 'sdI_I': 'sigma(dA/A)', 'sdI-X_I': 'sigma(dA_X/A)', 'sdI-Y_I': 'sigma(dA_Y/A)', 'sdI': 'sigma(dA) [V]', 'sdI-X': 'sigma(dA_X) [V]', 'sdI-Y': 'sigma(dA_Y) [V]', 'sI': 'sigma(A) [V]'}, 'label-tex': {'dI_I': '$\\Delta A/A$', 'dI-X_I': '$\\Delta A_X/A$', 'dI-Y_I': '$\\Delta A_Y/A$', 'dI': '$\\Delta A$', 'dI-X': '$\\Delta A_X$', 'dI-Y': '$\\Delta A_Y$', 'I': '$A$', 'sdI_I': '$\\sigma(\\Delta A/A$)', 'sdI-X_I': '$\\sigma(\\Delta A_X/A$)', 'sdI-Y_I': '$\\sigma(\\Delta A_Y/A$)', 'sdI': '$\\sigma(\\Delta A$)', 'sdI-X': '$\\sigma(\\Delta A_X$)', 'sdI-Y': '$\\sigma(\\Delta A_Y$)'}}}, '__static_attributes__': ('I_offset', '_offset_times', '_offset_value_keys', '_offset_values', 'data', 'dirname', 'dirpath', 'mode', 'name', 'wavelengths'), '__annotations__': {'data': 'dict'}})#
- __firstlineno__ = 48#
- __init__(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]#
- classmethod __init_subclass__(**kwargs)#
Auto-register subclasses
- __module__ = 'prsctrl.data.prsdata'#
- __static_attributes__ = ('I_offset', '_offset_times', '_offset_value_keys', '_offset_values', 'data', 'dirname', 'dirpath', 'mode', 'name', 'wavelengths')#
- __weakref__#
list of weak references to the object
- _assert_read_mode()#
- Raises:
RuntimeError – If instance was not initialized in read mode
- _calc_offset(wl, key) float[source]#
- Parameters:
wl – The wavelength key to calculate the offset for.
key – The offset data key, for example “lock-in-R”
- _calc_offsets(keys=['lock-in-R', 'slock-in-R', 'lock-in-aux', 'slock-in-aux', 'lock-in-theta', 'slock-in-theta'])[source]#
Initialize offset variables for later interpolation.
This function collects offset vs. time data and stores them as class members.
- _calculate_I_for_wl(wl) tuple[float, float][source]#
Calculate I If I - I_offset is negative for any wavelength, all I - I_offset values are shifted by that amount so that the smallest value is 0.
- _calculate_dIX_I_for_wl(wl) tuple[float, float][source]#
Calculate delta I_X/I :param wl: wavelength :return: delta I_X/I, standard error of delta I_X/I
- _calculate_dIX_for_wl(wl) tuple[float, float][source]#
Calculate the in-phase delta I from the lock-in’s R signal and the phase theta dI’ = lock-in-I * cos(theta) - dI_offset :param wl: wavelength :return: delta I_X, standard error of delta I_X
- _calculate_dIY_I_for_wl(wl) tuple[float, float][source]#
Calculate delta I_Y/I :param wl: wavelength :return: delta I_Y/I, standard error of delta I_Y/I
- _calculate_dIY_for_wl(wl) tuple[float, float][source]#
Calculate the quadrature (out-of-phase) delta I from the lock-in’s R signal and the phase theta dI’ = lock-in-I * sin(theta) :param wl: wavelength :return: delta I_Y, standard error of delta I_Y
- _calculate_dI_I_for_wl(wl) tuple[float, float][source]#
Calculate delta I/I :param wl: wavelength :return: delta I/I, standard error of delta I/I
- _calculate_dI_for_wl(wl) tuple[float, float][source]#
Calculate the magnitude delta I from the lock-in’s R signal and the phase theta dI’ = sqrt((delta I_X)^2 + (delta I_Y)^2) :param wl: wavelength :return: delta I, standard error of delta I
- _calculate_theta_corr_for_wl(wl) tuple[float, float][source]#
Calculate the offset corrected phase. The corrected phase is obtained by taking the arctan of the offset correct dI-X divided by dI-Y, which by our assumptions does not have an offset. ~~The arctan output of [-90°, 90°] is then mapped to an angle of [-180°, 180°] (angle from the positive x-axis).~~
- Parameters:
wl – wavelength key
- Returns:
corrected theta with error
- _calculate_theta_for_wl(wl) tuple[float, float][source]#
Calculate theta, which can then be used to calculate R
- Parameters:
wl – wavelength key
- Returns:
lock-in-theta - phase_offset_deg_before and mapped to [-180, 180]
- classmethod _get_column_data(key, column, default=None, mode='*', check_other_cls=True, instance=None)#
Search for column data in _COLUMN_DATA hierarchy
Searches for the specified key and column in the _COLUMN_DATA dictionary following a priority order: specific mode → wildcard mode → other subclasses → default.
- Parameters:
key – Data key (e.g., ‘label’)
column – Column key to retrieve
default – Default value to return if no data is found
mode – Optional data mode to search in
check_other_cls – Whether to check other Data subclasses before returning default
instance – Optional Data subclass instance to auto-determine mode from .mode attribute
- Returns:
The found column data or default value
- classmethod _get_column_key(key, value, default=None, mode='*', check_other_modes=True, check_other_cls=True, equality_check='equal')#
Reverse search of column data: returns the column key for the given data key and value. First checks the calling class, then all other subclasses.
- Parameters:
key – data key, e.g. ‘label’
value – the value of _COLUMN_DATA[mode][key][column] for which the column is returned
default – a default value to return of no value is found
mode – optional data mode
check_other_modes – whether to check if another mode in _COLUMN_DATA has the column data
check_other_cls – whether to check if other subclasses have the column data before returning the default
equality_check – How to check equality: ‘equal’, ‘startswith’ or ‘endswith’. The latter check if the searched value starts with the column data value
- Returns:
The column key to given value from _COLUMN_DATA
- static _spectrum_data_to_internal_data(sdata: ndarray[tuple[Any, ...], dtype[_ScalarT]], columns: list[str], mode=None) dict[source]#
- _subclasses = {'PrsData': <class 'prsctrl.data.prsdata.PrsData'>, 'TimeData': <class 'devctrl.data.time.data.TimeData'>}#
- data: dict#
- data_path#
Absolute path to the data file or directory
- default_spectrum_columns = ['wl', 'E', 'dI_I', 'dI-X_I', 'dI-Y_I', 'sdI_I', 'sdI-X_I', 'sdI-Y_I', 'dI', 'dI-X', 'dI-Y', 'sdI', 'sdI-X', 'sdI-Y', 'I', 'sI', 'theta-corr', 'stheta-corr', 'theta', 'stheta', 'lock-in-theta', 'slock-in-theta', 'lock-in-R', 'slock-in-R', 'lock-in-aux', 'slock-in-aux']#
- dir_name: str#
Name of the data directory
- dir_path: str#
Absolute path to the data directory
- get_column_color(**kw)#
- get_column_label(**kw)#
- get_column_label_with_unit(**kw)#
- get_column_scale(**kw)#
- get_column_tex_label(**kw)#
- get_column_tex_label_with_unit(**kw)#
- get_column_tex_label_with_unit_and_scale(**kw)#
- get_column_tex_unit(**kw)#
- get_column_unit(**kw)#
- 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.
- spectrum_columns_abs = ['wl', 'E', 'dI_I', 'dI-X_I', 'dI-Y_I', 'sdI_I', 'sdI-X_I', 'sdI-Y_I', 'dI', 'dI-X', 'dI-Y', 'sdI', 'sdI-X', 'sdI-Y', 'I', 'sI', 'theta-corr', 'stheta-corr']#
- spectrum_columns_reference = ['wl', 'E', 'I', 'sI', 'lock-in-aux', 'slock-in-aux']#
- to_csv(columns=None, sep=',')[source]#
Return a csv of the spectrum data as csv :param sep: csv separator :param columns: List of column names. If None, uses the default_spectrum_columns :return: csv as string