Coverage for tests/testGalSimDetector.py : 24%

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
#from lsst.sims.coordUtils.utils import ReturnCamera
lsst.utils.tests.init()
def tearDownClass(cls): sims_clean_up()
baseDir = os.path.join(getPackageDir('sims_GalSimInterface'), 'tests', 'cameraData')
self.camera = ReturnCamera(baseDir)
ra = 145.0 dec = -73.0 self.epoch = 2000.0 mjd = 49250.0 rotSkyPos = 45.0 self.obs = ObservationMetaData(pointingRA=ra, pointingDec=dec, boundType='circle', boundLength=1.0, mjd=mjd, rotSkyPos=rotSkyPos)
del self.camera
""" Test whether or not the method containsRaDec correctly identifies RA and Dec that fall inside and outside the detector """
photParams = PhotometricParameters() gsdet = GalSimDetector(self.camera[0].getName(), GalSimCameraWrapper(self.camera), self.obs, self.epoch, photParams=photParams)
xxList = [gsdet.xMinPix, gsdet.xMaxPix] yyList = [gsdet.yMinPix, gsdet.yMaxPix] dxList = [-1.0, 1.0] dyList = [-1.0, 1.0]
xPixList = [] yPixList = [] correctAnswer = []
for xx, yy, dx, dy in zip(xxList, yyList, dxList, dyList): xPixList.append(xx) yPixList.append(yy) correctAnswer.append(True)
xPixList.append(xx+dx) yPixList.append(yy) correctAnswer.append(False)
xPixList.append(xx) yPixList.append(yy+dy) correctAnswer.append(False)
nameList = [gsdet.name]*len(xPixList) xPixList = np.array(xPixList) yPixList = np.array(yPixList)
raList, decList = _raDecFromPixelCoords(xPixList, yPixList, nameList, camera=self.camera, obs_metadata=self.obs, epoch=self.epoch)
testAnswer = gsdet.containsRaDec(raList, decList)
for c, t in zip(correctAnswer, testAnswer): self.assertIs(c, t)
""" Test whether or not the method containsRaDec correctly identifies RA and Dec that fall inside and outside the detector """
photParams = PhotometricParameters() gsdet = GalSimDetector(self.camera[0].getName(), GalSimCameraWrapper(self.camera), self.obs, self.epoch, photParams=photParams)
xxList = [gsdet.xMinPix, gsdet.xMaxPix] yyList = [gsdet.yMinPix, gsdet.yMaxPix] dxList = [-1.0, 1.0] dyList = [-1.0, 1.0]
xPixList = [] yPixList = [] correctAnswer = []
for xx, yy, dx, dy in zip(xxList, yyList, dxList, dyList): xPixList.append(xx) yPixList.append(yy) correctAnswer.append(True)
xPixList.append(xx+dx) yPixList.append(yy) correctAnswer.append(False)
xPixList.append(xx) yPixList.append(yy+dy) correctAnswer.append(False)
nameList = [gsdet.name]*len(xPixList) xPixList = np.array(xPixList) yPixList = np.array(yPixList)
xPupilList, yPupilList = \ pupilCoordsFromPixelCoords(xPixList, yPixList, nameList, camera=self.camera)
testAnswer = gsdet.containsPupilCoordinates(xPupilList, yPupilList)
for c, t in zip(correctAnswer, testAnswer): self.assertIs(c, t)
""" Test that the FITS header keywords with the observing information are set correctly. """ photParams = PhotometricParameters() gsdet = GalSimDetector(self.camera[0].getName(), GalSimCameraWrapper(self.camera), self.obs, self.epoch, photParams=photParams) self.assertEqual(gsdet.wcs.fitsHeader.getScalar('MJD-OBS'), self.obs.mjd.TAI) self.assertEqual(gsdet.wcs.fitsHeader.getScalar('EXPTIME'), photParams.nexp*photParams.exptime) self.assertEqual(gsdet.wcs.fitsHeader.getScalar('RATEL'), self.obs.pointingRA) self.assertEqual(gsdet.wcs.fitsHeader.getScalar('DECTEL'), self.obs.pointingDec) self.assertEqual(gsdet.wcs.fitsHeader.getScalar('ROTANGLE'), self.obs.rotSkyPos)
lsst.utils.tests.init() unittest.main() |