Interface¶
- class sofia_redux.pipeline.interface.Interface(configuration=None)[source]¶
Bases:
object
Interface to Redux reduction objects.
Parent object to both command-line and graphical interfaces.
- Attributes:
- reduction: Reduction
A Redux reduction object for the currently loaded data
- chooser: Chooser
A Redux chooser object that selects reduction objects for new data
- configuration: Configuration
A Redux configuration object that selects a chooser and sets any necessary parameters for the reduction.
- viewers: list of Viewer
List of Redux Viewer objects associated with the reduction.
Initialize the interface, with an optional configuration.
- Parameters:
- configuration
Configuration
, optional Configuration items to be used for all reductions.
- configuration
Methods Summary
Clear reduction variables.
Close any open viewers.
Check for associated embedded viewers.
is_input_manifest
(data)Test if input data list is actually an input manifest file.
Set reduction chooser from configuration.
Load the input file description from the reduction.
load_files
(data)Load input files from a list of file names.
load_parameters
([param_file])Load reduction parameters.
read_input_manifest
(data)Read an input manifest and return input filenames.
reduce
()Call the reduce method of the current reduction.
register_viewers
([parent])Retrieve and start viewers defined by the reduction object.
reset_log
([loglevel])Reset astropy log to standard settings.
reset_reduction
(data)Reset the current reduction to its initial state.
Reset viewers to default state.
save_configuration
([filename])Save configuration values.
save_input_manifest
([filename, absolute_paths])Save input manifest to disk.
save_output_manifest
([filename, absolute_paths])Save the output manifest.
save_parameters
([filename])Save current reduction parameters.
set_log_file
([filename])Set a log file handler for the reduction.
set_output_directory
([dirname])Set the output directory for the reduction.
set_recipe
([recipe, step_to])Set a non-default processing recipe for the reduction.
start
(data)Start a new reduction from an input data set.
step
()Run a reduction step.
tidy_log
([loglevel])Tidy up log printing for easier human readability at INFO level.
Remove any existing log file handlers.
update_configuration
(config_file)Update top-level configuration.
Update all viewers associated with the current reduction.
Methods Documentation
- clear_reduction()[source]¶
Clear reduction variables.
Resets the reduction and viewers attributes. Removes any existing log file handlers.
- has_embedded_viewers()[source]¶
Check for associated embedded viewers.
- Returns:
- bool
True if associated viewers are intended to be embedded in the main GUI; False otherwise
- is_input_manifest(data)[source]¶
Test if input data list is actually an input manifest file.
- Parameters:
- data
list
of str List of input file names.
- data
- Returns:
- bool
True if
data
is a single plain text file; False otherwise.
- load_configuration()[source]¶
Set reduction chooser from configuration.
All other configuration items are accessed as needed.
- load_files(data)[source]¶
Load input files from a list of file names.
The reduction object is assigned by the chooser, then an output directory and log file are set, and the data is loaded into the reduction object.
- Parameters:
- data
list
of str or str Lists the input file names to be reduced.
- data
- load_parameters(param_file=None)[source]¶
Load reduction parameters.
Default reduction parameters may optionally be overridden by a parameter file in INI format with reduction step names as section headers, and parameters specified in key, value pairs.
- Parameters:
- param_filestr, optional
Parameter file name
- read_input_manifest(data)[source]¶
Read an input manifest and return input filenames.
Input manifests are assumed to be plain text files that list one input file per line. Only file names that exist on disk as files are returned.
- Parameters:
- datastr or
list
of str File name for the input manifest.
- datastr or
- Returns:
- list of str
List of input file names.
- register_viewers(parent=None)[source]¶
Retrieve and start viewers defined by the reduction object.
Calls the
Reduction.register_viewers()
method, to retrieveViewer
objects, then calls theViewer.start()
method to initialize them. If configuration.update_display is False, no viewers will be registered.- Parameters:
- parent: object, optional
A parent widget for the viewer. May be any type that the viewer understands (e.g. a Qt frame widget).
- static reset_log(loglevel=None)[source]¶
Reset astropy log to standard settings.
Removes any TidyLogHandlers, and resets filters for any astropy LogHandlers.
- Parameters:
- loglevelstr or int, optional
Logging level to use for the terminal log. May be any of the values accepted by the logging module (CRITICAL, ERROR, WARNING, INFO, DEBUG). If not specified, log levels will not be modified.
- reset_reduction(data)[source]¶
Reset the current reduction to its initial state.
Calls the
Reduction.load()
method on the input data. Also resets a non-standard recipe if necessary.- Parameters:
- data
list
of str or str Input data filenames.
- data
- save_configuration(filename=None)[source]¶
Save configuration values.
If a file name is provided, this function writes a plain text file in INI format, containing top-level configuration values.
- Parameters:
- filenamestr, optional
File path to write to.
- Returns:
- None or list of str
The return value depends on the
filename
parameter.
- save_input_manifest(filename=None, absolute_paths=None)[source]¶
Save input manifest to disk.
Writes a plain text file containing one file name per line. Input files are specified in the
reduction.raw_files
attribute.- Parameters:
- filenamestr, optional
Output file path to write to. Default may be set in the
configuration.input_manifest
attribute. Ifconfiguration.input_manifest
is not an absolute path, it will be joined with thereduction.output_directory
attribute.- absolute_pathsbool, optional
If True, input file names will be written as absolute paths. If False, they will be written as relative paths. If None, the default value specified in
configuration.absolute_paths
will be used if present; otherwise,absolute_paths
defaults to True.
- save_output_manifest(filename=None, absolute_paths=None)[source]¶
Save the output manifest.
Writes a plain text file containing one file name per line. Output files are specified in the
reduction.out_files
attribute.- Parameters:
- filenamestr, optional
Output file path to write to. Default may be set in the
configuration.output_manifest
attribute. Ifconfiguration.output_manifest
is not an absolute path, it will be joined with thereduction.output_directory
attribute.- absolute_pathsbool or None
If True, output file names will be written as absolute paths. If False, they will be written as relative paths. If None, the default value specified in
configuration.absolute_paths
will be used if present; otherwise,absolute_paths
defaults to True
- save_parameters(filename=None)[source]¶
Save current reduction parameters.
If a file name is provided, this function writes a plain text file in INI format. Reduction step index and names are used as section headers, followed by key-value pairs for all currently defined parameters.
If no filename is provided, this function will return a list of strings containing the parameters pretty-printed to INI format.
- Parameters:
- filenamestr, optional
File path to write to.
- Returns:
- None or list of str
The return value depends on the
filename
parameter.
- set_log_file(filename=None)[source]¶
Set a log file handler for the reduction.
If the provided file name is not an absolute path, it will be joined with
reduction.output_directory
. When called, any existing file handlers will be removed. If a log file has already been written, it will be moved to the new file name; any further log messages will be appended to the existing log file.- Parameters:
- filenamestr, optional
Log file path name. If not provided, the
configuration.log_file
attribute will be used. If this value is None, no action will be taken.
- set_output_directory(dirname=None)[source]¶
Set the output directory for the reduction.
Makes the directory if it does not yet exist. The directory name is stored in the
reduction.output_directory
attribute.- Parameters:
- dirnamestr, optional
Path to the output directory. If not provided, the
configuration.output_directory
attribute will be used. If this value is None, no action is taken.
- set_recipe(recipe=None, step_to=None)[source]¶
Set a non-default processing recipe for the reduction.
All specified processing steps must be known to the current reduction object. The reduction is not reset after setting the new recipe.
- Parameters:
- recipelist of str, optional
List of processing step names to use in place of the default reduction. If not provided, the
configuration.recipe
attribute will be used. If this value is also None, no action will be taken.- step_tostr, optional
A processing step name after which the recipe is terminated. If not provided, the
configuration.step_to
attribute will be used. If this value is also None, no action will be taken.
- start(data)[source]¶
Start a new reduction from an input data set.
- Parameters:
- data
list
of str or str Input data.
- data
- step()[source]¶
Run a reduction step.
Calls the current reduction’s
Reduction.step
method.- Returns:
- str
Empty string if step was successful; an error message otherwise.
- static tidy_log(loglevel='INFO')[source]¶
Tidy up log printing for easier human readability at INFO level.
INFO messages to the terminal will be printed directly. Messages at all other levels will use
astropy.log
format. Log file formatting is unaffected.- Parameters:
- loglevelstr or int, optional
Logging level to use for the terminal log. May be any of the values accepted by the logging module (CRITICAL, ERROR, WARNING, INFO, DEBUG).