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-31825: Update defaults to new source table names #72

Merged
merged 2 commits into from
Sep 30, 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
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