diff --git a/Catalog/C6_50sqdeg.py b/Catalog/C6_50sqdeg.py index f8ded9cdbb9ce7709d0ea3e6e9e4d69d195fcf5c..0c6d22b9deaf9a934ca23c4c6ad008ce0f44c00d 100644 --- a/Catalog/C6_50sqdeg.py +++ b/Catalog/C6_50sqdeg.py @@ -6,6 +6,7 @@ import h5py as h5 import healpy as hp import astropy.constants as cons import traceback +import cmath from astropy.coordinates import spherical_to_cartesian from astropy.table import Table from scipy import interpolate @@ -107,7 +108,7 @@ class Catalog(CatalogBase): self.AGN_SED_path = os.path.join(config["data_dir"], config["catalog_options"]["SED_templates_path"]["AGN_SED"]) if "rotateEll" in config["catalog_options"]: - self.rotation = float(int(config["catalog_options"]["rotateEll"]/45.)) + self.rotation = np.radians(float(config["catalog_options"]["rotateEll"])) else: self.rotation = 0. @@ -225,6 +226,10 @@ class Catalog(CatalogBase): param['ell_total'] = np.sqrt(param['e1']**2 + param['e2']**2) if param['ell_total'] > 0.9: continue + phi_e = cmath.phase(complex(param['e1'], param['e2'])) + param['e1'] = param['ell_total'] * np.cos(phi_e + 2*self.rotation) + param['e2'] = param['ell_total'] * np.sin(phi_e + 2*self.rotation) + param['e1_disk'] = param['e1'] param['e2_disk'] = param['e2'] param['e1_bulge'] = param['e1'] @@ -285,7 +290,7 @@ class Catalog(CatalogBase): param['id'] = '%06d'%(int(pix_id)) + '%06d'%(cat_id) + '%08d'%(igals) if param['star'] == 0: - obj = Galaxy(param, self.rotation, logger=self.logger) + obj = Galaxy(param, logger=self.logger) elif param['star'] == 2: obj = Quasar(param, logger=self.logger) diff --git a/Catalog/C6_Catalog.py b/Catalog/C6_Catalog.py index 5cef969ebff3223af77139a524c39641a0a9b6b3..7d114e573747b84a25e892e4938d02e020e355c8 100644 --- a/Catalog/C6_Catalog.py +++ b/Catalog/C6_Catalog.py @@ -83,7 +83,7 @@ class Catalog(CatalogBase): self._load_SED_lib_AGN() if "rotateEll" in config["catalog_options"]: - self.rotation = float(int(config["catalog_options"]["rotateEll"]/45.)) + self.rotation = np.radians(float(config["catalog_options"]["rotateEll"])) else: self.rotation = 0. @@ -259,7 +259,7 @@ class Catalog(CatalogBase): param['id'] = '%06d'%(int(pix_id)) + '%06d'%(cat_id) + '%08d'%(igals) if param['star'] == 0: - obj = Galaxy(param, self.rotation, logger=self.logger) + obj = Galaxy(param, logger=self.logger) # Need to deal with additional output columns obj.additional_output_str = self.add_fmt%("n", 0., 0., 0., diff --git a/Catalog/C6_fits_Catalog.py b/Catalog/C6_fits_Catalog.py index 47160dfe018ac19b1e008769dc0900c474e4b848..80af1cbe05224ff92a71424c4e6d859e6f957350 100644 --- a/Catalog/C6_fits_Catalog.py +++ b/Catalog/C6_fits_Catalog.py @@ -94,7 +94,7 @@ class Catalog(CatalogBase): ###mock_stamp_END if "rotateEll" in config["catalog_options"]: - self.rotation = float(int(config["catalog_options"]["rotateEll"]/45.)) + self.rotation = np.radians(float(config["catalog_options"]["rotateEll"])) else: self.rotation = 0. @@ -272,7 +272,7 @@ class Catalog(CatalogBase): param['id'] = '%06d'%(int(pix_id)) + '%06d'%(cat_id) + '%08d'%(igals) if param['star'] == 0: - obj = Galaxy(param, self.rotation, logger=self.logger) + obj = Galaxy(param, logger=self.logger) # Need to deal with additional output columns obj.additional_output_str = self.add_fmt%("n", 0., 0., 0., diff --git a/Catalog/FGS_Catalog.py b/Catalog/FGS_Catalog.py index b1e57afc57a9561cc4d37f4a090f3460ca99246d..3b0c23024d87a7e2cc8074692a3a401657f78e55 100644 --- a/Catalog/FGS_Catalog.py +++ b/Catalog/FGS_Catalog.py @@ -84,7 +84,7 @@ class Catalog(CatalogBase): self._load_SED_lib_AGN() if "rotateEll" in config["catalog_options"]: - self.rotation = float(int(config["catalog_options"]["rotateEll"]/45.)) + self.rotation = np.radians(float(config["catalog_options"]["rotateEll"])) else: self.rotation = 0. @@ -260,7 +260,7 @@ class Catalog(CatalogBase): param['id'] = '%06d'%(int(pix_id)) + '%06d'%(cat_id) + '%08d'%(igals) if param['star'] == 0: - obj = Galaxy(param, self.rotation, logger=self.logger) + obj = Galaxy(param, logger=self.logger) # Need to deal with additional output columns obj.additional_output_str = self.add_fmt%("n", 0., 0., 0., diff --git a/Catalog/NGPCatalog.py b/Catalog/NGPCatalog.py index 73433f72a1b7732033b0597c912fb4b147d41aa7..f37b73c467297ba5f514e2d374640b25b5626175 100644 --- a/Catalog/NGPCatalog.py +++ b/Catalog/NGPCatalog.py @@ -52,7 +52,7 @@ class Catalog(CatalogBase): self.galaxy_SED_path = os.path.join(config["data_dir"], config["catalog_options"]["SED_templates_path"]["galaxy_SED"]) self._load_SED_lib_gals() if "rotateEll" in config["catalog_options"]: - self.rotation = float(int(config["catalog_options"]["rotateEll"]/45.)) + self.rotation = np.radians(float(config["catalog_options"]["rotateEll"])) else: self.rotation = 0. @@ -191,7 +191,7 @@ class Catalog(CatalogBase): param['id'] = gals['galaxyID'][igals] if param['star'] == 0: - obj = Galaxy(param, self.rotation, logger=self.logger) + obj = Galaxy(param, logger=self.logger) if param['star'] == 2: obj = Quasar(param, logger=self.logger) diff --git a/Catalog/fd_test_C6.py b/Catalog/fd_test_C6.py index 4767f57a2593f41880579cdd45fb15b3d9684277..0b7909a3e3c7dfe3dce5cc2c3d0f55e66a9011a9 100644 --- a/Catalog/fd_test_C6.py +++ b/Catalog/fd_test_C6.py @@ -83,7 +83,7 @@ class Catalog(CatalogBase): self._load_SED_lib_AGN() if "rotateEll" in config["catalog_options"]: - self.rotation = float(int(config["catalog_options"]["rotateEll"]/45.)) + self.rotation = np.radians(float(config["catalog_options"]["rotateEll"])) else: self.rotation = 0. @@ -269,7 +269,7 @@ class Catalog(CatalogBase): param['id'] = '%06d'%(int(pix_id)) + '%06d'%(cat_id) + '%08d'%(igals) if param['star'] == 0: - obj = Galaxy(param, self.rotation, logger=self.logger) + obj = Galaxy(param, logger=self.logger) # Need to deal with additional output columns obj.additional_output_str = self.add_fmt%("n", 0., 0., 0., @@ -418,16 +418,16 @@ class Catalog(CatalogBase): self.objs = [] self.ids = 0 - if "star_cat" in self.config["catalog_options"]["input_path"] and self.config["catalog_options"]["input_path"]["star_cat"] and not self.config["catalog_options"]["galaxy_only"]: - star_cat = h5.File(self.star_path, 'r')['catalog'] - for pix in self.pix_list: - try: - stars = star_cat[str(pix)] - self._load_stars(stars, pix_id=pix) - del stars - except Exception as e: - self.logger.error(str(e)) - print(e) + # if "star_cat" in self.config["catalog_options"]["input_path"] and self.config["catalog_options"]["input_path"]["star_cat"] and not self.config["catalog_options"]["galaxy_only"]: + # star_cat = h5.File(self.star_path, 'r')['catalog'] + # for pix in self.pix_list: + # try: + # stars = star_cat[str(pix)] + # self._load_stars(stars, pix_id=pix) + # del stars + # except Exception as e: + # self.logger.error(str(e)) + # print(e) if "galaxy_cat" in self.config["catalog_options"]["input_path"] and self.config["catalog_options"]["input_path"]["galaxy_cat"] and not self.config["catalog_options"]["star_only"]: for pix in self.pix_list: @@ -443,13 +443,13 @@ class Catalog(CatalogBase): self.logger.error(str(e)) print(e) - if "AGN_cat" in self.config["catalog_options"]["input_path"] and self.config["catalog_options"]["input_path"]["AGN_cat"] and not self.config["catalog_options"]["star_only"]: - try: - self._load_AGNs() - except Exception as e: - traceback.print_exc() - self.logger.error(str(e)) - print(e) + # if "AGN_cat" in self.config["catalog_options"]["input_path"] and self.config["catalog_options"]["input_path"]["AGN_cat"] and not self.config["catalog_options"]["star_only"]: + # try: + # self._load_AGNs() + # except Exception as e: + # traceback.print_exc() + # self.logger.error(str(e)) + # print(e) if self.logger is not None: self.logger.info("maximum galaxy size: %.4f"%(self.max_size)) diff --git a/Catalog/testCat_galaxy.py b/Catalog/testCat_galaxy.py index 4859bad612fc4fe23120cc77e7aad3a533d90247..8ecd698e421cadd9aeb742701cab191d701776c8 100644 --- a/Catalog/testCat_galaxy.py +++ b/Catalog/testCat_galaxy.py @@ -81,7 +81,7 @@ class Catalog(CatalogBase): self._load_SED_lib_AGN() if "rotateEll" in config["catalog_options"]: - self.rotation = float(int(config["catalog_options"]["rotateEll"]/45.)) + self.rotation = np.radians(float(config["catalog_options"]["rotateEll"])) else: self.rotation = 0. @@ -253,7 +253,7 @@ class Catalog(CatalogBase): param['id'] = '%06d'%(int(pix_id)) + '%06d'%(cat_id) + '%08d'%(igals) if param['star'] == 0: - obj = Galaxy(param, self.rotation, logger=self.logger) + obj = Galaxy(param, logger=self.logger) # Need to deal with additional output columns obj.additional_output_str = self.add_fmt%("n", 0., 0., 0., diff --git a/Catalog/wcs_test_C6.py b/Catalog/wcs_test_C6.py index 2bb2e9c0efc1962f42d41e8c665f6984df102f69..896ab4ae5e4cd86a861509dc5556f709c7769e12 100644 --- a/Catalog/wcs_test_C6.py +++ b/Catalog/wcs_test_C6.py @@ -83,7 +83,7 @@ class Catalog(CatalogBase): self._load_SED_lib_AGN() if "rotateEll" in config["catalog_options"]: - self.rotation = float(int(config["catalog_options"]["rotateEll"]/45.)) + self.rotation = np.radians(float(config["catalog_options"]["rotateEll"])) else: self.rotation = 0. @@ -264,7 +264,7 @@ class Catalog(CatalogBase): param['id'] = '%06d'%(int(pix_id)) + '%06d'%(cat_id) + '%08d'%(igals) if param['star'] == 0: - obj = Galaxy(param, self.rotation, logger=self.logger) + obj = Galaxy(param, logger=self.logger) # Need to deal with additional output columns obj.additional_output_str = self.add_fmt%("n", 0., 0., 0., diff --git a/ObservationSim/MockObject/Galaxy.py b/ObservationSim/MockObject/Galaxy.py index e212ce51575ac175f668c67396e2a6ded7249d75..6bda70164cb33d8585a40aff447f1df1f471fb3f 100755 --- a/ObservationSim/MockObject/Galaxy.py +++ b/ObservationSim/MockObject/Galaxy.py @@ -12,7 +12,7 @@ from ObservationSim.MockObject.MockObject import MockObject # import tracemalloc class Galaxy(MockObject): - def __init__(self, param, rotation=None, logger=None): + def __init__(self, param, logger=None): super().__init__(param, logger=logger) # self.thetaR = self.param["theta"] # self.bfrac = self.param["bfrac"] @@ -27,8 +27,6 @@ class Galaxy(MockObject): # self.e1_bulge, self.e2_bulge = self.e_bulge.g1, self.e_bulge.g2 # self.e1_total, self.e2_total = self.e_total.g1, self.e_total.g2 - if rotation is not None: - self.rotateEllipticity(rotation) if not hasattr(self, "disk_sersic_idx"): self.disk_sersic_idx = 1. if not hasattr(self, "bulge_sersic_idx"): @@ -406,14 +404,6 @@ class Galaxy(MockObject): final = galsim.Convolve(psf, gal) return final - def rotateEllipticity(self, rotation): - if rotation == 1: - self.e1_disk, self.e2_disk, self.e1_bulge, self.e2_bulge, self.e1_total, self.e2_total = -self.e2_disk, self.e1_disk, -self.e2_bulge, self.e1_bulge, -self.e2_total, self.e1_total - if rotation == 2: - self.e1_disk, self.e2_disk, self.e1_bulge, self.e2_bulge, self.e1_total, self.e2_total = -self.e1_disk, -self.e2_disk, -self.e1_bulge, -self.e2_bulge, -self.e1_total, -self.e2_total - if rotation == 3: - self.e1_disk, self.e2_disk, self.e1_bulge, self.e2_bulge, self.e1_total, self.e2_total = self.e2_disk, -self.e1_disk, self.e2_bulge, -self.e1_bulge, self.e2_total, -self.e1_total - def drawObject(self, img, final, noise_level=0.0, flux=None, filt=None, tel=None, exptime=150.): """ Override the method in parent class Need to constrain the size of image stamp for extended objects diff --git a/config/config_50sqdeg.yaml b/config/config_50sqdeg.yaml index 1a2b8554a45f1331223fd315da2757d7b0392cf2..c0f4e7ffc4889323cb35726e64871bb6082d6005 100644 --- a/config/config_50sqdeg.yaml +++ b/config/config_50sqdeg.yaml @@ -11,7 +11,7 @@ # OK to pass either way or both, as long as they are consistent work_dir: "/share/home/fangyuedong/csst-simulation/workplace/" data_dir: "/share/simudata/CSSOSDataProductsSims/data/" -run_name: "50sqdeg_test" +run_name: "rotate_0" # Whether to use MPI run_option: @@ -48,7 +48,7 @@ catalog_options: star_only: NO # Only simulate galaxies? - galaxy_only: NO + galaxy_only: YES # rotate galaxy ellipticity rotateEll: 0. # [degree] @@ -163,20 +163,20 @@ ins_effects: add_dark: ON # Whether to add dark noise add_readout: ON # Whether to add read-out (Gaussian) noise add_bias: ON # Whether to add bias-level to images - bias_16channel: OFF # Whether to add different biases for 16 channels - gain_16channel: OFF # Whether to make different gains for 16 channels - shutter_effect: OFF # Whether to add shutter effect - flat_fielding: OFF # Whether to add flat-fielding effect - prnu_effect: OFF # Whether to add PRNU effect - non_linear: OFF # Whether to add non-linearity - cosmic_ray: OFF # Whether to add cosmic-ray - cray_differ: OFF # Whether to generate different cosmic ray maps CAL and MS output - cte_trail: OFF # Whether to simulate CTE trails - saturbloom: OFF # Whether to simulate Saturation & Blooming - add_badcolumns: OFF # Whether to add bad columns - add_hotpixels: OFF # Whether to add hot pixels - add_deadpixels: OFF # Whether to add dead(dark) pixels - bright_fatter: OFF # Whether to simulate Brighter-Fatter (also diffusion) effect + bias_16channel: ON # Whether to add different biases for 16 channels + gain_16channel: ON # Whether to make different gains for 16 channels + shutter_effect: ON # Whether to add shutter effect + flat_fielding: ON # Whether to add flat-fielding effect + prnu_effect: ON # Whether to add PRNU effect + non_linear: ON # Whether to add non-linearity + cosmic_ray: ON # Whether to add cosmic-ray + cray_differ: ON # Whether to generate different cosmic ray maps CAL and MS output + cte_trail: ON # Whether to simulate CTE trails + saturbloom: ON # Whether to simulate Saturation & Blooming + add_badcolumns: ON # Whether to add bad columns + add_hotpixels: ON # Whether to add hot pixels + add_deadpixels: ON # Whether to add dead(dark) pixels + bright_fatter: ON # Whether to simulate Brighter-Fatter (also diffusion) effect # Values: # default values have been defined individually for each chip in: diff --git a/config/config_C6.yaml b/config/config_C6.yaml index 42f979cddddf0b15c44ef25bc1f9377fff18e652..c130e59aee1b6bfa299f5ce6d2d5807bd86eff46 100644 --- a/config/config_C6.yaml +++ b/config/config_C6.yaml @@ -11,12 +11,11 @@ # OK to pass either way or both, as long as they are consistent work_dir: "/share/home/fangyuedong/csst-simulation/workplace/" data_dir: "/share/simudata/CSSOSDataProductsSims/data/" -run_name: "C6_test" -run_name: "C6_test" +run_name: "profile_C6" # Whether to use MPI run_option: - use_mpi: YES + use_mpi: NO # NOTE: "n_threads" paramters is currently not used in the backend # simulation codes. It should be implemented later in the web frontend # in order to config the number of threads to request from NAOC cluster @@ -95,14 +94,13 @@ obs_setting: # - give a list of indexes of pointings: [ip_1, ip_2...] # - run all pointings: null # Note: only valid when a pointing list is specified - run_pointings: [0,1,2,3,4] + run_pointings: [0] # Run specific chip(s): # - give a list of indexes of chips: [ip_1, ip_2...] # - run all chips: null # Note: for all pointings - run_chips: null - run_chips: null + run_chips: [8] # Whether to enable astrometric modeling enable_astrometric_model: True diff --git a/config/config_C6_test_wcs.yaml b/config/config_C6_test_wcs.yaml index 77319724594472467ba222aac182d0878fd04bb4..9aff707ca4ccbf14956897c3ee6dd53c0728e209 100644 --- a/config/config_C6_test_wcs.yaml +++ b/config/config_C6_test_wcs.yaml @@ -11,7 +11,7 @@ # OK to pass either way or both, as long as they are consistent work_dir: "/share/home/fangyuedong/csst-simulation/workplace/" data_dir: "/share/simudata/CSSOSDataProductsSims/data/" -run_name: "wcs_test_fd_shear" +run_name: "fd_shear_g2m" # Whether to use MPI run_option: @@ -100,10 +100,13 @@ obs_setting: # - give a list of indexes of chips: [ip_1, ip_2...] # - run all chips: null # Note: for all pointings - run_chips: null + run_chips: [9] # Whether to enable astrometric modeling - enable_astrometric_model: True + enable_astrometric_model: False + + # Whether to enable straylight model + enable_straylight_model: False # Cut by saturation magnitude in which band? cut_in_band: "z" diff --git a/config/test_fd_C6.yaml b/config/test_fd_C6.yaml index 6f85d4eedc91004a666d0437fee60a3254c831f5..3ecc3feb6c06d6e5f36614d8855a40568939f8e1 100644 --- a/config/test_fd_C6.yaml +++ b/config/test_fd_C6.yaml @@ -9,9 +9,9 @@ # Base diretories and naming setup # 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: "/share/home/fangyuedong/sim_v2/csst-simulation/workplace/" +work_dir: "/share/home/fangyuedong/csst-simulation/workplace/" data_dir: "/share/simudata/CSSOSDataProductsSims/data/" -run_name: "fd_test_C6_phi_0" +run_name: "fd_shear_g2m" # Whether to use MPI run_option: @@ -105,6 +105,9 @@ obs_setting: # Whether to enable astrometric modeling enable_astrometric_model: True + # Whether to enable straylight model + enable_straylight_model: False + # Cut by saturation magnitude in which band? cut_in_band: "z" @@ -154,21 +157,21 @@ ins_effects: # switches # Note: bias_16channel, gain_16channel, and shutter_effect # is currently not applicable to "FGS" observations - field_dist: ON # Whether to add field distortions - add_back: NO # Whether to add sky background - add_dark: NO # Whether to add dark noise + field_dist: YES # Whether to add field distortions + add_back: YES # Whether to add sky background + add_dark: YES # Whether to add dark noise add_readout: NO # Whether to add read-out (Gaussian) noise - add_bias: ON # Whether to add bias-level to images + add_bias: YES # Whether to add bias-level to images bias_16channel: NO # Whether to add different biases for 16 channels gain_16channel: NO # Whether to make different gains for 16 channels shutter_effect: NO # Whether to add shutter effect - flat_fielding: ON # Whether to add flat-fielding effect + flat_fielding: YES # Whether to add flat-fielding effect prnu_effect: NO # Whether to add PRNU effect non_linear: NO # Whether to add non-linearity cosmic_ray: NO # Whether to add cosmic-ray cray_differ: NO # Whether to generate different cosmic ray maps CAL and MS output cte_trail: NO # Whether to simulate CTE trails - saturbloom: ON # Whether to simulate Saturation & Blooming + saturbloom: NO # Whether to simulate Saturation & Blooming add_badcolumns: NO # Whether to add bad columns add_hotpixels: NO # Whether to add hot pixels add_deadpixels: NO # Whether to add dead(dark) pixels diff --git a/run_C6.pbs b/run_C6.pbs index 6447207188224701c54ab76a2c472cfe1176afc1..4d4da6e734b114519e93df4147d881a555473325 100755 --- a/run_C6.pbs +++ b/run_C6.pbs @@ -8,13 +8,16 @@ cd $PBS_O_WORKDIR -NP=60 -hostfile=wcl-2 +NP=96 +hostfile=wcl-1,wcl-2 date mpirun --oversubscribe -H $hostfile -np $NP python /share/home/fangyuedong/csst-simulation/run_sim.py \ - --config_file config_C6.yaml \ - --catalog C6_Catalog \ + --config_file config_50sqdeg.yaml \ + --catalog C6_50sqdeg \ -c /share/home/fangyuedong/csst-simulation/config + # --config_file config_C6.yaml \ + # --catalog C6_Catalog \ + # -c /share/home/fangyuedong/csst-simulation/config