Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

DM-24253: Generate stack produced calibration products for HiTS #434

Merged
merged 2 commits into from
Nov 20, 2020
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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