Commit 7e936912 authored by Fang Yuedong's avatar Fang Yuedong
Browse files

add galaxy rotation function to C6_50sqdeg.py by

rotate e1, e2.
remove the rotation parameter in Galaxy class (not used before).
modeling of ellpiticity rotation should be implemented in Catalog.py
parent 14bdd76b
......@@ -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)
......
......@@ -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.,
......
......@@ -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.,
......
......@@ -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.,
......
......@@ -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)
......
......@@ -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))
......
......@@ -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.,
......
......@@ -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.,
......
......@@ -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
......
......@@ -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:
......
......@@ -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
......
......@@ -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"
......
......@@ -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
......
......@@ -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
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