Coverage for tests/test_measureCrosstalk.py : 27%

Hot-keys on this page
r m x p toggle line displays
j k next/prev highlighted chunk
0 (zero) top of page
1 (one) first highlighted chunk
# # LSST Data Management System # Copyright 2008-2017 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 <https://www.lsstcorp.org/LegalNotices/>. #
"""Generate a simulated set of exposures and test the measured crosstalk matrix.
Parameters ---------- isTrimmed : `bool`, optional Should the simulation use trimmed or untrimmed raw exposures? nSources : `int`, optional Number of random simulated sources to generate in the simulated exposures.
Returns ------- coeffErr : `np.ndarray` Array of booleans indicating if the measured and expected crosstalk ratios are smaller than the measured uncertainty in the crosstalk ratio. """ config = isrMock.IsrMockConfig() config.rngSeed = 12345 config.doAddCrosstalk = True config.doAddSky = True config.doAddSource = True config.skyLevel = 0.0 config.readNoise = 0.0 mcConfig = MeasureCrosstalkConfig() mcConfig.threshold = 4000 mct = MeasureCrosstalkTask(config=mcConfig) fullResult = []
config.isTrimmed = isTrimmed
# Generate simulated set of exposures. for idx in range(0, 10): config.rngSeed = 12345 + idx * 1000
# Allow each simulated exposure to have nSources random # bright sources. config.sourceAmp = (np.random.randint(8, size=nSources)).tolist() config.sourceFlux = ((np.random.random(size=nSources) * 25000.0 + 20000.0).tolist()) config.sourceX = ((np.random.random(size=nSources) * 100.0).tolist()) config.sourceY = ((np.random.random(size=nSources) * 50.0).tolist())
exposure = isrMock.CalibratedRawMock(config=config).run() result = mct.run(exposure, dataId=None) fullResult.append(result)
# Generate the final measured CT ratios, uncertainties, pixel counts. coeff, coeffSig, coeffNum = mct.reduce(fullResult)
# Needed because measureCrosstalk cannot find coefficients equal to 0.0 coeff = np.nan_to_num(coeff) coeffSig = np.nan_to_num(coeffSig)
# Compare result against expectation used to create the simulation. expectation = isrMock.CrosstalkCoeffMock().run() coeffErr = abs(coeff - expectation) <= coeffSig return coeffErr
"""Measure crosstalk from a sequence of trimmed mocked images. """ coeffErr = self.setup_measureCrosstalk(isTrimmed=True, nSources=8)
# DM-18528 This doesn't always fully converge, so be permissive # for now. This is also more challenging on the test # chip due to density issues. self.assertTrue(np.any(coeffErr))
"""Measure crosstalk from a sequence of untrimmed mocked images. """ coeffErr = self.setup_measureCrosstalk(isTrimmed=False, nSources=8)
# DM-18528 This doesn't always fully converge, so be permissive # for now. This is also more challenging on the test # chip due to density issues. self.assertTrue(np.any(coeffErr))
lsst.utils.tests.init() unittest.main() |