measurement¶
The core data class of pleasant.
- class pleasant.measurement.Measurement(count_rate, exc_freq, timestamp=None, description=None, scan_duration=nan, break_duration=nan)¶
PLE measurement data.
A Measurement represents a sequence of subsequent resonant absorption scans. The scanned excitation frequencies are assumed to be the same for each scan. Scans in different directions (sometimes referred to as trace and retrace) are supposed to be treated as individual measurements. Single scans are also supported.
- property bin_count: int¶
Number of bins a scan is divided into.
- property bin_width: float¶
Frequency range that a single bin spans (in Hz).
- fit_scans(model_name='Lorentzian', fwhm_guess=50000000.0)¶
Fit all scans with a peak-like model.
- Parameters:
model_name (
str) – name of the model to use for fitting, can be Lorentzian, Gaussian, Pseudo Voigt and Voigt.fwhm_guess (
float) – initial value to use for the FWHM
- Raises:
AssertionError – for unknown fitting model name
- Return type:
None
- fit_sum_of_scans(scan_index_range=None)¶
Sum up the counts of all scans and fit the result with a Gaussian function.
A custom range may be specified.
- Parameters:
scan_index_range (
Optional[tuple[int,int]]) – scans to sum up- Raises:
AssertionError – if scan_duration is NaN
- Return type:
ModelResult- Returns:
fit result
- property freq_range: float¶
Scanned frequency range in Hz.
- peak_window_filter(min_snr=3, window=10)¶
Create a mask based on counts in a window around the maximum.
The mask is created by averaging the count rate in a window around the global maximum and comparing it to the overall average count rate.
- Parameters:
min_snr (
int) – threshold value for how many times the count rate in the peak window should exceed the averagewindow (
int) – size of the window around the peak in number of samples
- Return type:
ndarray- Returns:
mask array
- photon_count_filter(threshold)¶
Create a mask depending on a very simple photon count filtering condition.
The mask is used when scans are fitted later. If a scan contains a single bin in which at least as many counts were registered as the threshold, it passes the filter.
- Parameters:
threshold (
int) – minimum counts in a bin to pass the filter- Raises:
AssertionError – if scan_duration is NaN
- Return type:
ndarray- Returns:
mask array
- plot_individual_scan(i, freq_range=None, fit_eval_density=1)¶
Plot an individual scan.
The fit is included if it was performed before.
- Parameters:
i (
int) – Scan index to plot.freq_range (
Optional[float]) – If specified, trim the plot to this range (in Hz) around the fitted center frequency.fit_eval_density (
int) – factor to increase fit smoothness by evaluation at more data points
- Return type:
Figure- Returns:
matplotlib figure object
- plot_sum_of_scans(x_lim=None, scan_index_range=None)¶
Plot the count rates as a 2D image.
Sum up the counts of all scans and fit them with a Gaussian function.
- Parameters:
x_lim (
Optional[tuple[float,float]]) – limits for the x-axisscan_index_range (
Optional[tuple[int,int]]) – scans to sum up and display
- Raises:
AssertionError – if measurement contains less than two scans
- Return type:
Figure- Returns:
matplotlib figure object
- print_info()¶
Print information on this measurement.
- Return type:
None
- rebin(bins_to_merge, verbose=False)¶
Rebin specifying the number of bins to merge.
Rebin the count rate matrix and the frequency vector to a lower resolution than the original, increasing the bin width. If necessary, bins at the high frequency end will be trimmed. All previously performed fits and masks will be deleted.
- Parameters:
bins_to_merge (
int) – Number of bins to merge and average over. Factor that the bin count is reduced by.verbose (
bool) – print information about rebinning process
- Return type:
None
- rebin_data(bins_to_merge=None, target_bin_width=None, verbose=False)¶
Rebin with flexible goal specification.
Rebin the count rate matrix and the frequency vector to a lower resolution than the original, increasing the bin width. You can specify either a number of bins to merge or a target bin width. If necessary, bins at the high frequency end will be trimmed. All previously performed fits and masks will be deleted.
- Parameters:
bins_to_merge (
Optional[int]) – Number of bins to merge and average over. Factor that the bin count is reduced by.target_bin_width (
Optional[float]) – Target bin width in Hz.verbose (
bool) – print information about rebinning process A number of bins to merge will be calculated from this value.
- Raises:
AssertionError – if no keyword argument is given
- Return type:
None
- rebin_to_width(target_bin_width, verbose=False)¶
Rebin to a target bin width.
Rebin the count rate matrix and the frequency vector to achieve a new bin width as close as possible to target_bin_width.
- Parameters:
target_bin_width (
float) – Target bin width in Hz.verbose (
bool) – print information about rebinning process
- Return type:
None
- property scan_count: int¶
Number of scans performed for this measurement.
- property scan_direction: int¶
Get direction of scan.
Returns +1 or -1 depending on whether the scan is performed towards positive or negative frequency direction.
- property scan_fit_data: DataFrame¶
Scan fit data as a pandas data frame. Rows correspond to individual scans.
- property scan_speed: float¶
Scan speed in Hz/s.