JwstStep

class jwst.stpipe.core.JwstStep(name=None, parent=None, config_file=None, _validate_kwds=True, **kws)[source]

Bases: Step

A JWST pipeline step (jwst.stpipe.Step).

Create a Step instance.

Parameters:
namestr

The name of the Step instance. Used in logging messages and in cache filenames. If not provided, one will be generated based on the class name.

parentStep

The parent step of this step. Used to determine a fully-qualified name for this step, and to determine the mode in which to run this step.

config_filestr or pathlib.Path

The path to the config file that this step was initialized with. Use to determine relative path names of other config files.

_validate_kwdsbool

Validate given kws against specs/config.

**kwsdict

Additional parameters to set. These will be set as member variables on the new Step instance.

Attributes Summary

spec

Methods Summary

finalize_result(result, reference_files_used)

Update the result with the software version and reference files used.

get_stpipe_loggers()

Get the names of loggers to configure.

load_as_level2_asn(obj)

Load object as an association.

load_as_level3_asn(obj)

Load object as an association.

prepare_output(init[, make_copy, ...])

Open the input data as a model, making a copy if necessary.

remove_suffix(name)

Remove the suffix if a known suffix is already in name.

run(*args)

Run the step.

Attributes Documentation

spec
output_ext = string(default='.fits')  # Output file type

Methods Documentation

finalize_result(result, reference_files_used)[source]

Update the result with the software version and reference files used.

Parameters:
resultDataModel

The output data model to be updated.

reference_files_usedlist of tuple

The names and file paths of reference files used.

static get_stpipe_loggers()[source]

Get the names of loggers to configure.

Returns:
loggerstuple of str

Tuple of log names to configure.

load_as_level2_asn(obj)[source]

Load object as an association.

Loads the specified object into a Level2 association. If necessary, prepend Step.input_dir to all members.

Parameters:
objobject

Object to load as a Level2 association

Returns:
associationobject

Association from jwst.associations.lib.rules_level2_base.DMSLevel2bBase

load_as_level3_asn(obj)[source]

Load object as an association.

Loads the specified object into a Level3 association. If necessary, prepend Step.input_dir to all members.

Parameters:
objobject

Object to load as a Level3 association

Returns:
associationobject

Association from jwst.associations.lib.rules_level3_base.DMS_Level3_Base

prepare_output(init, make_copy=None, open_models=True, open_as_type=None, **kwargs)[source]

Open the input data as a model, making a copy if necessary.

If the input data is a filename or path, it is opened and the open model is returned.

If it is a list of models, it is opened as a ModelContainer. In this case, or if the input is a simple datamodel or a ModelContainer, a deep copy of the model/container is returned, in order to avoid modifying the input models.

If the input is a ModelLibrary, it is simply returned, in order to avoid making unnecessary copies for performance-critical use cases.

All copies are skipped if this step has a parent (i.e. it is called as part of a pipeline).

Set make_copy explicitly to True or False to override the above behavior.

Parameters:
initstr, list, JwstDataModel, ModelContainer, or ModelLibrary

Input data to open.

make_copybool or None

If True, a copy of the input will always be made. If False, a copy will never be made. If None, a copy is conditionally made, depending on the input and whether the step is called in a standalone context.

open_modelsbool

If True and the input is a filename or list of filenames, then datamodels.open will be called to open the input. If False, the input is returned as is.

open_as_typeclass or None

If provided, the input will be opened as the specified class before returning. Intended for use with simple datamodel input only: container types and associations should be handled directly in the calling code.

**kwargs

Additional keyword arguments to pass to datamodels.open. Used only if the input is a str or list.

Returns:
modelJwstDataModel or ModelContainer or ModelLibrary

The opened datamodel(s).

Raises:
TypeError

If make_copy=True and the input is a type that cannot be copied.

remove_suffix(name)[source]

Remove the suffix if a known suffix is already in name.

Parameters:
namestr

The name to remove the suffix from.

Returns:
namestr

The name with the suffix removed.

run(*args)[source]

Run the step.

Parameters:
*args

Arguments passed to stpipe.Step.run.

Returns:
resultAny

The step output