Commit 90a73995 authored by Fang Yuedong's avatar Fang Yuedong
Browse files

add option to save cosmic ray image

parent b3048b0d
......@@ -53,32 +53,34 @@ def getChipSLSConf(chipID):
if chipID == 30: confFile = ['CSST_GI8.conf', 'CSST_GI7.conf']
return confFile
def generateHeader(chip, ra_cen, dec_cen, img_rot, im_type, pointing_ID, exptime=150., project_cycle=6, run_counter=0, timestamp = 1621915200):
datetime_obs = datetime.utcfromtimestamp(timestamp)
date_obs = datetime_obs.strftime("%y%m%d")
time_obs = datetime_obs.strftime("%H%M%S")
def generateHeader(chip, pointing, img_type=None, img_type_code=None, project_cycle='9', run_counter='1'):
if (img_type is None) or (img_type_code is None):
img_type = pointing.pointing_type
img_type_code = pointing.pointing_type_code
h_prim = generatePrimaryHeader(
xlen=chip.npix_x,
ylen=chip.npix_y,
pointNum = str(pointing_ID),
ra=ra_cen,
dec=dec_cen,
pointing_id = pointing.obs_id,
pointing_type_code = img_type_code,
ra=pointing.ra,
dec=pointing.dec,
pixel_scale=chip.pix_scale,
date=date_obs,
time_obs=time_obs,
im_type = im_type,
exptime=exptime,
time_pt = pointing.timestamp,
exptime=pointing.exp_time,
im_type=img_type,
sat_pos=[pointing.sat_x, pointing.sat_y, pointing.sat_z],
sat_vel=[pointing.sat_vx, pointing.sat_vy, pointing.sat_vz],
project_cycle=project_cycle,
run_counter=run_counter,
chip_name=str(chip.chipID).rjust(2, '0')
)
chip_name=str(chip.chipID).rjust(2, '0'))
h_ext = generateExtensionHeader(
chip=chip,
xlen=chip.npix_x,
ylen=chip.npix_y,
ra=ra_cen,
dec=dec_cen,
pa=img_rot.deg,
ra=pointing.ra,
dec=pointing.dec,
pa=pointing.img_pa.deg,
gain=chip.gain,
readout=chip.read_noise,
dark=chip.dark_noise,
......@@ -87,24 +89,22 @@ 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='SCIE',
timestamp = timestamp,
exptime = exptime,
readoutTime = chip.readout_time)
extName=img_type,
timestamp=pointing.timestamp,
exptime=pointing.exp_time,
readoutTime=chip.readout_time,
t_shutter_open=pointing.t_shutter_open,
t_shutter_close=pointing.t_shutter_close)
return h_prim, h_ext
def outputCal(chip, img, ra_cen, dec_cen, img_rot, im_type, pointing_ID, output_dir, exptime=150., project_cycle=6, run_counter=0, timestamp = 1621915200):
def output_fits_image(chip, pointing, img, output_dir, img_type=None, img_type_code=None, project_cycle='9', run_counter='1'):
h_prim, h_ext = generateHeader(
chip=chip,
ra_cen=ra_cen,
dec_cen=dec_cen,
img_rot=img_rot,
im_type=im_type,
pointing_ID=pointing_ID,
exptime=exptime,
pointing=pointing,
img_type=img_type,
img_type_code=img_type_code,
project_cycle=project_cycle,
run_counter=run_counter,
timestamp=timestamp)
run_counter=run_counter)
hdu1 = fits.PrimaryHDU(header=h_prim)
hdu1.add_checksum()
hdu1.header.comments['CHECKSUM'] = 'HDU checksum'
......
......@@ -14,5 +14,17 @@ def add_cosmic_rays(self, chip, filt, tel, pointing, catalog, obs_param):
chip=chip,
exptime=exptime,
seed=self.overall_config["random_seeds"]["seed_CR"]+pointing.id*30+chip.chipID)
# [TODO] output cosmic ray image
# Save cosmic ray image
if (obs_param) and ("save_cosmic_img" in obs_param) and (obs_param["save_cosmic_img"] is not None):
if obs_param["save_cosmic_img"]:
chip_utils.output_fits_image(
chip=chip,
pointing=pointing,
img=crmap_gsimg,
output_dir=self.chip_output.subdir,
img_type='CRS',
img_type_code=pointing.pointing_type_code,
project_cycle=self.overall_config["project_cycle"],
run_counter=self.overall_config["run_counter"]
)
return chip, filt, tel, pointing
\ No newline at end of file
......@@ -48,6 +48,7 @@ call_sequence:
# [Optional]: exposure time of the pointing will be used as default.
# Set it here is you want to override the default
# exptime: 150. # [s]
save_cosmic_img: YES # # Whether to export cosmic ray image
# Add Poission noise and dark current
poisson_and_dark:
# [Optional]: exposure time of the pointing will be used as default.
......
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