Skip to content

Commit

Permalink
Merge pull request #187 from lsst/tickets/DM-38687
Browse files Browse the repository at this point in the history
DM-38687: Remove deprecated exposure-ID-bits arguments.
  • Loading branch information
TallJimbo committed Jan 4, 2024
2 parents 91e40bb + ec670fd commit ecae9a9
Show file tree
Hide file tree
Showing 5 changed files with 8 additions and 55 deletions.
26 changes: 3 additions & 23 deletions python/lsst/ap/association/diaForcedSource.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@

__all__ = ["DiaForcedSourceTask", "DiaForcedSourcedConfig"]

import warnings
import numpy as np

import lsst.afw.table as afwTable
Expand Down Expand Up @@ -93,10 +92,9 @@ def __init__(self, **kwargs):
def run(self,
dia_objects,
updatedDiaObjectIds,
expIdBits, # TODO: remove on DM-38687.
exposure,
diffim,
idGenerator=None):
idGenerator):
"""Measure forced sources on the direct and difference images.
Parameters
Expand All @@ -109,18 +107,12 @@ def run(self,
Array of diaObjectIds that were updated during this dia processing.
Used to assure that the pipeline includes all diaObjects that were
updated in case one falls on the edge of the CCD.
expIdBits : `int`
Bit length of the exposure id. Deprecated in favor of
``idGenerator``, and ignored if that is present. Pass `None`
explicitly to avoid a deprecation warning (a default is impossible
given that later positional arguments are not defaulted).
exposure : `lsst.afw.image.Exposure`
Direct image exposure.
diffim : `lsst.afw.image.Exposure`
Difference image.
idGenerator : `lsst.meas.base.IdGenerator`, optional
idGenerator : `lsst.meas.base.IdGenerator`
Object that generates source IDs and random number generator seeds.
Will be required after ``expIdBits`` is removed.
Returns
-------
Expand All @@ -131,19 +123,7 @@ def run(self,

afw_dia_objects = self._convert_from_pandas(dia_objects)

if expIdBits is not None:
warnings.warn(
"'expIdBits' argument is deprecated in favor of 'idGenerator'; will be removed after v26.",
category=FutureWarning,
stacklevel=3, # Caller + timeMethod
)

if idGenerator is None:
idFactoryDiff = afwTable.IdFactory.makeSource(
diffim.info.id,
afwTable.IdFactory.computeReservedFromMaxBits(int(expIdBits)))
else:
idFactoryDiff = idGenerator.make_table_id_factory()
idFactoryDiff = idGenerator.make_table_id_factory()

diffForcedSources = self.forcedMeasurement.generateMeasCat(
diffim,
Expand Down
19 changes: 2 additions & 17 deletions python/lsst/ap/association/diaPipe.py
Original file line number Diff line number Diff line change
Expand Up @@ -317,9 +317,6 @@ def __init__(self, initInputs=None, **kwargs):
def runQuantum(self, butlerQC, inputRefs, outputRefs):
inputs = butlerQC.get(inputRefs)
inputs["idGenerator"] = self.config.idGenerator.apply(butlerQC.quantum.dataId)
# Need to set ccdExposureIdBits (now deprecated) to None and pass it,
# since there are non-optional positional arguments after it.
inputs["ccdExposureIdBits"] = None
inputs["band"] = butlerQC.quantum.dataId["band"]
if not self.config.doSolarSystemAssociation:
inputs["solarSystemObjectTable"] = None
Expand All @@ -335,9 +332,8 @@ def run(self,
diffIm,
exposure,
template,
ccdExposureIdBits, # TODO: remove on DM-38687.
band,
idGenerator=None):
idGenerator):
"""Process DiaSources and DiaObjects.
Load previous DiaObjects and their DiaSource history. Calibrate the
Expand All @@ -357,17 +353,10 @@ def run(self,
``diffIm``.
template : `lsst.afw.image.ExposureF`
Template exposure used to create diffIm.
ccdExposureIdBits : `int`
Number of bits used for a unique ``ccdVisitId``. Deprecated in
favor of ``idGenerator``, and ignored if that is present (will be
removed after v26). Pass `None` explicitly to avoid a deprecation
warning (a default is impossible given that later positional
arguments are not defaulted).
band : `str`
The band in which the new DiaSources were detected.
idGenerator : `lsst.meas.base.IdGenerator`, optional
idGenerator : `lsst.meas.base.IdGenerator`
Object that generates source IDs and random number generator seeds.
Will be required after ``ccdExposureIdBits`` is removed.
Returns
-------
Expand Down Expand Up @@ -504,10 +493,6 @@ def run(self,
diaForcedSources = self.diaForcedSource.run(
diaCalResult.diaObjectCat,
diaCalResult.updatedDiaObjects.loc[:, "diaObjectId"].to_numpy(),
# Passing a ccdExposureIdBits here that isn't None will make
# diaForcedSource emit a deprecation warning, so we don't have to
# emit our own.
ccdExposureIdBits,
exposure,
diffIm,
idGenerator=idGenerator)
Expand Down
10 changes: 0 additions & 10 deletions python/lsst/ap/association/packageAlerts.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@

import io
import os
import warnings

from astropy import wcs
import astropy.units as u
Expand Down Expand Up @@ -86,7 +85,6 @@ def run(self,
diaForcedSources,
diffIm,
template,
ccdExposureIdBits=None, # TODO: remove (including docs) on DM-38687.
):
"""Package DiaSources/Object and exposure data into Avro alerts.
Expand All @@ -112,15 +110,7 @@ def run(self,
Difference image the sources in ``diaSourceCat`` were detected in.
template : `lsst.afw.image.ExposureF` or `None`
Template image used to create the ``diffIm``.
ccdExposureIdBits : `int`, optional
Unused. Deprecated and will be removed after v26.
"""
if ccdExposureIdBits is not None:
warnings.warn(
"The 'ccdExposureIdBits' argument is deprecated and unused; it will be removed after v26.",
category=FutureWarning,
stacklevel=3, # Caller + timeMethod
)
alerts = []
self._patchDiaSources(diaSourceCat)
self._patchDiaSources(diaSrcHistory)
Expand Down
5 changes: 2 additions & 3 deletions tests/test_diaForcedSource.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
import lsst.daf.base as dafBase
import lsst.meas.algorithms as measAlg
from lsst.ap.association import DiaForcedSourceTask
from lsst.meas.base import IdGenerator
import lsst.utils.tests


Expand Down Expand Up @@ -145,8 +146,6 @@ def setUp(self):
self.diffim.setFilter(afwImage.FilterLabel(band='g', physical='g.MP9401'))
self.diffim.setPhotoCalib(afwImage.PhotoCalib(self.calibration, self.calibrationErr))

self.expIdBits = 16

FWHM = 5
psf = measAlg.DoubleGaussianPsf(15, 15, FWHM/(2*np.sqrt(2*np.log(2))))
self.exposure.setPsf(psf)
Expand Down Expand Up @@ -184,7 +183,7 @@ def testRun(self):
test_objects.set_index("diaObjectId", inplace=True, drop=False)
dfs = DiaForcedSourceTask()
dia_forced_sources = dfs.run(
test_objects, self.updatedTestIds, self.expIdBits, self.exposure, self.diffim)
test_objects, self.updatedTestIds, self.exposure, self.diffim, IdGenerator())

direct_values = [199854.48417094944, 160097.40719241602,
82299.17897267535, 27148.604434624354,
Expand Down
3 changes: 1 addition & 2 deletions tests/test_packageAlerts.py
Original file line number Diff line number Diff line change
Expand Up @@ -288,8 +288,7 @@ def testRun(self):
self.diaSourceHistory,
self.diaForcedSources,
self.exposure,
self.exposure,
None)
self.exposure)

ccdVisitId = self.exposure.info.id
with open(os.path.join(tempdir, f"{ccdVisitId}.avro"), 'rb') as f:
Expand Down

0 comments on commit ecae9a9

Please sign in to comment.