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_order()

Add a new order.

add_pane()

Add a new pane.

add_panes(n_panes, kind[, layout])

Add new plot panes.

all_filenames_checking()

Update the order selector.

all_filenames_selection_changed()

Set selection for all files in the filename table.

all_panes_checking()

Handle a change to the all panes check box.

assign_models(mode, models, indices)

Assign models to panes.

atrophy()

Mark the view as stale.

atrophy_background_full()

Mark the figure background as stale.

atrophy_background_partial()

Mark the figure background as partially stale.

atrophy_controls()

Mark the control panel as stale.

axis_field_changed()

Change the axis field displayed.

axis_limits_changed()

Change axis limits.

axis_scale_changed()

Change axis scales.

axis_unit_changed()

Change axis units.

clear_cids([target])

Disconnect matplotlib event callbacks.

clear_fit()

Clear fit overlay artists.

clear_guides()

Clear all guide artists.

clear_selection()

Reset selection mode.

close()

Close the view window.

closed_cursor_popout()

Close the cursor position display window.

current_cursor_location(event)

Update the cursor location displays.

current_files_selected()

Retrieve all files currently selected in the file list.

current_pane_changed()

Set a new pane as the active pane.

decode_orders(orders)

Parse the text from an order selector.

disable_all_orders()

Disable all orders.

display_model(model[, pane_])

Display a model in a plot pane.

enable_all_models()

Enable all loaded models from the pane list widget.

enable_all_orders()

Enable all orders.

enable_cursor_position()

Enable cursor position displays.

enable_model(item)

Enable a model from the pane list.

end_selection()

End a zoom or fit interaction.

figure_clicked(event)

Select a pane by mouse click.

filename_order_selector_changed()

Handle a change in the filename order selector.

filename_table_selection_changed()

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.

hold_atrophy()

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.

models_per_pane()

Retrieve the number of models in each pane.

off_orders_changed()

Disable selected orders.

on_orders_changed()

Handle a change in order selection.

open_eye()

Open the view window and start the refresh timer.

open_fits_results()

View the fitting results.

open_ref_data()

View reference line data

pane_count()

Retrieve the current number of panes.

pane_layout()

Retrieve the current pane layout.

pane_order_selector_changed()

Handle a change to the pane selector.

popout_cursor_position()

Pop out a cursor position display window.

populate_order_selectors([set_current_pane])

Populate order selectors for currently loaded data.

print_current_artists()

Print current artists.

refresh_controls()

Refresh all control widgets.

refresh_file_table()

Refresh the file list from currently loaded data.

refresh_loop()

Refresh the view.

release_atrophy()

Reconnect atrophy signals.

remove_data_from_all_panes(model_id)

Remove loaded data from the view.

remove_file_from_pane()

Handle a file removal request.

remove_model_id(model_id)

Remove a file from the list.

remove_order()

Remove an order.

remove_pane()

Remove current selected pane.

remove_panes(panes)

Remove specified panes.

reset()

Remove all loaded models and panes.

reset_zoom()

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.

selected_target_axis()

Parse the state of the axis selection widget.

set_current_pane(pane_index)

Set the current pane.

set_field()

Set a new axis field from the control widget.

set_fields(fields, panes)

Set new axis fields from the API.

set_limits()

Set axis limits from the widget controls.

set_orders(orders)

Enable specified orders.

set_scale()

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()

Toggle analysis panel visibility.

toggle_axis_panel()

Toggle axis panel visibility.

toggle_controls()

Toggle control panel visibility.

toggle_cursor()

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()

Toggle file panel visibility.

toggle_fit_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()

Toggle order panel visibility.

toggle_overplot()

Enable or disable overplots for panes.

toggle_plot_panel()

Toggle plot panel visibility.

unload_reference_model()

Unload the reference data model.

update_controls()

Update control widgets in the Axis section from loaded data.

update_reference_lines()

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_order() None[source]

Add a new order.

add_pane() None[source]

Add a new pane.

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.

all_filenames_checking()[source]

Update the order selector.

all_filenames_selection_changed()[source]

Set selection for all files in the filename table.

all_panes_checking()[source]

Handle a change to the all panes check box.

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 for assigned mode. Specifies the index of the desired pane for the model.

Raises:
RuntimeError

If an invalid mode is provided.

atrophy() None[source]

Mark the view as stale.

atrophy_background_full() None[source]

Mark the figure background as stale.

atrophy_background_partial() None[source]

Mark the figure background as partially stale.

atrophy_controls() None[source]

Mark the control panel as stale.

axis_field_changed() None[source]

Change the axis field displayed.

axis_limits_changed() None[source]

Change axis limits.

axis_scale_changed() None[source]

Change axis scales.

axis_unit_changed() None[source]

Change axis units.

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.

clear_fit() None[source]

Clear fit overlay artists.

clear_guides() None[source]

Clear all guide artists.

clear_selection() None[source]

Reset selection mode.

close() None[source]

Close the view window.

closed_cursor_popout() None[source]

Close the cursor position display window.

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.

current_pane_changed() None[source]

Set a new pane as the active pane.

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.

disable_all_orders()[source]

Disable all orders.

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_all_models() None[source]

Enable all loaded models from the pane list widget.

enable_all_orders()[source]

Enable all orders.

enable_cursor_position() None[source]

Enable cursor position displays.

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.

end_selection() None[source]

End a zoom or fit interaction.

figure_clicked(event: Event) None[source]

Select a pane by mouse click.

Parameters:
eventmatplotlib.backend_bases.Event

Mouse click event.

filename_order_selector_changed()[source]

Handle a change in the filename order selector.

filename_table_selection_changed()[source]

Set selection for a cell in the filename table.

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.

hold_atrophy()[source]

Disconnect atrophy signals.

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.

off_orders_changed()[source]

Disable selected orders.

on_orders_changed()[source]

Handle a change in order selection.

open_eye() None[source]

Open the view window and start the refresh timer.

open_fits_results() None[source]

View the fitting results.

open_ref_data() None[source]

View reference line data

pane_count() int[source]

Retrieve the current number of panes.

Returns:
int

The pane count.

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.

pane_order_selector_changed()[source]

Handle a change to the pane selector.

popout_cursor_position() None[source]

Pop out a cursor position display window.

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.

print_current_artists() None[source]

Print current artists.

refresh_controls() None[source]

Refresh all control widgets.

refresh_file_table() None[source]

Refresh the file list from currently loaded data.

refresh_loop() None[source]

Refresh the view.

release_atrophy()[source]

Reconnect atrophy signals.

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_file_from_pane()[source]

Handle a file removal request.

remove_model_id(model_id: str) None[source]

Remove a file from the list.

Parameters:
model_idstr

ID of the model to remove.

remove_order() None[source]

Remove an order.

remove_pane() None[source]

Remove current selected pane.

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.

reset() None[source]

Remove all loaded models and panes.

reset_zoom() None[source]

Reset axis limits to full range.

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_field() None[source]

Set a new axis field from the control widget.

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_limits() None[source]

Set axis limits from the widget controls.

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_scale() None[source]

Set an axis scale from the widget controls.

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_unit() None[source]

Set a new unit from the widget controls.

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_analysis_panel() None[source]

Toggle analysis panel visibility.

toggle_axis_panel() None[source]

Toggle axis panel visibility.

toggle_controls() None[source]

Toggle control panel visibility.

toggle_cursor() None[source]

Toggle cursor panel visibility.

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_file_panel() None[source]

Toggle file panel visibility.

toggle_fit_visibility()[source]

Show or hide fit parameters

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.

toggle_markers(state: bool) None[source]

Set the marker visibility in all panes.

Parameters:
state: bool

If True, markers will be shown. If False, they will be hidden.

toggle_order_panel() None[source]

Toggle order panel visibility.

toggle_overplot()[source]

Enable or disable overplots for panes.

toggle_plot_panel() None[source]

Toggle plot panel visibility.

unload_reference_model() None[source]

Unload the reference data model.

update_controls() None[source]

Update control widgets in the Axis section from loaded data.

update_reference_lines() None[source]

Update the reference data model.