Commit 633fbbab authored by Fang Yuedong's avatar Fang Yuedong
Browse files

first test

parent 8d77fcd3
......@@ -342,7 +342,7 @@ def WCS_def(xlen = 9216, ylen = 9232, gapy = 898.0, gapx1 = 534, gapx2 = 1309, r
#TODO project_cycle is temporary, is not in header defined, delete in future
def generatePrimaryHeader(xlen = 9216, ylen = 9232, pointNum = '1', ra = 60, dec = -40, pixel_scale = 0.074, date='200930', time_obs='120000', im_type = 'MS', exptime=150., sat_pos = [0.,0.,0.], sat_vel = [0., 0., 0.], project_cycle=6, run_counter=0, chip_name="01"):
def generatePrimaryHeader(xlen = 9216, ylen = 9232, pointNum = '1', ra = 60, dec = -40, pixel_scale = 0.074, date='200930', time_obs='120000', im_type = 'SCIE', exptime=150., sat_pos = [0.,0.,0.], sat_vel = [0., 0., 0.], project_cycle=6, run_counter=0, chip_name="01"):
# array_size1, array_size2, flux, sigma = int(argv[1]), int(argv[2]), 1000.0, 5.0
......@@ -391,7 +391,8 @@ def generatePrimaryHeader(xlen = 9216, ylen = 9232, pointNum = '1', ra = 60, dec
# # Define file types
# file_type = {'SCI':'SCIE', 'BIAS':'BIAS', 'DARK':'DARK', 'FLAT':'FLAT', 'CRS':'CRS', 'CRD':'CRD','CALS':'CALS','CALF':'CALF'}
# h_prim['FILETYPE'] = file_type[im_type]
h_prim['FILETYPE'] = get_file_type(img_type=im_type)
# h_prim['FILETYPE'] = get_file_type(img_type=im_type)
h_prim['FILETYPE'] = im_type
co = coord.SkyCoord(ra, dec, unit='deg')
......@@ -450,7 +451,7 @@ def generatePrimaryHeader(xlen = 9216, ylen = 9232, pointNum = '1', ra = 60, dec
return h_prim
def generateExtensionHeader(chip, xlen = 9216, ylen = 9232,ra = 60, dec = -40, pa = -23.433, gain = 1.0, readout = 5.0, dark = 0.02, saturation=90000, pixel_scale = 0.074, pixel_size=1e-2,
extName='SCI', row_num = None, col_num = None, xcen=None, ycen=None, timestamp = 1621915200,exptime = 150., readoutTime = 40.):
extName='SCIE', row_num = None, col_num = None, xcen=None, ycen=None, timestamp = 1621915200,exptime = 150., readoutTime = 40.):
e_header_fn = os.path.split(os.path.realpath(__file__))[0] + '/extension_header.header'
f = open(os.path.split(os.path.realpath(__file__))[0] + '/filter.lst')
......
import numpy as np
import galsim
import yaml
from astropy.time import Time
import ObservationSim.Instrument._util as _util
......@@ -42,13 +43,13 @@ class Pointing(object):
return max(150., self.exp_time) # [TODO] for FGS
def read_pointing_columns(self, columns, id=0, t=1621915200, pointing_type='SCI'):
def read_pointing_columns(self, columns, id=0, t=1621915200, pointing_type='SCIE'):
self.id = id
col_len = len(columns)
self.ra = float(columns[0])
self.dec = float(columns[1])
self.img_pa = float(columns[4]) * galsim.degrees
self.pointing_type = pointing_type
# self.pointing_type = pointing_type
if col_len > 5:
jdt = np.double(columns[5])
t_temp = Time(jdt, format='jd')
......@@ -68,5 +69,14 @@ class Pointing(object):
# [TODO] Can also define other survey types
if is_deep != -1.0:
self.survey_field_type = "DEEP"
# Load the configuration file for this particular pointing
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"]
else:
self.timestamp = t
def get_obs_id(img_type='SCI', project_cycle=6, run_counter=0, pointing_num=0):
def get_obs_id(img_type='SCIE', project_cycle=6, run_counter=0, pointing_num=0):
# obs_type = {'SCI': '01', 'BIAS': '03', 'DARK': '07', 'FLAT': '11', 'CRS': '98', 'CRD': '99'}
obs_type = {'SCI': '01', 'BIAS': '03', 'DARK': '07', 'FLAT': '11', 'CRS': '98', 'CRD': '99', 'CAL': '01'}
# obs_id = '1'+ obs_type[img_type] + str(int(project_cycle)) + str(int(run_counter)).rjust(2, '0') + str(pointing_num).rjust(5,'0')
obs_type = {'SCIE': '01', 'BIAS': '03', 'DARK': '07', 'FLAT': '11', 'CRS': '98', 'CRD': '99', 'CAL': '01'}
obs_id = '1'+ obs_type[img_type] + str(int(project_cycle)).rjust(2, '0') + str(int(run_counter)) + str(pointing_num).rjust(8,'0')
return obs_id
......
......@@ -87,7 +87,7 @@ def generateHeader(chip, ra_cen, dec_cen, img_rot, im_type, pointing_ID, exptime
pixel_size=chip.pix_size,
xcen=chip.x_cen,
ycen=chip.y_cen,
extName='SCI',
extName='SCIE',
timestamp = timestamp,
exptime = exptime,
readoutTime = chip.readout_time)
......
......@@ -2,17 +2,24 @@ import galsim
import numpy as np
class FocalPlane(object):
def __init__(self, config=None, survey_type='Photometric', bad_chips=None):
def __init__(self, config=None, chip_list=None, survey_type='Photometric', bad_chips=None):
"""Get the focal plane layout
"""
self.nchips = 42
self.ignore_chips = []
if bad_chips == None:
self.bad_chips = []
else:
self.bad_chips = bad_chips
for chip_id in bad_chips:
self.ignore_chips.append(chip_id)
self.ignore_chips = []
if survey_type == 'Photometric':
if chip_list is not None:
for i in range(42):
if not (i+1 in chip_list):
self.ignore_chips.append(i+1)
elif survey_type == 'Photometric':
for i in range(5):
self.ignore_chips.append(i+1)
self.ignore_chips.append(i+26)
......
This diff is collapsed.
This diff is collapsed.
......@@ -96,7 +96,7 @@ def make_run_dirs(work_dir, run_name, pointing_list):
os.makedirs(imgDir, exist_ok=True)
except OSError:
pass
prefix = "MSC_"
# prefix = "MSC_"
# for pointing in pointing_list:
# fname=prefix + str(pointing.id).rjust(7, '0')
# subImgDir = os.path.join(imgDir, fname)
......@@ -107,26 +107,26 @@ def make_run_dirs(work_dir, run_name, pointing_list):
# pass
return imgDir
def imgName(tt=0):
ut = datetime.utcnow()
eye, emo, eda, eho, emi, ese = str(ut.year), str(ut.month), str(ut.day), str(ut.hour), str(ut.minute), str(ut.second)
emse = str(ut.microsecond)
if int(emo)<10: emo = "0%s"%emo
if int(eda)<10: eda = "0%s"%eda
if int(eho)<10: eho = "0%s"%eho
if int(emi)<10: emi = "0%s"%emi
if int(ese)<10: ese = "0%s"%ese
# def imgName(tt=0):
# ut = datetime.utcnow()
# eye, emo, eda, eho, emi, ese = str(ut.year), str(ut.month), str(ut.day), str(ut.hour), str(ut.minute), str(ut.second)
# emse = str(ut.microsecond)
# if int(emo)<10: emo = "0%s"%emo
# if int(eda)<10: eda = "0%s"%eda
# if int(eho)<10: eho = "0%s"%eho
# if int(emi)<10: emi = "0%s"%emi
# if int(ese)<10: ese = "0%s"%ese
if tt==0:
namekey = "CSST%s%s%sT%s%s%s"%(eye,emo,eda,eho,emi,ese)
elif tt==1:
namekey = "%s-%s-%sT%s:%s:%s.%s"%(eye,emo,eda,eho,emi,ese,emse)
elif tt==2:
namekey = "%s%s%s%s%s%s"%(eye,emo,eda,eho,emi,ese)
else:
raise ValueError("!!! Give a right 'tt' value.")
# if tt==0:
# namekey = "CSST%s%s%sT%s%s%s"%(eye,emo,eda,eho,emi,ese)
# elif tt==1:
# namekey = "%s-%s-%sT%s:%s:%s.%s"%(eye,emo,eda,eho,emi,ese,emse)
# elif tt==2:
# namekey = "%s%s%s%s%s%s"%(eye,emo,eda,eho,emi,ese)
# else:
# raise ValueError("!!! Give a right 'tt' value.")
return namekey
# return namekey
def makeSubDir_PointingList(path_dict, config, pointing_ID=0):
imgDir = os.path.join(path_dict["work_dir"], config["run_name"])
......
......@@ -73,9 +73,6 @@ obs_setting:
# Whether to enable astrometric modeling
enable_astrometric_model: True
# Whether to enable straylight model
enable_straylight_model: True
# Cut by saturation magnitude in which band?
cut_in_band: "z"
......
......@@ -11,15 +11,51 @@
# Observation type
obs_type: "SCIE"
# Define simulation sequence
# Define list of chips
run_chips: [6, 7, 8, 9, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 22, 23, 24, 25]
# Define observation sequence
call_sequence:
# Sky background simulation
sky_background:
# Accumulate fluxes from objects
scie_obs:
exptime: 150. # [s]
shutter_effect: YES
flat_fielding: YES
scie_obs:
field_dist: YES
# Accumulate fluxes from sky background
sky_background:
exptime: 150. # [s]
shutter_effect: YES
flat_fielding: YES
enable_straylight_model: True
# Apply PRNU to accumulated photons
PRNU_effect: {}
# Accumulate photons caused by cosmic rays
cosmic_rays: {}
# Add Poission noise and dark current
poisson_and_dark:
add_dark: YES
# Simulate brighter fatter effects
bright_fatter: {}
# Add detector defects: hot/warm pixels, bad columns
detector_defects:
hot_pixels: YES
dead_pixels: YES
bad_columns: YES
# Apply response nonlinearity
nonlinearity: {}
# Apply CCD Saturation & Blooming
blooming: {}
# Run CTE simulation
CTE_effect: {}
# Add prescan and overscan
prescan_overscan: {}
# Add bias
bias:
bias_16channel: YES
# Add readout noise
readout_noise: {}
# Apply gain
gain:
gain_16channel: YES
...
\ No newline at end of file
......@@ -50,10 +50,10 @@ def run_sim():
config['work_dir'] = args.work_dir
# Some default values
if "bias_16channel" not in config["ins_effects"]:
config["ins_effects"]["bias_16channel"] = False
if "gain_16channel" not in config["ins_effects"]:
config["ins_effects"]["gain_16channel"] = False
# if "bias_16channel" not in config["ins_effects"]:
# config["ins_effects"]["bias_16channel"] = False
# if "gain_16channel" not in config["ins_effects"]:
# config["ins_effects"]["gain_16channel"] = False
if "mag_sat_margin" not in config["obs_setting"]:
config["obs_setting"]["mag_sat_margin"] = -2.5
if "mag_lim_margin" not in config["obs_setting"]:
......
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