ModelBlender

class jwst.model_blender.ModelBlender(blend_ignore_attrs=None)[source]

Bases: object

Class to “blend” metadata from several datamodels.

Tht output “blended” model will contain:

  • metadata for a combined model

  • a table with metadata of each datamodel

Input models can be added to the blender using ModelBlender.accumulate and the output/combined model updated using ModelBlender.finalize_model.

All input/accumulated models must be of the same type.

>>> blender = ModelBlender()
>>> blender.accumulate(input_model_a)  
>>> blender.accumulate(input_model_b)  
>>> blender.finalize_model(combined_model)  

Create a new ModelBlender.

Parameters:

blend_ignore_attrs (list or None) – A list of metadata attributes to ignore during blending. These attributes will not be set on the output/combined. These attributes must be strings containing the dotted path of each attribute (for example “meta.filename”). (Note that “meta.wcs” will always be ignored).

Methods Summary

accumulate(model)

Blend metadata for model.

finalize_model(model)

Update model with the blend results.

Methods Documentation

accumulate(model)[source]

Blend metadata for model.

Process model adding its metadata to the blended metadata and the metadata table.

Parameters:

model (jwst.datamodels.JwstDataModel) – The datamodel to blend.

finalize_model(model)[source]

Update model with the blend results.

Add blended metadata and the accumulated metadata table to the provided datamodel. The update process involves:

  • setting the model metadata to the blended metadata values

  • adding an “hdrtab” attribute (containing the metadata table)

  • updating the model schema to save “hdrtab”

The provided model will be updated in-place.

Parameters:

model (jwst.datamodels.JwstDataModel) – A datamodel that will have its metadata set to the blended metadata and have the metadata table assigned to the “hdrtab” attribute.