hispecdrp.processing_component
Classes
|
- class ProcessingComponent(action, context)[source]
Bases:
BasePrimitive- _create_preview()[source]
Create a preview image for the output data model. This method can be overridden by subclasses to implement specific preview generation logic. By default, this method does nothing.
- _get_first_model(dataset, open=True, return_type=False, **kwargs)[source]
Get the first input model and its container type from the dataset.
- Parameters:
dataset (Any) – The dataset to extract the first model from.
open (bool, optional) – If True, open the model if it’s a file path. Default is True.
return_type (bool, optional) – If True, also return the container type and length. Default is False.
**kwargs – Additional keyword arguments to pass to the datamodels.open() function.
- Returns:
DataModel | tuple[DataModel, type | None, int] – If return_type is False, returns the first DataModel. If return_type is True, returns a tuple of (first DataModel, container type, length). Supported container types are Sequence and dict. For a single model, the type is None.
- _init_log_config(log_config=None)[source]
Resolve and store
self.log_configby merging (lowest → highest priority):Package defaults from
hispecdrp/configs/logging.yamlloggingattribute embedded inself.config.log_configkwarg passed at construction time (dict or file path/name)
- _post_condition()[source]
- _pre_condition()[source]
- apply(dataset=None, **kwargs)[source]
One of the two primary methods a user calls to run a primitive. The other is
Primitive.call(). Users should not need to override this method, and care should be taken if doing so.Both BasePrimitive and BasePipeline implement apply().
- generate_output_path(model, output_dir=None)[source]
Generate an output filepath for a model.
Parameter
- modelstr | DataModel
The model to generate the output path for.
- output_dirstr | None, optional
The output directory to use. If None, the output directory is determined by
self.get_output_dir(model).
- classmethod get_config(dataset, context=None)[source]
Retrieve the configuration for this primitive based on the dataset and context.
- Parameters:
dataset (Any) – The dataset to use for selecting the configuration. Cannot be None.
context (dict | None) – Optional context to use for selecting the configuration.
- Returns:
config_file (ConfigFile) – The configuration file for this primitive.
- static get_do_traces(input_model, do_fibers=None, do_orders=None)[source]
Determine which fibers and orders to process based on the input model and optional user-specified lists.
- Parameters:
- Returns:
do_fibers (list[str | int]) – The list of fiber numbers to process.
do_orders (list[int]) – The list of order numbers to process.
- get_input_dir(dataset=None)[source]
Get the input directory for a given model.
- Parameters:
dataset (Any, optional) – The input model to determine the input directory from. If None, uses
self.dataset.
- get_output_dir(model)[source]
Get the output directory for saving any results in the context of a model. The priority for determining the output directory is as follows:
self.output_dirif explicitly set (input model not used).model._filepathdirectory if available If an input model is provided, the fallback is the directory of self.dataset.Current working directory as a final fallback.
- get_pars()[source]
Get the current parameter values.
- Returns:
dict – A dictionary of parameter names and their current values. Primitive parameters include both parameters and calibrations.
- property pars_str
Pretty print the current parameters and calibrations for this primitive or pipeline.
- Returns:
str – A formatted string showing all current parameter values.
- save_model(model, output_path=None)[source]
Save a DataModel to a file in the context of this processing component. The file suffix will be added to the existing filename (
model.meta.filename) if present and filepath is not set.
- save_output()[source]
Saves all datamodels stored at self._output[‘output’].
- set_pars(**kwargs)[source]
Set parameter values including calibrations as top-level attributes.
- Parameters:
**kwargs – Parameters to set as attributes. For primitives, one can also override calibration values.
Notes
Selector logic is not run here.