コード例 #1
0
    def make_instance_catalog(self, obsHistID, band, boundLength, outfile=None):
        """
        Method to create instance catalogs.

        Parameters
        ----------
        obsHistID : int
            obsHistID for the desired visit from the opsim db file.

        band : str
            Desired LSST filter to use, ugrizy.

        boundLength : float
            Radius in degrees of sky cone in which to produce objects.

        outfile : str, optional
            File name of the instance catalog to be produced.  If None,
            a default name will be generated, e.g.,
            phosim_input_0000230_r_0.3deg.txt.
        """
        if outfile is None:
            outfile = 'phosim_input_%07i_%s_%.1fdeg.txt' % (obsHistID, band,
                                                            boundLength)
            obs_md = self.gen.getObservationMetaData(obsHistID=obsHistID,
                                                     boundLength=boundLength)[0]
        do_header = True
        for objid in self.star_objs:
            self.logger.info("processing %s", objid)
            db_obj = CatalogDBObject.from_objid(objid, **self.db_config)
            phosim_object = PhoSimCatalogPoint(db_obj, obs_metadata=obs_md)
            if do_header:
                with open(outfile, 'w') as file_obj:
                    phosim_object.write_header(file_obj)
                do_header = False
            phosim_object.write_catalog(outfile, write_mode='a',
                                        write_header=False,
                                        chunk_size=20000)

        for objid in self.gal_objs:
            self.logger.info("processing %s", objid)
            db_obj = CatalogDBObject.from_objid(objid, **self.db_config)
            phosim_object = PhoSimCatalogSersic2D(db_obj, obs_metadata=obs_md)
            phosim_object.write_catalog(outfile, write_mode='a',
                                        write_header=False,
                                        chunk_size=20000)
コード例 #2
0
for md in obsMetaDataResults:
    if md.bandpass == 'r':
        rVisits.append(md)
starObjNames = ['msstars', 'bhbstars', 'wdstars', 'rrlystars', 'cepheidstars']

for obs_metadata in rVisits[:10]:
    filename = "phosim_input_%s.txt"%(obs_metadata.phoSimMetaData['Opsim_obshistid'][0])
    obs_metadata.phoSimMetaData['SIM_NSNAP'] = (1, numpy.dtype(int))
    obs_metadata.phoSimMetaData['SIM_VISTIME'] = (30, numpy.dtype(float))
    doHeader= True
    for starName in starObjNames:
        print starName
        while True:
            try:
                stars = CatalogDBObject.from_objid(starName)
                star_phoSim=PhoSimCatalogPoint(stars,obs_metadata=obs_metadata) #the class for phoSim input files
                break
            except RuntimeError:
                continue
                                                                    #containing point sources
        if (doHeader):
            with open(filename,"w") as fh:
                star_phoSim.write_header(fh)
            doHeader = False

        #below, write_header=False prevents the code from overwriting the header just written
        #write_mode = 'a' allows the code to append the new objects to the output file, rather
        #than overwriting the file for each different class of object.
        star_phoSim.write_catalog(filename,write_mode='a',write_header=False,chunk_size=20000)

コード例 #3
0
from lsst.sims.catUtils.baseCatalogModels import OpSim3_61DBObject
from lsst.sims.catUtils.exampleCatalogDefinitions.phoSimCatalogExamples import \
        PhoSimCatalogPoint, PhoSimCatalogSersic2D, PhoSimCatalogZPoint
from sprinkler import sprinklerAGN

from lsst.sims.catUtils.baseCatalogModels import *

starObjNames = ['msstars', 'bhbstars', 'wdstars', 'rrlystars', 'cepheidstars']

obsMD = OpSim3_61DBObject()
obs_metadata = obsMD.getObservationMetaData(88625744, 0.05, makeCircBounds = True)

doHeader= True
for starName in starObjNames:
    stars = CatalogDBObject.from_objid(starName)
    star_phoSim=PhoSimCatalogPoint(stars,obs_metadata=obs_metadata) #the class for phoSim input files
                                                                #containing point sources
    if (doHeader):
        with open("phoSim_example.txt","w") as fh:
            star_phoSim.write_header(fh)
        doHeader = False

    #below, write_header=False prevents the code from overwriting the header just written
    #write_mode = 'a' allows the code to append the new objects to the output file, rather
    #than overwriting the file for each different class of object.
    star_phoSim.write_catalog("phoSim_example.txt",write_mode='a',write_header=False,chunk_size=20000)

gals = CatalogDBObject.from_objid('galaxyBulge')

#now append a bunch of objects with 2D sersic profiles to our output file
galaxy_phoSim = PhoSimCatalogSersic2D(gals, obs_metadata=obs_metadata)
コード例 #4
0
from lsst.sims.catUtils.baseCatalogModels import *

starObjNames = ['msstars', 'bhbstars', 'wdstars', 'rrlystars', 'cepheidstars']

obsMD = OpSim3_61DBObject()
obs_list = obsMD.getObservationMetaData((23.0, -50.0),
                                        2.0,
                                        fovRadius=0.1,
                                        makeCircBounds=True)

obs_metadata = obs_list[0]

doHeader = True
for starName in starObjNames:
    stars = CatalogDBObject.from_objid(starName)
    star_phoSim = PhoSimCatalogPoint(
        stars, obs_metadata=obs_metadata)  #the class for phoSim input files

    #containing point sources
    star_phoSim.phoSimHeaderMap = DefaultPhoSimHeaderMap
    if (doHeader):
        with open("phoSim_example.txt", "w") as fh:
            star_phoSim.write_header(fh)
        doHeader = False

    #below, write_header=False prevents the code from overwriting the header just written
    #write_mode = 'a' allows the code to append the new objects to the output file, rather
    #than overwriting the file for each different class of object.
    star_phoSim.write_catalog("phoSim_example.txt",
                              write_mode='a',
                              write_header=False,
                              chunk_size=20000)