find_row

jwst.lib.reffile_utils.find_row(ldict, match_keys)[source]

Find a row in a FITS table matching fields.

Parameters:
ldictlist of dict

A list of dictionaries, The dictionaries may have any number of items but must include all keys in match_keys.

match_keysdict

{key: value} pairs are matched against all items in ldict to find the dict which matches them.

Returns:
rowint or None

FITS table row index, None if no match.

Raises:
Warning

When a field name is not in the table.

MatchFitsTableRowError

When more than one rows match.

Examples

>>> ldict = [
...     {"row_offset": 2.1, "col_offset": 1.3, "filter": "F444W", "pupil": "CLEAR"},
...     {"row_offset": 1, "col_offset": 3, "filter": "F277W", "pupil": "FLAT"},
... ]
>>> match_keys = {"filter": "F444W", "pupil": "CLEAR"}
>>> result = find_row(ldict, match_keys)
>>> print(result)
{'row_offset': 2.1, 'col_offset': 1.3, 'filter': 'F444W', 'pupil': 'CLEAR'}