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