Coverage for tests/testCameraCoordsLSST.py : 25%

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
""" This file does not include the boilerplate memory leak tests. Those tests kept failing because the instantiations of the LSST Camera were not cleaned up before the tests were run. """
lsst.utils.tests.init()
""" This class will test that the CameraCoordsLSST mixin returns the same results as the CameraCoords mixin with self.camera=lsst_camera """
rng = np.random.RandomState(6512)
pointing_ra = 15.0 pointing_dec = 13.0
n_obj = 100 ra_list = pointing_ra + 2.0*rng.random_sample(n_obj) dec_list = pointing_dec + 2.0*rng.random_sample(n_obj) px_list = radiansFromArcsec(0.005)*rng.random_sample(n_obj) px_list += radiansFromArcsec(0.001) mura_list = radiansFromArcsec(0.005)*rng.random_sample(n_obj) mudec_list = radiansFromArcsec(0.005)*rng.random_sample(n_obj) vrad_list = 100.0*rng.random_sample(n_obj)
with lsst.utils.tests.getTempFilePath('.txt') as db_text_file: with open(db_text_file, 'w') as out_file: for ix, (rdeg, ddeg, rrad, drad, px, mura, mudec, vrad) in \ enumerate(zip(ra_list, dec_list, np.radians(ra_list), np.radians(dec_list), px_list, mura_list, mudec_list, vrad_list)):
out_file.write('%d %e %e %e %e %e %e %e %e\n' % (ix, rdeg, ddeg, rrad, drad, px, mura, mudec, vrad))
dtype = np.dtype([('id', int), ('raDeg', float), ('decDeg', float), ('raJ2000', float), ('decJ2000', float), ('parallax', float), ('properMotionRa', float), ('properMotionDec', float), ('radialVelocity', float)])
db = fileDBObject(db_text_file, dtype=dtype, idColKey='id') db.raColName = 'raDeg' db.decColName = 'decDeg'
class CameraCoordsCatalog(AstrometryStars, CameraCoords, InstanceCatalog): camera = LsstSimMapper().camera column_outputs = ['id', 'chipName']
class CameraCoordsLSSTCatalog(AstrometryStars, CameraCoordsLSST, InstanceCatalog): column_outputs = ['id', 'chipName']
obs = ObservationMetaData(pointingRA=pointing_ra, pointingDec=pointing_dec, boundLength=1.75, boundType='circle', rotSkyPos=23.0, mjd=59580.0)
control_cat = CameraCoordsCatalog(db, obs_metadata=obs) test_cat = CameraCoordsLSSTCatalog(db, obs_metadata=obs)
control_line_list = [] none_chips = 0 for line in control_cat.iter_catalog(): if line[1] is None: none_chips += 1 control_line_list.append(line) self.assertGreater(len(control_line_list), 0) self.assertLess(none_chips, len(control_line_list)/2)
line_ct = 0 for line in test_cat.iter_catalog(): line_ct += 1 self.assertIn(line, control_line_list) self.assertEqual(line_ct, len(control_line_list))
lsst.utils.tests.init() unittest.main() |