def setUp(self): self.tempDB = os.path.join(self.scratch_dir, 'PhoSimTestDatabase.db') self.obs_metadata = makePhoSimTestDB(size=10, filename=self.tempDB) self.bulgeDB = testGalaxyBulgeDBObj(driver='sqlite', database=self.tempDB) self.diskDB = testGalaxyDiskDBObj(driver='sqlite', database=self.tempDB) self.agnDB = testGalaxyAgnDBObj(driver='sqlite', database=self.tempDB) self.starDB = testStarsDBObj(driver='sqlite', database=self.tempDB) filter_translation = {'u': 0, 'g': 1, 'r': 2, 'i': 3, 'z': 4, 'y': 5} alt, az, pa = altAzPaFromRaDec(self.obs_metadata.pointingRA, self.obs_metadata.pointingDec, self.obs_metadata, includeRefraction=False) self.control_header = [ 'moondec %.7f\n' % np.degrees(self.obs_metadata.OpsimMetaData['moondec']), 'rottelpos %.7f\n' % np.degrees(self.obs_metadata.OpsimMetaData['rottelpos']), 'declination %.17f\n' % self.obs_metadata.pointingDec, 'moonalt %.7f\n' % np.degrees(self.obs_metadata.OpsimMetaData['moonalt']), 'rotskypos %.17f\n' % self.obs_metadata.rotSkyPos, 'moonra %.7f\n' % np.degrees(self.obs_metadata.OpsimMetaData['moonra']), 'sunalt %.7f\n' % np.degrees(self.obs_metadata.OpsimMetaData['sunalt']), 'mjd %.17f\n' % (self.obs_metadata.mjd.TAI + 16.5 / 86400.0), 'azimuth %.17f\n' % az, 'rightascension %.17f\n' % self.obs_metadata.pointingRA, 'dist2moon %.7f\n' % np.degrees(self.obs_metadata.OpsimMetaData['dist2moon']), 'filter %d\n' % filter_translation[self.obs_metadata.bandpass], 'altitude %.17f\n' % alt ]
def test_galaxy_astrometry_degrees(self): """ Test that we can go from raPhoSim, decPhoSim to ICRS coordinates in the case of galaxies (in degrees) """ db = testGalaxyDiskDBObj(driver='sqlite', database=self.db_name) cat = GalaxyTestCatalog(db, obs_metadata=self.obs) with lsst.utils.tests.getTempFilePath('.txt') as cat_name: cat.write_catalog(cat_name) dtype = np.dtype([('raICRS', float), ('decICRS', float), ('raPhoSim', float), ('decPhoSim', float)]) data = np.genfromtxt(cat_name, dtype=dtype) self.assertGreater(len(data), 100) # verify that, when transforming back to ICRS, we are within # 10^-3 arcsec ra_icrs, dec_icrs = PhoSimAstrometryBase.icrsFromPhoSim( data['raPhoSim'], data['decPhoSim'], self.obs) dist = angularSeparation(data['raICRS'], data['decICRS'], ra_icrs, dec_icrs) dist = 3600.0 * dist self.assertLess(dist.max(), 0.001) # verify that the distance between raPhoSim, decPhoSim and # raICRS, decICRS is greater than the distance between # the original raICRS, decICRS and the newly-calculated # raICRS, decICRS dist_bad = angularSeparation(data['raPhoSim'], data['decPhoSim'], data['raICRS'], data['decICRS']) dist_bad = 3600.0 * dist_bad self.assertGreater(dist_bad.min(), dist.max()) del db
def setUp(self): self.obs_metadata = makePhoSimTestDB(size=10) self.bulgeDB = testGalaxyBulgeDBObj(driver='sqlite', database='PhoSimTestDatabase.db') self.diskDB = testGalaxyDiskDBObj(driver='sqlite', database='PhoSimTestDatabase.db') self.agnDB = testGalaxyAgnDBObj(driver='sqlite', database='PhoSimTestDatabase.db') self.starDB = testStarsDBObj(driver='sqlite', database='PhoSimTestDatabase.db') baseLineFileName = lsst.utils.getPackageDir('sims_catUtils')+'/tests/testData/phoSimControlCatalog.txt' self.baseLineFile = open(baseLineFileName,'r')
def setUpClass(cls): cls.dbName = tempfile.mktemp(dir=ROOT, prefix='PhoSimVariabilityDatabase-', suffix='.db') cls.obs_metadata = makePhoSimTestDB(size=10, filename=cls.dbName) cls.obs_metadata.mjd = ModifiedJulianDate(TAI=60000.0) cls.bulgeDB = testGalaxyBulgeDBObj(driver='sqlite', database=cls.dbName) cls.diskDB = testGalaxyDiskDBObj(driver='sqlite', database=cls.dbName) cls.agnDB = testGalaxyAgnDBObj(driver='sqlite', database=cls.dbName) cls.starDB = testStarsDBObj(driver='sqlite', database=cls.dbName)
def setUp(cls): cls.dbName = 'PhoSimVariabilityDatabase.db' if os.path.exists(cls.dbName): os.unlink(cls.dbName) cls.obs_metadata = makePhoSimTestDB(size=10, filename=cls.dbName) cls.bulgeDB = testGalaxyBulgeDBObj(driver='sqlite', database=cls.dbName) cls.diskDB = testGalaxyDiskDBObj(driver='sqlite', database=cls.dbName) cls.agnDB = testGalaxyAgnDBObj(driver='sqlite', database=cls.dbName) cls.starDB = testStarsDBObj(driver='sqlite', database=cls.dbName)
def testGalaxyDisks(self): """ Test that GalSimInterpreter puts the right number of counts on images of galaxy disks """ catName = os.path.join(self.scratch_dir, 'testDiskCat.sav') gals = testGalaxyDiskDBObj(driver=self.driver, database=self.dbName) cat = testGalaxyCatalog(gals, obs_metadata=self.obs_metadata) cat.write_catalog(catName) self.catalogTester(catName=catName, catalog=cat, nameRoot='disk') if os.path.exists(catName): os.unlink(catName)
def testGalaxyDisks(self): """ Test that GalSimInterpreter puts the right number of counts on images of galaxy disks """ catName = 'testDiskCat.sav' gals = testGalaxyDiskDBObj(driver=self.driver, database=self.dbName) cat = testGalaxyCatalog(gals, obs_metadata = self.obs_metadata) cat.write_catalog(catName) self.catalogTester(catName=catName, catalog=cat, nameRoot='disk') if os.path.exists(catName): os.unlink(catName)
def test_galaxy_astrometry_radians(self): """ Test that we can go from raPhoSim, decPhoSim to ICRS coordinates in the case of galaxies (in radians) """ cat_name = os.path.join(self.scratch_dir, 'phosim_ast_gal_cat_rad.txt') if os.path.exists(cat_name): os.unlink(cat_name) db = testGalaxyDiskDBObj(driver='sqlite', database=self.db_name) cat = GalaxyTestCatalog(db, obs_metadata=self.obs) cat.write_catalog(cat_name) dtype = np.dtype([('raICRS', float), ('decICRS', float), ('raPhoSim', float), ('decPhoSim', float)]) data = np.genfromtxt(cat_name, dtype=dtype) self.assertGreater(len(data), 100) ra_pho_rad = np.radians(data['raPhoSim']) dec_pho_rad = np.radians(data['decPhoSim']) # verify that, when transforming back to ICRS, we are within # 10^-3 arcsec ra_icrs, dec_icrs = PhoSimAstrometryBase._icrsFromPhoSim( ra_pho_rad, dec_pho_rad, self.obs) dist = _angularSeparation(np.radians(data['raICRS']), np.radians(data['decICRS']), ra_icrs, dec_icrs) dist = arcsecFromRadians(dist) self.assertLess(dist.max(), 0.001) # verify that the distance between raPhoSim, decPhoSim and # raICRS, decICRS is greater than the distance between # the original raICRS, decICRS and the newly-calculated # raICRS, decICRS dist_bad = _angularSeparation(ra_pho_rad, dec_pho_rad, np.radians(data['raICRS']), np.radians(data['decICRS'])) dist_bad = arcsecFromRadians(dist_bad) self.assertGreater(dist_bad.min(), dist.max()) if os.path.exists(cat_name): os.unlink(cat_name) del db
def setUp(self): self.obs_metadata = makePhoSimTestDB(size=10) self.bulgeDB = testGalaxyBulgeDBObj(driver='sqlite', database='PhoSimTestDatabase.db') self.diskDB = testGalaxyDiskDBObj(driver='sqlite', database='PhoSimTestDatabase.db') self.agnDB = testGalaxyAgnDBObj(driver='sqlite', database='PhoSimTestDatabase.db') self.starDB = testStarsDBObj(driver='sqlite', database='PhoSimTestDatabase.db') filter_translation={'u':0,'g':1, 'r':2, 'i':3, 'z':4, 'y':5} self.control_header = ['Opsim_moondec %.9g\n' % numpy.degrees(self.obs_metadata.phoSimMetaData['Opsim_moondec'][0]), 'Opsim_rottelpos %.9g\n' % numpy.degrees(self.obs_metadata.phoSimMetaData['Opsim_rottelpos'][0]), 'Unrefracted_Dec %.9g\n' % numpy.degrees(self.obs_metadata.phoSimMetaData['pointingDec'][0]), 'Opsim_moonalt %.9g\n' % numpy.degrees(self.obs_metadata.phoSimMetaData['Opsim_moonalt'][0]), 'Opsim_rotskypos %.9g\n' % numpy.degrees(self.obs_metadata.phoSimMetaData['Opsim_rotskypos'][0]), 'Opsim_moonra %.9g\n' % numpy.degrees(self.obs_metadata.phoSimMetaData['Opsim_moonra'][0]), 'Opsim_sunalt %.9g\n' % numpy.degrees(self.obs_metadata.phoSimMetaData['Opsim_sunalt'][0]), 'Opsim_expmjd %.9g\n' % self.obs_metadata.phoSimMetaData['Opsim_expmjd'][0], 'Unrefracted_Azimuth %.9g\n' % numpy.degrees(self.obs_metadata.phoSimMetaData['Unrefracted_Azimuth'][0]), 'Unrefracted_RA %.9g\n' % numpy.degrees(self.obs_metadata.phoSimMetaData['pointingRA'][0]), 'Opsim_dist2moon %.9g\n' % numpy.degrees(self.obs_metadata.phoSimMetaData['Opsim_dist2moon'][0]), 'Opsim_filter %d\n' % filter_translation[self.obs_metadata.phoSimMetaData['Opsim_filter'][0]], 'Unrefracted_Altitude %.9g\n' % numpy.degrees(self.obs_metadata.phoSimMetaData['Unrefracted_Altitude'][0])]
def test_galaxy_astrometry_radians(self): """ Test that we can go from raPhoSim, decPhoSim to ICRS coordinates in the case of galaxies (in radians) """ db = testGalaxyDiskDBObj(driver='sqlite', database=self.db_name) cat = GalaxyTestCatalog(db, obs_metadata=self.obs) with lsst.utils.tests.getTempFilePath('.txt') as cat_name: cat.write_catalog(cat_name) dtype = np.dtype([('raICRS', float), ('decICRS', float), ('raPhoSim', float), ('decPhoSim', float)]) data = np.genfromtxt(cat_name, dtype=dtype) self.assertGreater(len(data), 100) ra_pho_rad = np.radians(data['raPhoSim']) dec_pho_rad = np.radians(data['decPhoSim']) # verify that, when transforming back to ICRS, we are within # 10^-3 arcsec ra_icrs, dec_icrs = PhoSimAstrometryBase._icrsFromPhoSim(ra_pho_rad, dec_pho_rad, self.obs) dist = _angularSeparation(np.radians(data['raICRS']), np.radians(data['decICRS']), ra_icrs, dec_icrs) dist = arcsecFromRadians(dist) self.assertLess(dist.max(), 0.001) # verify that the distance between raPhoSim, decPhoSim and # raICRS, decICRS is greater than the distance between # the original raICRS, decICRS and the newly-calculated # raICRS, decICRS dist_bad = _angularSeparation(ra_pho_rad, dec_pho_rad, np.radians(data['raICRS']), np.radians(data['decICRS'])) dist_bad = arcsecFromRadians(dist_bad) self.assertGreater(dist_bad.min(), dist.max()) del db
def setUp(self): self.tempDB = os.path.join(self.scratch_dir, 'PhoSimTestDatabase.db') self.obs_metadata = makePhoSimTestDB(size=10, filename=self.tempDB) self.bulgeDB = testGalaxyBulgeDBObj(driver='sqlite', database=self.tempDB) self.diskDB = testGalaxyDiskDBObj(driver='sqlite', database=self.tempDB) self.agnDB = testGalaxyAgnDBObj(driver='sqlite', database=self.tempDB) self.starDB = testStarsDBObj(driver='sqlite', database=self.tempDB) filter_translation = {'u': 0, 'g': 1, 'r': 2, 'i': 3, 'z': 4, 'y': 5} alt, az, pa = altAzPaFromRaDec(self.obs_metadata.pointingRA, self.obs_metadata.pointingDec, self.obs_metadata, includeRefraction=False) self.control_header = ['moondec %.7f\n' % np.degrees(self.obs_metadata.OpsimMetaData['moondec']), 'rottelpos %.7f\n' % np.degrees(self.obs_metadata.OpsimMetaData['rottelpos']), 'declination %.17f\n' % self.obs_metadata.pointingDec, 'moonalt %.7f\n' % np.degrees(self.obs_metadata.OpsimMetaData['moonalt']), 'rotskypos %.17f\n' % self.obs_metadata.rotSkyPos, 'moonra %.7f\n' % np.degrees(self.obs_metadata.OpsimMetaData['moonra']), 'sunalt %.7f\n' % np.degrees(self.obs_metadata.OpsimMetaData['sunalt']), 'mjd %.17f\n' % (self.obs_metadata.mjd.TAI+16.5/86400.0), 'azimuth %.17f\n' % az, 'rightascension %.17f\n' % self.obs_metadata.pointingRA, 'dist2moon %.7f\n' % np.degrees(self.obs_metadata.OpsimMetaData['dist2moon']), 'filter %d\n' % filter_translation[self.obs_metadata.bandpass], 'altitude %.17f\n' % alt]