RawDataModel¶
class RawDataModel(**kwargs)
Bases: MetaModel
Subclass of MetaModel for processing raw signal data.
Includes methods to compute PSDs and integrate noise.
Public Methods¶
- RawDataModel.calculate_psd(psd_data: list, samplerate: float) tuple[list, list, ndarray | None, list[int]]¶
Calculate a psd for each dataset in the list, assuming a common samplerate
- Parameters:
- Returns:
Pxx_list, rms_list, the frequency axis, and the indices into
psd_datathat were successfully processed. A channel is skipped (and its index omitted) if it has too few samples, ifwelch()fails, or if the resulting frequency axis is too short to integrate noise over.- Return type:
- RawDataModel.gaussian_fit(histogram: ndarray[tuple[int, ...], dtype[float64]], bins: ndarray[tuple[int, ...], dtype[float64]], mean_guess: float, stdev_guess: float) tuple[float, float, float]¶
Fit a Gaussian function to histogram data using a linearized least squares approach.
- Parameters:
- Returns:
Tuple containing (amplitude, mean, standard deviation) of the fitted Gaussian.
- Return type:
- Raises:
ValueError – If standard deviation guess is invalid or the fit fails.
- RawDataModel.get_baseline_stats(data: ndarray[tuple[int, ...], dtype[float64]]) ndarray[tuple[int, ...], dtype[float64]]¶
Get the local amplitude, mean, and standard deviation for a chunk of data. Assumes data is rectified.
- Parameters:
data (npt.NDArray[np.float64]) – Chunk of timeseries data to compute statistics on.
- Returns:
Array of local amplitude, mean, and standard deviation, in that order.
- Return type:
npt.NDArray[np.float64]
- Raises:
ValueError – If a baseline histogram width cannot be estimated for this chunk (no variation in the data), or if the underlying Gaussian fit fails.
- RawDataModel.integrate_noise(f: ndarray[tuple[int, ...], dtype[floating]], Pxx: ndarray[tuple[int, ...], dtype[floating]]) ndarray[tuple[int, ...], dtype[floating]]¶
Compute the integrated noise from a power spectral density.
This method integrates the power spectral density (PSD) over frequency to obtain the cumulative root-mean-square (RMS) noise as a function of frequency. It assumes evenly spaced frequency bins.
- Parameters:
f (npt.NDArray[np.floating]) – Array of frequency values (Hz), evenly spaced.
Pxx (npt.NDArray[np.floating]) – Power spectral density values corresponding to f.
- Returns:
Array of integrated RMS noise values for each frequency point.
- Return type:
npt.NDArray[np.floating]
Private Methods¶
- RawDataModel._init() None¶
Perform additional initialization specific to the algorithm being implemented. Must be implemented by subclasses.
This function is called at the end of the class constructor to perform additional initialization specific to the algorithm being implemented. kwargs provided to the base class constructor are available as class attributes.