Model Blender Rules

Blending models relies on rules to define how to evaluate all the input values for a model attribute in order to determine the final output value. These rules then get specified in the model schema for each attribute.

The rules get interpreted and applied as list or array operations that work on the set of input values for each attribute. The full set of pre-defined rules includes

import numpy as np
# translation dictionary for function entries from rules files
blender_funcs = {'first': first,
                  'last': last,
                  'float_one': float_one,
                  'int_one': int_one,
                  'zero': zero,
                  'multi': multi,
                  'multi?': multi1,
                  'mean': np.mean,
                  'sum': np.sum,
                  'max': np.max,
                  'min': np.min,
                  'stddev': np.std,
                  'mintime': mintime,
                  'maxtime': maxtime,
                  'mindate': mindate,
                  'maxdate': maxdate,
                  'mindatetime': mindatetime,
                  'maxdatetime': maxdatetime}

The rules that should be referenced in the model schema definition are the keys defined for jwst.model_blender.blender_rules.blender_funcs listed above. This definition illustrates how several rules are simply interfaces for numpy array operations, while others are defined internally to model_blender.

jwst.model_blender.blendrules Module

blendmeta - Merge metadata from multiple models to create a new metadata instance and table

Functions

find_keywords_in_section(hdr, title)

Return a list of keyword names.

first(items)

Return first item from list of values

float_one(vals)

Return a constant floating point value of 1.0

int_one(vals)

Return an integer value of 1

interpret_attr_line(attr, line_spec)

Generate rule for single attribute from input line from rules file.

interpret_entry(line, hdr)

Generate the rule(s) specified by the entry from the rules file.

last(items)

Return last item from list of values

maxdate(items)

Return the maximum date from a list of date strings in yyyy-mm-dd format.

maxdatetime(items)

Return the maximum datetime from a list of datetime strings in ISO-8601 format.

maxtime(items)

mindate(items)

Return the minimum date from a list of date strings in yyyy-mm-dd format.

mindatetime(items)

Return the minimum datetime from a list of datetime strings in ISO-8601 format.

mintime(items)

multi(vals)

This will either return the common value from a list of identical values or ‘MULTIPLE’

multi1(vals)

This will either return the common value from a list of identical values or the single character ‘?’

zero(vals)

Return a value of 0

Classes

KeywordRules(model)

Read in the rules used to interpret the keywords from the specified instrument image header.

KwRule(line)

This class encapsulates the logic needed for interpreting a single keyword rule from a text file.

Class Inheritance Diagram

Inheritance diagram of jwst.model_blender.blendrules.KeywordRules, jwst.model_blender.blendrules.KwRule