KeywordRules

class jwst.model_blender.blendrules.KeywordRules(model)[source]

Bases: object

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

Methods Summary

add_rules_kws(hdr)

Update metadata with ..

apply(models[, tabhdu])

For a full list of metadata objects, apply the specified rules to generate a dictionary of new values and a table using blender.

index_of(kw)

Reports the index of the specified kw.

interpret_rules(hdrs)

Convert specifications for rules from rules file into specific rules for this header(instrument/detector).

merge(kwrules)

Merge a new set of interpreted rules into the current set The new rules, kwrules, can either be a new class or a whole new set of rules (like those obtained from using self.interpret_rules with a new header).

Methods Documentation

add_rules_kws(hdr)[source]

Update metadata with .. warning:

Needs to be modified to work with metadata.

Update PRIMARY header with HISTORY cards that report the exact
rules used to create this header. Only non-comment lines from the
rules file will be reported.
apply(models, tabhdu=False)[source]

For a full list of metadata objects, apply the specified rules to generate a dictionary of new values and a table using blender.

This method returns the new metadata object and summary table as datamodels.model.ndmodel and fits.binTableHDU objects.

index_of(kw)[source]

Reports the index of the specified kw.

interpret_rules(hdrs)[source]

Convert specifications for rules from rules file into specific rules for this header(instrument/detector).

Notes

This allows for expansion rules to be applied to rules from the rules files (such as any wildcards or section titles).

Output will be ‘self.rules’ that contains a list of tuples: - a tuple of 2 values for each column in the table - a tuple of 4 values for each attribute identified in metadata Partial sample from HST to show format: [(‘CTYPE1O’, ‘CTYPE1O’), (‘CTYPE2O’, ‘CTYPE2O’), (‘CUNIT1O’, ‘CUNIT1O’), (‘CUNIT2O’, ‘CUNIT2O’), (‘APERTURE’, ‘APERTURE’, <function fitsblender.blendheaders.multi>, ‘ignore’), (‘DETECTOR’, ‘DETECTOR’, <function fitsblender.blender.first>, ‘ignore’), (‘EXPEND’, ‘EXPEND’, <function numpy.core.fromnumeric.amax>, ‘ignore’), (‘EXPSTART’, ‘EXPSTART’, <function numpy.core.fromnumeric.amin>, ‘ignore’), (‘EXPTIME’, ‘TEXPTIME’, <function numpy.core.fromnumeric.sum>, ‘ignore’), (‘EXPTIME’, ‘EXPTIME’, <function numpy.core.fromnumeric.sum>, ‘ignore’)]

This rules format will allow the algorithm, logic and code from the original fitsblender to be used with as little change as possible. It will need to be derived (as with HST) from the input models metadata for expansion of attribute sections or wildcards in attributes specified in the rules.

merge(kwrules)[source]

Merge a new set of interpreted rules into the current set The new rules, kwrules, can either be a new class or a whole new set of rules (like those obtained from using self.interpret_rules with a new header).