11.2. How to understand what flags are in your data

The pipeline may have raised a flag (or some flags) in your datasets during the different levels of processing. Using the Spectrum Explorer, you can view channel flags in your spectrum by clicking on the blue flag icon in the button bar at the top of the Spectrum Explorer window.

To view channel flags in your spectrum, click on the blue flag icon (highlighted by the red oval)

Figure 11.1. To view channel flags in your spectrum, click on the blue flag icon (highlighted by the red oval)


Coloured bars appear over the spectrum in the regions where data is flagged. The colour mapping applied to the flags is random. You can also see what kind of flags were applied by moving the mouse over the spectrum - the information is given in the bottom left of the plot window in form of [row, segment, channel, flag name] (see the next two figures).

Alternatively, you can right click in the window of the spectrum, then select view, and then flags.

To view channel flags in your spectrum by using a pointing device such as a touchpad or a mouse

Figure 11.2. To view channel flags in your spectrum by using a pointing device such as a touchpad or a mouse


The region flagged is colour-coded

Figure 11.3. The region flagged is colour-coded


Column RowFlags are not directly overlaid on the Spectrum Explorer since, by definition, they affect the entire spectrum. Rowflags are stored in extra columns within your dataset, and are shown as a table with the Spectrum Explorer. In Figure 11.2, you see an example of this table underneath the spectrum, with columns for LO frequency, longitude, Band, etc. Scrolling over, you will find the 'rowflag' column.

A flag value may just be a single bit with an already defined value (see Chapter 10), e.g. rowflag = 256 corresponds to bit = 8 (Unaligned_HK) (i.e. value=2n), or it can also be a combination (by addition) of two or more flag values, e.g. rowflag = 262400 is a combination of the rowflag Suspect_LO: bit = 18, value = 262144, and the rowflag Unaligned_HK: bit = 8, value = 256.

To determine if a particular bit is set, you can employ the mask classes defined in Chapter 10. For example, to test if a particular rowflag has the UnalignedHK bit set, you can type:

print RowMask.UNALIGNED_HK.isSet(rowflagvalue)

A script to test all rowflags is given below:

from herschel.hifi.pipeline.product import RowMask
#
## Extract the fourth spectrum from level 1 WBS-H in the
## Observation context
#
ds=obs.getProduct('level1').getProduct('WBS-H').get(4)
#
# Extract the rowflags and print out which are set:
#
flags=ds['rowflag'].data
print 'PACKET_ORDER:  ',RowMask.PACKET_ORDER.isSet(flags)
print 'PACKET_LENGTH: ',RowMask.PACKET_LENGTH.isSet(flags)
print 'TOO_MUCH_DATA: ',RowMask.TOO_MUCH_DATA.isSet(flags)
print 'FIRST_PACKET:  ',RowMask.FIRST_PACKET.isSet(flags)
print 'NO_BLOCK:      ',RowMask.NO_BLOCK.isSet(flags)
print 'UNALIGNED_HK:  ',RowMask.UNALIGNED_HK.isSet(flags)
print 'NO_CHOPPER:    ',RowMask.NO_CHOPPER.isSet(flags)
print 'NO_COM_CHOP:   ',RowMask.NO_COM_CHOP.isSet(flags)
print 'NO_FREQ_MON:   ',RowMask.NO_FREQ_MON.isSet(flags)
print 'NO_LO_OFF:     ',RowMask.NO_LO_OFF.isSet(flags)
print 'NO_LO_MAIN:    ',RowMask.NO_LO_MAIN.isSet(flags)
print 'MCD_REF:       ',RowMask.MCD_REF.isSet(flags)
print 'MCD_OFF:       ',RowMask.MCD_OFF.isSet(flags)
print 'MCD_HOT:       ',RowMask.MCD_HOT.isSet(flags)
print 'NO_HOT_COLD:   ',RowMask.NO_HOT_COLD.isSet(flags)
print 'SUSPECT_LO:    ',RowMask.SUSPECT_LO.isSet(flags)
print 'SPUR_DETECTED: ',RowMask.SPUR_DETECTED.isSet(flags)
print 'IGNORE_DATA:   ',RowMask.IGNORE_DATA.isSet(flags)
print 'BBID_CORR:     ',RowMask.BBID_CORR.isSet(flags)
print 'PERM_USER_FLAG:',RowMask.PERM_USER_FLAG.isSet(flags)
print 'TEMP_USER_FLAG:',RowMask.TEMP_USER_FLAG.isSet(flags)