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-38546: fixes while implementing new CalibrateImageTask #181

Merged
merged 7 commits into from
Jul 31, 2023
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.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 6 additions & 5 deletions python/lsst/meas/astrom/astrometry.py
Original file line number Diff line number Diff line change
Expand Up @@ -108,18 +108,19 @@ class AstrometryTask(RefMatchTask):
Parameters
----------
refObjLoader : `lsst.meas.algorithms.ReferenceLoader`
A reference object loader object
A reference object loader object; gen3 pipeline tasks will pass `None`
and call `setRefObjLoader` in `runQuantum`.
schema : `lsst.afw.table.Schema`
Used to set "calib_astrometry_used" flag in output source catalog.
**kwargs
additional keyword arguments for pipe_base
`lsst.pipe.base.Task.__init__`
Additional keyword arguments for pipe_base
`lsst.pipe.base.Task.__init__`.
"""
ConfigClass = AstrometryConfig
_DefaultName = "astrometricSolver"

def __init__(self, refObjLoader, schema=None, **kwargs):
RefMatchTask.__init__(self, refObjLoader, **kwargs)
def __init__(self, refObjLoader=None, schema=None, **kwargs):
RefMatchTask.__init__(self, refObjLoader=refObjLoader, **kwargs)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It'd be nice to actually deprecate this argument, but certainly out of scope for this ticket.

Copy link
Contributor Author

@parejkoj parejkoj Jul 14, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure we actually want to deprecate it: I could see uses of it in e.g. notebooks.


if schema is not None:
self.usedKey = schema.addField("calib_astrometry_used", type="Flag",
Expand Down
14 changes: 3 additions & 11 deletions python/lsst/meas/astrom/directMatch.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@

__all__ = ["DirectMatchConfig", "DirectMatchTask", "DirectMatchConfigWithoutLoader"]

import warnings

from lsst.pex.config import Config, Field, ConfigurableField, ConfigField
from lsst.pipe.base import Task, Struct
from lsst.meas.algorithms import (LoadReferenceObjectsConfig, ScienceSourceSelectorTask,
Expand Down Expand Up @@ -37,23 +35,17 @@ class DirectMatchTask(Task):
butler : `None`
Compatibility parameter. Should not be used.
refObjLoader : `lsst.meas.algorithms.ReferenceObjectLoader` or `None`
For loading reference objects.
A reference object loader object; gen3 pipeline tasks will pass `None`
and call `setRefObjLoader` in `runQuantum`.
**kwargs
Other keyword arguments required for instantiating a Task (such as
``config``).
"""
ConfigClass = DirectMatchConfig
_DefaultName = "directMatch"

def __init__(self, butler=None, refObjLoader=None, **kwargs):
def __init__(self, refObjLoader=None, **kwargs):
Task.__init__(self, **kwargs)
if not refObjLoader:
if butler:
if not isinstance(self.config, DirectMatchConfig):
raise RuntimeError("DirectMatchTask must be initialized with DirectMatchConfig "
"if a refObjLoader is not supplied at initialization")
warnings.warn("The 'butler' parameter is no longer used and can be safely removed.",
category=FutureWarning, stacklevel=2)
self.refObjLoader = refObjLoader
self.makeSubtask("sourceSelection")
self.makeSubtask("referenceSelection")
Expand Down
9 changes: 9 additions & 0 deletions python/lsst/meas/astrom/matchPessimisticB.py
Original file line number Diff line number Diff line change
Expand Up @@ -267,6 +267,15 @@ def matchObjectsToSources(self, refCat, sourceCat, wcs, sourceFluxField, refFlux
int(self.config.minFracMatchedPairs
* min([len(refCat), len(goodSourceCat)])))

if len(goodSourceCat) <= self.config.numPointsForShape:
msg = (f"Not enough catalog objects ({len(goodSourceCat)}) to make a "
f"shape for the matcher (need {self.config.numPointsForShape}).")
raise RuntimeError(msg)
if len(refCat) <= self.config.numPointsForShape:
msg = (f"Not enough refcat objects ({len(refCat)}) to make a "
f"shape for the matcher (need {self.config.numPointsForShape}).")
raise RuntimeError(msg)

if len(refCat) > self.config.maxRefObjects:
self.log.warning(
"WARNING: Reference catalog larger that maximum allowed. "
Expand Down
12 changes: 6 additions & 6 deletions python/lsst/meas/astrom/ref_match.py
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,6 @@ class RefMatchConfig(pexConfig.Config):
)

def setDefaults(self):
self.sourceSelector.name = "science"
self.sourceSelector['science'].fluxLimit.fluxField = \
'slot_%sFlux_instFlux' % (self.sourceFluxType)
self.sourceSelector['science'].signalToNoise.fluxField = \
Expand All @@ -80,14 +79,15 @@ class RefMatchTask(pipeBase.Task):
Parameters
----------
refObjLoader : `lsst.meas.algorithms.ReferenceLoader`
A reference object loader object
A reference object loader object; gen3 pipeline tasks will pass `None`
and call `setRefObjLoader` in `runQuantum`.
**kwargs
additional keyword arguments for pipe_base `lsst.pipe.base.Task`
Additional keyword arguments for pipe_base `lsst.pipe.base.Task`.
"""
ConfigClass = RefMatchConfig
_DefaultName = "calibrationBaseClass"

def __init__(self, refObjLoader, **kwargs):
def __init__(self, refObjLoader=None, **kwargs):
pipeBase.Task.__init__(self, **kwargs)
if refObjLoader:
self.refObjLoader = refObjLoader
Expand All @@ -104,12 +104,12 @@ def __init__(self, refObjLoader, **kwargs):
self.makeSubtask("referenceSelector")

def setRefObjLoader(self, refObjLoader):
"""Sets the reference object loader for the task
"""Sets the reference object loader for the task.

Parameters
----------
refObjLoader
An instance of a reference object loader task or class
An instance of a reference object loader task or class.
"""
self.refObjLoader = refObjLoader

Expand Down