Loading ObservationSim/Config/ChipOutput.py +1 −3 Original line number Diff line number Diff line Loading @@ -60,7 +60,7 @@ class ChipOutput(object): self.hdr += additional_column_names def create_output_file(self): if self.pointing_type == 'SCI': if self.pointing_type == 'SCIE': self.cat = open(os.path.join(self.subdir, self.cat_name), "w") self.logger.info("Creating catalog file %s ...\n"%(os.path.join(self.subdir, self.cat_name))) if not self.hdr.endswith("\n"): Loading @@ -68,8 +68,6 @@ class ChipOutput(object): self.cat.write(self.hdr) def cat_add_obj(self, obj, pos_img, pos_shear): # ximg = pos_img.x - self.chip.bound.xmin + 1.0 # yimg = pos_img.y - self.chip.bound.ymin + 1.0 # self.logger.info('-------------debug-----------------') # self.logger.info('from global',ximg, yimg) ximg = obj.real_pos.x + 1.0 Loading ObservationSim/Config/Config.py +1 −1 Original line number Diff line number Diff line Loading @@ -19,7 +19,7 @@ def config_dir(config, work_dir=None, data_dir=None): path_dict["data_dir"] = data_dir # PSF data directory if config["psf_setting"]["psf_model"] == "Interp": path_dict["psf_dir"] = os.path.join(path_dict["data_dir"], config["psf_setting"]["psf_dir"]) path_dict["psf_pho_dir"] = os.path.join(path_dict["data_dir"], config["psf_setting"]["psf_pho_dir"]) path_dict["psf_sls_dir"] = os.path.join(path_dict["data_dir"], config["psf_setting"]["psf_sls_dir"]) return path_dict Loading ObservationSim/Config/Pointing.py +2 −1 Original line number Diff line number Diff line Loading @@ -71,12 +71,13 @@ class Pointing(object): self.survey_field_type = "DEEP" # Load the configuration file for this particular pointing # [TODO] self.obs_config_file = "/share/home/fangyuedong/20231211/csst-simulation/config/obs_config_SCI_WIDE_phot.yaml" with open(self.obs_config_file, "r") as stream: try: self.obs_param = yaml.safe_load(stream) except yaml.YAMLError as exc: print(exc) self.pointing_type = self.obs_config_file["obs_type"] self.pointing_type = self.obs_param["obs_type"] else: self.timestamp = t ObservationSim/Instrument/Chip/Chip.py +23 −31 Original line number Diff line number Diff line Loading @@ -57,10 +57,8 @@ class Chip(FocalPlane): for key in chip_dict: setattr(self, key, chip_dict[key]) if self.filter_type == "FGS": if ("field_dist" in config) and (config["ins_effects"]["field_dist"]) == False: self.fdModel = None else: if self.filter_type == "FGS": fgs_name = self.chip_name[0:4] try: with pkg_resources.files('ObservationSim.Instrument.data.field_distortion').joinpath("FieldDistModelGlobal_pr4_%s.pickle"%(fgs_name.lower())) as field_distortion: Loading @@ -72,9 +70,6 @@ class Chip(FocalPlane): self.fdModel = pickle.load(f) else: # Get the corresponding field distortion model if ("field_dist" in config) and (config["ins_effects"]["field_dist"] == False): self.fdModel = None else: try: with pkg_resources.files('ObservationSim.Instrument.data.field_distortion').joinpath("FieldDistModel_v2.0.pickle") as field_distortion: with open(field_distortion, "rb") as f: Loading Loading @@ -117,10 +112,7 @@ class Chip(FocalPlane): self.effCurve = self._getChipEffCurve(self.filter_type) self._getCRdata() # Define the sensor model if "bright_fatter" in config["ins_effects"] and config["ins_effects"]["bright_fatter"] == True and self.survey_type == "photometric": self.sensor = galsim.SiliconSensor(strength=self.df_strength, treering_func=treering_func) else: # # Define the sensor model self.sensor = galsim.Sensor() self.flat_cube = None # for spectroscopic flat field cube simulation Loading @@ -132,9 +124,9 @@ class Chip(FocalPlane): self.rotate_angle = 0. self.overscan = 1000 # Override default values for key in ["gain", "bias_level, dark_exptime", "flat_exptime", "readout_time", "full_well", "read_noise", "dark_noise", "overscan"]: if key in config["ins_effects"]: setattr(self, key, config["ins_effects"][key]) # for key in ["gain", "bias_level, dark_exptime", "flat_exptime", "readout_time", "full_well", "read_noise", "dark_noise", "overscan"]: # if key in config["ins_effects"]: # setattr(self, key, config["ins_effects"][key]) def _getChipRowCol(self): self.rowID, self.colID = self.getChipRowCol(self.chipID) Loading ObservationSim/MockObject/Galaxy.py +13 −15 Original line number Diff line number Diff line import numpy as np import galsim import os, sys import astropy.constants as cons from astropy.table import Table from scipy import interpolate from ObservationSim.MockObject._util import eObs, integrate_sed_bandpass, getNormFactorForSpecWithABMAG, getObservedSED, getABMAG,convolveGaussXorders from ObservationSim.MockObject._util import eObs, integrate_sed_bandpass, getNormFactorForSpecWithABMAG from ObservationSim.MockObject.SpecDisperser import SpecDisperser from ObservationSim.MockObject.MockObject import MockObject Loading Loading @@ -64,6 +61,11 @@ class Galaxy(MockObject): bulge_shape = galsim.Shear(g1=self.e1_bulge, g2=self.e2_bulge) bulge = bulge.shear(bulge_shape) if self.bfrac == 0: gal = disk elif self.bfrac == 1: gal = bulge else: gal = self.bfrac * bulge + (1.0 - self.bfrac) * disk gal = gal.withFlux(nphotons) if fd_shear is not None: Loading Loading @@ -155,9 +157,13 @@ class Galaxy(MockObject): # Get PSF model psf, pos_shear = psf_model.get_PSF(chip=chip, pos_img=pos_img, bandpass=bandpass, folding_threshold=folding_threshold) if self.bfrac == 0: gal_temp = disk elif self.bfrac == 1: gal_temp = bulge else: gal_temp = self.bfrac * bulge + (1.0 - self.bfrac) * disk gal_temp = gal_temp.shear(gal_shear) gal_temp = gal_temp.withFlux(nphotons) if not big_galaxy: # Not apply PSF for very big galaxy gal_temp = galsim.Convolve(psf, gal_temp) Loading @@ -172,14 +178,6 @@ class Galaxy(MockObject): # kfrac = np.random.random()*(1.0 - self.bfrac) # gal = self.bfrac * bulge + (1.0 - self.bfrac - kfrac) * disk + kfrac * knots # # [C6 TEST] # print('xmax = %d, ymax = %d '%(xmax, ymax)) # # Output memory usage # snapshot = tracemalloc.take_snapshot() # top_stats = snapshot.statistics('lineno') # for stat in top_stats[:10]: # print(stat) # stamp = gal.drawImage(wcs=chip_wcs_local, method='phot', offset=offset, save_photons=True) stamp = gal.drawImage(wcs=chip_wcs_local, offset=offset) if np.sum(np.isnan(stamp.array)) > 0: Loading Loading
ObservationSim/Config/ChipOutput.py +1 −3 Original line number Diff line number Diff line Loading @@ -60,7 +60,7 @@ class ChipOutput(object): self.hdr += additional_column_names def create_output_file(self): if self.pointing_type == 'SCI': if self.pointing_type == 'SCIE': self.cat = open(os.path.join(self.subdir, self.cat_name), "w") self.logger.info("Creating catalog file %s ...\n"%(os.path.join(self.subdir, self.cat_name))) if not self.hdr.endswith("\n"): Loading @@ -68,8 +68,6 @@ class ChipOutput(object): self.cat.write(self.hdr) def cat_add_obj(self, obj, pos_img, pos_shear): # ximg = pos_img.x - self.chip.bound.xmin + 1.0 # yimg = pos_img.y - self.chip.bound.ymin + 1.0 # self.logger.info('-------------debug-----------------') # self.logger.info('from global',ximg, yimg) ximg = obj.real_pos.x + 1.0 Loading
ObservationSim/Config/Config.py +1 −1 Original line number Diff line number Diff line Loading @@ -19,7 +19,7 @@ def config_dir(config, work_dir=None, data_dir=None): path_dict["data_dir"] = data_dir # PSF data directory if config["psf_setting"]["psf_model"] == "Interp": path_dict["psf_dir"] = os.path.join(path_dict["data_dir"], config["psf_setting"]["psf_dir"]) path_dict["psf_pho_dir"] = os.path.join(path_dict["data_dir"], config["psf_setting"]["psf_pho_dir"]) path_dict["psf_sls_dir"] = os.path.join(path_dict["data_dir"], config["psf_setting"]["psf_sls_dir"]) return path_dict Loading
ObservationSim/Config/Pointing.py +2 −1 Original line number Diff line number Diff line Loading @@ -71,12 +71,13 @@ class Pointing(object): self.survey_field_type = "DEEP" # Load the configuration file for this particular pointing # [TODO] self.obs_config_file = "/share/home/fangyuedong/20231211/csst-simulation/config/obs_config_SCI_WIDE_phot.yaml" with open(self.obs_config_file, "r") as stream: try: self.obs_param = yaml.safe_load(stream) except yaml.YAMLError as exc: print(exc) self.pointing_type = self.obs_config_file["obs_type"] self.pointing_type = self.obs_param["obs_type"] else: self.timestamp = t
ObservationSim/Instrument/Chip/Chip.py +23 −31 Original line number Diff line number Diff line Loading @@ -57,10 +57,8 @@ class Chip(FocalPlane): for key in chip_dict: setattr(self, key, chip_dict[key]) if self.filter_type == "FGS": if ("field_dist" in config) and (config["ins_effects"]["field_dist"]) == False: self.fdModel = None else: if self.filter_type == "FGS": fgs_name = self.chip_name[0:4] try: with pkg_resources.files('ObservationSim.Instrument.data.field_distortion').joinpath("FieldDistModelGlobal_pr4_%s.pickle"%(fgs_name.lower())) as field_distortion: Loading @@ -72,9 +70,6 @@ class Chip(FocalPlane): self.fdModel = pickle.load(f) else: # Get the corresponding field distortion model if ("field_dist" in config) and (config["ins_effects"]["field_dist"] == False): self.fdModel = None else: try: with pkg_resources.files('ObservationSim.Instrument.data.field_distortion').joinpath("FieldDistModel_v2.0.pickle") as field_distortion: with open(field_distortion, "rb") as f: Loading Loading @@ -117,10 +112,7 @@ class Chip(FocalPlane): self.effCurve = self._getChipEffCurve(self.filter_type) self._getCRdata() # Define the sensor model if "bright_fatter" in config["ins_effects"] and config["ins_effects"]["bright_fatter"] == True and self.survey_type == "photometric": self.sensor = galsim.SiliconSensor(strength=self.df_strength, treering_func=treering_func) else: # # Define the sensor model self.sensor = galsim.Sensor() self.flat_cube = None # for spectroscopic flat field cube simulation Loading @@ -132,9 +124,9 @@ class Chip(FocalPlane): self.rotate_angle = 0. self.overscan = 1000 # Override default values for key in ["gain", "bias_level, dark_exptime", "flat_exptime", "readout_time", "full_well", "read_noise", "dark_noise", "overscan"]: if key in config["ins_effects"]: setattr(self, key, config["ins_effects"][key]) # for key in ["gain", "bias_level, dark_exptime", "flat_exptime", "readout_time", "full_well", "read_noise", "dark_noise", "overscan"]: # if key in config["ins_effects"]: # setattr(self, key, config["ins_effects"][key]) def _getChipRowCol(self): self.rowID, self.colID = self.getChipRowCol(self.chipID) Loading
ObservationSim/MockObject/Galaxy.py +13 −15 Original line number Diff line number Diff line import numpy as np import galsim import os, sys import astropy.constants as cons from astropy.table import Table from scipy import interpolate from ObservationSim.MockObject._util import eObs, integrate_sed_bandpass, getNormFactorForSpecWithABMAG, getObservedSED, getABMAG,convolveGaussXorders from ObservationSim.MockObject._util import eObs, integrate_sed_bandpass, getNormFactorForSpecWithABMAG from ObservationSim.MockObject.SpecDisperser import SpecDisperser from ObservationSim.MockObject.MockObject import MockObject Loading Loading @@ -64,6 +61,11 @@ class Galaxy(MockObject): bulge_shape = galsim.Shear(g1=self.e1_bulge, g2=self.e2_bulge) bulge = bulge.shear(bulge_shape) if self.bfrac == 0: gal = disk elif self.bfrac == 1: gal = bulge else: gal = self.bfrac * bulge + (1.0 - self.bfrac) * disk gal = gal.withFlux(nphotons) if fd_shear is not None: Loading Loading @@ -155,9 +157,13 @@ class Galaxy(MockObject): # Get PSF model psf, pos_shear = psf_model.get_PSF(chip=chip, pos_img=pos_img, bandpass=bandpass, folding_threshold=folding_threshold) if self.bfrac == 0: gal_temp = disk elif self.bfrac == 1: gal_temp = bulge else: gal_temp = self.bfrac * bulge + (1.0 - self.bfrac) * disk gal_temp = gal_temp.shear(gal_shear) gal_temp = gal_temp.withFlux(nphotons) if not big_galaxy: # Not apply PSF for very big galaxy gal_temp = galsim.Convolve(psf, gal_temp) Loading @@ -172,14 +178,6 @@ class Galaxy(MockObject): # kfrac = np.random.random()*(1.0 - self.bfrac) # gal = self.bfrac * bulge + (1.0 - self.bfrac - kfrac) * disk + kfrac * knots # # [C6 TEST] # print('xmax = %d, ymax = %d '%(xmax, ymax)) # # Output memory usage # snapshot = tracemalloc.take_snapshot() # top_stats = snapshot.statistics('lineno') # for stat in top_stats[:10]: # print(stat) # stamp = gal.drawImage(wcs=chip_wcs_local, method='phot', offset=offset, save_photons=True) stamp = gal.drawImage(wcs=chip_wcs_local, offset=offset) if np.sum(np.isnan(stamp.array)) > 0: Loading