JwstStep
- class jwst.stpipe.core.JwstStep(name=None, parent=None, config_file=None, _validate_kwds=True, **kws)[source]
Bases:
StepA JWST pipeline step (
jwst.stpipe.Step).Create a
Stepinstance.- 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.
- parent
Step 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
kwsagainst specs/config.- **kwsdict
Additional parameters to set. These will be set as member variables on the new Step instance.
Attributes Summary
Methods Summary
add_asn_id_to_output_name(models)Set up output path name to include the association ID.
finalize_result(result, reference_files_used)Update the result with the software version and reference files used.
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
- add_asn_id_to_output_name(models)[source]
Set up output path name to include the association ID.
The input models are checked for an ASN ID in either a ModelContainer
asn_tableattribute or a ModelLibraryasnattribute.If not found, the current step and its parents are searched for an
asn_idattribute.If an ASN ID is found, the
_make_output_pathfunction is updated to include it in output filenames.If no ASN ID is found,
_make_output_pathis updated to passasn_id=None. This will override any previously passed ASN IDs, so that no ASN ID appears in the output filename.- Parameters:
- models
JwstDataModel,ModelContainer, orModelLibrary The model or models to search for an ASN ID.
- models
- Returns:
- asn_idstr or None
The ASN ID, as found in the models or step.
- finalize_result(result, reference_files_used)[source]
Update the result with the software version and reference files used.
- Parameters:
- result
JwstDataModel The output data model to be updated.
- reference_files_usedlist of tuple
The names and file paths of reference files used.
- result
- 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_dirto 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_dirto 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