Skip to content

Commit

Permalink
Convert to use calibrateImage
Browse files Browse the repository at this point in the history
  • Loading branch information
parejkoj committed Aug 16, 2024
1 parent b867dec commit 234b8b4
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 19 deletions.
2 changes: 1 addition & 1 deletion bin.src/ci_imsim_run.py
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ 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}",
"--config", f"calibrateImage:deblend.useCiLimits={not self.arguments.no_limit_deblend}",
"--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 TestCalibrateImageOutputs(lsst.utils.tests.TestCase):
"""Test the output data products of CalibrateImageTask 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("initial_pvi", self.dataId)
self.catalog = self.butler.get("initial_stars_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
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

0 comments on commit 234b8b4

Please sign in to comment.