Skip to content

Commit

Permalink
Merge branch 'tickets/DM-24253' into master
Browse files Browse the repository at this point in the history
  • Loading branch information
mrawls committed Nov 20, 2020
2 parents f735745 + b957cb2 commit 74ec3ae
Showing 1 changed file with 22 additions and 2 deletions.
24 changes: 22 additions & 2 deletions python/lsst/pipe/tasks/ingest.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
from glob import glob
from contextlib import contextmanager

from astro_metadata_translator import fix_header
from lsst.pex.config import Config, Field, DictField, ListField, ConfigurableField
from lsst.afw.fits import readMetadata
from lsst.pipe.base import Task, InputOnlyArgumentParser
Expand Down Expand Up @@ -67,17 +68,35 @@ class ParseTask(Task):
"""Task that will parse the filename and/or its contents to get the required information
for putting the file in the correct location and populating the registry."""
ConfigClass = ParseConfig
translator_class = None
"""Metadata translation support (astro_metadata_translator.MetadataTranslator).
Notes
-----
The default of `None` will attempt to guess the correct translator,
but specifying one (e.g., in obs-package specific ingest) will be faster.
"""

def getInfo(self, filename):
"""Get information about the image from the filename and its contents
Here, we open the image and parse the header, but one could also look at the filename itself
and derive information from that, or set values from the configuration.
@param filename Name of file to inspect
@return File properties; list of file properties for each extension
Parameters
----------
filename : `str`
Name of file to inspect
Returns
-------
phuInfo : `dict`
File properties
infoList : `list`
List of file properties for each extension
"""
md = readMetadata(filename, self.config.hdu)
fix_header(md, translator_class=self.translator_class)
phuInfo = self.getInfoFromMetadata(md)
if len(self.config.extnames) == 0:
# No extensions to worry about
Expand All @@ -90,6 +109,7 @@ def getInfo(self, filename):
extnum += 1
try:
md = readMetadata(filename, extnum)
fix_header(md, translator_class=self.translator_class)
except Exception as e:
self.log.warn("Error reading %s extensions %s: %s" % (filename, extnames, e))
break
Expand Down

0 comments on commit 74ec3ae

Please sign in to comment.