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-27170: Deprecate and phase out afw::image::Filter #102

Merged
merged 2 commits into from
Jan 29, 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
4 changes: 0 additions & 4 deletions data/apdb-ap-pipe-schema-extra.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -612,10 +612,6 @@ columns:
type: CHAR
nullable: false
description: Name of stored filter.
- name: filterId
type: INT
nullable: false
description: id number of stored filter.
parejkoj marked this conversation as resolved.
Show resolved Hide resolved
- name: isDipole
type: BOOL
nullable: true
Expand Down
4 changes: 0 additions & 4 deletions python/lsst/ap/association/afwUtils.py
Original file line number Diff line number Diff line change
Expand Up @@ -711,9 +711,6 @@ def make_dia_source_schema():
schema.addField("filterName", type='String', size=10,
doc='String name of the filter this source was observed '
'in.')
schema.addField("filterId", type='L',
doc='Obs package id of the filter this source was '
'observed in.')
schema.addField("isDipole", type='Flag',
doc='Object determined to be a dipole.')
schema.addField("bboxSize", type='L',
Expand Down Expand Up @@ -769,7 +766,6 @@ def getCcdVisitSchemaSql():
return oDict([("ccdVisitId", "INTEGER PRIMARY KEY"),
("ccdNum", "INTEGER"),
("filterName", "TEXT"),
("filterId", "INTEGER"),
("ra", "REAL"),
("decl", "REAL"),
("expTime", "REAL"),
Expand Down
4 changes: 1 addition & 3 deletions python/lsst/ap/association/diaForcedSource.py
Original file line number Diff line number Diff line change
Expand Up @@ -277,9 +277,7 @@ def _calibrate_and_merge(self,
midPointTaiMJD = visit_info.getDate().get(system=DateTime.MJD)
output_catalog["ccdVisitId"] = ccdVisitId
output_catalog["midPointTai"] = midPointTaiMJD
# TODO DM-27170: fix this [0] workaround which gets a single character
# representation of the band.
output_catalog["filterName"] = diff_exp.getFilter().getCanonicalName()[0]
output_catalog["filterName"] = diff_exp.getFilterLabel().bandLabel
parejkoj marked this conversation as resolved.
Show resolved Hide resolved

# Drop superfluous columns from output DataFrame.
output_catalog.drop(columns=self.config.dropColumns, inplace=True)
Expand Down
6 changes: 1 addition & 5 deletions python/lsst/ap/association/mapApData.py
Original file line number Diff line number Diff line change
Expand Up @@ -232,10 +232,7 @@ def run(self, inputCatalog, exposure, return_pandas=False):
visit_info = exposure.getInfo().getVisitInfo()
ccdVisitId = visit_info.getExposureId()
midPointTaiMJD = visit_info.getDate().get(system=DateTime.MJD)
filterId = exposure.getFilter().getId()
# TODO DM-27170: fix this [0] workaround which gets a single character
# representation of the band.
filterName = exposure.getFilter().getCanonicalName()[0]
filterName = exposure.getFilterLabel().bandLabel
wcs = exposure.getWcs()

photoCalib = exposure.getPhotoCalib()
Expand All @@ -253,7 +250,6 @@ def run(self, inputCatalog, exposure, return_pandas=False):
self.computeBBoxSize(inputRecord, outputRecord)
outputRecord.set("ccdVisitId", ccdVisitId)
outputRecord.set("midPointTai", midPointTaiMJD)
outputRecord.set("filterId", filterId)
outputRecord.set("filterName", filterName)

if not outputCatalog.isContiguous():
Expand Down
23 changes: 3 additions & 20 deletions tests/test_association_task.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@
from lsst.afw.cameraGeom.testUtils import DetectorWrapper
import lsst.afw.geom as afwGeom
import lsst.afw.image as afwImage
import lsst.afw.image.utils as afwImageUtils
import lsst.afw.table as afwTable
import lsst.daf.base as dafBase
import lsst.geom as geom
Expand Down Expand Up @@ -162,15 +161,7 @@ class TestAssociationTask(unittest.TestCase):
def setUp(self):
"""Create a sqlite3 database with default tables and schemas.
"""
# CFHT Filters from the camera mapper.
self.filter_names = ["u", "g", "r", "i", "z"]
afwImageUtils.resetFilters()
afwImageUtils.defineFilter('u', lambdaEff=374, alias="u.MP9301")
afwImageUtils.defineFilter('g', lambdaEff=487, alias="g.MP9401")
afwImageUtils.defineFilter('r', lambdaEff=628, alias="r.MP9601")
afwImageUtils.defineFilter('i', lambdaEff=778, alias="i.MP9701")
afwImageUtils.defineFilter('z', lambdaEff=1170, alias="z.MP9801")

self.dia_object_schema = make_dia_object_schema()

# metadata taken from CFHT data
Expand Down Expand Up @@ -210,7 +201,7 @@ def setUp(self):
dafBase.DateTime.Timescale.TAI))
self.exposure.setDetector(detector)
self.exposure.getInfo().setVisitInfo(visit)
self.exposure.setFilter(afwImage.Filter('g'))
self.exposure.setFilterLabel(afwImage.FilterLabel(band='g'))
self.flux0 = 10000
self.flux0_err = 100
self.exposure.setPhotoCalib(
Expand Down Expand Up @@ -323,10 +314,7 @@ def _run_association_and_retrieve_objects(self, create_objects=False):
dia_source=dia_source,
flux=10000,
fluxErr=100,
# TODO DM-27170: fix this [0] workaround which gets a
# single character representation of the band.
filterName=self.exposure.getFilter().getCanonicalName()[0],
filterId=self.exposure.getFilter().getId(),
filterName=self.exposure.getFilterLabel().bandLabel,
ccdVisitId=self.exposure.getInfo().getVisitInfo().getExposureId(),
midPointTai=self.exposure.getInfo().getVisitInfo().getDate().get(system=dafBase.DateTime.MJD))

Expand Down Expand Up @@ -356,7 +344,7 @@ def _run_association_and_retrieve_objects(self, create_objects=False):
return results.diaObjects

def _set_source_values(self, dia_source, flux, fluxErr, filterName,
filterId, ccdVisitId, midPointTai):
ccdVisitId, midPointTai):
"""Set fluxes and visit info for DiaSources.

Parameters
Expand All @@ -369,8 +357,6 @@ def _set_source_values(self, dia_source, flux, fluxErr, filterName,
Flux error of DiaSource
filterName : `string`
Name of filter for flux.
filterId : `int`
Unique id of filter.
ccdVisitId : `int`
Integer id of this ccd/visit.
midPointTai : `double`
Expand All @@ -391,7 +377,6 @@ def _set_source_values(self, dia_source, flux, fluxErr, filterName,
(fluxErr / self.flux0) ** 2
+ (flux * self.flux0_err / self.flux0 ** 2) ** 2)
dia_source["filterName"] = filterName
dia_source["filterId"] = filterId
dia_source["x"] = 0.
dia_source["y"] = 0.

Expand Down Expand Up @@ -452,7 +437,6 @@ def _create_dia_objects_and_sources(self):
flux=10000,
fluxErr=100,
filterName='g',
filterId=1,
ccdVisitId=1232,
midPointTai=dateTime.get(system=dafBase.DateTime.MJD))
else:
Expand All @@ -461,7 +445,6 @@ def _create_dia_objects_and_sources(self):
flux=10000,
fluxErr=100,
filterName='r',
filterId=2,
ccdVisitId=1233,
midPointTai=dateTime.get(system=dafBase.DateTime.MJD))
dia_sources = dia_sources.asAstropy().to_pandas()
Expand Down
14 changes: 2 additions & 12 deletions tests/test_diaForcedSource.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@
from lsst.afw.cameraGeom.testUtils import DetectorWrapper
import lsst.afw.geom as afwGeom
import lsst.afw.image as afwImage
import lsst.afw.image.utils as afwImageUtils
import lsst.afw.table as afwTable
import lsst.daf.base as dafBase
import lsst.meas.algorithms as measAlg
Expand Down Expand Up @@ -67,15 +66,6 @@ def create_test_dia_objects(n_points, wcs, startPos=100):
class TestDiaForcedSource(unittest.TestCase):

def setUp(self):
# CFHT Filters from the camera mapper.
self.filter_names = ["u", "g", "r", "i", "z"]
parejkoj marked this conversation as resolved.
Show resolved Hide resolved
afwImageUtils.resetFilters()
afwImageUtils.defineFilter('u', lambdaEff=374, alias="u.MP9301")
afwImageUtils.defineFilter('g', lambdaEff=487, alias="g.MP9401")
afwImageUtils.defineFilter('r', lambdaEff=628, alias="r.MP9601")
afwImageUtils.defineFilter('i', lambdaEff=778, alias="i.MP9701")
afwImageUtils.defineFilter('z', lambdaEff=1170, alias="z.MP9801")

# metadata taken from CFHT data
# v695856-e0/v695856-e0-c000-a00.sci_img.fits
self.metadata = dafBase.PropertySet()
Expand Down Expand Up @@ -132,7 +122,7 @@ def setUp(self):
dafBase.DateTime.Timescale.TAI))
self.exposure.setDetector(detector)
self.exposure.getInfo().setVisitInfo(visit)
self.exposure.setFilter(afwImage.Filter('g'))
self.exposure.setFilterLabel(afwImage.FilterLabel(band='g', physical='g.MP9401'))
self.exposure.setPhotoCalib(afwImage.PhotoCalib(self.calibration, self.calibrationErr))

# Difference Image
Expand All @@ -148,7 +138,7 @@ def setUp(self):
self.diffim = afwImage.makeExposure(masked_image, self.wcs)
self.diffim.setDetector(detector)
self.diffim.getInfo().setVisitInfo(visit)
self.diffim.setFilter(afwImage.Filter('g'))
self.diffim.setFilterLabel(afwImage.FilterLabel(band='g', physical='g.MP9401'))
self.diffim.setPhotoCalib(afwImage.PhotoCalib(self.calibration, self.calibrationErr))

self.expIdBits = 16
Expand Down
8 changes: 1 addition & 7 deletions tests/test_loadDiaCatalogs.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@
from lsst.afw.cameraGeom.testUtils import DetectorWrapper
import lsst.afw.geom as afwGeom
import lsst.afw.image as afwImage
import lsst.afw.image.utils as afwImageUtils
from lsst.ap.association import (LoadDiaCatalogsTask,
LoadDiaCatalogsConfig,
make_dia_source_schema,
Expand Down Expand Up @@ -117,7 +116,7 @@ def makeExposure(flipX=False, flipY=False):
dafBase.DateTime.Timescale.TAI))
exposure.setDetector(detector)
exposure.getInfo().setVisitInfo(visit)
exposure.setFilter(afwImage.Filter('g'))
exposure.setFilterLabel(afwImage.FilterLabel(band='g'))

return exposure

Expand Down Expand Up @@ -249,11 +248,6 @@ class TestLoadDiaCatalogs(unittest.TestCase):
def setUp(self):
np.random.seed(1234)

# CFHT Filters from the camera mapper.
self.filter_names = ["g"]
afwImageUtils.resetFilters()
afwImageUtils.defineFilter('g', lambdaEff=487, alias="g.MP9401")

self.db_file_fd, self.db_file = tempfile.mkstemp(
dir=os.path.dirname(__file__))

Expand Down
12 changes: 1 addition & 11 deletions tests/test_map_ap_data.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@
import lsst.afw.table as afwTable
import lsst.daf.base as dafBase
import lsst.afw.image as afwImage
import lsst.afw.image.utils as afwImageUtils
import lsst.geom as geom
import lsst.meas.base.tests as measTests
from lsst.utils import getPackageDir
Expand Down Expand Up @@ -88,16 +87,7 @@ def make_input_source_catalog(dataset, add_flags=False):
class TestAPDataMapperTask(unittest.TestCase):

def setUp(self):

nSources = 10
# CFHT Filters from the camera mapper.
afwImageUtils.resetFilters()
afwImageUtils.defineFilter('u', lambdaEff=374, alias="u.MP9301")
afwImageUtils.defineFilter('g', lambdaEff=487, alias="g.MP9401")
afwImageUtils.defineFilter('r', lambdaEff=628, alias="r.MP9601")
afwImageUtils.defineFilter('i', lambdaEff=778, alias="i.MP9701")
afwImageUtils.defineFilter('z', lambdaEff=1170, alias="z.MP9801")

self.bbox = geom.Box2I(geom.Point2I(0, 0),
geom.Extent2I(1024, 1153))
dataset = measTests.TestDataset(self.bbox)
Expand All @@ -114,7 +104,7 @@ def setUp(self):
date=dafBase.DateTime(nsecs=1400000000 * 10**9))
self.exposure.setDetector(detector)
self.exposure.getInfo().setVisitInfo(visit)
self.exposure.setFilter(afwImage.Filter('g.MP9401'))
self.exposure.setFilterLabel(afwImage.FilterLabel(band='g', physical='g.MP9401'))
scale = 2
scaleErr = 1
self.photoCalib = afwImage.PhotoCalib(scale, scaleErr)
Expand Down
15 changes: 3 additions & 12 deletions tests/test_packageAlerts.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,6 @@
make_dia_object_schema)
from lsst.afw.cameraGeom.testUtils import DetectorWrapper
import lsst.afw.image as afwImage
import lsst.afw.image.utils as afwImageUtils
import lsst.daf.base as dafBase
from lsst.dax.apdb import Apdb, ApdbConfig
import lsst.geom as geom
Expand Down Expand Up @@ -157,10 +156,7 @@ def makeDiaSources(nSources, diaObjectIds, exposure):
"diaSourceId": idx,
"pixelId": htmIdx,
"midPointTai": midPointTaiMJD + 1.0 * idx,
# TODO DM-27170: fix this [0] workaround which gets a
# single character representation of the band.
"filterName": exposure.getFilter().getCanonicalName()[0],
"filterId": 0,
"filterName": exposure.getFilterLabel().bandLabel,
"psNdata": 0,
"trailNdata": 0,
"dipNdata": 0,
Expand Down Expand Up @@ -199,9 +195,7 @@ def makeDiaForcedSources(nSources, diaObjectIds, exposure):
"ccdVisitId": ccdVisitId + idx,
"diaObjectId": objId,
"midPointTai": midPointTaiMJD + 1.0 * idx,
# TODO DM-27170: fix this [0] workaround which gets a
# single character representation of the band.
"filterName": exposure.getFilter().getCanonicalName()[0],
"filterName": exposure.getFilterLabel().bandLabel,
"flags": 0})

return pd.DataFrame(data=data)
Expand Down Expand Up @@ -306,10 +300,7 @@ def setUp(self):
dafBase.DateTime.Timescale.TAI))
self.exposure.getInfo().setVisitInfo(visit)

self.filter_names = ["g"]
afwImageUtils.resetFilters()
afwImageUtils.defineFilter('g', lambdaEff=487, alias="g.MP9401")
self.exposure.setFilter(afwImage.Filter('g'))
self.exposure.setFilterLabel(afwImage.FilterLabel(band='g', physical="g.MP9401"))

diaObjects = makeDiaObjects(2, self.exposure)
diaSourceHistory = makeDiaSources(10,
Expand Down