Skip to content

Commit

Permalink
Cleanup refcat loaders
Browse files Browse the repository at this point in the history
LoadIndexedReferenceObjectsTask and ref_dataset_name are gen2 only, but we have
to keep using the former for the ConfigField until it has followed one
deprecation cycle (`ref_dataset_name` exists in currently-used configs).
  • Loading branch information
parejkoj committed Jul 22, 2022
1 parent fb722ac commit 8652d17
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 17 deletions.
22 changes: 10 additions & 12 deletions python/lsst/jointcal/jointcal.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,8 @@
from lsst.pipe.tasks.colorterms import ColortermLibrary
from lsst.verify import Job, Measurement

from lsst.meas.algorithms import (LoadIndexedReferenceObjectsTask, ReferenceSourceSelectorTask,
ReferenceObjectLoader)
from lsst.meas.algorithms import (ReferenceObjectLoader, ReferenceSourceSelectorTask,
LoadIndexedReferenceObjectsConfig)
from lsst.meas.algorithms.sourceSelector import sourceSelectorRegistry

import lsst.jointcal
Expand Down Expand Up @@ -424,12 +424,12 @@ class JointcalConfig(pipeBase.PipelineTaskConfig,
dtype=int,
default=20,
)
astrometryRefObjLoader = pexConfig.ConfigurableField(
target=LoadIndexedReferenceObjectsTask,
astrometryRefObjLoader = pexConfig.ConfigField(
dtype=LoadIndexedReferenceObjectsConfig,
doc="Reference object loader for astrometric fit",
)
photometryRefObjLoader = pexConfig.ConfigurableField(
target=LoadIndexedReferenceObjectsTask,
photometryRefObjLoader = pexConfig.ConfigField(
dtype=LoadIndexedReferenceObjectsConfig,
doc="Reference object loader for photometric fit",
)
sourceSelector = sourceSelectorRegistry.makeField(
Expand Down Expand Up @@ -535,12 +535,10 @@ def setDefaults(self):
]
self.sourceSelector["science"].flags.bad = badFlags

# Default to Gaia-DR2 (with proper motions) for astrometry and
# PS1-DR1 for photometry.
self.astrometryRefObjLoader.ref_dataset_name = "gaia_dr2_20200414"
# Use Gaia-DR2 with proper motions for astrometry; phot_g_mean is the
# primary Gaia band, but is not like any normal photometric band.
self.astrometryRefObjLoader.requireProperMotion = True
self.astrometryRefObjLoader.anyFilterMapsToThis = "phot_g_mean"
self.photometryRefObjLoader.ref_dataset_name = "ps1_pv3_3pi_20170110"


def writeModel(model, filename, log):
Expand Down Expand Up @@ -1000,7 +998,7 @@ def _do_load_refcat_and_fit(self, associations, defaultFilter, center, radius,
On-sky radius to load from reference catalog.
name : `str`
Name of thing being fit: "astrometry" or "photometry".
refObjLoader : `lsst.meas.algorithms.LoadReferenceObjectsTask`
refObjLoader : `lsst.meas.algorithms.ReferenceObjectLoader`
Reference object loader to use to load a reference catalog.
referenceSelector : `lsst.meas.algorithms.ReferenceSourceSelectorTask`
Selector to use to pick objects from the loaded reference catalog.
Expand Down Expand Up @@ -1074,7 +1072,7 @@ def _load_reference_catalog(self, refObjLoader, referenceSelector, center, radiu
Parameters
----------
refObjLoader : `lsst.meas.algorithms.LoadReferenceObjectsTask`
refObjLoader : `lsst.meas.algorithms.ReferenceObjectLoader`
The reference catalog loader to use to get the data.
referenceSelector : `lsst.meas.algorithms.ReferenceSourceSelectorTask`
Source selector to apply to loaded reference catalog.
Expand Down
8 changes: 3 additions & 5 deletions tests/test_jointcal.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
import lsst.daf.butler
from lsst.daf.base import DateTime
import lsst.geom
from lsst.meas.algorithms import getRefFluxField, LoadIndexedReferenceObjectsTask, DatasetConfig
from lsst.meas.algorithms import getRefFluxField, ReferenceObjectLoader
import lsst.obs.base
import lsst.pipe.base
import lsst.jointcal
Expand All @@ -52,8 +52,7 @@ def setup_module(module):

def make_fake_refcat(center, flux, filterName):
"""Make a fake reference catalog."""
schema = LoadIndexedReferenceObjectsTask.makeMinimalSchema([filterName],
addProperMotion=True)
schema = ReferenceObjectLoader.makeMinimalSchema([filterName], addProperMotion=True)
catalog = lsst.afw.table.SimpleCatalog(schema)
record = catalog.addNew()
record.setCoord(center)
Expand Down Expand Up @@ -159,7 +158,6 @@ def setUp(self):

# Mock a Butler so the refObjLoaders have something to call `get()` on.
self.butler = unittest.mock.Mock(spec=lsst.daf.butler.Butler)
self.butler.get.return_value.indexer = DatasetConfig().indexer

# Mock the association manager and give it access to the ccd list above.
self.associations = mock.Mock(spec=lsst.jointcal.Associations)
Expand Down Expand Up @@ -304,7 +302,7 @@ def _make_fake_refcat(self):
fakeRefCat = make_fake_refcat(center, flux, filter.bandLabel)
fluxField = getRefFluxField(fakeRefCat.schema, filter.bandLabel)
returnStruct = lsst.pipe.base.Struct(refCat=fakeRefCat, fluxField=fluxField)
refObjLoader = mock.Mock(spec=LoadIndexedReferenceObjectsTask)
refObjLoader = mock.Mock(spec=ReferenceObjectLoader)
refObjLoader.loadSkyCircle.return_value = returnStruct

return refObjLoader, center, radius, filter, fakeRefCat
Expand Down

0 comments on commit 8652d17

Please sign in to comment.