Skip to content

Commit

Permalink
Replace uses of filter to physicalFilter as appropriate.
Browse files Browse the repository at this point in the history
  • Loading branch information
erykoff committed Feb 1, 2021
1 parent b155db7 commit c67d0a2
Show file tree
Hide file tree
Showing 13 changed files with 171 additions and 171 deletions.
35 changes: 22 additions & 13 deletions python/lsst/fgcmcal/fgcmBuildStarsBase.py
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,15 @@ class FgcmBuildStarsConfigBase(pexConfig.Config):
keytype=str,
itemtype=str,
default={},
deprecated=("This field is no longer used, and has been deprecated by "
"DM-28088. It will be removed after v22. Use "
"physicalFilterMap instead.")
)
physicalFilterMap = pexConfig.DictField(
doc="Mapping from 'physicalFilter' to band.",
keytype=str,
itemtype=str,
default={},
)
requiredBands = pexConfig.ListField(
doc="Bands required for each star",
Expand Down Expand Up @@ -549,16 +558,17 @@ def _fillVisitCatalog(self, visitCat, groupedDataRefs, bkgDataRefDict=None,
if isinstance(dataRef, dafPersist.ButlerDataRef):
exp = dataRef.get(datasetType='calexp_sub', bbox=bbox)
visitInfo = exp.getInfo().getVisitInfo()
f = exp.getFilter()
label = dataRef.get(datasetType='calexp_filterLabel')
physicalFilter = label.physicalLabel
psf = exp.getPsf()
else:
visitInfo = dataRef.get(component='visitInfo')
f = dataRef.get(component='filter')
physicalFilter = dataRef.dataId['physical_filter']
psf = dataRef.get(component='psf')

rec = visitCat[i]
rec['visit'] = visit
rec['filtername'] = f.getName()
rec['physicalFilter'] = physicalFilter
# TODO DM-26991: when gen2 is removed, gen3 workflow will make it
# much easier to get the wcs's necessary to recompute the pointing
# ra/dec at the center of the camera.
Expand Down Expand Up @@ -688,9 +698,9 @@ def fgcmMatchStars(self, visitCat, obsCat, lutDataRef=None):
"""
# get filter names into a numpy array...
# This is the type that is expected by the fgcm code
visitFilterNames = np.zeros(len(visitCat), dtype='a10')
visitFilterNames = np.zeros(len(visitCat), dtype='a30')
for i in range(len(visitCat)):
visitFilterNames[i] = visitCat[i]['filtername']
visitFilterNames[i] = visitCat[i]['physicalFilter']

# match to put filterNames with observations
visitIndex = np.searchsorted(visitCat['visit'],
Expand All @@ -703,10 +713,10 @@ def fgcmMatchStars(self, visitCat, obsCat, lutDataRef=None):
lutCat = lutDataRef.get()

stdFilterDict = {filterName: stdFilter for (filterName, stdFilter) in
zip(lutCat[0]['filterNames'].split(','),
lutCat[0]['stdFilterNames'].split(','))}
zip(lutCat[0]['physicalFilters'].split(','),
lutCat[0]['stdPhysicalFilters'].split(','))}
stdLambdaDict = {stdFilter: stdLambda for (stdFilter, stdLambda) in
zip(lutCat[0]['stdFilterNames'].split(','),
zip(lutCat[0]['stdPhysicalFilters'].split(','),
lutCat[0]['lambdaStdFilter'])}

del lutCat
Expand All @@ -722,9 +732,9 @@ def fgcmMatchStars(self, visitCat, obsCat, lutDataRef=None):
referenceFilterNames = []

# make the fgcm starConfig dict

print(self.config.physicalFilterMap)
starConfig = {'logger': self.log,
'filterToBand': self.config.filterMap,
'filterToBand': self.config.physicalFilterMap,
'requiredBands': self.config.requiredBands,
'minPerBand': self.config.minPerBand,
'matchRadius': self.config.matchRadius,
Expand Down Expand Up @@ -824,8 +834,7 @@ def _makeFgcmVisitSchema(self, nCcd):

schema = afwTable.Schema()
schema.addField('visit', type=np.int32, doc="Visit number")
# Note that the FGCM code currently handles filternames up to 2 characters long
schema.addField('filtername', type=str, size=10, doc="Filter name")
schema.addField('physicalFilter', type=str, size=30, doc="Physical filter")
schema.addField('telra', type=np.float64, doc="Pointing RA (deg)")
schema.addField('teldec', type=np.float64, doc="Pointing Dec (deg)")
schema.addField('telha', type=np.float64, doc="Pointing Hour Angle (deg)")
Expand Down Expand Up @@ -923,7 +932,7 @@ def _getReferenceFilterNames(self, visitCat, stdFilterDict, stdLambdaDict):
"""

# Find the unique list of filter names in visitCat
filterNames = np.unique(visitCat.asAstropy()['filtername'])
filterNames = np.unique(visitCat.asAstropy()['physicalFilter'])

# Find the unique list of "standard" filters
stdFilterNames = {stdFilterDict[filterName] for filterName in filterNames}
Expand Down
17 changes: 4 additions & 13 deletions python/lsst/fgcmcal/fgcmCalibrateTractBase.py
Original file line number Diff line number Diff line change
Expand Up @@ -240,20 +240,11 @@ def runDataRef(self, butler, dataRefs):
if struct.photoCalibs is not None:
self.log.info("Outputting photoCalib files.")

filterMapping = {}
for visit, detector, filtername, photoCalib in struct.photoCalibs:
if filtername not in filterMapping:
# We need to find the mapping from encoded filter to dataid filter,
# and this trick allows us to do that.
dataId = {visitDataRefName: visit,
ccdDataRefName: detector}
dataRef = butler.dataRef('raw', dataId=dataId)
filterMapping[filtername] = dataRef.dataId['filter']

for visit, detector, physicalFilter, photoCalib in struct.photoCalibs:
butler.put(photoCalib, 'fgcm_tract_photoCalib',
dataId={visitDataRefName: visit,
ccdDataRefName: detector,
'filter': filterMapping[filtername],
'filter': physicalFilter,
'tract': tract})

self.log.info("Done outputting photoCalib files.")
Expand Down Expand Up @@ -380,7 +371,7 @@ def run(self, dataRefDict, tract,
# Load the LUT
lutCat = dataRefDict['fgcmLookUpTable'].get()
fgcmLut, lutIndexVals, lutStd = translateFgcmLut(lutCat,
dict(self.config.fgcmFitCycle.filterMap))
dict(self.config.fgcmFitCycle.physicalFilterMap))
del lutCat

# Translate the visit catalog into fgcm format
Expand Down Expand Up @@ -426,7 +417,7 @@ def run(self, dataRefDict, tract,

refMag, refMagErr = extractReferenceMags(fgcmRefCat,
self.config.fgcmFitCycle.bands,
self.config.fgcmFitCycle.filterMap)
self.config.fgcmFitCycle.physicalFilterMap)
refId = fgcmRefCat['fgcm_id'][:]

fgcmStars = fgcm.FgcmStars(fgcmFitCycle.fgcmConfig)
Expand Down
14 changes: 12 additions & 2 deletions python/lsst/fgcmcal/fgcmFitCycle.py
Original file line number Diff line number Diff line change
Expand Up @@ -242,6 +242,15 @@ class FgcmFitCycleConfig(pipeBase.PipelineTaskConfig,
keytype=str,
itemtype=str,
default={},
deprecated=("This field is no longer used, and has been deprecated by "
"DM-28088. It will be removed after v22. Use "
"physicalFilterMap instead.")
)
physicalFilterMap = pexConfig.DictField(
doc="Mapping from 'physicalFilter' to band.",
keytype=str,
itemtype=str,
default={},
)
doReferenceCalibration = pexConfig.Field(
doc="Use reference catalog as additional constraint on calibration",
Expand Down Expand Up @@ -1075,7 +1084,8 @@ def _fgcmFitCycle(self, camera, dataRefDict):
self.outputZeropoints)

lutCat = dataRefDict['fgcmLookUpTable'].get()
fgcmLut, lutIndexVals, lutStd = translateFgcmLut(lutCat, dict(self.config.filterMap))
fgcmLut, lutIndexVals, lutStd = translateFgcmLut(lutCat,
dict(self.config.physicalFilterMap))
del lutCat

# next we need the exposure/visit information
Expand Down Expand Up @@ -1132,7 +1142,7 @@ def _fgcmFitCycle(self, camera, dataRefDict):

refMag, refMagErr = extractReferenceMags(refStars,
self.config.bands,
self.config.filterMap)
self.config.physicalFilterMap)
refId = refStars['fgcm_id'][:]
else:
refStars = None
Expand Down

0 comments on commit c67d0a2

Please sign in to comment.