Commit e1d1ebda authored by Fang Yuedong's avatar Fang Yuedong
Browse files

fix bug with cat_out_only option

parent b0fc6421
...@@ -239,6 +239,7 @@ class Observation(object): ...@@ -239,6 +239,7 @@ class Observation(object):
try: try:
if self.config["run_option"]["out_cat_only"]: if self.config["run_option"]["out_cat_only"]:
isUpdated = True isUpdated = True
pos_shear = 0.
elif chip.survey_type == "photometric" and not self.config["run_option"]["out_cat_only"]: elif chip.survey_type == "photometric" and not self.config["run_option"]["out_cat_only"]:
isUpdated, pos_shear = obj.drawObj_multiband( isUpdated, pos_shear = obj.drawObj_multiband(
tel=self.tel, tel=self.tel,
...@@ -289,65 +290,67 @@ class Observation(object): ...@@ -289,65 +290,67 @@ class Observation(object):
# Detector Effects # Detector Effects
# =========================================================== # ===========================================================
# whether to output zero, dark, flat calibration images. # whether to output zero, dark, flat calibration images.
chip.img = chip.addEffects(
config=self.config, if not self.config["run_option"]["out_cat_only"]:
img=chip.img, chip.img = chip.addEffects(
chip_output=chip_output, config=self.config,
filt=filt, img=chip.img,
ra_cen=pointing.ra, chip_output=chip_output,
dec_cen=pointing.dec, filt=filt,
img_rot=pointing.img_pa, ra_cen=pointing.ra,
pointing_ID=pointing.id, dec_cen=pointing.dec,
timestamp_obs=pointing.timestamp, img_rot=pointing.img_pa,
pointing_type=pointing.pointing_type, pointing_ID=pointing.id,
sky_map=sky_map, tel = self.tel, timestamp_obs=pointing.timestamp,
logger=chip_output.logger) pointing_type=pointing.pointing_type,
sky_map=sky_map, tel = self.tel,
if pointing.pointing_type == 'MS': logger=chip_output.logger)
datetime_obs = datetime.fromtimestamp(pointing.timestamp)
date_obs = datetime_obs.strftime("%y%m%d") if pointing.pointing_type == 'MS':
time_obs = datetime_obs.strftime("%H%M%S") datetime_obs = datetime.fromtimestamp(pointing.timestamp)
h_prim = generatePrimaryHeader( date_obs = datetime_obs.strftime("%y%m%d")
xlen=chip.npix_x, time_obs = datetime_obs.strftime("%H%M%S")
ylen=chip.npix_y, h_prim = generatePrimaryHeader(
pointNum = str(pointing.id), xlen=chip.npix_x,
ra=pointing.ra, ylen=chip.npix_y,
dec=pointing.dec, pointNum = str(pointing.id),
psize=chip.pix_scale, ra=pointing.ra,
row_num=chip.rowID, dec=pointing.dec,
col_num=chip.colID, psize=chip.pix_scale,
date=date_obs, row_num=chip.rowID,
time_obs=time_obs, col_num=chip.colID,
exptime=pointing.exp_time, date=date_obs,
im_type='SCI', time_obs=time_obs,
sat_pos=[pointing.sat_x, pointing.sat_y, pointing.sat_z], exptime=pointing.exp_time,
sat_vel=[pointing.sat_vx, pointing.sat_vy, pointing.sat_vz]) im_type='SCI',
h_ext = generateExtensionHeader( sat_pos=[pointing.sat_x, pointing.sat_y, pointing.sat_z],
xlen=chip.npix_x, sat_vel=[pointing.sat_vx, pointing.sat_vy, pointing.sat_vz])
ylen=chip.npix_y, h_ext = generateExtensionHeader(
ra=pointing.ra, xlen=chip.npix_x,
dec=pointing.dec, ylen=chip.npix_y,
pa=pointing.img_pa.deg, ra=pointing.ra,
gain=chip.gain, dec=pointing.dec,
readout=chip.read_noise, pa=pointing.img_pa.deg,
dark=chip.dark_noise, gain=chip.gain,
saturation=90000, readout=chip.read_noise,
psize=chip.pix_scale, dark=chip.dark_noise,
row_num=chip.rowID, saturation=90000,
col_num=chip.colID, psize=chip.pix_scale,
extName='raw') row_num=chip.rowID,
chip.img = galsim.Image(chip.img.array, dtype=np.uint16) col_num=chip.colID,
hdu1 = fits.PrimaryHDU(header=h_prim) extName='raw')
hdu2 = fits.ImageHDU(chip.img.array, header=h_ext) chip.img = galsim.Image(chip.img.array, dtype=np.uint16)
hdu1 = fits.HDUList([hdu1, hdu2]) hdu1 = fits.PrimaryHDU(header=h_prim)
fname = os.path.join(chip_output.subdir, h_prim['FILENAME'] + '.fits') hdu2 = fits.ImageHDU(chip.img.array, header=h_ext)
hdu1.writeto(fname, output_verify='ignore', overwrite=True) hdu1 = fits.HDUList([hdu1, hdu2])
# print("# objects that are too bright %d out of %d"%(bright_obj, self.nobj)) fname = os.path.join(chip_output.subdir, h_prim['FILENAME'] + '.fits')
# print("# objects that are too dim %d out of %d"%(dim_obj, self.nobj)) hdu1.writeto(fname, output_verify='ignore', overwrite=True)
# print("# objects that are missed %d out of %d"%(missed_obj, self.nobj)) # print("# objects that are too bright %d out of %d"%(bright_obj, self.nobj))
chip_output.logger.info("# objects that are too bright %d out of %d"%(bright_obj, self.nobj)) # print("# objects that are too dim %d out of %d"%(dim_obj, self.nobj))
chip_output.logger.info("# objects that are too dim %d out of %d"%(dim_obj, self.nobj)) # print("# objects that are missed %d out of %d"%(missed_obj, self.nobj))
chip_output.logger.info("# objects that are missed %d out of %d"%(missed_obj, self.nobj)) chip_output.logger.info("# objects that are too bright %d out of %d"%(bright_obj, self.nobj))
chip_output.logger.info("# objects that are too dim %d out of %d"%(dim_obj, self.nobj))
chip_output.logger.info("# objects that are missed %d out of %d"%(missed_obj, self.nobj))
del chip.img del chip.img
# print("check running:2: pointing-{:} chip-{:} pid-{:} memory-{:6.2}GB".format(pointing.id, chip.chipID, os.getpid(), (psutil.Process(os.getpid()).memory_info().rss / 1024 / 1024 / 1024) ), flush=True) # print("check running:2: pointing-{:} chip-{:} pid-{:} memory-{:6.2}GB".format(pointing.id, chip.chipID, os.getpid(), (psutil.Process(os.getpid()).memory_info().rss / 1024 / 1024 / 1024) ), flush=True)
......
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