Commit e1458fd3 authored by Fang Yuedong's avatar Fang Yuedong
Browse files

galaxy SED bug fixed

parent 1908e835
......@@ -20,12 +20,7 @@ class Catalog(object):
self.chip = chip
self.template_dir = template_dir
self.rng_sedGal = random.Random()
self.rng_sedStar = random.Random()
self.rng_sedGal.seed(config["seed_gal"])
self.rng_sedStar.seed(config["seed_star"])
self.seed_Av = config["seed_Av"]
self.ud = galsim.UniformDeviate(config["seed_mock"])
self.pRa = float('{:8.4f}'.format(pRa))
self.pDec = float('{:8.4f}'.format(pDec))
......@@ -74,20 +69,16 @@ class Catalog(object):
self.cosids = sed_info["IDCosmoDC2"]
self.objtypes = sed_info["objType"]
def _load_gals(self, gals):
def _load_gals(self, gals, pix_id=None):
ngals = len(gals['galaxyID'])
self.rng_sedGal = random.Random()
self.rng_sedGal.seed(pix_id) # Use healpix index as the random seed
self.ud = galsim.UniformDeviate(pix_id)
# print(ngals)
for igals in range(ngals):
param = {}
param['ra'] = gals['ra_true'][igals]
param['dec'] = gals['dec_true'][igals]
if not self.chip.isContainObj(ra_obj=param['ra'], dec_obj=param['dec'], margin=200):
continue
param['mag_use_normal'] = gals['mag_true_g_lsst'][igals]
if param['mag_use_normal'] >= 26.5:
continue
self.ids += 1
param['id'] = self.ids
param['z'] = gals['redshift_true'][igals]
param['model_tag'] = 'None'
param['gamma1'] = 0
......@@ -122,6 +113,15 @@ class Catalog(object):
if param['sed_type'] >= 29:
param['av'] = 0.6 * param['av'] / 3.0 # for quasar, av=[0, 0.2], 3.0=av.max-av.im
param['star'] = 2 # Quasar
if not self.chip.isContainObj(ra_obj=param['ra'], dec_obj=param['dec'], margin=200):
continue
param['mag_use_normal'] = gals['mag_true_g_lsst'][igals]
if param['mag_use_normal'] >= 26.5:
continue
self.ids += 1
param['id'] = self.ids
if param['star'] == 0:
obj = Galaxy(param, self.rotation)
self.objs.append(obj)
......@@ -129,7 +129,7 @@ class Catalog(object):
obj = Quasar(param)
self.objs.append(obj)
def _load_stars(self, stars):
def _load_stars(self, stars, pix_id=None):
nstars = len(stars['sourceID'])
# print(nstars)
for istars in range(nstars):
......@@ -167,8 +167,8 @@ class Catalog(object):
for pix in self.pix_list:
gals = gals_cat[str(pix)]
stars = star_cat[str(pix)]
self._load_gals(gals)
self._load_stars(stars)
self._load_gals(gals, pix_id=pix)
self._load_stars(stars, pix_id=pix)
print("number of objects in catalog: ", len(self.objs))
del self.avGal
# for igals in range(self.ngals):
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment