View¶
- class sofia_redux.visualization.display.view.View(signals: Signals)[source]¶
Bases:
QMainWindow
,Ui_MainWindow
Interactively display data.
The View class holds data models and displays and handles user interaction events.
- Parameters:
- signalssofia_redux.visualization.signals.Signals
Custom signals recognized by the Eye interface, used to trigger callbacks from user events.
- Attributes:
- stalebool
Flag to indicate that view is stale and should be refreshed.
- stale_background_fullbool
Flag to indicate that plot backgrounds and axis limits are stale and should be refreshed.
- stale_background_partialbool
Flag to indicate that plot backgrounds are stale and should be refreshed, but axis scales remain the same.
- figuresofia_redux.visualization.display.figure.Figure
The main plot display associated with the View.
- signalssofia_redux.visualization.signals.Signals
Custom signals recognized by the Eye interface, used to trigger callbacks from user events.
- ciddict
Matplotlib event CIDs.
- model_collectionlist of HighModel
Loaded data models, available for display.
- timerQtCore.QTimer
Refresh loop timer.
- fit_resultsfitting_results.FittingResults
Dialog window for table display of fit parameters.
- cursor_location_windowcursor_location.CursorLocation
Dialog window for table display of fit parameters.
Methods Summary
add_filename
(model_id, filename)Add a file that has been read in to the model collection.
Add a new order.
add_pane
()Add a new pane.
add_panes
(n_panes, kind[, layout])Add new plot panes.
Update the order selector.
Set selection for all files in the filename table.
Handle a change to the all panes check box.
assign_models
(mode, models, indices)Assign models to panes.
atrophy
()Mark the view as stale.
Mark the figure background as stale.
Mark the figure background as partially stale.
Mark the control panel as stale.
Change the axis field displayed.
Change axis limits.
Change axis scales.
Change axis units.
clear_cids
([target])Disconnect matplotlib event callbacks.
Clear fit overlay artists.
Clear all guide artists.
Reset selection mode.
close
()Close the view window.
Close the cursor position display window.
current_cursor_location
(event)Update the cursor location displays.
Retrieve all files currently selected in the file list.
Set a new pane as the active pane.
decode_orders
(orders)Parse the text from an order selector.
Disable all orders.
display_model
(model[, pane_])Display a model in a plot pane.
Enable all loaded models from the pane list widget.
Enable all orders.
Enable cursor position displays.
enable_model
(item)Enable a model from the pane list.
End a zoom or fit interaction.
figure_clicked
(event)Select a pane by mouse click.
Handle a change in the filename order selector.
Set selection for a cell in the filename table.
format_orders_pairs
(orders)Format a list of orders selection display.
get_fields
(panes)Get the fields associated with a given pane selection.
get_orders
(panes)Get the orders associated with a given pane selection.
get_scales
(panes)Get the axes scales associated with a given pane selection.
get_units
(panes)Get the units associated with a given pane selection.
Disconnect atrophy signals.
keyPressEvent
(event)Handle keyboard shortcuts.
leave_axes
(event)Reset cursor labels when the mouse leaves a plot.
merge_dicts
(dol1, dol2)Merge two dictionaries.
model_backup
(models)Obtain the backup model.
Retrieve the number of models in each pane.
Disable selected orders.
Handle a change in order selection.
open_eye
()Open the view window and start the refresh timer.
View the fitting results.
View reference line data
Retrieve the current number of panes.
Retrieve the current pane layout.
Handle a change to the pane selector.
Pop out a cursor position display window.
populate_order_selectors
([set_current_pane])Populate order selectors for currently loaded data.
Print current artists.
Refresh all control widgets.
Refresh the file list from currently loaded data.
Refresh the view.
Reconnect atrophy signals.
remove_data_from_all_panes
(model_id)Remove loaded data from the view.
Handle a file removal request.
remove_model_id
(model_id)Remove a file from the list.
Remove an order.
Remove current selected pane.
remove_panes
(panes)Remove specified panes.
reset
()Remove all loaded models and panes.
Reset axis limits to full range.
save
(filename, **kwargs)Save the current figure to a file.
select_color_cycle
(text)Select the color cycle for the plot.
select_pane
(item)Select a pane as current from the pane list widget.
select_plot_type
(text)Select the plot type.
Parse the state of the axis selection widget.
set_current_pane
(pane_index)Set the current pane.
Set a new axis field from the control widget.
set_fields
(fields, panes)Set new axis fields from the API.
Set axis limits from the widget controls.
set_orders
(orders)Enable specified orders.
Set an axis scale from the widget controls.
set_scales
(scales, panes)Set the axis scale for specified panes.
set_unit
()Set a new unit from the widget controls.
set_units
(units, panes)Change the axis unit for specified panes.
setup_axis_limits
([panes, target])Set up axis limit text boxes based on loaded data.
setup_initial_scales
([panes, target])Set up plot scale selectors based on loaded data.
setup_overplot_flag
([panes])Set up overplot display flags.
setup_property_selectors
([panes, target])Set up plot field selectors based on loaded data.
setup_unit_selectors
([panes, target])Set up plot unit selectors based on loaded data.
start_selection
(mode)Start a user range selection, for zoom or fit.
Toggle analysis panel visibility.
Toggle axis panel visibility.
Toggle control panel visibility.
Toggle cursor panel visibility.
toggle_dark_mode
(state)Set a dark background in all panes.
toggle_error
(state)Set the error range visibility in all panes.
Toggle file panel visibility.
Show or hide fit parameters
toggle_grid
(state)Set the grid visibility in all panes.
toggle_markers
(state)Set the marker visibility in all panes.
Toggle order panel visibility.
Enable or disable overplots for panes.
Toggle plot panel visibility.
Unload the reference data model.
Update control widgets in the Axis section from loaded data.
Update the reference data model.
Methods Documentation
- add_filename(model_id: IDT, filename: str) None [source]¶
Add a file that has been read in to the model collection.
Logs a warning if file is already in the loaded list.
- Parameters:
- model_id: str, uuid.UUID
Unique ID for model.
- filenamestr
Name of the file that was added to models.
- add_panes(n_panes: int, kind: List[str], layout: str | None = 'grid') None [source]¶
Add new plot panes.
- Parameters:
- n_panesint
The number of panes to add.
- kind{‘spectrum’, ‘onedim’, ‘image’, ‘twodim’}
The kind of pane to add.
- layout{‘grid’, ‘rows’, ‘columns’}, optional
The layout method for the new panes.
- assign_models(mode: str, models: Dict[str, MT], indices: List[int]) None [source]¶
Assign models to panes.
- Parameters:
- mode{‘split’, ‘first’, ‘last’, assigned’}
Specifies how to arrange the models on the panes. ‘Split’ divides the models as evenly as possible across all present panes. ‘First’ assigns all the models to the first pane, while ‘last’ assigns all the models to the last pane. ‘Assigned’ attaches each model to the pane index provided in
indices
.- modelsdict
Dictionary of models to add. Keys are the model ID, with the values being the models themselves.
- indiceslist of int
A list of integers with the same length of
models
. Only used forassigned
mode. Specifies the index of the desired pane for the model.
- Raises:
- RuntimeError
If an invalid mode is provided.
- clear_cids(target: str | None = None) None [source]¶
Disconnect matplotlib event callbacks.
- Parameters:
- targetstr, optional
Event name associated with the CID to clear. If not provided, all CIDs will be cleared.
- current_cursor_location(event: Event) None [source]¶
Update the cursor location displays.
- Parameters:
- eventQEvent
Keypress event.
- current_files_selected() List[str] | None [source]¶
Retrieve all files currently selected in the file list.
- Returns:
- filenameslist of str or None
The selected filenames. If no files are selected, None is returned.
- decode_orders(orders: str) Dict [source]¶
Parse the text from an order selector.
- Parameters:
- ordersstr
Comma-separated list of order ranges. A ‘*’ indicates all orders; a ‘-’ indicates none.
- Returns:
- dict
Keys are model_ids and values are lists of index numbers.
- display_model(model: MT, pane_: PT | None = None) None [source]¶
Display a model in a plot pane.
- Parameters:
- modelhigh_model.HighModel
The model to display.
- pane_pane.Pane, optional
The pane to display to. If not provided, the current pane will be used.
- enable_model(item: None) None [source]¶
Enable a model from the pane list.
- Parameters:
- itemQtWidgets.QTreeWidgetItem
The model item associated with the model. Should have pane_id and model_id stored as data, under the UserRole tag.
- figure_clicked(event: Event) None [source]¶
Select a pane by mouse click.
- Parameters:
- eventmatplotlib.backend_bases.Event
Mouse click event.
- static format_orders_pairs(orders)[source]¶
Format a list of orders selection display.
- Parameters:
- orderslist of int
Order list to format
- Returns:
- str
String representation summarizing the list of orders.
- get_fields(panes: PaneID) List [source]¶
Get the fields associated with a given pane selection.
- Parameters:
- panesstr, None, or list of int
May be set to ‘all’ to apply to all panes, None to apply only to the current pane, or a list of pane indices to modify.
- Returns:
- fieldslist
List of fields for corresponding to pane selection provided.
- get_orders(panes: PaneID) Dict[int, Dict] [source]¶
Get the orders associated with a given pane selection.
- Parameters:
- panesstr, None, or list of int
May be set to ‘all’ to apply to all panes, None to apply only to the current pane, or a list of pane indices to modify.
- Returns:
- ordersdict
Dictionary of orders for corresponding to pane selection provided. Keys are the indices of the panes.
- get_scales(panes: PaneID) List [source]¶
Get the axes scales associated with a given pane selection.
- Parameters:
- panesstr, None, or list of int
May be set to ‘all’ to apply to all panes, None to apply only to the current pane, or a list of pane indices to modify.
- Returns:
- scaleslist
List of axes scales for corresponding to pane selection provided.
- get_units(panes: PaneID) List [source]¶
Get the units associated with a given pane selection.
- Parameters:
- panesstr, None, or list of int
May be set to ‘all’ to apply to all panes, None to apply only to the current pane, or a list of pane indices to modify.
- Returns:
- unitslist
List of units for corresponding to pane selection provided.
- keyPressEvent(event: Event) None [source]¶
Handle keyboard shortcuts.
- Parameters:
- eventQEvent
Keypress event.
- leave_axes(event: Event | None) None [source]¶
Reset cursor labels when the mouse leaves a plot.
- Parameters:
- eventmatplotlib.backend_bases.Event
Mouse motion event.
- static merge_dicts(dol1, dol2)[source]¶
Merge two dictionaries.
- Parameters:
- dol1dict
First dictionary.
- dol2dict
Second dictionary.
- Returns:
- dict
Merged dictionary.
- model_backup(models: Dict[IDT, MT])[source]¶
Obtain the backup model.
- Parameters:
- modelshigh_model.HighModel
The model for which we want to obtain its backup copy.
- models_per_pane() List[int] [source]¶
Retrieve the number of models in each pane.
- Returns:
- countlist of int
The number of models in each existing pane.
- pane_layout() None | Tuple[int, int] [source]¶
Retrieve the current pane layout.
- Returns:
- geometrytuple of int, or None
If there is an active layout, (nrow, ncol) is returned. Otherwise, None.
- populate_order_selectors(set_current_pane: bool | None = False)[source]¶
Populate order selectors for currently loaded data.
- Parameters:
- set_current_panebool, optional
- If set, the current index of the selector will be set to
current pane after populating.
- remove_data_from_all_panes(model_id: str) None [source]¶
Remove loaded data from the view.
- Parameters:
- model_idstr
The Unique id for the file to remove.
- remove_model_id(model_id: str) None [source]¶
Remove a file from the list.
- Parameters:
- model_idstr
ID of the model to remove.
- remove_panes(panes: str | List[int]) None [source]¶
Remove specified panes.
- Parameters:
- panesstr or list of int
If ‘all’, all panes will be removed. Otherwise, specify a list of pane indices to remove.
- save(filename: str, **kwargs) None [source]¶
Save the current figure to a file.
- Parameters:
- filenamestr
Full file path to save the image to.
- kwargsdict, optional
Additional keyword arguments to pass to
matplotlib.figure.Figure.savefig
.
- select_color_cycle(text: str) None [source]¶
Select the color cycle for the plot.
- Parameters:
- text{‘spectral’, ‘tableau’, ‘accessible’}
Color cycle to set.
- select_pane(item: None) None [source]¶
Select a pane as current from the pane list widget.
- Parameters:
- itemQtWidgets.QTreeWidgetItem
The pane item selected from the tree widget. Should have the pane index stored as data, under the UserRole tag.
- select_plot_type(text: str) None [source]¶
Select the plot type.
- Parameters:
- text{‘line’, ‘step’, ‘scatter’}
The plot type to set.
- selected_target_axis() Dict[str, str] [source]¶
Parse the state of the axis selection widget.
- Returns:
- targetdict
Keys are ‘axis’ or ‘pane’; values can be str, int or list.
- set_current_pane(pane_index: List[int] | int) None [source]¶
Set the current pane.
- Parameters:
- pane_indexint or list of int
The panes to activate.
- set_fields(fields: Dict[str, str], panes: PaneID) None [source]¶
Set new axis fields from the API.
- Parameters:
- fieldsdict
Should contain axis name keys (‘x’, ‘y’), specifying the field strings as values.
- panesstr, None, or list of int, optional
May be set to ‘all’ to apply to all panes, None to apply only to the current pane, or a list of pane indexes to modify.
- set_orders(orders: Dict[int, Dict]) None [source]¶
Enable specified orders.
- Parameters:
- ordersdict
Keys are indices for the panes to update. Values are dicts, with model ID keys, order list values.
- set_scales(scales: Dict[str, str], panes: PaneID) None [source]¶
Set the axis scale for specified panes.
- Parameters:
- scalesdict
Keys are ‘x’, ‘y’. Values are ‘linear’ or ‘log’.
- panesstr, None, or list of int
May be set to ‘all’ to apply to all panes, None to apply only to the current pane, or a list of
- set_units(units: Dict[str, str], panes: PaneID) None [source]¶
Change the axis unit for specified panes.
If incompatible units are specified, the current units are left unchanged.
- Parameters:
- unitsdict
Keys are ‘x’, ‘y’. Values are the units to convert to.
- panesstr, None, or list of int
May be set to ‘all’ to apply to all panes, None to apply only to the current pane, or a list of
- setup_axis_limits(panes: List[PT] | PT | None = None, target: Dict | None = None) None [source]¶
Set up axis limit text boxes based on loaded data.
- Parameters:
- panespane.Pane or list of pane.Pane, optional
The panes containing loaded data. If not provided apply to the current pane.
- targetDict, optional
Keys are
axis
,pane
and values can be str, int or list
- setup_initial_scales(panes: List[PT] | PT | None = None, target: Dict | None = None) None [source]¶
Set up plot scale selectors based on loaded data.
- Parameters:
- panespane.Pane or list of pane.Pane, optional
The pane containing loaded data. If not provided, apply to the current pane.
- targetDict, optional
Keys are
axis
,pane
and values can be str, int or list
- setup_overplot_flag(panes: List[PT] | PT | None = None) None [source]¶
Set up overplot display flags.
- Parameters:
- panespane.Pane or list of pane.Pane, optional
The panes containing loaded data. If not provided, apply to the current pane.
- setup_property_selectors(panes: List[PT] | PT | None = None, target: Dict | None = None) None [source]¶
Set up plot field selectors based on loaded data.
- Parameters:
- panespane.Pane or list of pane.Pane, optional
The panes containing loaded data. If not provided, apply to the current pane.
- targetdict, optional
Keys are
axis
,pane
and values can be str, int or list.
- setup_unit_selectors(panes: List[PT] | PT | None = None, target: Dict | None = None) None [source]¶
Set up plot unit selectors based on loaded data.
- Parameters:
- panespane.Pane or list of pane.Pane, optional
The panes containing loaded data. If not provided, apply to the current pane.
- targetDict, optional
Keys are
axis
,pane
and values can be str, int or list
- start_selection(mode: str) None [source]¶
Start a user range selection, for zoom or fit.
- Parameters:
- mode{‘x_zoom’, ‘y_zoom’, ‘b_zoom’, ‘fit’}
The mode to start.
- toggle_dark_mode(state: bool) None [source]¶
Set a dark background in all panes.
- Parameters:
- state: bool
If True, dark mode will be enabled. If False, it will be disabled.
- toggle_error(state: bool) None [source]¶
Set the error range visibility in all panes.
- Parameters:
- state: bool
If True, error ranges will be shown. If False, they will be hidden.
- toggle_grid(state: bool) None [source]¶
Set the grid visibility in all panes.
- Parameters:
- state: bool
If True, gridlines will be shown. If False, they will be hidden.