Commit 6078791f authored by Fang Yuedong's avatar Fang Yuedong
Browse files

first commit of user-customizable catalog version

parent 1635e47d
...@@ -33,14 +33,14 @@ class Catalog(object): ...@@ -33,14 +33,14 @@ class Catalog(object):
# star_file = 'stars_ccd' + chip.getChipLabel(chip.chipID) + '_p_RA'+str(self.pRa) + '_DE' + str(self.pDec) + '.hdf5' # star_file = 'stars_ccd' + chip.getChipLabel(chip.chipID) + '_p_RA'+str(self.pRa) + '_DE' + str(self.pDec) + '.hdf5'
# galaxy_file = 'galaxies_ccd' + chip.getChipLabel(chip.chipID) + '_p_RA'+str(self.pRa) + '_DE' + str(self.pDec) + '.hdf5' # galaxy_file = 'galaxies_ccd' + chip.getChipLabel(chip.chipID) + '_p_RA'+str(self.pRa) + '_DE' + str(self.pDec) + '.hdf5'
if "star_cat" in config["input_path"]: if "star_cat" in config["input_path"] and config["input_path"]["star_cat"]:
star_file = config["input_path"]["star_cat"] star_file = config["input_path"]["star_cat"]
star_SED_file = config["SED_templates_path"]["star_SED"] star_SED_file = config["SED_templates_path"]["star_SED"]
self.star_path = os.path.join(self.cat_dir, star_file) self.star_path = os.path.join(self.cat_dir, star_file)
self.star_SED_path = os.path.join(config["data_dir"], star_SED_file) self.star_SED_path = os.path.join(config["data_dir"], star_SED_file)
self._load_SED_lib_star() self._load_SED_lib_star()
if "galaxy_cat" in config["input_path"]:
if "galaxy_cat" in config["input_path"] and config["input_path"]["galaxy_cat"]:
galaxy_file = config["input_path"]["galaxy_cat"] galaxy_file = config["input_path"]["galaxy_cat"]
self.galaxy_path = os.path.join(self.cat_dir, galaxy_file) self.galaxy_path = os.path.join(self.cat_dir, galaxy_file)
self.galaxy_SED_path = os.path.join(config["data_dir"], config["SED_templates_path"]["galaxy_SED"]) self.galaxy_SED_path = os.path.join(config["data_dir"], config["SED_templates_path"]["galaxy_SED"])
...@@ -86,7 +86,6 @@ class Catalog(object): ...@@ -86,7 +86,6 @@ class Catalog(object):
self.rng_sedGal = random.Random() self.rng_sedGal = random.Random()
self.rng_sedGal.seed(pix_id) # Use healpix index as the random seed self.rng_sedGal.seed(pix_id) # Use healpix index as the random seed
self.ud = galsim.UniformDeviate(pix_id) self.ud = galsim.UniformDeviate(pix_id)
# print(ngals)
for igals in range(ngals): for igals in range(ngals):
param = {} param = {}
param['ra'] = gals['ra_true'][igals] param['ra'] = gals['ra_true'][igals]
...@@ -143,7 +142,6 @@ class Catalog(object): ...@@ -143,7 +142,6 @@ class Catalog(object):
def _load_stars(self, stars, pix_id=None): def _load_stars(self, stars, pix_id=None):
nstars = len(stars['sourceID']) nstars = len(stars['sourceID'])
# print(nstars)
for istars in range(nstars): for istars in range(nstars):
param = {} param = {}
param['ra'] = stars['RA'][istars] param['ra'] = stars['RA'][istars]
...@@ -168,10 +166,6 @@ class Catalog(object): ...@@ -168,10 +166,6 @@ class Catalog(object):
def _load(self): def _load(self):
self.nav = 15005 self.nav = 15005
self.avGal = extAv(self.nav, seed=self.seed_Av) self.avGal = extAv(self.nav, seed=self.seed_Av)
# gals = Table.read(self.galaxy_path)
# stars = Table.read(self.star_path)
# self.ngals = gals['galaxyID'].size
# self.nstars = stars['sourceID'].size
gals_cat = h5.File(self.galaxy_path, 'r')['galaxies'] gals_cat = h5.File(self.galaxy_path, 'r')['galaxies']
star_cat = h5.File(self.star_path, 'r')['catalog'] star_cat = h5.File(self.star_path, 'r')['catalog']
self.objs = [] self.objs = []
...@@ -182,66 +176,4 @@ class Catalog(object): ...@@ -182,66 +176,4 @@ class Catalog(object):
self._load_gals(gals, pix_id=pix) self._load_gals(gals, pix_id=pix)
self._load_stars(stars, pix_id=pix) self._load_stars(stars, pix_id=pix)
print("number of objects in catalog: ", len(self.objs)) print("number of objects in catalog: ", len(self.objs))
del self.avGal del self.avGal
# for igals in range(self.ngals): \ No newline at end of file
# param = {}
# param['id'] = igals + 1
# param['ra'] = gals['ra_true'][igals]
# param['dec'] = gals['dec_true'][igals]
# param['z'] = gals['redshift_true'][igals]
# param['model_tag'] = 'None'
# param['gamma1'] = 0
# param['gamma2'] = 0
# param['kappa'] = 0
# param['delta_ra'] = 0
# param['delta_dec'] = 0
# sersicB = gals['sersic_bulge'][igals]
# hlrMajB = gals['size_bulge_true'][igals]
# hlrMinB = gals['size_minor_bulge_true'][igals]
# sersicD = gals['sersic_disk'][igals]
# hlrMajD = gals['size_disk_true'][igals]
# hlrMinD = gals['size_minor_disk_true'][igals]
# aGal = gals['size_true'][igals]
# bGal = gals['size_minor_true'][igals]
# param['bfrac'] = gals['bulge_to_total_ratio_i'][igals]
# param['theta'] = gals['position_angle_true'][igals]
# param['hlr_bulge'] = np.sqrt(hlrMajB * hlrMinB)
# param['hlr_disk'] = np.sqrt(hlrMajD * hlrMinD)
# param['ell_bulge'] = (hlrMajB - hlrMinB)/(hlrMajB + hlrMinB)
# param['ell_disk'] = (hlrMajD - hlrMinD)/(hlrMajD + hlrMinD)
# param['ell_tot'] = (aGal - bGal) / (aGal + bGal)
# # Assign each galaxy a template SED
# param['sed_type'] = sed_assign(phz=param['z'], btt=param['bfrac'], rng=self.rng_sedGal)
# param['redden'] = self.tempRed_gal[param['sed_type']]
# param['av'] = avGal[int(self.ud()*nav)]
# if param['sed_type'] <= 5:
# param['av'] = 0.0
# param['redden'] = 0
# param['star'] = 0 # Galaxy
# 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
# param['mag_use_normal'] = gals['mag_true_g_lsst'][igals]
# if param['star'] == 0:
# obj = Galaxy(param, self.rotation)
# self.objs.append(obj)
# if param['star'] == 2:
# obj = Quasar(param)
# self.objs.append(obj)
# for istars in range(self.nstars):
# param = {}
# param['id'] = self.ngals + istars + 1
# param['ra'] = stars['RA'][istars]
# param['dec'] = stars['Dec'][istars]
# param['sed_type'] = stars['sourceID'][istars]
# param['model_tag'] = stars['model_tag'][istars]
# param['z'] = 0.0
# param['star'] = 1 # Star
# param['mag_use_normal'] = stars['app_sdss_g'][istars]
# obj = Star(param)
# self.objs.append(obj)
# del gals
# del stars
# del avGal
\ No newline at end of file
import numpy as np
import galsim
import copy
from astropy.table import Table
from abc import abstractmethod, ABCMeta
from ObservationSim.MockObject._util import integrate_sed_bandpass, getNormFactorForSpecWithABMAG, getABMAG
class CatalogBase(metaclass=ABCMeta):
def __init__(self):
pass
@abstractmethod
def load_sed(self, obj, **kward):
pass
@abstractmethod
def _load(self, **kward):
pass
@abstractmethod
def load_norm_filt(self, obj):
return None
@staticmethod
def initialize_param():
param = {
"star":-1,
"id":-1,
"ra":0,
"dec":0,
"z":0,
"sed_type":-1,
"model_tag":"unknown",
"mag_use_normal":100,
"theta":0,
"kappa":0,
"gamma1":0,
"gamma2":0,
"bfrac":0,
"hlr_bulge":0,
"hlr_disk":0,
"ell_bulge":0,
"ell_disk":0,
"ell_tot":0,
"teff":0,
"logg":0,
"feh":0
}
return param
@staticmethod
def convert_sed(mag, sed, target_filt, norm_filt=None):
bandpass = target_filt.bandpass_full
if norm_filt is not None:
norm_thr_rang_ids = norm_filt['SENSITIVITY'] > 0.001
else:
norm_filt = Table(
np.array(np.array([bandpass.wave_list*10.0, bandpass.func(bandpass.wave_list)])).T, names=(['WAVELENGTH', 'SENSITIVITY'])
)
norm_thr_rang_ids = norm_filt['SENSITIVITY'] > 0.001
sedNormFactor = getNormFactorForSpecWithABMAG(ABMag=mag,
spectrum=sed,
norm_thr=norm_filt,
sWave=np.floor(norm_filt[norm_thr_rang_ids][0][0]),
eWave=np.ceil(norm_filt[norm_thr_rang_ids][-1][0]))
sed_photon = copy.copy(sed)
sed_photon = np.array([sed_photon['WAVELENGTH'], sed_photon['FLUX']*sedNormFactor]).T
sed_photon = galsim.LookupTable(x=np.array(sed_photon[:, 0]), f=np.array(sed_photon[:, 1]), interpolant='nearest')
# Get magnitude
sed_photon = galsim.SED(sed_photon, wave_type='A', flux_type='1', fast=False)
interFlux = integrate_sed_bandpass(sed=sed_photon, bandpass=bandpass)
mag_csst = getABMAG(
interFlux=interFlux,
bandpass=bandpass
)
if target_filt.survey_type == "photometric":
return sed_photon, mag_csst
elif target_filt.survey_type == "spectroscopic":
del sed_photon
return sed, mag_csst
\ No newline at end of file
...@@ -28,65 +28,65 @@ class Galaxy(MockObject): ...@@ -28,65 +28,65 @@ class Galaxy(MockObject):
if rotation is not None: if rotation is not None:
self.rotateEllipticity(rotation) self.rotateEllipticity(rotation)
def load_SED(self, survey_type, sed_path=None, cosids=None, objtypes=None, sed_templates=None, normFilter=None, target_filt=None): # def load_SED(self, survey_type, sed_path=None, cosids=None, objtypes=None, sed_templates=None, normFilter=None, target_filt=None):
if survey_type == "photometric": # if survey_type == "photometric":
norm_thr_rang_ids = normFilter['SENSITIVITY'] > 0.001 # norm_thr_rang_ids = normFilter['SENSITIVITY'] > 0.001
if sed_templates is None: # if sed_templates is None:
# Read SED data directly # # Read SED data directly
itype = objtypes[cosids==self.sed_type][0] # itype = objtypes[cosids==self.sed_type][0]
sed_file = os.path.join(sed_path, itype + "_ID%s.sed"%(self.sed_type)) # sed_file = os.path.join(sed_path, itype + "_ID%s.sed"%(self.sed_type))
if not os.path.exists(sed_file): # if not os.path.exists(sed_file):
raise ValueError("!!! No SED found.") # raise ValueError("!!! No SED found.")
sed_data = Table.read(sed_file, format="ascii") # sed_data = Table.read(sed_file, format="ascii")
wave, flux = sed_data["observedLambda"].data, sed_data["observedFlux"].data # wave, flux = sed_data["observedLambda"].data, sed_data["observedFlux"].data
else: # else:
# Load SED from templates # # Load SED from templates
sed_data = sed_templates[self.sed_type] # sed_data = sed_templates[self.sed_type]
# redshift, intrinsic extinction # # redshift, intrinsic extinction
sed_data = getObservedSED( # sed_data = getObservedSED(
sedCat=sed_data, # sedCat=sed_data,
redshift=self.z, # redshift=self.z,
av=self.param['av'], # av=self.param['av'],
redden=self.param['redden']) # redden=self.param['redden'])
wave, flux = sed_data[0], sed_data[1] # wave, flux = sed_data[0], sed_data[1]
flux_photon = flux * (wave / (cons.h.value * cons.c.value)) * 1e-13 # flux_photon = flux * (wave / (cons.h.value * cons.c.value)) * 1e-13
sed_photon = Table(np.array([wave, flux_photon]).T, names=('WAVELENGTH', 'FLUX')) # sed_photon = Table(np.array([wave, flux_photon]).T, names=('WAVELENGTH', 'FLUX'))
# Get scaling factor for SED # # Get scaling factor for SED
sedNormFactor = getNormFactorForSpecWithABMAG(ABMag=self.param['mag_use_normal'], # sedNormFactor = getNormFactorForSpecWithABMAG(ABMag=self.param['mag_use_normal'],
spectrum=sed_photon, # spectrum=sed_photon,
norm_thr=normFilter, # norm_thr=normFilter,
sWave=np.floor(normFilter[norm_thr_rang_ids][0][0]), # sWave=np.floor(normFilter[norm_thr_rang_ids][0][0]),
eWave=np.ceil(normFilter[norm_thr_rang_ids][-1][0])) # eWave=np.ceil(normFilter[norm_thr_rang_ids][-1][0]))
sed_photon = np.array([sed_photon['WAVELENGTH'], sed_photon['FLUX']*sedNormFactor]).T # sed_photon = np.array([sed_photon['WAVELENGTH'], sed_photon['FLUX']*sedNormFactor]).T
# Convert to galsim.SED object # # Convert to galsim.SED object
spec = galsim.LookupTable(x=np.array(sed_photon[:, 0]), f=np.array(sed_photon[:, 1]), interpolant='nearest') # spec = galsim.LookupTable(x=np.array(sed_photon[:, 0]), f=np.array(sed_photon[:, 1]), interpolant='nearest')
self.sed = galsim.SED(spec, wave_type='A', flux_type='1', fast=False) # self.sed = galsim.SED(spec, wave_type='A', flux_type='1', fast=False)
# Get magnitude # # Get magnitude
interFlux = integrate_sed_bandpass(sed=self.sed, bandpass=target_filt.bandpass_full) # interFlux = integrate_sed_bandpass(sed=self.sed, bandpass=target_filt.bandpass_full)
self.param['mag_%s'%target_filt.filter_type] = getABMAG( # self.param['mag_%s'%target_filt.filter_type] = getABMAG(
interFlux=interFlux, # interFlux=interFlux,
bandpass=target_filt.bandpass_full) # bandpass=target_filt.bandpass_full)
# print('mag_use_normal = ', self.param['mag_use_normal']) # # print('mag_use_normal = ', self.param['mag_use_normal'])
# print('mag_%s = '%target_filt.filter_type, self.param['mag_%s'%target_filt.filter_type]) # # print('mag_%s = '%target_filt.filter_type, self.param['mag_%s'%target_filt.filter_type])
# print('redshift = %.3f'%(self.z)) # # print('redshift = %.3f'%(self.z))
# print('sed_type = %d, av = %.2f, redden = %d'%(self.sed_type, self.param['av'], self.param['redden'])) # # print('sed_type = %d, av = %.2f, redden = %d'%(self.sed_type, self.param['av'], self.param['redden']))
elif survey_type == "spectroscopic": # elif survey_type == "spectroscopic":
if sed_templates is None: # if sed_templates is None:
self.sedPhotons(sed_path=sed_path, cosids=cosids, objtypes=objtypes) # self.sedPhotons(sed_path=sed_path, cosids=cosids, objtypes=objtypes)
else: # else:
sed_data = sed_templates[self.sed_type] # sed_data = sed_templates[self.sed_type]
sed_data = getObservedSED( # sed_data = getObservedSED(
sedCat=sed_data, # sedCat=sed_data,
redshift=self.z, # redshift=self.z,
av=self.param['av'], # av=self.param['av'],
redden=self.param['redden']) # redden=self.param['redden'])
speci = interpolate.interp1d(sed_data[0], sed_data[1]) # speci = interpolate.interp1d(sed_data[0], sed_data[1])
lamb = np.arange(2500, 10001 + 0.5, 0.5) # lamb = np.arange(2500, 10001 + 0.5, 0.5)
y = speci(lamb) # y = speci(lamb)
# erg/s/cm2/A --> photo/s/m2/A # # erg/s/cm2/A --> photo/s/m2/A
all_sed = y * lamb / (cons.h.value * cons.c.value) * 1e-13 # all_sed = y * lamb / (cons.h.value * cons.c.value) * 1e-13
self.sed = Table(np.array([lamb, all_sed]).T, names=('WAVELENGTH', 'FLUX')) # self.sed = Table(np.array([lamb, all_sed]).T, names=('WAVELENGTH', 'FLUX'))
def unload_SED(self): def unload_SED(self):
...@@ -94,23 +94,23 @@ class Galaxy(MockObject): ...@@ -94,23 +94,23 @@ class Galaxy(MockObject):
""" """
del self.sed del self.sed
def sedPhotons(self, sed_path, cosids, objtypes): # def sedPhotons(self, sed_path, cosids, objtypes):
itype = objtypes[cosids == self.sed_type][0] # itype = objtypes[cosids == self.sed_type][0]
sed_file = os.path.join(sed_path, itype + "_ID%s.sed" % (self.sed_type)) # sed_file = os.path.join(sed_path, itype + "_ID%s.sed" % (self.sed_type))
if not os.path.exists(sed_file): # if not os.path.exists(sed_file):
raise ValueError("!!! No SED found.") # raise ValueError("!!! No SED found.")
sed = Table.read(sed_file, format="ascii") # sed = Table.read(sed_file, format="ascii")
spec_data = {} # spec_data = {}
f_orig = sed["observedFlux"].data # f_orig = sed["observedFlux"].data
w_orig = sed["observedLambda"].data # w_orig = sed["observedLambda"].data
speci = interpolate.interp1d(w_orig, f_orig) # speci = interpolate.interp1d(w_orig, f_orig)
lamb = np.arange(2500, 10001 + 0.5, 0.5) # lamb = np.arange(2500, 10001 + 0.5, 0.5)
y = speci(lamb) # y = speci(lamb)
# erg/s/cm2/A --> photo/s/m2/A # # erg/s/cm2/A --> photo/s/m2/A
all_sed = y * lamb / (cons.h.value * cons.c.value) * 1e-13 # all_sed = y * lamb / (cons.h.value * cons.c.value) * 1e-13
self.sed = Table(np.array([lamb, all_sed]).T, names=('WAVELENGTH', 'FLUX')) # self.sed = Table(np.array([lamb, all_sed]).T, names=('WAVELENGTH', 'FLUX'))
def getGSObj_multiband(self, tel, psf_list, bandpass_list, filt, nphotons_tot=None, g1=0, g2=0, exptime=150.): def getGSObj_multiband(self, tel, psf_list, bandpass_list, filt, nphotons_tot=None, g1=0, g2=0, exptime=150.):
if len(psf_list) != len(bandpass_list): if len(psf_list) != len(bandpass_list):
......
...@@ -3,7 +3,7 @@ import numpy as np ...@@ -3,7 +3,7 @@ import numpy as np
import astropy.constants as cons import astropy.constants as cons
from astropy.table import Table from astropy.table import Table
from ObservationSim.MockObject._util import magToFlux, vc_A, convolveGaussXorders from ObservationSim.MockObject._util import magToFlux, VC_A, convolveGaussXorders
from ObservationSim.MockObject._util import integrate_sed_bandpass, getNormFactorForSpecWithABMAG, getObservedSED, getABMAG from ObservationSim.MockObject._util import integrate_sed_bandpass, getNormFactorForSpecWithABMAG, getObservedSED, getABMAG
from ObservationSim.MockObject.SpecDisperser import SpecDisperser from ObservationSim.MockObject.SpecDisperser import SpecDisperser
...@@ -24,6 +24,7 @@ class MockObject(object): ...@@ -24,6 +24,7 @@ class MockObject(object):
self.sed_type = self.param["sed_type"] self.sed_type = self.param["sed_type"]
self.model_tag = self.param["model_tag"] self.model_tag = self.param["model_tag"]
self.mag_use_normal = self.param["mag_use_normal"] self.mag_use_normal = self.param["mag_use_normal"]
self.sed = None
def getMagFilter(self, filt): def getMagFilter(self, filt):
if filt.filter_type in ["GI", "GV", "GU"]: if filt.filter_type in ["GI", "GV", "GU"]:
...@@ -39,7 +40,7 @@ class MockObject(object): ...@@ -39,7 +40,7 @@ class MockObject(object):
def getElectronFluxFilt(self, filt, tel, exptime=150.): def getElectronFluxFilt(self, filt, tel, exptime=150.):
photonEnergy = filt.getPhotonE() photonEnergy = filt.getPhotonE()
flux = magToFlux(self.getMagFilter(filt)) flux = magToFlux(self.getMagFilter(filt))
factor = 1.0e4 * flux/photonEnergy * vc_A * (1.0/filt.blue_limit - 1.0/filt.red_limit) factor = 1.0e4 * flux/photonEnergy * VC_A * (1.0/filt.blue_limit - 1.0/filt.red_limit)
return factor * filt.efficiency * tel.pupil_area * exptime return factor * filt.efficiency * tel.pupil_area * exptime
def getPosWorld(self): def getPosWorld(self):
......
...@@ -17,60 +17,60 @@ class Star(MockObject): ...@@ -17,60 +17,60 @@ class Star(MockObject):
""" """
del self.sed del self.sed
def load_SED(self, survey_type, normFilter=None, target_filt=None, sed_lib=None, sed_path=None): # def load_SED(self, survey_type, normFilter=None, target_filt=None, sed_lib=None, sed_path=None):
if survey_type == "photometric": # if survey_type == "photometric":
norm_thr_rang_ids = normFilter['SENSITIVITY'] > 0.001 # norm_thr_rang_ids = normFilter['SENSITIVITY'] > 0.001
# spec_lambda = Table.read(sed_path, path=f"/SED/wave_{self.model_tag}") # # spec_lambda = Table.read(sed_path, path=f"/SED/wave_{self.model_tag}")
# spec_flux = Table.read(sed_path, path=f"/SED/{self.sed_type}") # # spec_flux = Table.read(sed_path, path=f"/SED/{self.sed_type}")
# wave, flux = spec_lambda['col0'].data, spec_flux['col0'].data # # wave, flux = spec_lambda['col0'].data, spec_flux['col0'].data
_, wave, flux = tag_sed( # _, wave, flux = tag_sed(
h5file=sed_lib, # h5file=sed_lib,
model_tag=self.param['model_tag'], # model_tag=self.param['model_tag'],
teff=self.param['teff'], # teff=self.param['teff'],
logg=self.param['logg'], # logg=self.param['logg'],
feh=self.param['feh']) # feh=self.param['feh'])
flux_photon = flux * (wave / (cons.h.value * cons.c.value)) * 1e-13 # flux_photon = flux * (wave / (cons.h.value * cons.c.value)) * 1e-13
sed_photon = Table(np.array([wave, flux_photon]).T, names=('WAVELENGTH', 'FLUX')) # sed_photon = Table(np.array([wave, flux_photon]).T, names=('WAVELENGTH', 'FLUX'))
# Get scaling factor for SED # # Get scaling factor for SED
sedNormFactor = getNormFactorForSpecWithABMAG(ABMag=self.param['mag_use_normal'], # sedNormFactor = getNormFactorForSpecWithABMAG(ABMag=self.param['mag_use_normal'],
spectrum=sed_photon, # spectrum=sed_photon,
norm_thr=normFilter, # norm_thr=normFilter,
sWave=np.floor(normFilter[norm_thr_rang_ids][0][0]), # sWave=np.floor(normFilter[norm_thr_rang_ids][0][0]),
eWave=np.ceil(normFilter[norm_thr_rang_ids][-1][0])) # eWave=np.ceil(normFilter[norm_thr_rang_ids][-1][0]))
sed_photon = np.array([sed_photon['WAVELENGTH'], sed_photon['FLUX']*sedNormFactor]).T # sed_photon = np.array([sed_photon['WAVELENGTH'], sed_photon['FLUX']*sedNormFactor]).T
# Convert to galsim.SED object # # Convert to galsim.SED object
spec = galsim.LookupTable(x=np.array(sed_photon[:, 0]), f=np.array(sed_photon[:, 1]), interpolant='nearest') # spec = galsim.LookupTable(x=np.array(sed_photon[:, 0]), f=np.array(sed_photon[:, 1]), interpolant='nearest')
self.sed = galsim.SED(spec, wave_type='A', flux_type='1', fast=False) # self.sed = galsim.SED(spec, wave_type='A', flux_type='1', fast=False)
# Get magnitude # # Get magnitude
interFlux = integrate_sed_bandpass(sed=self.sed, bandpass=target_filt.bandpass_full) # interFlux = integrate_sed_bandpass(sed=self.sed, bandpass=target_filt.bandpass_full)
self.param['mag_%s'%target_filt.filter_type] = getABMAG( # self.param['mag_%s'%target_filt.filter_type] = getABMAG(
interFlux=interFlux, # interFlux=interFlux,
bandpass=target_filt.bandpass_full) # bandpass=target_filt.bandpass_full)
# print('mag_use_normal = ', self.param['mag_use_normal']) # # print('mag_use_normal = ', self.param['mag_use_normal'])
# print('mag_%s = '%target_filt.filter_type, self.param['mag_%s'%target_filt.filter_type]) # # print('mag_%s = '%target_filt.filter_type, self.param['mag_%s'%target_filt.filter_type])
elif survey_type == "spectroscopic": # elif survey_type == "spectroscopic":
# self.sedPhotons(sed_path=sed_path) # # self.sedPhotons(sed_path=sed_path)
self.sedPhotons(sed_lib=sed_lib) # self.sedPhotons(sed_lib=sed_lib)
def sedPhotons(self, sed_path=None, sed_lib=None): # def sedPhotons(self, sed_path=None, sed_lib=None):
# spec_lambda = Table.read(sed_path, path=f"/SED/wave_{self.model_tag}") # # spec_lambda = Table.read(sed_path, path=f"/SED/wave_{self.model_tag}")
# spec_flux = Table.read(sed_path, path=f"/SED/{self.sed_type}") # # spec_flux = Table.read(sed_path, path=f"/SED/{self.sed_type}")
_, w_orig, f_orig = tag_sed( # _, w_orig, f_orig = tag_sed(
h5file=sed_lib, # h5file=sed_lib,
model_tag=self.param['model_tag'], # model_tag=self.param['model_tag'],
teff=self.param['teff'], # teff=self.param['teff'],
logg=self.param['logg'], # logg=self.param['logg'],
feh=self.param['feh']) # feh=self.param['feh'])
# spec_data = {} # # spec_data = {}
# f_orig = spec_flux["col0"].data # # f_orig = spec_flux["col0"].data
# w_orig = spec_lambda["col0"].data # # w_orig = spec_lambda["col0"].data
speci = interpolate.interp1d(w_orig, f_orig) # speci = interpolate.interp1d(w_orig, f_orig)
lamb = np.arange(2500, 10001 + 0.5, 0.5) # lamb = np.arange(2500, 10001 + 0.5, 0.5)
y = speci(lamb) # y = speci(lamb)
# erg/s/cm2/A --> photo/s/m2/A # # erg/s/cm2/A --> photo/s/m2/A
all_sed = y * lamb / (cons.h.value * cons.c.value) * 1e-13 # all_sed = y * lamb / (cons.h.value * cons.c.value) * 1e-13
self.sed = Table(np.array([lamb, all_sed]).T, names=('WAVELENGTH', 'FLUX')) # self.sed = Table(np.array([lamb, all_sed]).T, names=('WAVELENGTH', 'FLUX'))
def getGSObj(self, psf, g1=0, g2=0, flux=None, filt=None, tel=None, exptime=150.): def getGSObj(self, psf, g1=0, g2=0, flux=None, filt=None, tel=None, exptime=150.):
if flux == None: if flux == None:
......
from .MockObject import MockObject from .MockObject import MockObject
from .Galaxy import Galaxy from .Galaxy import Galaxy
from .CatalogBase import CatalogBase
from .Quasar import Quasar from .Quasar import Quasar
from .Star import Star from .Star import Star
from .Catalog import Catalog from .Catalog import Catalog
......
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