Coverage for tests/testEBV.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
lsst.utils.tests.init()
def tearDownClass(cls): sims_clean_up()
""" Test that EBVbase() only loads each dust map once """ sims_clean_up() self.assertEqual(len(EBVbase._ebv_map_cache), 0)
ebv1 = EBVbase() ebv1.load_ebvMapNorth() ebv1.load_ebvMapSouth() self.assertEqual(len(EBVbase._ebv_map_cache), 2)
ebv2 = EBVbase() ebv2.load_ebvMapNorth() ebv2.load_ebvMapSouth() self.assertEqual(len(EBVbase._ebv_map_cache), 2)
rng = np.random.RandomState(881) ra_list = rng.random_sample(10)*2.0*np.pi dec_list = rng.random_sample(10)*np.pi - 0.5*np.pi
ebv1_vals = ebv1.calculateEbv(equatorialCoordinates=np.array([ra_list, dec_list])) ebv2_vals = ebv2.calculateEbv(equatorialCoordinates=np.array([ra_list, dec_list]))
self.assertEqual(len(EBVbase._ebv_map_cache), 2)
np.testing.assert_array_equal(ebv1_vals, ebv2_vals)
ebvObject = EBVbase() ra = [] dec = [] gLat = [] gLon = [] for i in range(10): ra.append(i*2.0*np.pi/10.0) dec.append(i*np.pi/10.0)
gLat.append(-0.5*np.pi+i*np.pi/10.0) gLon.append(i*2.0*np.pi/10.0)
equatorialCoordinates = np.array([ra, dec]) galacticCoordinates = np.array([gLon, gLat])
ebvOutput = ebvObject.calculateEbv(equatorialCoordinates=equatorialCoordinates) self.assertEqual(len(ebvOutput), len(ra))
ebvOutput = ebvObject.calculateEbv(galacticCoordinates=galacticCoordinates) self.assertEqual(len(ebvOutput), len(gLon)) self.assertGreater(len(ebvOutput), 0)
self.assertRaises(RuntimeError, ebvObject.calculateEbv, equatorialCoordinates=equatorialCoordinates, galacticCoordinates=galacticCoordinates) self.assertRaises(RuntimeError, ebvObject.calculateEbv, equatorialCoordinates=None, galacticCoordinates=None) self.assertRaises(RuntimeError, ebvObject.calculateEbv)
lsst.utils.tests.init() unittest.main() |