cherab.nagdis.experiment.ConditionalAverage

class cherab.nagdis.experiment.ConditionalAverage(path: Path | str, dt: int)Source

Bases: object

Class to perform conditional average of dataset.

Parameters:
path: Path | str

Path to the dataset.

dt: int

Time range to perform the conditional average (\(\pm\Delta t\) around the peaked time). The unit is in microseconds [µs].

Methods

average(peak_time[, time_eps])

Average the dataset.

average_per_tau(peak_times, d_tau[, tau_eps])

Average the dataset per tau.

create_images(ds[, time_name])

Create images from the dataset.

create_t_y_contour(ds[, time_name])

Create t-y contour from the dataset.

get_peaks_time([signal, height, prominence])

Get time of peaks in the dataset.

get_peaks_time(signal: str = 'I_sat', height: ArrayLike | None = 2.5, prominence: float | None = None) ndarraySource

Get time of peaks in the dataset.

Parameters:
signal: str = 'I_sat'

Signal to find peaks.

height: ArrayLike | None = 2.5

Factor of standard deviation to set the height of peaks, by default 2.5. If a float, the height is set to mean + height * std. If an array_like with two elements, the height is set to (mean + height[0] * std, mean + height[1] * std). Otherwise, raise ValueError.

prominence: float | None = None

Required prominence of peaks, by default the standard deviation of the signal.

Returns:

numpy.ndarray – Time of peaks in microseconds [µs].

Raises:

ValueError – If height is not a float, tuple of two floats, or None.

average_per_tau(peak_times: ArrayLike, d_tau: int, tau_eps: float | None = None) DatasetSource

Average the dataset per tau.

Average the data \(f(t)\) like:

\[ \begin{align}\begin{aligned}f_\mathrm{avg}(\tau) = \frac{1}{|T(\tau)|}\sum_{t \in T(\tau)} f(t),\\\begin{split}T(\tau) \equiv \left\{ t' \in T_\mathrm{video} \middle | \begin{gathered} t' = t_\mathrm{peak} + \tau\\ t_\mathrm{peak} \in T_\mathrm{peak} \end{gathered} \right\},\end{split}\end{aligned}\end{align} \]

where \(\tau \in \{-\Delta t, -\Delta t + \Delta \tau, \ldots, \Delta t\}\), \(T_\mathrm{peak}\) is the set of peak times from the waveform signal, and \(T_\mathrm{video}\) is the set of video times. This function enables to enhance the \(\tau\) resolution even if the frequency of the video dataset is lower than the signal dataset.

Parameters:
peak_times: ArrayLike

Set of peak times \(T_\mathrm{peak}\).

d_tau: int

Time interval of tau \(\Delta \tau\), in microseconds [µs].

tau_eps: float | None = None

Tolerance of video dataset time to match with signal dataset time, by default d_tau * 0.5.

Returns:

xarray.Dataset – Conditional Averaged dataset.

average(peak_time, time_eps: float | None = None) DatasetSource

Average the dataset.

Average the data \(f(t)\) like:

\[ \begin{align}\begin{aligned}f_\mathrm{avg}(\tau) &= \frac{1}{|T|}\sum_{t \in T} f(t + \tau),\\T &\equiv \{t' \mid t'\in T_\mathrm{peak}\cap T_\mathrm{video}\},\end{aligned}\end{align} \]

where \(\tau \in [-\Delta t, \Delta t]\), \(T_\mathrm{peak}\) is the set of peak times from the waveform signal, and \(T_\mathrm{video}\) is the set of video times.

Parameters:
peak_time

Set of peak times \(T_\mathrm{peak}\).

time_eps: float | None = None

Tolerance of peak time corresponding video time, by default the half of the time step of the signal dataset.

Returns:

xarray.Dataset – Conditional Averaged dataset.

static create_images(ds: Dataset, time_name: str = 'tau') DataArraySource

Create images from the dataset.

This function is a proxy for the create_images function in the utils module.

Parameters:
ds: Dataset

Dataset to create images.

time_name: str = 'tau'

Name of time dimension, by default “tau”.

Returns:

xarray.DataArray – DataArray of images.

static create_t_y_contour(ds: Dataset, time_name: str = 'tau') DataArraySource

Create t-y contour from the dataset.

Parameters:
ds: Dataset

Dataset to create time-axis and y-axis contour.

time_name: str = 'tau'

Name of time dimension, by default “tau”.

Returns:

xarray.DataArray\(t-y\) contour DataArray.