blendmodels

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

Run main interface for blending metadata 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.

  • ignore (list of str, None, optional) – A list of string the meta attribute names which, if provided, will show which attributes should not be blended.

  • 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 stdatamodels.jwst import datamodels
>>> asnfile = "jw99999-a3001_20170327t121212_coron3_001_asn.json"
>>> data = datamodels.open(asnfile)
>>> input_models = [data[3], data[4]]  # we know the last datasets are SCIENCE
>>> blendmodels(data.meta.asn_table.products[0].name, inputs=input_models)