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-29266: Deprecate specialist gen3 raw ingest task #86

Merged
merged 1 commit into from
Mar 23, 2021
Merged
Show file tree
Hide file tree
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
47 changes: 6 additions & 41 deletions python/lsst/obs/cfht/ingest.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,9 @@

import re

from lsst.daf.butler import ButlerURI, Formatter
from deprecated.sphinx import deprecated

import lsst.obs.base
from lsst.obs.base.ingest import RawFileData
from astro_metadata_translator import fix_header

from lsst.pipe.tasks.ingest import ParseTask
import lsst.pex.exceptions
Expand All @@ -46,47 +45,13 @@
}


@deprecated(reason="MegaPrime no longer requires a specialist gen3 ingest task. Please use the default."
" Will be removed after v23.",
category=FutureWarning,
version="22.0")
class MegaPrimeRawIngestTask(lsst.obs.base.RawIngestTask):
"""Task for ingesting raw MegaPrime multi-extension FITS data into Gen3.
"""
def extractMetadata(self, filename: ButlerURI) -> RawFileData:
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should this have an explicit pass for readability?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Python doesn't require it. The pass seems superfluous to me.

datasets = []

try:
with filename.as_local() as local_file:
fitsData = lsst.afw.fits.Fits(local_file.ospath, "r")

# NOTE: The primary header (HDU=0) does not contain detector
# data.
for i in range(1, fitsData.countHdus()):
fitsData.setHdu(i)
header = fitsData.readMetadata()
if not header["EXTNAME"].startswith("ccd"):
continue
fix_header(header)
datasets.append(self._calculate_dataset_info(header, filename))
except Exception as e:
self.log.debug("Problem extracting metadata from %s: %s", filename, e)
# Indicate to the caller that we failed to read.
# Do not try to ingest partial contents of file.
datasets = []
formatterClass = Formatter
instrument = None
self._on_metadata_failure(filename, e)
if self.config.failFast:
raise RuntimeError(f"Problem extracting metadata for file {filename}") from e
else:
# The data model currently assumes that whilst multiple datasets
# can be associated with a single file, they must all share the
# same formatter.
instrument, formatterClass = self._determine_instrument_formatter(datasets[0].dataId, filename)
if instrument is None:
datasets = []

self.log.info(f"Found images for {len(datasets)} detectors in {filename}")
return RawFileData(datasets=datasets, filename=filename,
FormatterClass=formatterClass,
instrumentClass=type(instrument))


class MegacamParseTask(ParseTask):
Expand Down
1 change: 0 additions & 1 deletion tests/test_ingest.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,6 @@ class MegaPrimeIngestTestCase(IngestTestBase, lsst.utils.tests.TestCase):
curatedCalibrationDatasetTypes = ()
ingestDir = os.path.dirname(__file__)
instrumentClassName = "lsst.obs.cfht.MegaPrime"
rawIngestTask = "lsst.obs.cfht.MegaPrimeRawIngestTask"
filterLabel = lsst.afw.image.FilterLabel(physical="i.MP9702", band="i")

@property
Expand Down