Skip to content

Commit

Permalink
Add fix_header class method to handle raw decam bias filter mismatch
Browse files Browse the repository at this point in the history
  • Loading branch information
mrawls committed Nov 19, 2020
1 parent 00cc688 commit 26790af
Showing 1 changed file with 44 additions and 0 deletions.
44 changes: 44 additions & 0 deletions python/astro_metadata_translator/translators/decam.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@

import re
import posixpath
import logging

from astropy.coordinates import EarthLocation, Angle
import astropy.units as u
Expand All @@ -24,6 +25,8 @@
from .helpers import altaz_from_degree_headers, is_non_science, \
tracking_from_degree_headers

log = logging.getLogger(__name__)


class DecamTranslator(FitsTranslator):
"""Metadata translator for DECam standard headers.
Expand Down Expand Up @@ -248,3 +251,44 @@ def to_detector_name(self):
# Docstring will be inherited. Property defined in properties.py
name = self.to_detector_unique_name()
return name[1:]

@classmethod
def fix_header(cls, header, obsid, filename=None):
"""Fix DECam headers.
Parameters
----------
header : `dict`
The header to update. Updates are in place.
obsid : `str`
Unique observation identifier associated with this header.
Will always be provided.
filename : `str`, optional
Filename associated with this header. May not be set since headers
can be fixed independently of any filename being known.
Returns
-------
modified = `bool`
Returns `True` if the header was updated.
Notes
-----
Fixes the following issues:
* If OBSTYPE contains "zero" or "bias",
update the FILTER keyword to "solid plate 0.0 0.0".
Corrections are reported as debug level log messages.
"""
modified = False

obsid = header.get("OBSID", "unknown")
obstype = header.get("OBSTYPE", "unknown")

if "bias" in obstype.lower() or "zero" in obstype.lower():
header["FILTER"] = "solid plate 0.0 0.0"
modified = True
log.debug("%s: Set FILTER to %s because OBSTYPE is %s",
obsid, header["FILTER"], header["OBSTYPE"])

return modified

0 comments on commit 26790af

Please sign in to comment.