Skip to content

Commit

Permalink
Merge branch 'tickets/DM-31825'
Browse files Browse the repository at this point in the history
  • Loading branch information
yalsayyad committed Sep 30, 2021
2 parents 676009e + c6b6e24 commit 9c3108e
Show file tree
Hide file tree
Showing 4 changed files with 42 additions and 19 deletions.
30 changes: 15 additions & 15 deletions python/lsst/fgcmcal/fgcmBuildStarsTable.py
Original file line number Diff line number Diff line change
Expand Up @@ -179,24 +179,24 @@ def setDefaults(self):
# sourceTable_visit catalogs, which differ from the raw src
# catalogs. Therefore, all field and flag names cannot
# be derived from the base config class.
self.instFluxField = 'ApFlux_12_0_instFlux'
self.localBackgroundFluxField = 'LocalBackground_instFlux'
self.apertureInnerInstFluxField = 'ApFlux_12_0_instFlux'
self.apertureOuterInstFluxField = 'ApFlux_17_0_instFlux'
self.psfCandidateName = 'Calib_psf_candidate'
self.instFluxField = 'apFlux_12_0_instFlux'
self.localBackgroundFluxField = 'localBackground_instFlux'
self.apertureInnerInstFluxField = 'apFlux_12_0_instFlux'
self.apertureOuterInstFluxField = 'apFlux_17_0_instFlux'
self.psfCandidateName = 'calib_psf_candidate'

sourceSelector = self.sourceSelector["science"]

fluxFlagName = self.instFluxField[0: -len('instFlux')] + 'flag'

sourceSelector.flags.bad = ['PixelFlags_edge',
'PixelFlags_interpolatedCenter',
'PixelFlags_saturatedCenter',
'PixelFlags_crCenter',
'PixelFlags_bad',
'PixelFlags_interpolated',
'PixelFlags_saturated',
'Centroid_flag',
sourceSelector.flags.bad = ['pixelFlags_edge',
'pixelFlags_interpolatedCenter',
'pixelFlags_saturatedCenter',
'pixelFlags_crCenter',
'pixelFlags_bad',
'pixelFlags_interpolated',
'pixelFlags_saturated',
'centroid_flag',
fluxFlagName]

if self.doSubtractLocalBackground:
Expand All @@ -207,7 +207,7 @@ def setDefaults(self):
sourceSelector.signalToNoise.errField = self.instFluxField + 'Err'

sourceSelector.isolated.parentName = 'parentSourceId'
sourceSelector.isolated.nChildName = 'Deblend_nChild'
sourceSelector.isolated.nChildName = 'deblend_nChild'

sourceSelector.unresolved.name = 'extendedness'

Expand Down Expand Up @@ -487,7 +487,7 @@ def fgcmMakeAllStarObservations(self, groupedDataRefs, visitCat,
# The "visit" name in the parquet table is hard-coded.
tempCat[visitKey][:] = df['visit'].values[use]
tempCat[ccdKey][:] = df[detColumn].values[use]
tempCat['psf_candidate'] = df['Calib_psf_candidate'].values[use]
tempCat['psf_candidate'] = df[self.config.psfCandidateName].values[use]

if self.config.doSubtractLocalBackground:
# At the moment we only adjust the flux and not the flux
Expand Down
8 changes: 4 additions & 4 deletions python/lsst/fgcmcal/utilities.py
Original file line number Diff line number Diff line change
Expand Up @@ -825,7 +825,7 @@ def computeApertureRadiusFromDataRef(dataRef, fluxField):
Raises
------
RuntimeError: Raised if flux field is not a CircularApertureFlux, ApFlux,
or associated slot.
apFlux, or associated slot.
"""
# TODO: Move this method to more general stack method in DM-25775
if isinstance(dataRef, dafPersist.ButlerDataRef):
Expand Down Expand Up @@ -866,11 +866,11 @@ def computeApertureRadiusFromName(fluxField):
Raises
------
RuntimeError: Raised if flux field is not a CircularApertureFlux
or ApFlux.
RuntimeError: Raised if flux field is not a CircularApertureFlux,
ApFlux, or apFlux.
"""
# TODO: Move this method to more general stack method in DM-25775
m = re.search(r'(CircularApertureFlux|ApFlux)_(\d+)_(\d+)_', fluxField)
m = re.search(r'(CircularApertureFlux|ApFlux|apFlux)_(\d+)_(\d+)_', fluxField)

if m is None:
raise RuntimeError(f"Flux field {fluxField} does not correspond to a CircularApertureFlux or ApFlux")
Expand Down
21 changes: 21 additions & 0 deletions tests/config/fgcmBuildStarsTableHsc.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,3 +33,24 @@
config.fgcmLoadReferenceCatalog.referenceSelector.doSignalToNoise = True
config.fgcmLoadReferenceCatalog.referenceSelector.signalToNoise.fluxField = 'i_flux'
config.fgcmLoadReferenceCatalog.referenceSelector.signalToNoise.errField = 'i_fluxErr'

# TODO: DM-31889: These overrides can be removed when testdata_jointcal is
# updated to the new column names.
config.instFluxField = 'ApFlux_12_0_instFlux'
config.localBackgroundFluxField = 'LocalBackground_instFlux'
config.apertureInnerInstFluxField = 'ApFlux_12_0_instFlux'
config.apertureOuterInstFluxField = 'ApFlux_17_0_instFlux'
config.psfCandidateName = 'Calib_psf_candidate'
config.sourceSelector['science'].flags.bad = ['PixelFlags_edge',
'PixelFlags_interpolatedCenter',
'PixelFlags_saturatedCenter',
'PixelFlags_crCenter',
'PixelFlags_bad',
'PixelFlags_interpolated',
'PixelFlags_saturated',
'Centroid_flag',
'ApFlux_12_0_flag',
'LocalBackground_flag']
config.sourceSelector['science'].signalToNoise.fluxField = 'ApFlux_12_0_instFlux'
config.sourceSelector['science'].signalToNoise.errField = 'ApFlux_12_0_instFluxErr'
config.sourceSelector['science'].isolated.nChildName = 'Deblend_nChild'
2 changes: 2 additions & 0 deletions tests/test_apertures.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,8 @@ def test_fgcmApertureHsc(self):

self.assertEqual(computeApertureRadiusFromName('ApFlux_12_0_instFlux'), 12.0)
self.assertEqual(computeApertureRadiusFromName('ApFlux_4_5_instFlux'), 4.5)
self.assertEqual(computeApertureRadiusFromName('apFlux_12_0_instFlux'), 12.0)
self.assertEqual(computeApertureRadiusFromName('apFlux_4_5_instFlux'), 4.5)
self.assertRaises(RuntimeError, computeApertureRadiusFromName, 'not_a_field')


Expand Down

0 comments on commit 9c3108e

Please sign in to comment.