22__all__ = [
"getGen3CoaddExposureId"]
27def getGen3CoaddExposureId(dataRef, coaddName="deep", includeBand=True, log=None):
28 """Return the coadd expId consistent with Gen3 implementation.
30 This is a temporary interface intended to aid
with the migration
from
31 Gen2 to Gen3 middleware. It will be removed
with the Gen2 middleware.
35 dataRef : `lsst.daf.persistence.butlerSubset.ButlerDataRef`
36 The data reference
for the patch.
37 coaddName : `str`, optional
38 The prefix
for the coadd name, e.g.
"deep" for "deepCoadd"
39 includeBand : `bool`, optional
40 Whether to include band
as part of the dataId packing.
42 Logger object
for logging messages.
47 The integer id associated
with `patchRef` that mimics that of Gen3.
49 tract = dataRef.dataId["tract"]
50 patch = dataRef.dataId[
"patch"]
51 filter = dataRef.dataId[
"filter"]
52 skyMap = dataRef.get(coaddName +
"Coadd_skyMap")
53 tractInfo = skyMap[tract]
56 band = dataRef.get(coaddName +
"Coadd_band")
58 camera = dataRef.get(
"camera")
59 log.info(
"Filter %s has been assigned %s as the associated generic band for expId "
60 "computation.", filter, band)
64 camera = dataRef.get(
"camera")
65 log.info(
"No %s mapping found for %s. Using filter %s in dataId as band",
66 coaddName +
"Coadd_band", camera.getName(), band)
74 for patchInfo
in tractInfo:
75 patchIndexStr = str(patchInfo.getIndex()[0]) +
"," + str(patchInfo.getIndex()[1])
76 if patchIndexStr == patch:
77 patchNumId = tractInfo.getSequentialPatchIndex(patchInfo)
80 expId, maxBits = skyMap.pack_data_id(tract, patchNumId, band=band)
81 except Exception
as e:
83 log.warning(
"Setting exposureId to match Gen3 failed with: %s. Falling back to "
84 "Gen2 implementation.", e)
85 expId = int(dataRef.get(coaddName +
"CoaddId"))