DQParser

class stginga.utils.DQParser(definition_file)[source]

Bases: object

Class to handle parsing of DQ flags.

Definition Table

A “definition table” is an ASCII table that defines each DQ flag and its short and long descriptions. It can have optional comment line(s) for metadata, e.g.:

# TELESCOPE = ANY
# INSTRUMENT = ANY

It must have three columns:

  1. DQFLAG contains the flag value (uint16).

  2. SHORT_DESCRIPTION (string).

  3. LONG_DESCRIPTION (string).

Example file contents:

# INSTRUMENT = HSTGENERIC
DQFLAG SHORT_DESCRIPTION LONG_DESCRIPTION
0      "OK"              "Good pixel"
1      "LOST"            "Lost during compression"
...    ...               ...

The table format must be readable by astropy.io.ascii.

Parameters:
definition_filestr

ASCII table that defines the DQ flags (see above).

Attributes:
tabastropy.table.Table

Table object from given definition file.

metadataastropy.table.Table

Table object from file metadata.

Methods Summary

interpret_array(data)

Interpret DQ values for an array.

interpret_dqval(dqval)

Interpret DQ values for a single pixel.

Methods Documentation

interpret_array(data)[source]

Interpret DQ values for an array.

Warning

If the array is large and has a lot of flagged elements, this can be resource intensive.

Parameters:
datandarray

DQ values.

Returns:
dqs_by_flagdict

Dictionary mapping each interpreted DQ value to indices of affected array elements.

interpret_dqval(dqval)[source]

Interpret DQ values for a single pixel.

Parameters:
dqvalint

DQ value.

Returns:
dqsastropy.table.Table

Table object containing a list of interpreted DQ values and their meanings.