|
13 | 13 | from aiapy.util.decorators import validate_channel |
14 | 14 | from aiapy.util.net import _get_data_from_jsoc |
15 | 15 |
|
16 | | -__all__ = ["sdo_location", "telescope_number"] |
| 16 | +__all__ = ["check_quality_flag", "sdo_location", "telescope_number"] |
| 17 | + |
| 18 | +# This comes from Table 2 in Section 7.7.6 of the SDO User Guide |
| 19 | +_QUALITY_FLAG_MESSAGES = { |
| 20 | + 0: "Flatfield data are not available", |
| 21 | + 1: "Orbit data are not available", |
| 22 | + 2: "Ancillary science data are not available", |
| 23 | + 3: "Master pointing data are not available", |
| 24 | + 4: "Limb-fit data are not available (generally not applicable to AIA images)", |
| 25 | + 8: "Value of MISSVALS keyword is nonzero", |
| 26 | + 9: "Value of MISSVALS keyword is more than 1% of the value of the TOTVALS keyword", |
| 27 | + 10: "Value of MISSVALS keyword is more than 5% of the value of the TOTVALS keyword", |
| 28 | + 11: "Value of MISSVALS keyword is more than 25% of the value of the TOTVALS keyword", |
| 29 | + 12: "Spacecraft is not in science pointing mode (coincides with ACS_MODE keyword set to a value other than SCIENCE)", |
| 30 | + 13: "Spacecraft eclipse flag is set (coincides with ACS_ECLP keyword set to YES)", |
| 31 | + 14: "Spacecraft sun presence flag is not set (coincides with ACS_SUNP keyword set to NO)", |
| 32 | + 15: "Spacecraft safe mode flag is set (coincides with ACS_SAFE keyword set to YES)", |
| 33 | + 16: "Dark image flag is set (coincides with IMG_TYPE keyword set to DARK)", |
| 34 | + 17: "Image Stabilization System (ISS) loop is open (coincides with AISTATE keyword set to OPEN)", |
| 35 | + 18: "Calibration image", |
| 36 | + 20: "Focus is out of range", |
| 37 | + 21: "Register flag is set", |
| 38 | + 30: "Quicklook image", |
| 39 | + 31: "Image is not available", |
| 40 | +} |
| 41 | + |
| 42 | + |
| 43 | +def check_quality_flag(quality): |
| 44 | + """ |
| 45 | + Interpret the ``QUALITY`` flag in the header of an AIA observation. |
| 46 | +
|
| 47 | + AIA images are occasionally affected by operations associated with |
| 48 | + calibration maneuvers or are missing data e.g. due to eclipses. For |
| 49 | + these operating periods, the ``QUALITY`` keyword in the header, |
| 50 | + a 32-bit integer, records the reason for the operation not being |
| 51 | + nominal. Various flags for different operating modes are encoded |
| 52 | + bitwise such that ``QUALITY`` can indicate multiple non-nominal |
| 53 | + operating modes. For more information, see |
| 54 | + `section 7.7.6 of the SDO user guide <https://www.lmsal.com/sdodocs/doc/dcur/SDOD0060.zip/zip/entry/>`__. |
| 55 | + This function decodes the ``QUALITY`` flag and returns a string |
| 56 | + indicating the reason(s) for the flags being set. For a nominal |
| 57 | + operation (``QUALITY==0``), "nominal" is returned. |
| 58 | +
|
| 59 | + Parameters |
| 60 | + ---------- |
| 61 | + quality: `int` |
| 62 | + Quality flag encoded as an integer. This is typically found in |
| 63 | + the ``QUALITY`` keyword in the FITS header. |
| 64 | +
|
| 65 | + Returns |
| 66 | + ------- |
| 67 | + : `list` |
| 68 | + Messages associated with quality flags that are set. |
| 69 | + """ |
| 70 | + flags = [i for i in range(32) if (quality & (1 << i))] |
| 71 | + if flags: |
| 72 | + return [_QUALITY_FLAG_MESSAGES.get(f, "(empty)") for f in flags] |
| 73 | + return ["nominal"] |
17 | 74 |
|
18 | 75 |
|
19 | 76 | def sdo_location(time): |
|
0 commit comments