def testInterface(self): obsTestDir = lsst.utils.getPackageDir('obs_test') inputDir = os.path.join(obsTestDir, "data", "input") # Configure a ProcessCcd task such that it will return a minimal # number of measurements plus our test plugin. cfg = ProcessCcdConfig() cfg.calibrate.measurement.plugins.names = ["base_SdssCentroid", "base_SkyCoord", PLUGIN_NAME] cfg.calibrate.measurement.slots.shape = None cfg.calibrate.measurement.slots.psfFlux = None cfg.calibrate.measurement.slots.apFlux = None cfg.calibrate.measurement.slots.gaussianFlux = None cfg.calibrate.measurement.slots.modelFlux = None cfg.calibrate.measurement.slots.calibFlux = None # no reference catalog, so... cfg.calibrate.doAstrometry = False cfg.calibrate.doPhotoCal = False # disable aperture correction because we aren't measuring aperture flux cfg.calibrate.doApCorr = False # Extendedness requires modelFlux, disabled above. cfg.calibrate.catalogCalculation.plugins.names.discard("base_ClassificationExtendedness") # Process the test data with ProcessCcd then perform a transform. with tempDirectory() as tempDir: measResult = ProcessCcdTask.parseAndRun(args=[inputDir, "--output", tempDir, "--id", "visit=1"], config=cfg, doReturnResults=True) trArgs = [tempDir, "--output", tempDir, "--id", "visit=1", "-c", "inputConfigType=processCcd_config"] trResult = SrcTransformTask.parseAndRun(args=trArgs, doReturnResults=True) # It should be possible to reprocess the data through a new transform task with exactly # the same configuration without throwing. This check is useful since we are # constructing the task on the fly, which could conceivably cause problems with # configuration/metadata persistence. trResult = SrcTransformTask.parseAndRun(args=trArgs, doReturnResults=True) measSrcs = measResult.resultList[0].result.calibRes.sourceCat trSrcs = trResult.resultList[0].result # The length of the measured and transformed catalogs should be the same. self.assertEqual(len(measSrcs), len(trSrcs)) # Each source should have been measured & transformed appropriately. for measSrc, trSrc in zip(measSrcs, trSrcs): # The TrivialMeasurement should be transformed as defined above. self.assertEqual(trSrc[PLUGIN_NAME], measSrc[PLUGIN_NAME]) self.assertEqual(trSrc[PLUGIN_NAME + "_transform"], -1.0 * measSrc[PLUGIN_NAME]) # The SdssCentroid should be transformed to celestial coordinates. # Checking that the full transformation has been done correctly is # out of scope for this test case; we just ensure that there's # plausible position in the transformed record. trCoord = afwTable.CoordKey(trSrcs.schema["base_SdssCentroid"]).get(trSrc) self.assertAlmostEqual(measSrc.getCoord().getLongitude(), trCoord.getLongitude()) self.assertAlmostEqual(measSrc.getCoord().getLatitude(), trCoord.getLatitude())
#!/usr/bin/env python # # LSST Data Management System # Copyright 2008-2015 AURA/LSST. # # This product includes software developed by the # LSST Project (http://www.lsst.org/). # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the LSST License Statement and # the GNU General Public License along with this program. If not, # see <http://www.lsstcorp.org/LegalNotices/>. # from lsst.pipe.tasks.transformMeasurement import SrcTransformTask SrcTransformTask.parseAndRun()