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

Merge branch 'milky_way_extinction' into 'develop'

Add Milky Way extinction and extend the range for SED integration

See merge request !27
parents 6e13d206 b9723717
Loading
Loading
Loading
Loading
Loading
+30 −9
Original line number Diff line number Diff line
@@ -111,10 +111,14 @@ class Catalog(CatalogBase):
        self.max_size = 0.

        # [TODO] Milky Way extinction
        if "enable_mw_ext_gal" in config["catalog_options"] and config["catalog_options"]["enable_mw_ext_gal"]:
            if "planck_ebv_map" not in config["catalog_options"]:
                raise ValueError(
                    "Planck dust map must be given to enable Milky Way extinction calculation for galaxies.")
            self.mw_ext = ExtinctionMW()
            self.mw_ext.init_ext_model(model_name="odonnell")
            self.mw_ext.load_Planck_ext(
            file_path="/public/home/fangyuedong/project/ext_maps/planck/HFI_CompMap_ThermalDustModel_2048_R1.20.fits")
                file_path=config["catalog_options"]["planck_ebv_map"])

        if "star_cat" in config["catalog_options"]["input_path"] and config["catalog_options"]["input_path"]["star_cat"] and not config["catalog_options"]["galaxy_only"]:
            # Get the cloest star catalog file
@@ -255,7 +259,10 @@ class Catalog(CatalogBase):
            )

        # [TODO] get Milky Way extinction AVs
        if "enable_mw_ext_gal" in self.config["catalog_options"] and self.config["catalog_options"]["enable_mw_ext_gal"]:
            MW_Av_arr = self.mw_ext.Av_from_Planck(ra=ra_arr, dec=dec_arr)
        else:
            MW_Av_arr = np.zeros(len(ra_arr))

        for igals in range(ngals):
            # # (TEST)
@@ -544,14 +551,28 @@ class Catalog(CatalogBase):
        y = speci(lamb)

        # [TODO] Apply Milky Way extinction
        if obj.type != 'star':
            self.mw_ext.apply_extinction(y, Av=obj.mw_Av)
        if obj.type != 'star' and ("enable_mw_ext_gal" in self.config["catalog_options"] and self.config["catalog_options"]["enable_mw_ext_gal"]):
            y = self.mw_ext.apply_extinction(y, Av=obj.mw_Av)

        # erg/s/cm2/A --> photon/s/m2/A
        all_sed = y * lamb / (cons.h.value * cons.c.value) * 1e-13
        sed = Table(np.array([lamb, all_sed]).T, names=('WAVELENGTH', 'FLUX'))
        if obj.type == 'quasar':
        # if obj.type == 'quasar':
        #     # integrate to get the magnitudes
        #     sed_photon = np.array([sed['WAVELENGTH'], sed['FLUX']]).T
        #     sed_photon = galsim.LookupTable(x=np.array(sed_photon[:, 0]), f=np.array(
        #         sed_photon[:, 1]), interpolant='nearest')
        #     sed_photon = galsim.SED(
        #         sed_photon, wave_type='A', flux_type='1', fast=False)
        #     interFlux = integrate_sed_bandpass(
        #         sed=sed_photon, bandpass=self.filt.bandpass_full)
        #     obj.param['mag_use_normal'] = getABMAG(
        #         interFlux, self.filt.bandpass_full)
        #     # mag = getABMAG(interFlux, self.filt.bandpass_full)
        #     # print("mag diff = %.3f"%(mag - obj.param['mag_use_normal']))

        # integrate to get the magnitudes
        if obj.type == 'quasar' or obj.type == 'galaxy':
            sed_photon = np.array([sed['WAVELENGTH'], sed['FLUX']]).T
            sed_photon = galsim.LookupTable(x=np.array(sed_photon[:, 0]), f=np.array(
                sed_photon[:, 1]), interpolant='nearest')
+7 −3
Original line number Diff line number Diff line
@@ -11,7 +11,7 @@
# can add some of the command-line arguments here as well;
# ok to pass either way or both, as long as they are consistent
work_dir: "/public/home/fangyuedong/project/workplace/"
run_name: "ext_test"
run_name: "ext_on"

# Project cycle and run counter are used to name the outputs
project_cycle: 9
@@ -44,11 +44,15 @@ catalog_options:
  star_only: NO

  # Only simulate galaxies?
  galaxy_only: YES
  galaxy_only: NO

  # rotate galaxy ellipticity
  rotateEll: 0. # [degree]

  # Whether to apply milky way extinction to galaxies
  enable_mw_ext_gal: YES
  planck_ebv_map: "/public/home/fangyuedong/project/ext_maps/planck/HFI_CompMap_ThermalDustModel_2048_R1.20.fits"

###############################################
# Observation setting
###############################################
@@ -68,7 +72,7 @@ obs_setting:
  run_pointings: [0, 1, 2, 3, 4]

  # Whether to enable astrometric modeling
  enable_astrometric_model: True
  enable_astrometric_model: YES

  # Cut by saturation magnitude in which band?
  cut_in_band: "z"
+1 −1
Original line number Diff line number Diff line
3000
2000
4500
4750
5000
+2 −2
Original line number Diff line number Diff line
3800
2000
4217
4432
4631
@@ -6,4 +6,4 @@
5002
5179
5354
5799
 No newline at end of file
11000
 No newline at end of file
+2 −2
Original line number Diff line number Diff line
6600
2000
7061
7255
7448
@@ -6,4 +6,4 @@
7833
8027
8226
8999
 No newline at end of file
11000
 No newline at end of file
Loading