import json import os import shutil chip_filename = 'chip_definition.json' # chip_list = {} # chip_id = "39" # chip_dict= { # "chip_name": "FGS3-D1", # "pix_size": 7.5e-3, # [mm] # "pix_scale": 0.0555, # [arcsec/pix] # "npix_x": 11264, # "npix_y": 7680, # "x_cen": -273.35, # [mm] # "y_cen": 211.36, # [mm] # "rotate_angle": 90. # [deg] # } # chip_list[chip_id] = chip_dict def get_chip_row_col_main_fp(chip_id): rowID = ((chip_id - 1) % 5) + 1 colID = 6 - ((chip_id - 1) // 5) return rowID, colID def get_chip_center_main_fp(chip_id, pixel_size=1e-2): row, col = get_chip_row_col_main_fp(chip_id) npix_x = 9216 npix_y = 9232 gx1, gx2 = (534, 1309) gy = 898 nchip_x = 6 nchip_y = 5 xrem = 2*(col - 1) - (nchip_x - 1) xcen = (npix_x//2 + gx1//2) * xrem if chip_id >= 26 or chip_id == 21: xcen = (npix_x//2 + gx1//2) * xrem - (gx2-gx1) if chip_id <= 5 or chip_id == 10: xcen = (npix_x//2 + gx1//2) * xrem + (gx2-gx1) # ylim of a given CCD chip yrem = (row - 1) - nchip_y // 2 ycen = (npix_y + gy) * yrem return xcen * pixel_size, ycen * pixel_size def create_chip_dict_main_fp(chip_id, pixel_size=1e-2): filter_list = ["GV", "GI", "y", "z", "y", "GI", "GU", "r", "u", "NUV", "i", "GV", "GU", "g", "NUV", "NUV", "g", "GU", "GV", "i", "NUV", "u", "r", "GU", "GI", "y", "z", "y", "GI", "GV"] chip_label_list = [3,3,3,1,1,1,3,2,2,1,1,1,4,2,3,2,1,1,4,2,4,1,1,2,4,2,2,4,2,2] chip_id_list = [26, 21, 16, 11, 6, 1, 27, 22, 17, 12, 7, 2, 28, 23, 18, 13, 8, 3, 29, 24, 19, 14, 9, 4, 30, 25, 20, 15, 10, 5] npix_x = 9216 npix_y = 9232 idx = chip_id_list.index(chip_id) chip_name = filter_list[idx] + "-" + str(chip_label_list[idx]) xcen, ycen = get_chip_center_main_fp(chip_id, pixel_size) row, col = get_chip_row_col_main_fp(chip_id) rotate_angle = 0. if filter_list[idx] in ['GU', 'GV', 'GI']: rotate_angle = 1. if col > 2: rotate_angle = -1. * rotate_angle chip_dict = { "chip_name": chip_name, "pix_size": 1e-2, # [mm] "pix_scale": 0.074, # [arcsec/pix] "npix_x": npix_x, "npix_y": npix_y, "x_cen": xcen, # [mm] "y_cen": ycen, # [mm] "rotate_angle": rotate_angle, # [deg] "n_psf_samples": 900, "dark_exptime": 300, "flat_exptime": 150, "readout_time": 40, "df_strength": 2.3, "bias_level": 500, "gain": 1.1, "full_well": 90000 } return chip_dict def set_fgs_chips(filepath): with open(filepath, "r") as f: data = json.load(f) for i in range(12): chip_id = str(31 + i) data[chip_id]["dark_exptime"] = 300. data[chip_id]["falt_exptime"] = 150. data[chip_id]["readout_time"] = 0.01 data[chip_id]["df_strength"] = 2.3 data[chip_id]["bias_level"] = 2000. data[chip_id]["gain"] = 1. data[chip_id]["full_well"] = 90000 with open(filepath, "w") as f: json.dump(data, f, indent=4) def add_main_fp(filepath): for i in range(30): chip_id = i + 1 chip_dict = create_chip_dict_main_fp(chip_id) add_dict_to_json(filepath, str(chip_id), chip_dict) def add_dict_to_json(filepath, key, value): with open(filepath, 'r') as f: data = json.load(f) data[key] = value with open(filepath, "w") as f: json.dump(data, f, indent=4) if __name__=="__main__": src = "../ObservationSim/Instrument/data/ccd/chip_definition.json" shutil.copy(src, chip_filename) add_main_fp(chip_filename) set_fgs_chips(chip_filename)