save_data module¶
The save_data.py module is used for saving the collected data, as well as other experiment specific files (i.e. hardware config files) into the directory which is specified by the user on the GUI. One class is designated for data and certain files. The other class is used to save the background of the measurement.
Overview:
Classes:
SaveData:
create_initial_path
create_delay_dirs
create_pump_dirs
save_scan
save_weights
save_s2s_std
save_s2s
save_counts
save_raw_data
save_pump_spectrum
save_avg
save_readme
save_hwconfig
save_logfile
save_other
save_figures
Background
save_background
load_background
-
class
Background(path: str)[source]¶ Bases:
objectClass that handels saving and loading of background / dark noise data on detector.
It enabled saving background data in the specified directory and loading the most recent file from the directory. If the directory does not exist it will be created.
- Parameters
path (str) – Path to folder where background data should be saved and loaded.
-
load_background() → numpy.ndarray[source]¶ Loads most recent background from file.
- Returns
- Raw, non linearized background for each
pixel.
shape: 1D
E.g. (n_pixels)
- Return type
ndarray
-
save_background(background_data: numpy.ndarray)[source]¶ Saves background to folder specified in path attribute and prepends the current date and time to the filename.
- Parameters
background_data (ndarray) –
Raw, nonlinearized averaged data during time when detector was closed. We save all the data (also from channels that are not pixels) because this will make data processing easier in the routines.
shape: 1D
E.g. (number of channels)
-
class
SaveData(path: str, file_name: str, username: str, delays: Optional[numpy.ndarray] = None, pump_pixels: Optional[numpy.ndarray] = None, raw_data: bool = False)[source]¶ Bases:
objectSaveData class is used for creating directories and saving measurement data, figures etc. which result from the experiments
SaveData class is used to make it easier to save data from the given experiments programs. It can be passed as an object through processes and used to save certain data which is generated during the measurements.
- Parameters
path (str) – Path to where the data should be saved.
file_name (str) – Name of the file.
username (str) – Name of user who is measuring data.
delays (ndarray, optional) –
Delays from the delay file. Defaults to None, when there are no delays.
shape: 1D.
pump_pixels (ndarray, optional) –
Pump pixels from the pump pixels file. Defaults to None, when there are no pump pixels.
shape: 1D.
raw_data (bool, optional) – Bool value which specifies whether raw data from adc should be saved. Defaults to False.
-
create_initial_path()[source]¶ Directories in specified path are created. If the directory already exists, a new directory with the same name but appended numbers will be created.
-
save_avg(data: numpy.ndarray, delay_idx: Optional[int] = None, pump_idx: Optional[int] = None, **kwargs)[source]¶ Saves averaged data to binary file
- Parameters
data (ndarray) – Data which should be saved as binary.
delay_idx (int, optional) – Index of delay. Defaults to None.
-
save_counts(data: numpy.ndarray, scan_idx: int, delay_idx: Optional[int] = None, pump_idx: Optional[int] = None, **kwargs)[source]¶ Saves data from single scan to binary file. In this case the data is intended to be the counts (number of samples acquired in each state).
- Parameters
data (ndarray) – Data which should be saved as binary.
scan_idx (int) – Index of scan.
delay_idx (int, optional) – Index of delay. Defaults to None.
pump_idx (int, optional) – Index of pump pixel / frequency. Defaults to None.
kwargs (int, optional) – Can be used to specify arbitrary index which will be appended to name of file. The name/key of the index will preprendend to the value of the index. The value of the index will be padded with a maximum of 3 zeros.
-
save_figures(scan_idx: int)[source]¶ Returns path to save figure for a given scan.
- Parameters
scan_idx (int) – Index of scan.
- Returns
Path including filename for the figure of a given scan.
- Return type
path
-
save_other(data: numpy.ndarray, name: str)[source]¶ Save numpy array (in binary) to main folder with name specified in name variable.
This can be used to save probe wavenumber axis etc.
- Parameters
data (ndarray) – Array that should be saved in main folder of the folder structure.
name (str) – Name that will be prepended to the general file name.
-
save_pump_spectrum(data: numpy.ndarray, scan_idx: int, pump_idx: int)[source]¶ Saves data from single scan to binary file. In this case the data is intended to be the pump spectrum of a Fabry Perot tuned to a given pixel.
Because the delays are looped within each pump frequency the pump spectrum only needs to be saved once for all delays within one scan. They are directly saved into each pump pixel folder. If the order of looping within the experiment ever changes this needs to be reconfigured.
- Parameters
data (ndarray) – Data which should be saved as binary.
scan_idx (int) – Index of scan.
pump_idx (int) – Index of pump pixel / frequency.
-
save_raw_data(data: numpy.ndarray, scan_idx: int, delay_idx: Optional[int] = None, pump_idx: Optional[int] = None, **kwargs)[source]¶ Saves raw data from single scan to binary file.
- Parameters
data (ndarray) – Data which should be saved as binary.
scan_idx (int) – Index of scan.
delay_idx (int, optional) – Index of delay. Defaults to None.
pump_idx (int, optional) – Index of pump pixel / frequency. Defaults to None.
kwargs (int, optional) – Can be used to specify arbitrary index which will be appended to name of file. The name/key of the index will preprendend to the value of the index. The value of the index will be padded with a maximum of 3 zeros.
-
save_readme(text: str, name: str)[source]¶ Save numpy array (in binary) to main folder with name specified in name variable.
This can be used to save probe wavenumber axis etc.
- Parameters
data (ndarray) – Array that should be saved in main folder of the folder structure.
name (str) – Name that will be prepended to the general file name.
-
save_s2s_signal(data: numpy.ndarray, scan_idx: int, delay_idx: Optional[int] = None, pump_idx: Optional[int] = None, **kwargs)[source]¶ Saves data from single scan to binary file. In this case the data is intended to be the shot-to-shot difference signal.
- Parameters
data (ndarray) – Data which should be saved as binary.
scan_idx (int) – Index of scan.
delay_idx (int, optional) – Index of delay. Defaults to None.
pump_idx (int, optional) – Index of pump pixel / frequency. Defaults to None.
kwargs (int, optional) – Can be used to specify arbitrary index which will be appended to name of file. The name/key of the index will preprendend to the value of the index. The value of the index will be padded with a maximum of 3 zeros.
-
save_s2s_std(data: numpy.ndarray, scan_idx: int, delay_idx: Optional[int] = None, pump_idx: Optional[int] = None, **kwargs)[source]¶ Saves data from single scan to binary file. In this case the data is intended to be the standard deviation of the shot-to-shot difference signal.
Note
For correct weighting this data then needs to be transformed into the inverse variances of the shot-to-shot difference signals. For this square data and take inverse.
- Parameters
data (ndarray) – Data which should be saved as binary.
scan_idx (int) – Index of scan.
delay_idx (int, optional) – Index of delay. Defaults to None.
pump_idx (int, optional) – Index of pump pixel / frequency. Defaults to None.
kwargs (int, optional) – Can be used to specify arbitrary index which will be appended to name of file. The name/key of the index will preprendend to the value of the index. The value of the index will be padded with a maximum of 3 zeros.
-
save_scan(data: numpy.ndarray, scan_idx: int, delay_idx: Optional[int] = None, pump_idx: Optional[int] = None, **kwargs)[source]¶ Saves data from single scan to binary file.
- Parameters
data (ndarray) – Data which should be saved as binary.
scan_idx (int) – Index of scan.
delay_idx (int, optional) – Index of delay. Defaults to None.
pump_idx (int, optional) – Index of pump pixel / frequency. Defaults to None.
kwargs (int, optional) – Can be used to specify arbitrary index which will be appended to name of file. The name/key of the index will preprendend to the value of the index. The value of the index will be padded with a maximum of 3 zeros.
-
save_weights(data: numpy.ndarray, scan_idx: int, delay_idx: Optional[int] = None, pump_idx: Optional[int] = None, **kwargs)[source]¶ Saves data from single scan to binary file. In this case the data is intended to be the inverse variance of the transmission for each state. Any other data that should be saved as weights can be used too.
- Parameters
data (ndarray) – Data which should be saved as binary.
scan_idx (int) – Index of scan.
delay_idx (int, optional) – Index of delay. Defaults to None.
pump_idx (int, optional) – Index of pump pixel / frequency. Defaults to None.
kwargs (int, optional) – Can be used to specify arbitrary index which will be appended to name of file. The name/key of the index will preprendend to the value of the index. The value of the index will be padded with a maximum of 3 zeros.