コード例 #1
0
    def testCreationOfPhoSimCatalog_2(self):
        """
        Make sure that we can create PhoSim input catalogs using the returned
        ObservationMetaData.

        Use the actual DefaultPhoSimHeader map; make sure that opsim_version
        does not make it into the header.
        """

        dbName = tempfile.mktemp(dir=ROOT, prefix='obsMetaDataGeneratorTest-', suffix='.db')
        makePhoSimTestDB(filename=dbName)
        bulgeDB = testGalaxyBulgeDBObj(driver='sqlite', database=dbName)
        gen = self.gen
        results = gen.getObservationMetaData(fieldRA=np.degrees(1.370916),
                                             telescopeFilter='i')
        testCat = PhoSimCatalogSersic2D(bulgeDB, obs_metadata=results[0])
        testCat.phoSimHeaderMap = DefaultPhoSimHeaderMap
        with lsst.utils.tests.getTempFilePath('.txt') as catName:
            testCat.write_catalog(catName)
            ct_lines = 0
            with open(catName, 'r') as in_file:
                for line in in_file:
                    ct_lines += 1
                    self.assertNotIn('opsim_version', line)
                self.assertGreater(ct_lines, 10)  # check that some lines did get written

        if os.path.exists(dbName):
            os.unlink(dbName)
コード例 #2
0
    def testNoisyCatalog(self):
        """
        Compare noisy and noiseless images drawn from the same catalog.
        Make sure that the pixel-by-pixel difference between the two is
        as expected from Poisson statistics.
        """
        noisyCatName = os.path.join(self.scratch_dir, 'testNoisyCatalog.sav')
        cleanCatName = os.path.join(self.scratch_dir, 'testCleanCatalog.sav')

        gals = testGalaxyBulgeDBObj(driver=self.driver, database=self.dbName)

        noisyCat = noisyCatalog(gals, obs_metadata=self.obs_metadata)
        cleanCat = backgroundCatalog(gals, obs_metadata=self.obs_metadata)

        noisyCat.write_catalog(noisyCatName)
        cleanCat.write_catalog(cleanCatName)

        self.compareCatalogs(cleanCat, noisyCat,
                             PhotometricParameters().gain,
                             PhotometricParameters().readnoise)

        if os.path.exists(noisyCatName):
            os.unlink(noisyCatName)
        if os.path.exists(cleanCatName):
            os.unlink(cleanCatName)
コード例 #3
0
    def testMultipleImages(self):
        """
        Test that GalSimInterpreter puts the right number of counts on images of multiple objects
        """
        dbName = 'galSimTestMultipleDB.db'
        driver = 'sqlite'

        if os.path.exists(dbName):
            os.unlink(dbName)

        displacedRA = numpy.array([72.0/3600.0, 55.0/3600.0, 75.0/3600.0])
        displacedDec = numpy.array([0.0, 15.0/3600.0, -15.0/3600.0])
        obs_metadata = makePhoSimTestDB(filename=dbName, size=1,
                                        displacedRA=displacedRA, displacedDec=displacedDec,
                                        bandpass=self.bandpassNameList,
                                        m5=self.m5, seeing=self.seeing)

        gals = testGalaxyBulgeDBObj(driver=driver, database=dbName)
        cat = testGalaxyCatalog(gals, obs_metadata=obs_metadata)
        catName = 'multipleCatalog.sav'
        cat.write_catalog(catName)
        self.catalogTester(catName=catName, catalog=cat, nameRoot='multiple')
        if os.path.exists(catName):
            os.unlink(catName)

        stars = testStarsDBObj(driver=driver, database=dbName)
        cat = testStarCatalog(stars, obs_metadata=obs_metadata)
        catName = 'multipleStarCatalog.sav'
        cat.write_catalog(catName)
        self.catalogTester(catName=catName, catalog=cat, nameRoot='multipleStars')
        if os.path.exists(catName):
            os.unlink(catName)

        if os.path.exists(dbName):
            os.unlink(dbName)
コード例 #4
0
    def testCompoundFitsFiles_one_empty(self):
        """
        Test that GalSimInterpreter puts the right number of counts on images
        containing different types of objects in the case where one of the
        input catalogs is empty (really, this is testing that we can
        successfully copy the GalSimInterpreter and all of the supporting
        properties from an empty GalSimCatalog to another GalSimCatalog)
        """
        driver = 'sqlite'
        dbName1 = os.path.join(self.scratch_dir, 'galSimTestCompound1DB_one_empty.db')
        if os.path.exists(dbName1):
            os.unlink(dbName1)

        deltaRA = np.array([72.0/3600.0, 55.0/3600.0, 75.0/3600.0])
        deltaDec = np.array([0.0, 15.0/3600.0, -15.0/3600.0])
        obs_metadata1 = makePhoSimTestDB(filename=dbName1, size=1,
                                         deltaRA=deltaRA, deltaDec=deltaDec,
                                         bandpass=self.bandpassNameList,
                                         m5=self.m5, seeing=self.seeing)

        dbName2 = os.path.join(self.scratch_dir, 'galSimTestCompound2DB_one_empty.db')
        if os.path.exists(dbName2):
            os.unlink(dbName2)

        deltaRA = np.array([55.0/3600.0, 60.0/3600.0, 62.0/3600.0])
        deltaDec = np.array([-3.0/3600.0, 10.0/3600.0, 10.0/3600.0])
        obs_metadata2 = makePhoSimTestDB(filename=dbName2, size=1,
                                         deltaRA=deltaRA, deltaDec=deltaDec,
                                         bandpass=self.bandpassNameList,
                                         m5=self.m5, seeing=self.seeing)

        gals = testGalaxyBulgeDBObj(driver=driver, database=dbName1)

        # shift the obs_metadata so that the catalog will not contain
        # any objects
        ra0 = obs_metadata1.pointingRA
        dec0 = obs_metadata1.pointingDec
        obs_metadata1.pointingRA = ra0 + 20.0

        cat1 = testGalaxyCatalog(gals, obs_metadata=obs_metadata1)
        cat1.camera_wrapper = GalSimCameraWrapper(self.camera)
        catName = os.path.join(self.scratch_dir, 'compoundCatalog_one_empty.sav')
        cat1.write_catalog(catName)
        with open(catName, "r") as input_file:
            input_lines = input_file.readlines()
            self.assertEqual(len(input_lines), 1)  # just the header
        self.assertFalse(hasattr(cat1, 'bandpassDict'))

        stars = testStarsDBObj(driver=driver, database=dbName2)
        cat2 = testStarCatalog(stars, obs_metadata=obs_metadata2)
        cat2.copyGalSimInterpreter(cat1)
        cat2.write_catalog(catName, write_header=False, write_mode='a')
        self.catalogTester(catName=catName, catalog=cat2, nameRoot='compound_one_empty')

        if os.path.exists(dbName1):
            os.unlink(dbName1)
        if os.path.exists(dbName2):
            os.unlink(dbName2)
        if os.path.exists(catName):
            os.unlink(catName)
コード例 #5
0
 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
     ]
コード例 #6
0
    def testCreationOfPhoSimCatalog(self):
        """
        Make sure that we can create PhoSim input catalogs using the returned
        ObservationMetaData. This test will just make sure that all of the
        expected header entries are there.
        """

        scratch_dir = os.path.join(getPackageDir('sims_catUtils'), 'tests',
                                   'scratchSpace')
        dbName = os.path.join(scratch_dir, 'obsMetaDataGeneratorTest.db')
        catName = os.path.join(scratch_dir,
                               'testPhoSimFromObsMetaDataGenerator.txt')
        if os.path.exists(dbName):
            os.unlink(dbName)
        makePhoSimTestDB(filename=dbName)
        bulgeDB = testGalaxyBulgeDBObj(driver='sqlite', database=dbName)
        gen = self.gen
        results = gen.getObservationMetaData(fieldRA=np.degrees(1.370916),
                                             telescopeFilter='i')
        testCat = PhoSimCatalogSersic2D(bulgeDB, obs_metadata=results[0])
        testCat.phoSimHeaderMap = {}
        testCat.write_catalog(catName)

        if os.path.exists(catName):
            os.unlink(catName)

        if os.path.exists(dbName):
            os.unlink(dbName)
コード例 #7
0
    def testCreationOfPhoSimCatalog_3(self):
        """
        Make sure that we can create PhoSim input catalogs using the returned
        ObservationMetaData.

        Test that an error is actually raised if we try to build a PhoSim catalog
        with a v3 header map using a v4 ObservationMetaData
        """

        dbName = tempfile.mktemp(dir=ROOT, prefix='obsMetaDataGeneratorTest-', suffix='.db')
        makePhoSimTestDB(filename=dbName)
        bulgeDB = testGalaxyBulgeDBObj(driver='sqlite', database=dbName)
        opsim_db = os.path.join(getPackageDir('sims_data'), 'OpSimData',
                                'astro-lsst-01_2014.db')
        assert os.path.isfile(opsim_db)
        gen = ObservationMetaDataGenerator(opsim_db, driver='sqlite')
        results = gen.getObservationMetaData(fieldRA=(70.0, 85.0),
                                             telescopeFilter='i')
        self.assertGreater(len(results), 0)
        testCat = PhoSimCatalogSersic2D(bulgeDB, obs_metadata=results[0])
        testCat.phoSimHeaderMap = DefaultPhoSimHeaderMap
        with lsst.utils.tests.getTempFilePath('.txt') as catName:
            with self.assertRaises(RuntimeError):
                testCat.write_catalog(catName)

        if os.path.exists(dbName):
            os.unlink(dbName)
コード例 #8
0
 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')
コード例 #9
0
    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)
コード例 #10
0
    def testCompoundFitsFiles(self):
        """
        Test that GalSimInterpreter puts the right number of counts on images
        containing different types of objects
        """
        driver = "sqlite"
        dbName1 = "galSimTestCompound1DB.db"
        if os.path.exists(dbName1):
            os.unlink(dbName1)

        deltaRA = np.array([72.0 / 3600.0, 55.0 / 3600.0, 75.0 / 3600.0])
        deltaDec = np.array([0.0, 15.0 / 3600.0, -15.0 / 3600.0])
        obs_metadata1 = makePhoSimTestDB(
            filename=dbName1,
            size=1,
            deltaRA=deltaRA,
            deltaDec=deltaDec,
            bandpass=self.bandpassNameList,
            m5=self.m5,
            seeing=self.seeing,
        )

        dbName2 = "galSimTestCompound2DB.db"
        if os.path.exists(dbName2):
            os.unlink(dbName2)

        deltaRA = np.array([55.0 / 3600.0, 60.0 / 3600.0, 62.0 / 3600.0])
        deltaDec = np.array([-3.0 / 3600.0, 10.0 / 3600.0, 10.0 / 3600.0])
        obs_metadata2 = makePhoSimTestDB(
            filename=dbName2,
            size=1,
            deltaRA=deltaRA,
            deltaDec=deltaDec,
            bandpass=self.bandpassNameList,
            m5=self.m5,
            seeing=self.seeing,
        )

        gals = testGalaxyBulgeDBObj(driver=driver, database=dbName1)
        cat1 = testGalaxyCatalog(gals, obs_metadata=obs_metadata1)
        catName = "compoundCatalog.sav"
        cat1.write_catalog(catName)

        stars = testStarsDBObj(driver=driver, database=dbName2)
        cat2 = testStarCatalog(stars, obs_metadata=obs_metadata2)
        cat2.copyGalSimInterpreter(cat1)
        cat2.write_catalog(catName, write_header=False, write_mode="a")
        self.catalogTester(catName=catName, catalog=cat2, nameRoot="compound")

        if os.path.exists(dbName1):
            os.unlink(dbName1)
        if os.path.exists(dbName2):
            os.unlink(dbName2)
        if os.path.exists(catName):
            os.unlink(catName)
コード例 #11
0
 def testGalaxyBulges(self):
     """
     Test that GalSimInterpreter puts the right number of counts on images of galaxy bulges
     """
     catName = 'testBulgeCat.sav'
     gals = testGalaxyBulgeDBObj(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='bulge')
     if os.path.exists(catName):
         os.unlink(catName)
コード例 #12
0
    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)
コード例 #13
0
 def testGalaxyBulges(self):
     """
     Test that GalSimInterpreter puts the right number of counts on images of galaxy bulges
     """
     catName = os.path.join(self.scratch_dir, 'testBulgeCat.sav')
     gals = testGalaxyBulgeDBObj(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='bulge')
     if os.path.exists(catName):
         os.unlink(catName)
コード例 #14
0
 def testPSFimages(self):
     """
     Test that GalSimInterpreter puts the right number of counts on images of Galaxy bulges convolved
     with a PSF
     """
     catName = "testPSFcat.sav"
     gals = testGalaxyBulgeDBObj(driver=self.driver, database=self.dbName)
     cat = psfCatalog(gals, obs_metadata=self.obs_metadata)
     cat.write_catalog(catName)
     self.catalogTester(catName=catName, catalog=cat, nameRoot="psf")
     if os.path.exists(catName):
         os.unlink(catName)
コード例 #15
0
 def testBackground(self):
     """
     Test that GalSimInterpreter puts the right number of counts on images of Galaxy bulges with
     a sky background
     """
     catName = "testBackgroundCat.sav"
     gals = testGalaxyBulgeDBObj(driver=self.driver, database=self.dbName)
     cat = backgroundCatalog(gals, obs_metadata=self.obs_metadata)
     cat.write_catalog(catName)
     self.catalogTester(catName=catName, catalog=cat, nameRoot="background")
     if os.path.exists(catName):
         os.unlink(catName)
コード例 #16
0
    def testCompoundFitsFiles(self):
        """
        Test that GalSimInterpreter puts the right number of counts on images
        containing different types of objects
        """
        driver = 'sqlite'
        dbName1 = os.path.join(self.scratch_dir, 'galSimTestCompound1DB.db')
        if os.path.exists(dbName1):
            os.unlink(dbName1)

        deltaRA = np.array([72.0 / 3600.0, 55.0 / 3600.0, 75.0 / 3600.0])
        deltaDec = np.array([0.0, 15.0 / 3600.0, -15.0 / 3600.0])
        obs_metadata1 = makePhoSimTestDB(filename=dbName1,
                                         size=1,
                                         deltaRA=deltaRA,
                                         deltaDec=deltaDec,
                                         bandpass=self.bandpassNameList,
                                         m5=self.m5,
                                         seeing=self.seeing)

        dbName2 = os.path.join(self.scratch_dir, 'galSimTestCompound2DB.db')
        if os.path.exists(dbName2):
            os.unlink(dbName2)

        deltaRA = np.array([55.0 / 3600.0, 60.0 / 3600.0, 62.0 / 3600.0])
        deltaDec = np.array([-3.0 / 3600.0, 10.0 / 3600.0, 10.0 / 3600.0])
        obs_metadata2 = makePhoSimTestDB(filename=dbName2,
                                         size=1,
                                         deltaRA=deltaRA,
                                         deltaDec=deltaDec,
                                         bandpass=self.bandpassNameList,
                                         m5=self.m5,
                                         seeing=self.seeing)

        gals = testGalaxyBulgeDBObj(driver=driver, database=dbName1)
        cat1 = testGalaxyCatalog(gals, obs_metadata=obs_metadata1)
        cat1.camera_wrapper = GalSimCameraWrapper(self.camera)
        catName = os.path.join(self.scratch_dir, 'compoundCatalog.sav')
        cat1.write_catalog(catName)

        stars = testStarsDBObj(driver=driver, database=dbName2)
        cat2 = testStarCatalog(stars, obs_metadata=obs_metadata2)
        cat2.copyGalSimInterpreter(cat1)
        cat2.write_catalog(catName, write_header=False, write_mode='a')
        self.catalogTester(catName=catName, catalog=cat2, nameRoot='compound')

        if os.path.exists(dbName1):
            os.unlink(dbName1)
        if os.path.exists(dbName2):
            os.unlink(dbName2)
        if os.path.exists(catName):
            os.unlink(catName)
コード例 #17
0
 def testBackground(self):
     """
     Test that GalSimInterpreter puts the right number of counts on images of Galaxy bulges with
     a sky background
     """
     catName = os.path.join(self.scratch_dir, 'testBackgroundCat.sav')
     gals = testGalaxyBulgeDBObj(driver=self.driver, database=self.dbName)
     cat = backgroundCatalog(gals, obs_metadata=self.obs_metadata)
     cat.camera_wrapper = GalSimCameraWrapper(self.camera)
     cat.write_catalog(catName)
     self.catalogTester(catName=catName, catalog=cat, nameRoot='background')
     if os.path.exists(catName):
         os.unlink(catName)
コード例 #18
0
    def testMultipleImages(self):
        """
        Test that GalSimInterpreter puts the right number of counts on images of multiple objects
        """
        dbName = os.path.join(self.scratch_dir, 'galSimTestMultipleDB.db')
        driver = 'sqlite'

        if os.path.exists(dbName):
            os.unlink(dbName)

        deltaRA = np.array([72.0 / 3600.0, 55.0 / 3600.0, 75.0 / 3600.0])
        deltaDec = np.array([0.0, 15.0 / 3600.0, -15.0 / 3600.0])
        obs_metadata = makePhoSimTestDB(filename=dbName,
                                        size=1,
                                        deltaRA=deltaRA,
                                        deltaDec=deltaDec,
                                        bandpass=self.bandpassNameList,
                                        m5=self.m5,
                                        seeing=self.seeing)

        gals = testGalaxyBulgeDBObj(driver=driver, database=dbName)
        cat = testGalaxyCatalog(gals, obs_metadata=obs_metadata)
        cat.camera_wrapper = GalSimCameraWrapper(self.camera)
        catName = os.path.join(self.scratch_dir, 'multipleCatalog.sav')
        cat.write_catalog(catName)
        self.catalogTester(catName=catName, catalog=cat, nameRoot='multiple')
        if os.path.exists(catName):
            os.unlink(catName)

        stars = testStarsDBObj(driver=driver, database=dbName)
        cat = testStarCatalog(stars, obs_metadata=obs_metadata)
        cat.camera_wrapper = GalSimCameraWrapper(self.camera)
        catName = os.path.join(self.scratch_dir, 'multipleStarCatalog.sav')
        cat.write_catalog(catName)
        self.catalogTester(catName=catName,
                           catalog=cat,
                           nameRoot='multipleStars')
        if os.path.exists(catName):
            os.unlink(catName)

        if os.path.exists(dbName):
            os.unlink(dbName)
コード例 #19
0
 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])]
コード例 #20
0
    def testCreationOfPhoSimCatalog(self):
        """
        Make sure that we can create PhoSim input catalogs using the returned
        ObservationMetaData. This test will just make sure that all of the
        expected header entries are there.
        """

        dbName = tempfile.mktemp(dir=ROOT, prefix='obsMetaDataGeneratorTest-', suffix='.db')
        makePhoSimTestDB(filename=dbName)
        bulgeDB = testGalaxyBulgeDBObj(driver='sqlite', database=dbName)
        gen = self.gen
        results = gen.getObservationMetaData(fieldRA=np.degrees(1.370916),
                                             telescopeFilter='i')
        testCat = PhoSimCatalogSersic2D(bulgeDB, obs_metadata=results[0])
        testCat.phoSimHeaderMap = {}
        with lsst.utils.tests.getTempFilePath('.txt') as catName:
            testCat.write_catalog(catName)

        if os.path.exists(dbName):
            os.unlink(dbName)
コード例 #21
0
    def testNoisyCatalog(self):
        """
        Compare noisy and noiseless images drawn from the same catalog.
        Make sure that the pixel-by-pixel difference between the two is
        as expected from Poisson statistics.
        """
        noisyCatName = 'testNoisyCatalog.sav'
        cleanCatName = 'testCleanCatalog.sav'

        gals = testGalaxyBulgeDBObj(driver=self.driver, database=self.dbName)

        noisyCat = noisyCatalog(gals, obs_metadata=self.obs_metadata)
        cleanCat = backgroundCatalog(gals, obs_metadata=self.obs_metadata)

        noisyCat.write_catalog(noisyCatName)
        cleanCat.write_catalog(cleanCatName)

        self.compareCatalogs(cleanCat, noisyCat, PhotometricParameters().gain, PhotometricParameters().readnoise)

        if os.path.exists(noisyCatName):
            os.unlink(noisyCatName)
        if os.path.exists(cleanCatName):
            os.unlink(cleanCatName)
コード例 #22
0
 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]