RawDataView¶
class RawDataView(*args, **kwargs)
Bases: MetaView, WalkthroughMixin
Subclass of MetaView for visualizing raw signal data and PSD plots.
Handles plot rendering, signal responses, and interactions with readers, filters, and event finders.
Public Methods¶
- RawDataView.get_current_view() str¶
Abstract method to get the name of the current view.
Subclasses must override this to return the current view name.
- Returns:
The name of the view currently displayed.
- Return type:
- Raises:
NotImplementedError – Always, unless overridden by a subclass.
- RawDataView.get_save_filename() str¶
Open a dialog to save a CSV file.
- Returns:
Selected file path, or an empty string if cancelled.
- Return type:
- RawDataView.get_walkthrough_steps() List[Tuple[str, str, str, Callable[[], QWidget | List[QWidget]]]]¶
Abstract method to retrieve the walkthrough steps for the current view.
Subclasses must override this to return a list of walkthrough steps, each a (title, description, view name, widget getter) tuple.
- Returns:
The ordered walkthrough steps for this view.
- Return type:
List[WalkthroughStep]
- Raises:
NotImplementedError – Always, unless overridden by a subclass.
- RawDataView.handle_parameter_change(submodel_name: str, action_name: str, args: tuple) None¶
Handle parameter changes triggered by RawDataControls and dispatch the corresponding action.
- RawDataView.notify_plugin_state_changed(metaclass: str, plugin_key: str, reason: str) None¶
This tab does not currently react to any plugin_state_changed notifications.
- RawDataView.set_data_filter_function(data_filter: Callable) None¶
Set the callcable function to filter data
- Parameters:
data_filter (Callable) – a callable function
- RawDataView.set_eventfinding_status(status: bool) None¶
Set the current event finding status.
- Parameters:
status (bool) – Whether event finding is complete.
- RawDataView.set_num_events_allowed(num_events: int) None¶
Set the number of events available for display.
- Parameters:
num_events (int) – Maximum valid event index + 1.
- RawDataView.set_psd(Pxx_list: List[ndarray[tuple[int, ...], dtype[float64]]], rms_list: List[ndarray[tuple[int, ...], dtype[float64]]], frequency: ndarray[tuple[int, ...], dtype[float64]] | None, kept_indices: List[int]) None¶
Set the PSD and RMS lists for visualization.
- Parameters:
Pxx_list (List[npt.NDArray[np.float64]]) – Power spectral density data, one array per kept channel.
rms_list (List[npt.NDArray[np.float64]]) – RMS noise data, one array per kept channel.
frequency (Optional[npt.NDArray[np.float64]]) – Frequency axis data, or None if no channel was processed.
kept_indices (List[int]) – Indices into the channel list passed to calculate_psd that were successfully processed, since some channels may have been skipped.
- RawDataView.update_available_plugins(available_plugins: Dict[str, List[str]]) None¶
Called whenever a new plugin is instantiated elsewhere in the app, to keep an up-to-date list of possible data sources for use by this plugin.
- RawDataView.update_channels(channels: Sequence[int]) None¶
Update the channel combo box with available channels.
- Parameters:
channels (Sequence[int]) – Available channel identifiers.
- RawDataView.update_plot(data: Sequence[ndarray[tuple[int, ...], dtype[float64]]], channels: Sequence[int], start: float = 0, baseline: bool = False) None¶
Update the plot area with the provided data across multiple channels in a grid layout.
- Parameters:
data (Sequence[npt.NDArray[np.float64]]) – One array of current samples per channel.
channels (Sequence[int]) – List of channel identifiers corresponding to the data.
start (float) – Time offset added to the plotted time axis, in seconds.
baseline (bool) – If True, overlay baseline mean and standard deviation statistics on each subplot.
- RawDataView.update_plot_data(data: Any | None = None) None¶
Update the stored plot data for future use.
- Parameters:
data (Optional[Any]) – Data dictionary or raw array to store.
- RawDataView.update_plot_samplerate(samplerate: float) None¶
Update the sampling rate used for plotting.
- Parameters:
samplerate (float) – Sampling frequency in Hz.
- RawDataView.update_psd(psd_data: Sequence[ndarray[tuple[int, ...], dtype[float64]]], rms_data: Sequence[ndarray[tuple[int, ...], dtype[float64]]], frequency: ndarray[tuple[int, ...], dtype[float64]], channels: Sequence[int]) None¶
Update the plot area with the provided psd and frequency data across multiple channels in a grid layout.
- Parameters:
psd_data (Sequence[npt.NDArray[np.float64]]) – Power spectral density values, one array for each channel.
rms_data (Sequence[npt.NDArray[np.float64]]) – Integrated RMS noise values corresponding to
psd_data, one array for each channel.frequency (npt.NDArray[np.float64]) – Frequency axis shared across all channels.
channels (Sequence[int]) – List of channel identifiers corresponding to the data.
Private Methods¶
- RawDataView.__init__(*args: Any, **kwargs: Any) None¶
Initialize the MetaTab with a blank plot canvas and a space for controls.
- RawDataView._apply_filter(data_filter: str, channel_data: ndarray[tuple[int, ...], dtype[float64]]) ndarray[tuple[int, ...], dtype[float64]]¶
Apply a data filter using a signal-based plugin system.
- Parameters:
data_filter (str) – Name of the filter plugin.
channel_data (npt.NDArray[np.float64]) – Data to filter.
- Returns:
Filtered data if successful, else the original data.
- Return type:
npt.NDArray[np.float64]
- RawDataView._extract_commit_event_parameters(parameters: Dict[str, Any]) Tuple[str | None, List[int]]¶
Extract writer and channels from parameters.
- RawDataView._extract_event_parameters(parameters: Dict[str, Any]) Tuple[str | None, str | None, List[int]]¶
Extract parameters used for event finding.
- RawDataView._extract_plot_event_parameters(parameters: Dict[str, Any]) Tuple[str | None, str | None, List[int], List[int] | None]¶
Extract event plotting parameters from input.
- RawDataView._extract_plot_parameters(parameters: Dict[str, Any]) Tuple[str | None, List[int], float, float]¶
Extract reader, channel, start time, and length from parameters.
- RawDataView._factors(n: int) Tuple[int, int]¶
Determine the factor pair (rows, cols) closest to a square layout.
- RawDataView._gaussian(x: float, A: float, m: float, s: float) float¶
Calculate the value of a 1D gaussian distribution at a location x with the given paramters
- RawDataView._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.
- RawDataView._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.
- RawDataView._get_event_index_text() str¶
Get the event index input from the UI.
- Returns:
The current text from the event index input field.
- Return type:
- RawDataView._handle_commit_events(parameters: Dict[str, Any]) None¶
Handle committing of found events to the selected writer plugin.
- Parameters:
parameters (Dict[str, Any]) – Dictionary containing writer and channels.
- RawDataView._handle_find_events(parameters: Dict[str, Any]) None¶
Handle the initiation of the event finding process using the given parameters.
- Parameters:
parameters (Dict[str, Any]) – Dictionary containing eventfinder, filter, and channels.
- RawDataView._handle_load_data_and_update_plot(parameters: Dict[str, Any], baseline: bool = False) None¶
Handle data loading and update the main signal plot.
This method: - Extracts plot parameters (reader, channels, start, length) - Loads data using the specified reader for each channel - Optionally applies a filter to the data - Updates the main plot area with the retrieved data
- RawDataView._handle_load_data_and_update_psd(parameters: Dict[str, Any]) None¶
Handle data loading and update the PSD (Power Spectral Density) plot.
This method extracts plotting parameters, loads data from the reader, optionally applies a filter, emits the signal to calculate PSD, and updates the PSD plot.
- Parameters:
parameters (Dict[str, Any]) – Dictionary containing reader, channels, start time, length, and optional filter.
- RawDataView._handle_other_actions(action_name: str, parameters: Dict[str, Any]) None¶
Handle plugin-specific actions not otherwise accounted for.
- RawDataView._handle_plot_events(parameters: Dict[str, Any]) None¶
Handle loading and plotting of selected events based on provided parameters.
- RawDataView._handle_timer(parameters: Dict[str, Any]) None¶
Open a time range selection dialog for a given event finder and update the internal time limits.
- Parameters:
parameters (Dict[str, Any]) – Dictionary containing the ‘eventfinder’ key.
- RawDataView._load_data(reader: str | None, channels: int | List[int], start: float, length: float) None¶
Load data from the specified reader plugin.
- RawDataView._load_event_data(eventfinder: str | None, channel: int, event: int, data_filter: Callable | None) None¶
Load data for a single event from the eventfinder.
- RawDataView._reset_actions(axis_type: str = '2d') None¶
Clears the figure and reinitializes axes. This will also add a flag to the tab action history if @register_action is being used to keep track of actions. Only actions applied after the most recent call to this function will be recreated if the related file is loaded.
- Parameters:
axis_type (str) – Either ‘2d’ or ‘3d’ to determine plot projection.
- RawDataView._set_control_area(layout: QBoxLayout) None¶
Set up the control area layout by embedding the RawDataControls widget.
- Parameters:
layout (QBoxLayout) – The layout where controls will be added.
- RawDataView._shift_range_and_update_plot(parameters: Dict[str, Any], direction: str) None¶
Shift selected event index ranges left or right and update the plot accordingly.
- RawDataView._shift_range_and_update_trace(parameters: Dict[str, Any], direction: str) None¶
Shift numeric range left or right and update the plot and GUI input.
- RawDataView._start_eventfinder(eventfinder: str, data_filter: str, channels: int | List[int]) None¶
Start the event finding operation on the specified channels with an optional filter.
- Parameters:
- Raises:
Exception – If setting up the data filter fails.
- RawDataView._start_writer(writer: str, channels: int | List[int]) None¶
Start a writer plugin to commit events for the specified channels.
- RawDataView._update_event_plot(event_data: Sequence[ndarray[tuple[int, ...], dtype[float64]]], event_indices: Sequence[int]) None¶
Plot the event data in a grid that gets as close to square as possible
- Parameters:
event_data (Sequence[npt.NDArray[np.float64]]) – a list of event data to plot in a grid
event_indices (Sequence[int]) – the indices of the events to plot