Skip to content

Commit

Permalink
Rewrite lookupStaticCalibrations to avoid needing a special collection.
Browse files Browse the repository at this point in the history
This is probably a bit slower than the previous version, because it
can use multiple smaller queries instead of a single larger one
(depending on dimensions).  But it's at most n_detectors or
n_physical_filters extra queries, and that's a small price to pay for
being able to get rid of the special "unbounded" collection.
  • Loading branch information
TallJimbo committed Aug 25, 2023
1 parent 9393ac4 commit 9ff8052
Showing 1 changed file with 13 additions and 6 deletions.
19 changes: 13 additions & 6 deletions python/lsst/fgcmcal/utilities.py
Expand Up @@ -29,6 +29,7 @@
import re

from lsst.daf.base import PropertyList
from lsst.daf.butler import Timespan
import lsst.afw.table as afwTable
import lsst.afw.image as afwImage
import lsst.afw.math as afwMath
Expand Down Expand Up @@ -855,9 +856,15 @@ def extractReferenceMags(refStars, bands, filterMap):


def lookupStaticCalibrations(datasetType, registry, quantumDataId, collections):
instrument = Instrument.fromName(quantumDataId["instrument"], registry)
unboundedCollection = instrument.makeUnboundedCalibrationRunName()

return registry.queryDatasets(datasetType,
dataId=quantumDataId,
collections=[unboundedCollection])
# For static calibrations, we search with a timespan that has unbounded
# begin and end; we'll get an error if there's more than one match (because
# then it's not static).
timespan = Timespan(begin=None, end=None)
result = []
# First iterate over all of the data IDs for this dataset type that are
# consistent with the quantum data ID.
for dataId in registry.queryDataIds(datasetType.dimensions, dataId=quantumDataId):
# Find the dataset with this data ID using the unbounded timespan.
if ref := registry.findDataset(datasetType, dataId, collections=collections, timespan=timespan):
result.append(ref)
return ref

0 comments on commit 9ff8052

Please sign in to comment.