ReduxMainWindow

class sofia_redux.pipeline.gui.main.ReduxMainWindow(interface)[source]

Bases: QMainWindow, Ui_MainWindow

Redux Qt5 GUI main window.

All attributes and methods for this class are intended for internal use, to support the main GUI event loop and operations. This class is normally instantiated from a redux.Application object; all methods are triggered by user interaction only.

The UI for this application is built in Qt Designer: see the designer folder for the Designer input files; the compiled Python scripts are in the ui module. All ui_*.py files should not be edited manually, as they are automatically generated. See the designer/compile_ui file for the sequence of commands required to rebuild the UI from Designer files.

Start up the main GUI window.

Parameters:
interfaceredux.Application

Reduction interface object. This class chooses, instantiates, and runs appropriate reduction objects for input data, as well as controlling any associated viewers.

Methods Summary

addLog(msg)

Add a log message to the log widget.

cleanup(*args)

Quit the application.

closeEvent(event)

Confirm before closing the application.

enableControls([enable])

Toggle reduction-related controls.

enableReduction([enable])

Toggle all non-default controls.

highlightStep(idx)

Highlight the currently running step.

onAddFiles()

Add new files to the current reduction.

onCloseReduction()

Close the current reduction.

onDisplayConfig()

Display all current configuration in a new widget.

onDisplayParameters()

Display all current parameters in a new widget.

onEdit(index)

Edit parameters for a reduction step.

onEditConfiguration()

onLoadConfiguration([default, config_edit])

Load persistent configuration from a file.

onLoadParameters()

Load parameters from a configuration file.

onOpenReduction([add, remove_files])

Open a new reduction.

onRemoveFiles()

Remove files from the current reduction.

onResetConfiguration()

Reset configuration to default values.

onResetParameters()

Reset all parameters to default values.

onRun(index)

Run the next reduction step.

openFinish(result)

Finish loading a new reduction.

reduce()

Run all remaining reduction steps.

resetPipeline()

Reset the pipeline when a reduction is closed.

resetSteps()

Reset reduction steps to re-start a loaded reduction.

resetView()

Remove the Data View tab.

saveConfiguration()

Save configuration settings to disk.

saveInputManifest()

Save an input manifest to disk.

saveOutputManifest()

Save an output manifest to disk.

saveParameters()

Save reduction parameters to disk.

setFileSummary()

Set a loaded file summary message.

setOutputDirectory()

Set an output directory for the reduction.

setPipeName([msg])

Set the pipeline name in a label widget.

setStatus(msg)

Set a status message.

step([skip_save, skip_break, run_all])

Launch a reduction step, or series of steps.

stepFinish(status)

Update GUI after a reduction step finishes.

stepProgress(value)

Update the progress widget.

stopReduction()

Cancel reduction in thread after current step.

toggleDisplay()

Toggle viewers.

toggleDisplayIntermediate()

Toggle intermediate display setting.

undo()

Undo the last reduction step.

updateConfigView()

Update config viewer widget with new values.

updateParamView()

Update parameter viewer widget with new values.

Methods Documentation

addLog(msg)[source]

Add a log message to the log widget.

Callback for the TextEditLogger. Messages are appended to the end of the TextEdit window, in HTML format.

Parameters:
msgstr

HTML formatted string to display in the TextEdit widget.

cleanup(*args)[source]

Quit the application.

closeEvent(event)[source]

Confirm before closing the application.

Parameters:
eventQEvent

Close event.

enableControls(enable=True)[source]

Toggle reduction-related controls.

These controls (add files, edit parameters, run step, etc.) are disabled while a reduction step is running.

Parameters:
enablebool

If True, controls are enabled. If False they are disabled.

enableReduction(enable=True)[source]

Toggle all non-default controls.

These controls are disabled when no data is loaded. Only opening a new reduction or quitting is allowed in this condition.

Parameters:
enablebool

If True, enable the controls. If False, disable them.

highlightStep(idx)[source]

Highlight the currently running step.

Parameters:
idxint

Step index number.

onAddFiles()[source]

Add new files to the current reduction.

onCloseReduction()[source]

Close the current reduction.

Called when the user selects Close Reduction from the File menu.

onDisplayConfig()[source]

Display all current configuration in a new widget.

onDisplayParameters()[source]

Display all current parameters in a new widget.

onEdit(index)[source]

Edit parameters for a reduction step.

Called when an Edit button in a widgets.PipeStep is pushed.

Parameters:
indexint

Reduction step index. This value is stored in the step widget (widgets.PipeStep).

onEditConfiguration()[source]
onLoadConfiguration(default=False, config_edit=False)[source]

Load persistent configuration from a file.

onLoadParameters()[source]

Load parameters from a configuration file.

onOpenReduction(add=False, remove_files=None)[source]

Open a new reduction.

Called when the following File menu items are selected:

  • Open New Reduction

  • Add Files (add = True)

  • Remove Files (remove_files = True)

Any of these three options will reset the reduction and load the data into a new reduction object. If files are being removed or added, the parameters and output directory from the old reduction object will be saved and restored into the new one.

Files are loaded in a new thread from a thread pool, via QtCore.QThreadPool. The worker for this thread is widgets.LoadRunnable.

Parameters:
addbool

Add more files to the current reduction.

remove_filesbool

Remove files from the current reduction

onRemoveFiles()[source]

Remove files from the current reduction.

onResetConfiguration()[source]

Reset configuration to default values.

onResetParameters()[source]

Reset all parameters to default values.

onRun(index)[source]

Run the next reduction step.

Called when a Run button in a widgets.PipeStep is pushed.

Parameters:
indexint

Reduction step index. This value is stored in the step widget (widgets.PipeStep). index is currently ignored, since the Run buttons are enabled for the next step only.

openFinish(result)[source]

Finish loading a new reduction.

This method builds the pipeline step widgets, updates display widgets and viewers, and enables reduction controls.

This method is the callback for the widgets.LoadRunnable class, which loads new data from disk in a separate thread.

Parameters:
resulttuple

If result is a three-element tuple, it is assumed to be an unexpected exception, with elements (type, message, traceback). If it is a two-element tuple, the first element is a set of saved parameters from the previous reduction and the second element is the output directory from the old reduction. If either element is non-null, it will be restored to the new reduction.

reduce()[source]

Run all remaining reduction steps.

resetPipeline()[source]

Reset the pipeline when a reduction is closed.

All data items, parameter values, and pipeline steps are removed.

resetSteps()[source]

Reset reduction steps to re-start a loaded reduction.

Parameters are not reset from edited values. The raw data is re-loaded into the reduction. Viewers are reset.

resetView()[source]

Remove the Data View tab.

saveConfiguration()[source]

Save configuration settings to disk.

Called by a Settings menu option. Calls the Interface.save_configuration method.

saveInputManifest()[source]

Save an input manifest to disk.

Called by a File menu option. Calls the Interface.save_input_manifest method.

saveOutputManifest()[source]

Save an output manifest to disk.

Called by a File menu option. Calls the Interface.save_output_manifest method.

saveParameters()[source]

Save reduction parameters to disk.

Called by a Parameters menu option. Calls the Interface.save_parameters method.

setFileSummary()[source]

Set a loaded file summary message.

setOutputDirectory()[source]

Set an output directory for the reduction.

Called by a File menu option. Calls the Interface.set_output_directory method.

setPipeName(msg=None)[source]

Set the pipeline name in a label widget.

Parameters:
msgstr, optional

Pipeline version label. If not provided, the Redux version label will be displayed.

setStatus(msg)[source]

Set a status message.

Messages are displayed in the status bar and as an INFO level log message.

Parameters:
msgstr

Status message.

step(skip_save=False, skip_break=False, run_all=False)[source]

Launch a reduction step, or series of steps.

Reduction steps are run in a separate thread from a thread pool, via QtCore.QThreadPool. The worker for this thread is widgets.StepRunnable.

The number of steps to run is determined by the widget from which this method was triggered. If the Reduce button is pressed, all remaining steps are run (run_all=True). If the Run button next to a step is pressed, only that step is run (skip_break=True). If the Step button is pressed, all steps up through the value selected in the Step Through box are run (default).

Parameters:
skip_savebool, optional

If True, the reduction object will not be pickled before running the step. This effectively disables Undo for the step.

skip_breakbool, optional

If True, the value of the stepThroughComboBox will be ignored and only the next step will be run.

run_allbool, optional

If True, all remaining steps will be run.

stepFinish(status)[source]

Update GUI after a reduction step finishes.

Callback for the widgets.StepRunnable, which runs a reduction step in a separate thread.

Parameters:
statustuple or str

If tuple, status is assumed to be an unexpected exception message, with values (type, message, traceback). If str, it is assumed to be an error caught by the reduction object and recorded as a return value for the step. Either way, if the message is not an empty string, it is displayed to the user in a QMessageBox warning and reduction is halted.

Returns:
bool

True if reduction step succeeded; False if it threw an error.

stepProgress(value)[source]

Update the progress widget.

Callback for the widgets.StepRunnable for intermediate progress.

stopReduction()[source]

Cancel reduction in thread after current step.

Called when the Stop Reduction button is pressed in the progress widget.

toggleDisplay()[source]

Toggle viewers.

toggleDisplayIntermediate()[source]

Toggle intermediate display setting.

undo()[source]

Undo the last reduction step.

This method unpickles the last reduction object saved in the pickled_reduction attribute. This normally happens at the beginning of the step method, but a pickled reduction may be unavailable for either of the following reasons:

  • the reduction object does not allow undo operations (because the object is too large to save, for example)

  • serialization failed (the reduction object currently holds a reference to a file pointer, for example)

It is recommended that the user install the dill module, as it allows serialization for more complex software structures than the built-in pickle module.

updateConfigView()[source]

Update config viewer widget with new values.

updateParamView()[source]

Update parameter viewer widget with new values.