Commit 0697a198 authored by Fang Yuedong's avatar Fang Yuedong
Browse files

v0 for testing

parent e1458fd3
......@@ -14,13 +14,13 @@ class ChipOutput(object):
self.ra_cen = ra_cen
self.dec_cen = dec_cen
else:
self.ra_cen = config["ra_center"]
self.dec_cen = config["dec_center"]
self.ra_cen = config["obs_setting"]["ra_center"]
self.dec_cen = config["obs_setting"]["dec_center"]
exp_name = imgKey0 + "_%s_%s.fits"
self.chipLabel = focal_plane.getChipLabel(chip.chipID)
self.img_name = prefix + exp_name%(self.chipLabel, filt.filter_type)
# self.cat_name = self.img_name[:-5] + ".cat"
self.cat_name = 'MSC_' + config["date_obs"] + config["time_obs"] + "_" + str(pointing_ID).rjust(7, '0') + "_" + self.chipLabel.rjust(2,'0') + ".cat"
self.cat_name = 'MSC_' + config["obs_setting"]["date_obs"] + config["obs_setting"]["time_obs"] + "_" + str(pointing_ID).rjust(7, '0') + "_" + self.chipLabel.rjust(2,'0') + ".cat"
self.subdir = subdir
# hdr1 = "#ID ID_chip filter xImage yImage ra dec z mag flag SNR "
......
......@@ -2,7 +2,7 @@ import galsim
import os
from astropy.time import Time as asTime
def ConfigDir(cat_dir=None, work_dir=None, data_dir=None, config_file_path=None):
def ConfigDir(config, work_dir=None, data_dir=None):
path_dict = {}
# Working directory
if work_dir == None:
......@@ -11,48 +11,35 @@ def ConfigDir(cat_dir=None, work_dir=None, data_dir=None, config_file_path=None)
else:
path_dict["work_dir"] = work_dir
# Configuration file
if config_file_path is not None:
path_dict["config_file"] = config_file_path
else:
path_dict["config_file"] = os.path.join(path_dict["work_dir"], "ObservationSim.cfg")
# Output directories
# path_dict["output_fig_dir"] = os.path.join(path_dict["work_dir"], "figure/")
# if not os.path.exists(path_dict["output_fig_dir"]):
# os.system("mkdir %s"%path_dict["output_fig_dir"])
# path_dict["output_cat_dir"] = os.path.join(path_dict["work_dir"], "scat/")
# if not os.path.exists(path_dict["output_cat_dir"]):
# os.system("mkdir %s"%path_dict["output_cat_dir"])
# path_dict["output_img_dir"] = os.path.join(path_dict["work_dir"], "simg/")
# if not os.path.exists(path_dict["output_img_dir"]):
# os.system("mkdir %s"%path_dict["output_img_dir"])
# Data directory
if data_dir == None:
# Assume all input datasets are in the work directory
path_dict["data_dir"] =os.path.join(path_dict["work_dir"], "data/")
else:
path_dict["data_dir"] = data_dir
# Data sub-catalogs
# Object catalog direcotry
# path_dict["cat_dir"] = os.path.join(path_dict["data_dir"], "catalog_points_7degree2/", cat_dir)
path_dict["cat_dir"] = os.path.join(path_dict["data_dir"], "Catalog_20210126")
path_dict["cat_dir"] = os.path.join(path_dict["data_dir"], config["input_path"]["cat_dir"])
# PSF data directory
path_dict["psf_dir"] = os.path.join(path_dict["data_dir"], "csstPSFdata/CSSOS_psf_20210108/CSST_psf_ciomp_2p5um_cycle3_ccr90_proc")
path_dict["psf_dir"] = os.path.join(path_dict["data_dir"], config["psf_setting"]["psf_dir"])
# SED catalog directory
# TODO: SED_dir is deprecated
path_dict["SED_dir"] = os.path.join(path_dict["data_dir"], "imageSims/Catalog/SEDObject")
path_dict["template_dir"] = path_dict["data_dir"] + "Templates/"
# path_dict["template_dir"] = path_dict["data_dir"] + "Templates/"
# path_dict["template_dir"] = os.path.join(path_dict["data_dir"], config["SED_templates_path"]["galaxy_SED"])
# Directories/files for instrument parameters, e.g. efficiency curves.
path_dict["filter_dir"] = os.path.join(path_dict["data_dir"], "Filters")
path_dict["ccd_dir"] = os.path.join(path_dict["data_dir"], "Filter_CCD_Mirror/ccd")
path_dict["mirror_file"] = os.path.join(path_dict["data_dir"], "Filter_CCD_Mirror/mirror_ccdnote.txt")
path_dict["filter_dir"] = os.path.join(path_dict["data_dir"], config["Efficiency_curve_path"]["filter_eff"])
path_dict["ccd_dir"] = os.path.join(path_dict["data_dir"], config["Efficiency_curve_path"]["ccd_eff"])
path_dict["mirror_file"] = os.path.join(path_dict["data_dir"], config["Efficiency_curve_path"]["mirror_eff"])
# Cosmic-ray data directory:
path_dict["CRdata_dir"] = os.path.join(path_dict["data_dir"], "CRdata")
path_dict["CRdata_dir"] = os.path.join(path_dict["data_dir"], config["CR_data_path"])
path_dict["sky_file"] = os.path.join(path_dict["data_dir"], config["sky_data_path"])
# Slitless spectroscopy realted
path_dict["sls_dir"] = os.path.join(path_dict["data_dir"], "CONF/")
path_dict["normalize_dir"] = os.path.join(path_dict["data_dir"], "normalize_filter/")
path_dict["sls_dir"] = os.path.join(path_dict["data_dir"], config["SLS_path"]["SLS_conf"])
path_dict["normalize_dir"] = os.path.join(path_dict["data_dir"], config["SLS_path"]["SLS_norm"])
return path_dict
......
This diff is collapsed.
......@@ -669,7 +669,7 @@ def produceCR_Map(xLen, yLen, exTime, cr_pixelRatio, gain, attachedSizes, seed=2
CRmap[sly, slx] += crMatrix_n[oky,:][:,okx]
return CRmap.astype(np.int32);
return CRmap.astype(np.int32), cr_event_size
def ShutterEffectArr(GSImage, t_shutter=1.3, dist_bearing=735, dt=1E-3):
......
import numpy as np
import os
vc_A = 2.99792458e+18 # speed of light: A/s
vc_m = 2.99792458e+8 # speed of light: m/s
h_Plank = 6.626196e-27 # Plank constant: erg s
VC_A = 2.99792458e+18 # speed of light: A/s
VC_M = 2.99792458e+8 # speed of light: m/s
H_PLANK = 6.626196e-27 # Plank constant: erg s
def photonEnergy(lambd):
""" The energy of photon at a given wavelength
......@@ -13,6 +13,6 @@ def photonEnergy(lambd):
Return:
eph: energy of photon in unit of erg
"""
nu = vc_A / lambd
eph = h_Plank * nu
nu = VC_A / lambd
eph = H_PLANK * nu
return eph
\ No newline at end of file
......@@ -11,32 +11,43 @@ from ._util import seds, sed_assign, extAv
from astropy.table import Table
from astropy.coordinates import spherical_to_cartesian
nside = 128
NSIDE = 128
class Catalog(object):
def __init__(self, config, chip, cat_dir, sed_dir, pRa, pDec, rotation=None, template_dir=None):
def __init__(self, config, chip, cat_dir=None, pRa=None, pDec=None, sed_dir=None, rotation=None):
if cat_dir is not None:
self.cat_dir = cat_dir
else:
self.cat_dir = os.path.join(config["data_dir"], config["input_path"]["cat_dir"])
self.sed_dir = sed_dir
self.chip = chip
self.template_dir = template_dir
self.seed_Av = config["seed_Av"]
self.seed_Av = config["random_seeds"]["seed_Av"]
if pRa is not None:
self.pRa = float('{:8.4f}'.format(pRa))
if pDec is not None:
self.pDec = float('{:8.4f}'.format(pDec))
# 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'
# star_file = 'MMW_Cluster_D20_10_healpix.hdf5'
star_file = 'MMW_Cluster_D20_healpix_21.hdf5'
galaxy_file = 'galaxyCats_r_10.0_healpix.hdf5'
star_SED_file = 'SpecLib.hdf5'
self.star_path = os.path.join(cat_dir, star_file)
self.galaxy_path = os.path.join(cat_dir, galaxy_file)
self.star_SED_path = os.path.join(cat_dir, star_SED_file)
self.rotation = rotation
self._load_SED_lib_gals()
if "star_cat" in config["input_path"]:
star_file = config["input_path"]["star_cat"]
star_SED_file = config["SED_templates_path"]["star_SED"]
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._load_SED_lib_star()
if "galaxy_cat" in config["input_path"]:
galaxy_file = config["input_path"]["galaxy_cat"]
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._load_SED_lib_gals()
if "rotateEll" in config["shear_setting"]:
self.rotation = float(int(config["shear_setting"]["rotateEll"]/45.))
else:
self.rotation = 0.
# self._load_SED_info()
self._get_healpix_list()
self._load()
......@@ -48,20 +59,20 @@ class Catalog(object):
ra = np.deg2rad(np.array([ra_min, ra_max, ra_max, ra_min]))
dec = np.deg2rad(np.array([dec_max, dec_max, dec_min, dec_min]))
# phi, theta = ra, np.pi/2. - dec
# vertices_pix = np.unique(hp.ang2pix(nside, theta, phi))
# vertices_pix = np.unique(hp.ang2pix(NSIDE, theta, phi))
# print(vertices_pix)
vertices = spherical_to_cartesian(1., dec, ra)
self.pix_list = hp.query_polygon(nside, np.array(vertices).T, inclusive=True)
self.pix_list = hp.query_polygon(NSIDE, np.array(vertices).T, inclusive=True)
print("HEALPix List: ", self.pix_list)
def _load_SED_lib_star(self):
self.tempSED_star = h5.File(self.star_SED_path,'r')
def _load_SED_lib_gals(self):
tempdir_gal = os.path.join(self.template_dir, "Galaxy/")
# tempdir_gal = os.path.join(self.template_dir, "Galaxy/")
# tempdir_star = os.path.join(self.template_dir, "PicklesStars/")
self.tempSed_gal, self.tempRed_gal = seds("galaxy.list", seddir=tempdir_gal)
# self.tempSed_star, self.tempRed_star = seds("star.list", seddir=tempdir_star)
self.tempSed_gal, self.tempRed_gal = seds("galaxy.list", seddir=self.galaxy_SED_path)
def _load_SED_info(self):
sed_info_file = os.path.join(self.sed_dir, "sed.info")
......
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