blendmodels

jwst.model_blender.blendmeta.blendmodels(product, inputs=None, output=None, verbose=False)[source]

Run main interface for blending metatdata from multiple models.

Blend models that went into creating the original drzfile into a new metadata instance with a table that contains attribute values from all input datamodels.

The product will be used to determine the names of the input models, should no filenames be provided in the ‘inputs’ parameter.

The product will be updated ‘in-place’ with the new metadata attributes and FITS BinTableHDU table. The blended FITS table, with extname=HDRTAB, has 1 column for each metadata attribute recorded from the input models, one row for each input model, and column names are the FITS keywords for that metadata attribute. For example, values from meta.observation.time would be stored in the TIME-OBS column.

Rules for what function to use to determine the blended output attribute value and what metadata attributes should be used as columns in the blended FITS table are defined in the datamodel schema.

Note

Custom rules for a metadata value should be computed by the calling routine and used to update the metadata in the output model AFTER calling this function.

Parameters
  • product (str) – Name of combined product with metadata that needs updating. This can be specified as a single filename. When no value for inputs has been provided, this file will also evaluate meta.asn to determine the names of the input datamodels whose metadata need to be blended to create the new combined metadata.

  • inputs (list, optional) – This can be either a list of filenames or a list of DataModels objects. If provided, the filenames provided in this list will be used to get the metadata which will be blended into the final output metadata.

  • output (str, optional) – If provided, update meta.filename in the blended product to define what file this model will get written out to.

  • verbose (bool, optional [Default: False]) – Print out additional messages during processing when specified.

Example

This example shows how to blend the metadata from a set of DataModels already read in memory for the product created by the resample step. This example relies on the Association file used as the input to the resample step to specify all the inputs for blending using the following syntax:

>>> from .. import datamodels
>>> asnfile = "jw99999-a3001_20170327t121212_coron3_001_asn.json"
>>> asn = datamodels.open(asnfile)
>>> input_models = [asn[3],asn[4]]  # we know the last datasets are SCIENCE
>>> blendmodels(asn.meta.resample.output, inputs=input_models)

Alternatively, the filenames for all the inputs could be provided directly instead using:

>>> from ..associations import load_asn
>>> asn = load_asn(open(asnfile))
>>> input_names = [i['expname'] for i in asn['products'][0]['members'][3:]]
>>> blendmodels(asn['products'][0]['name'], inputs=input_names)