liger_iris_pipeline.base_step

Classes

LigerIRISStep([config_file])

Here we override several core methods from stpipe.step.Step to provide: 1.

class liger_iris_pipeline.base_step.LigerIRISStep(config_file: str | None = None, **kwargs)[source]

Bases: Step

Here we override several core methods from stpipe.step.Step to provide: 1. Manual control on deriving the configuration from spec, a config file, and additional kwargs. 2. Broader signatures for run, process, (and eventually call if appropriate). Once the DRS is robust enough, we will realign (although not completely) with stpipe.step.Step methods.

Attributes:

exclude_spec (list[str]): A list of attributes to exclude from the spec.

static asn_product_by_types(exp_product: dict)[source]

Get the members of an exposure product by type.

Parameters:

exp_product (dict): The exposure product.

Returns:

dict: The members of the exposure product by type.

exclude_spec = ['pre_hooks', 'post_hooks', 'output_use_index', 'output_use_model', 'search_output_file', 'input_dir', 'output_ext', 'steps']
finalize_result(result: LigerIRISDataModel, reference_files_used: dict[str, str] | None = None)[source]

Finalize the result by updating metadata.

Args:

result (LigerIRISDataModel): The result to finalize. reference_files_used (dict[str, str]): The reference files used in the processing.

Returns:

(LigerIRISDataModel): The finalized result. Updates are in-place.

get_pars(full_spec: bool = True)[source]

Get the current parameters for this step.

Args:

full_spec (bool, optional): If True, return the full spec. Defaults to True.

init_logger(config: ConfigObj | None = None)[source]

Initialize logging for the step. Config ignored for now.

classmethod load_spec_file(preserve_comments=<stpipe.utilities._NotSet object>)[source]

Load the merged parameters for this class from the spec attributes.

make_output_path(model: LigerIRISDataModel, output_dir: str | None = None, filename: str | None = None, suffix: str | None = None) str[source]

Generate the output path for the given model in the context of this Step instance.

Args:

model (LigerIRISDataModel): The model to generate the output path for. output_dir (str, optional): The directory to save the output file. Defaults to self.output_dir. filename (str, optional): The filename to save the output file. Defaults to model.meta.filename suffix (str, optional): An optional suffix to add to the filename. Defaults to self.suffix.

Returns:

(str): The full path to save the output file.

on_skip(input)[source]

Hook for when a step is skipped.

Args:

input (str | LigerIRISDataModel):

open_model(name: str | LigerIRISDataModel, _copy: bool = False)[source]

Open a model from a file or copy an existing datamodel in the context of this Step. Any Step that opens a DataModel should call this method.

Args:

name (str | LigerIRISDataModel): The name of the file or the datamodel to open. _copy (bool, optional): Copy and return the input if already a LigerIRISDataModel. Defaults to False.

Returns:

(LigerIRISDataModel): The opened or copied datamodel.

static parse_config_kwarg(key: str, val: str | None, spec)[source]

TODO: Implement spec validation, defaults are grabbed above.

process(input: str | LigerIRISDataModel | LigerIRISAssociation)[source]

This is where real work happens. Every Step subclass has to override this method. The default behaviour is to raise a NotImplementedError exception. The signature must be process(self, input : str | LigerIRISDataModel | LigerIRISAssociation).

run(input, **kwargs)[source]

Run handles the generic setup and teardown that happens with the running of each step. The real work that is unique to each step type is done in the process method.

Args:
input (str | LigerIRISDataModel | LigerIRISAssociation): The input to process:
  1. filename of datamodel

  2. filename of ASN

  3. datamodel

  4. ASN

**kwargs: Additional spec parameters to pass to the step.

Returns:

(LigerIRISDataModel | list[LigerIRISDataModel]): The result(s) of the step. Steps can only return a single model, but Pipelines can return a list of datamodels.

save_model(model, output_path: str | None = None, output_dir: str | None = None, output_filename: str | None = None, suffix: str | None = None)[source]

Saves the given model using the step/pipeline’s naming scheme.

Args:

See Step.make_output_path for argument information.

Returns:

(str): The full path to the saved model.