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)
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) #now append a bunch of objects with 2D sersic profiles to our output file while True: try: gals = CatalogDBObject.from_objid('galaxyBulge') galaxy_phoSim = PhoSimCatalogSersic2D(gals, obs_metadata=obs_metadata) break except RuntimeError: continue galaxy_phoSim.write_catalog(filename,write_mode='a',write_header=False,chunk_size=20000) print 'bulge' while True: try:
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) galaxy_phoSim.write_catalog("phoSim_example.txt",write_mode='a',write_header=False,chunk_size=20000) gals = CatalogDBObject.from_objid('galaxyDisk') galaxy_phoSim = PhoSimCatalogSersic2D(gals, obs_metadata=obs_metadata) galaxy_phoSim.write_catalog("phoSim_example.txt",write_mode='a',write_header=False,chunk_size=20000) gals = CatalogDBObject.from_objid('sprinklerAGN') #gals = CatalogDBObject.from_objid('galaxyAgn') #PhoSimCatalogZPoint is the phoSim input class for extragalactic point sources (there will be no parallax
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) 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) galaxy_phoSim.write_catalog("phoSim_example.txt", write_mode='a', write_header=False, chunk_size=20000) gals = CatalogDBObject.from_objid('galaxyDisk') galaxy_phoSim = PhoSimCatalogSersic2D(gals, obs_metadata=obs_metadata) galaxy_phoSim.write_catalog("phoSim_example.txt", write_mode='a',