Eye

class sofia_redux.visualization.eye.Eye(args=None, view_=None)[source]

Bases: object

Run the Eye of SOFIA.

This class provides the primary control interface to the display functions provided by the Eye viewer. It is intended to be instantiated from the standalone interface (sofia_redux.visualization.controller) or the pipeline interface (sofia_redux.visualization.redux_viewer), but may also be directly instantiated and controlled, via the API interface.

Parameters:
argsargparse.Namespace, optional

Command-line arguments to pass to the Eye interface. Expected attributes are ‘filenames’, containing a list of input files to load, ‘log_level’ specifying a terminal log level (e.g. ‘DEBUG’), or ‘system_logs’ = True, to specify that logs should be written to disk.

view_view.View, optional

A previously instantiated View object, to register with the Eye controller. If not provided, a new View instance will be generated.

Methods Summary

add_data([filename])

Add data.

add_panes([layout, n_panes, kind])

Create blank panes in the figure.

assign_data(mode[, indices])

Assign models to panes.

close()

Close the GUI.

deleteLater()

Delete the view when the control is deleted.

display_selected_model()

Display a selected file in the current pane.

generate()

Initiate or refresh the view.

get_fields([panes])

Get the currently displayed fields for current panes.

get_model_backup()

Return a copy of raw loaded data.

get_orders([panes])

Get enabled orders.

get_pane_layout()

Retrieve the current pane layout.

get_scale([panes])

Get scale setting for active panes.

get_units([panes])

Get the current units for active panes.

load(data_list)

Load a list of data files into the Eye.

models_per_pane()

Retrieve the number of models in all active panes.

number_panes()

Retrieve the number of open panes.

open_eye()

Open the GUI.

remove_data([model_ids])

Remove loaded data from the view.

remove_panes([panes])

Remove currently displayed panes.

reset()

Reset to an empty view.

save(filename, **kwargs)

Save the current view to an image.

set_current_pane(pane_id)

Set the current pane in the view.

set_fields([x_field, y_field, z_field, ...])

Set the axis fields to show for panes.

set_orders(orders)

Set orders to enable.

set_parent(parent)

Set the parent widget for the view.

set_scale(scales[, panes])

Set scale setting for active panes.

set_units(units[, panes])

Set new units for specified panes.

setup_eye()

Setup the GUI and signal connections.

toggle_analysis_panel()

Toggle the plot panel visibility.

toggle_axis_panel()

Toggle the axis panel visibility.

toggle_controls()

Toggle the control panel visibility.

toggle_cursor()

Toggle the cursor panel visibility.

toggle_file_panel()

Toggle the file panel visibility.

toggle_order_panel()

Toggle the order panel visibility.

toggle_plot_panel()

Toggle the plot panel visibility.

unload()

Remove all loaded data.

Methods Documentation

add_data(filename: str | None = None) None[source]

Add data.

Parameters:
filenamelist of str, optional

Absolute paths of FITS files to add to the Eye. If not provided, prompt the user for the filename.

add_panes(layout='grid', n_panes=1, kind='spectrum') None[source]

Create blank panes in the figure.

Parameters:
layout[‘grid’, ‘rows’, ‘columns’], optional

Layout strategy.

n_panesint, optional

Number of panes to create.

kind[‘spectrum’, ‘image’], optional

Type of pane to create. Can also be a list of length rows * cols to create a mixture.

Raises:
ValueError

If the layout to create cannot be inferred from the provided arguments.

assign_data(mode: str, indices: List[int] | None = None) None[source]

Assign models to panes.

Parameters:
mode[‘split’, ‘first’, ‘last’, ‘assigned’]

How to assign the data. Split will split the models equally between the panes, first will assign all the models to the first pane, last will assign all the models to the last pane, and assign will set the models according to the values in indices.

indiceslist of int, optional

List of pane indices to which models should be assigned. Must match the length of the current list of loaded models. Must contain valid pane index values.

Raises:
ValueError

If an invalid mode is provided, or indices do not match models or panes.

close() None[source]

Close the GUI.

deleteLater() None[source]

Delete the view when the control is deleted.

display_selected_model() None[source]

Display a selected file in the current pane.

generate() None[source]

Initiate or refresh the view.

get_fields(panes: str | List[int] | None = 'all') List[source]

Get the currently displayed fields for current panes.

Parameters:
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.

Returns:
fieldslist of list of dict

List of fields for each pane specified.

get_model_backup()[source]

Return a copy of raw loaded data.

get_orders(panes: str | List[int] | None = 'all') Dict[source]

Get enabled orders.

Parameters:
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.

Returns:
ordersdict

Keys are model IDs, values are lists of enabled orders.

get_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.

get_scale(panes: str | List[int] | None = 'all') List[source]

Get scale setting for active panes.

Parameters:
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.

Returns:
scaleslist

Keys are ‘x’ and ‘y’, values are ‘linear’ or ‘log’.

get_units(panes: str | List[int] | None = 'all') List[source]

Get the current units for active panes.

Parameters:
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.

Returns:
unitslist of list of dict

List of units for each pane specified.

load(data_list: list) None[source]

Load a list of data files into the Eye.

Parameters:
data_listlist of str or astropy.io.fits.HDUList

Data to load.

models_per_pane() List[int][source]

Retrieve the number of models in all active panes.

Returns:
model_countlist of int

The model count for each pane.

number_panes() int[source]

Retrieve the number of open panes.

Returns:
int

The pane count.

open_eye() None[source]

Open the GUI.

remove_data(model_ids: List[str] | None = None) None[source]

Remove loaded data from the view.

Parameters:
filenameslist of str, optional

If not provided, currently selected files in the file panel will be removed.

remove_panes(panes: str | List[int] | None = 'all') None[source]

Remove currently displayed panes.

Parameters:
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.

reset() None[source]

Reset to an empty view.

Data is unloaded and all viewer panes are deleted.

save(filename: str, **kwargs) None[source]

Save the current view to an image.

Parameters:
filenamestr

File path to save to.

kwargsdict

Optional arguments to pass to view.View.save.

set_current_pane(pane_id: int) None[source]

Set the current pane in the view.

Parameters:
pane_idint

Pane index to make current.

set_fields(x_field: str | None = None, y_field: str | None = None, z_field: str | None = None, fields: str | None = None, panes: str | List[int] | None = 'all') None[source]

Set the axis fields to show for panes.

Either fields or x_field, y_field, and z_field should be set.

Parameters:
x_fieldstr, optional

The x field to set, if not provided in fields.

y_fieldstr, optional

The y field to set, if not provided in fields.

z_fieldstr, optional

The z field to set, if not provided in fields.

fieldsdict, optional

Should contain keys ‘x’, ‘y’, and ‘z’, 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) None[source]

Set orders to enable.

Parameters:
ordersdict

Keys are model IDs, values are lists of orders to enable.

set_parent(parent: QWidget) None[source]

Set the parent widget for the view.

Parameters:
parentQtWidgets.QWidget

The parent widget.

set_scale(scales: Dict, panes: str | List[int] | None = 'all') None[source]

Set scale setting for active panes.

Parameters:
scalesdict

Keys are ‘x’ and ‘y’, values are ‘linear’ or ‘log’.

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_units(units: Dict, panes: str | List[int] | None = 'all') None[source]

Set new units for specified panes.

Parameters:
unitsdict

New units to apply. Should contain ‘x’, ‘y’ keys.

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.

setup_eye() None[source]

Setup the GUI and signal connections.

toggle_analysis_panel() None[source]

Toggle the plot panel visibility.

toggle_axis_panel() None[source]

Toggle the axis panel visibility.

toggle_controls() None[source]

Toggle the control panel visibility.

toggle_cursor() None[source]

Toggle the cursor panel visibility.

toggle_file_panel() None[source]

Toggle the file panel visibility.

toggle_order_panel() None[source]

Toggle the order panel visibility.

toggle_plot_panel() None[source]

Toggle the plot panel visibility.

unload() None[source]

Remove all loaded data.