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-43077: Convert all tasks to use CalibrateImageTask outputs #43

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 2 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
1 change: 0 additions & 1 deletion bin.src/ci_imsim_run.py
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,6 @@ def run(self, currentState: BuildState):
"-p", "$DRP_PIPE_DIR/pipelines/LSSTCam-imSim/DRP-ci_imsim.yaml",
"--skip-existing",
"--save-qgraph", os.path.join(self.runner.RunDir, QGRAPH_FILE),
"--config", f"calibrate:deblend.useCiLimits={not self.arguments.no_limit_deblend}",
Copy link
Contributor

Choose a reason for hiding this comment

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

Is this not implemented in the new task? I vaguely remember it didn't work right anyway and only the multiband one was really necessary (to limit Scarlet runtime, which might also be moot now).

"--config", f"deblend:multibandDeblend.processSingles={self.arguments.process_singles}",
"--config", f"deblend:multibandDeblend.useCiLimits={not self.arguments.no_limit_deblend}",
)
Expand Down
37 changes: 19 additions & 18 deletions tests/test_calibrate.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,54 +29,55 @@
from lsst.utils import getPackageDir


class TestCalibrateOutputs(lsst.utils.tests.TestCase):
"""Test the output data products of calibrate task make sense
class TestReprocessVisitImageOutputs(lsst.utils.tests.TestCase):
"""Test the output data products of ReprocessVisitImageTask make sense.

This is a regression test and not intended for scientific validation
This is a regression test and not intended for scientific validation.
"""

def setUp(self):
self.butler = Butler(os.path.join(getPackageDir("ci_imsim"), "DATA"),
writeable=False, collections=["LSSTCam-imSim/runs/ci_imsim"])
self.dataId = {"detector": 55, "visit": 206039, "band": "y"}
self.calexp = self.butler.get("calexp", self.dataId)
self.src = self.butler.get("src", self.dataId)
self.exposure = self.butler.get("pvi", self.dataId)
self.catalog = self.butler.get("sources_footprints_detector", self.dataId)

def testLocalPhotoCalibColumns(self):
"""Check calexp's calibs are consistent with src's photocalib columns
"""Check exposure's calibs are consistent with catalog's
Copy link
Contributor

Choose a reason for hiding this comment

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

Check that

photocalib columns.
"""
# Check that means are in the same ballpark
calexpCalib = self.calexp.getPhotoCalib().getCalibrationMean()
calexpCalibErr = self.calexp.getPhotoCalib().getCalibrationErr()
srcCalib = np.mean(self.src['base_LocalPhotoCalib'])
srcCalibErr = np.mean(self.src['base_LocalPhotoCalibErr'])
exposureCalib = self.exposure.photoCalib.getCalibrationMean()
exposureCalibErr = self.exposure.photoCalib.getCalibrationErr()
catalogCalib = np.mean(self.catalog['base_LocalPhotoCalib'])
catalogCalibErr = np.mean(self.catalog['base_LocalPhotoCalibErr'])

self.assertAlmostEqual(calexpCalib, srcCalib, places=3)
self.assertAlmostEqual(calexpCalibErr, srcCalibErr, places=3)
self.assertAlmostEqual(exposureCalib, catalogCalib, places=3)
self.assertAlmostEqual(exposureCalibErr, catalogCalibErr, places=3)

# and that calibs evalutated at local positions match a few rows
randomRows = [0, 8, 20]
for rowNum in randomRows:
record = self.src[rowNum]
localEval = self.calexp.getPhotoCalib().getLocalCalibration(record.getCentroid())
record = self.catalog[rowNum]
localEval = self.exposure.photoCalib.getLocalCalibration(record.getCentroid())
self.assertAlmostEqual(localEval, record['base_LocalPhotoCalib'])

def testLocalWcsColumns(self):
"""Check the calexp's wcs match local wcs columns in src
"""Check the initial_pvi's wcs match local wcs columns in initial_stars
"""
# Check a few rows:
randomRows = [1, 9, 21]
for rowNum in randomRows:
record = self.src[rowNum]
record = self.catalog[rowNum]
centroid = record.getCentroid()
trueCdMatrix = np.radians(self.calexp.getWcs().getCdMatrix(centroid))
trueCdMatrix = np.radians(self.exposure.wcs.getCdMatrix(centroid))

self.assertAlmostEqual(record['base_LocalWcs_CDMatrix_1_1'], trueCdMatrix[0, 0])
self.assertAlmostEqual(record['base_LocalWcs_CDMatrix_2_1'], trueCdMatrix[1, 0])
self.assertAlmostEqual(record['base_LocalWcs_CDMatrix_1_2'], trueCdMatrix[0, 1])
self.assertAlmostEqual(record['base_LocalWcs_CDMatrix_2_2'], trueCdMatrix[1, 1])
self.assertAlmostEqual(
self.calexp.getWcs().getPixelScale(centroid).asRadians(),
self.exposure.wcs.getPixelScale(centroid).asRadians(),
np.sqrt(np.fabs(record['base_LocalWcs_CDMatrix_1_1']*record['base_LocalWcs_CDMatrix_2_2']
- record['base_LocalWcs_CDMatrix_2_1']*record['base_LocalWcs_CDMatrix_1_2'])))

Expand Down
Loading