Commit 00a96bcb authored by Zhang Xin's avatar Zhang Xin
Browse files

add model: straylight; fix header file consistent with doc:KSC-00-JK-0001-02.01.pdf

parent 81589f9d
Loading
Loading
Loading
Loading
+60 −40
Original line number Diff line number Diff line
@@ -18,6 +18,10 @@ from astropy.wcs.utils import fit_wcs_from_points
from astropy.time import Time
from astropy import wcs

from datetime import datetime
# import socket
import platform

def chara2digit(char):
    """ Function to judge and convert characters to digitals

@@ -381,7 +385,7 @@ def generatePrimaryHeader(xlen = 9216, ylen = 9232, pointNum = '1', ra = 60, dec
    h_prim['EXPTIME'] = exptime
    
    # Define file types
    file_type = {'SCI':'SCIE', 'BIAS':'BIAS', 'DARK':'DARK', 'FLAT':'FLAT', 'CRS':'cosmic_ray', 'CRD':'cosmic_ray','CALS':'CALS','CALF':'CALF'}
    file_type = {'SCI':'SCIE', 'BIAS':'BIAS', 'DARK':'DARK', 'FLAT':'FLAT', 'CRS':'cosmic_ray', 'CRD':'CRD','CALS':'CALS','CALF':'CALF'}
    h_prim['FILETYPE'] = file_type[im_type]

    co = coord.SkyCoord(ra, dec, unit='deg')
@@ -417,7 +421,7 @@ def generatePrimaryHeader(xlen = 9216, ylen = 9232, pointNum = '1', ra = 60, dec
    file_end_time = end_time_str[0:4] + end_time_str[5:7]+end_time_str[8:10] + end_time_str[11:13] + end_time_str[14:16] + end_time_str[17:19]
    # h_prim['FILENAME'] = 'CSST_MSC_MS_' + im_type + '_' + file_start_time + '_' + file_end_time + '_' + OBS_id + '_' + CCDID[
    #     k - 1].rjust(2, '0') + '_L0_V01'
    h_prim['FILENAME'] = 'CSST_MSC_MS_' + im_type + '_' + file_start_time + '_' + file_end_time + '_' + OBS_id + '_' + chip_name + '_L0_V01'
    h_prim['FILENAME'] = 'CSST_MSC_MS_' + file_type[im_type] + '_' + file_start_time + '_' + file_end_time + '_' + OBS_id + '_' + chip_name + '_L0_V01'


    h_prim['POSI0_X'] = sat_pos[0]
@@ -433,12 +437,15 @@ def generatePrimaryHeader(xlen = 9216, ylen = 9232, pointNum = '1', ra = 60, dec
    # Get version of CSSTSim Package
    from pkg_resources import get_distribution
    # h_prim['SIM_VER'] = (get_distribution("CSSTSim").version, "Version of CSST MSC simulation software")
    h_prim['FITSCREA'] = get_distribution("CSSTSim").version
    currentDateAndTime = datetime.now()
    compute_name = platform.node()
    h_prim['FITSCREA'] = get_distribution("CSSTSim").version +'_' + currentDateAndTime.strftime("%Y%m%d") + '_' +compute_name
    h_prim['EPOCH'] = round((Time(h_prim['EXPSTART'], format='mjd', scale='tcb')).jyear, 1)

    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):
                            extName='SCI', 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')
@@ -460,47 +467,60 @@ def generateExtensionHeader(chip, xlen = 9216, ylen = 9232,ra = 60, dec = -40, p
    # h_ext['CCDCHIP'] = CCDID[k - 1].rjust(2, '0')
    # h_ext['CCDLABEL'] = filters[k-1] + '-' + filterID[k-1]
    # h_ext['FILTER'] = filters[k-1]
    h_ext['CCDCHIP'] = chip.chip_name
    h_ext['CCDLABEL'] = chip.filter_type + '-' + str(chip.chipID).rjust(2, '0')
    h_ext['CHIPID'] = str(chip.chipID).rjust(2, '0')
    h_ext['CHIPLAB'] = chip.chip_name
    h_ext['FILTER'] = chip.filter_type
    h_ext['NAXIS1'] = xlen
    h_ext['NAXIS2'] = ylen
    h_ext['EXTNAME'] = extName
    h_ext['GAIN1'] = gain
    h_ext['GAIN2'] = gain
    h_ext['GAIN3'] = gain
    h_ext['GAIN4'] = gain
    h_ext['GAIN5'] = gain
    h_ext['GAIN6'] = gain
    h_ext['GAIN7'] = gain
    h_ext['GAIN8'] = gain
    h_ext['GAIN9'] = gain
    h_ext['GAIN10'] = gain
    h_ext['GAIN11'] = gain
    h_ext['GAIN12'] = gain
    h_ext['GAIN13'] = gain
    h_ext['GAIN14'] = gain
    h_ext['GAIN15'] = gain
    h_ext['GAIN16'] = gain
    h_ext['RDNOIS1'] = readout
    h_ext['RDNOIS2'] = readout
    h_ext['RDNOIS3'] = readout
    h_ext['RDNOIS4'] = readout
    h_ext['RDNOIS5'] = readout
    h_ext['RDNOIS6'] = readout
    h_ext['RDNOIS7'] = readout
    h_ext['RDNOIS8'] = readout
    h_ext['RDNOIS9'] = readout
    h_ext['RDNOIS10'] = readout
    h_ext['RDNOIS11'] = readout
    h_ext['RDNOIS12'] = readout
    h_ext['RDNOIS13'] = readout
    h_ext['RDNOIS14'] = readout
    h_ext['RDNOIS15'] = readout
    h_ext['RDNOIS16'] = readout
    h_ext['GAIN01'] = chip.gain_channel[0]
    h_ext['GAIN02'] = chip.gain_channel[1]
    h_ext['GAIN03'] = chip.gain_channel[2]
    h_ext['GAIN04'] = chip.gain_channel[3]
    h_ext['GAIN05'] = chip.gain_channel[4]
    h_ext['GAIN06'] = chip.gain_channel[5]
    h_ext['GAIN07'] = chip.gain_channel[6]
    h_ext['GAIN08'] = chip.gain_channel[7]
    h_ext['GAIN09'] = chip.gain_channel[8]
    h_ext['GAIN10'] = chip.gain_channel[9]
    h_ext['GAIN11'] = chip.gain_channel[10]
    h_ext['GAIN12'] = chip.gain_channel[11]
    h_ext['GAIN13'] = chip.gain_channel[12]
    h_ext['GAIN14'] = chip.gain_channel[13]
    h_ext['GAIN15'] = chip.gain_channel[14]
    h_ext['GAIN16'] = chip.gain_channel[15]
    h_ext['RON01'] = readout
    h_ext['RON02'] = readout
    h_ext['RON03'] = readout
    h_ext['RON04'] = readout
    h_ext['RON05'] = readout
    h_ext['RON06'] = readout
    h_ext['RON07'] = readout
    h_ext['RON08'] = readout
    h_ext['RON09'] = readout
    h_ext['RON10'] = readout
    h_ext['RON11'] = readout
    h_ext['RON12'] = readout
    h_ext['RON13'] = readout
    h_ext['RON14'] = readout
    h_ext['RON15'] = readout
    h_ext['RON16'] = readout

    h_ext['PIXSCAL1'] = pixel_scale
    h_ext['PIXSCAL2'] = pixel_scale
    h_ext['EXPTIME'] = exptime
    h_ext['DARKTIME'] = exptime + 2

    datetime_obs = datetime.utcfromtimestamp(timestamp)
    tstart = Time(datetime_obs)
    tstart_read = Time(tstart.mjd + exptime / 86400., format="mjd")
    tend_read = Time(tstart.mjd + (exptime + readoutTime) / 86400., format="mjd")
    t_s1 = str(tstart_read.datetime).split()
    h_ext['READT0'] = t_s1[0]+'T'+t_s1[1]
    t_s2 = str(tend_read.datetime).split()
    h_ext['READT1'] = t_s2[0] + 'T' + t_s2[1]



    # h_ext['POS_ANG'] = pa
    header_wcs = WCS_def(xlen=xlen, ylen=ylen, gapy=898.0, gapx1=534, gapx2=1309, ra_ref=ra, dec_ref=dec, pa=pa, pixel_scale=pixel_scale, pixel_size=pixel_size, 
@@ -514,8 +534,8 @@ def generateExtensionHeader(chip, xlen = 9216, ylen = 9232,ra = 60, dec = -40, p
    h_ext['CD1_2'] = header_wcs['CD1_2']
    h_ext['CD2_1'] = header_wcs['CD2_1']
    h_ext['CD2_2'] = header_wcs['CD2_2']
    h_ext['EQUINOX'] = header_wcs['EQUINOX']
    h_ext['WCSDIM'] = header_wcs['WCSDIM']
    # h_ext['EQUINOX'] = header_wcs['EQUINOX']
    # h_ext['WCSDIM'] = header_wcs['WCSDIM']
    h_ext['CTYPE1'] = header_wcs['CTYPE1']
    h_ext['CTYPE2'] = header_wcs['CTYPE2']

+1 −1

File changed.

Preview size limit exceeded, changes collapsed.

+1 −1
Original line number Diff line number Diff line
SIMPLE  =                    T / conforms to FITS standard                      BITPIX  =                    8 / array data type                                NAXIS   =                    0 / number of array dimensions                     EXTEND  =                    T                                                  NEXTEND =                    1                                                  GROUPS  =                    F                                                  DATE    = '2021-03-04T09:30:00'/ date this file was written                     FILENAME= 'MSC_MS_210304093000_100000000_06_raw' / file name                    FILETYPE= 'SCI     '           / observation type                               TELESCOP= 'CSST    '           / telescope used to acquire data                 INSTRUME= 'MSC     '           / instrument used to acquire data                RADECSYS= 'ICRS    '           / frame of reference of coordinates              EQUINOX =               2000.0 /                                                FITSCREA= 'C6'                 / FITS create software version                   COMMENT ==================================================================      COMMENT Object information                                                      COMMENT ==================================================================      OBJECT  = '00000000'           / object name                                    TARGET  = '+000000000000'      / target name (hhmmss+ddmmss)                    OBSID   = '00000000'           / observation ID                                 OBJ_RA  =            62.228226 / R.A. of the object (degrees)                   OBJ_DEC =           -42.316932 / declination of the object (degrees)            COMMENT ==================================================================      COMMENT Telescope information                                                   COMMENT ==================================================================      REFFRAME= 'CSSTGSC-1.0'        / guide star catalog version                     DATE-OBS= '2021-03-04T09:30:00'/ date of the observation (yyyy-mm-dd hh:mm:ss)  SATESWV = '0001'               / software version in the satellite              EXPSTART=              59130.5 / exposure start time (MJD)                      CABSTART=              59130.5 / (MJD)                                          SUNANGL0=                 50.0 / angle between sun and optical axis at CABSTART MOONANG0=                 30.0 / angle moon and opt axis at CABSTART at CABST   TEL_ALT0=                 20.0 / angle opt axis and the ground-piston at CABST  POS_ANG0=                 20.0 / angle bwt y axis and the North Pole at CABST   POSI0_X =                  0.0 / the orbital position in X at CABSTART          POSI0_Y =                  0.0 / the orbital position in Y at CABSTART          POSI0_Z =                  0.0 / the orbital position in Z at CABSTART          VELO0_X =                  0.0 / the orbital velocity in X at CABSTART          VELO0_Y =                  0.0 / the orbital velocity in Y at CABSTART          VELO0_Z =                  0.0 / the orbital velocity in Z at CABSTART          EULER0_1=                  0.0 / Euler angle 1 at  CABSTART                     EULER0_2=                  0.0 / Euler angle 2 at  CABSTART                     EULER0_3=                  0.0 / Euler angle 3 at  CABSTART                     RA_PNT0 =                  0.0 / RA of the pointing (degrees) at CABSTART       DEC_PNT0=                  0.0 / DEC of the pointing (degrees) at CABSTART      EXPEND  =                  0.0 / exposure end time (MJD)                        CABEND  =                  0.0 / (MJD)                                          SUNANGL1=                 50.0 / angle between sun and optical axis at CABEND   MOONANG1=                 30.0 / angle btw moon and optical axis at CABEND      TEL_ALT1=                 20.0 / angle opt axis and the ground-piston at CAEND  POS_ANG1=                 20.0 / angle bwt y axis and the North Pole at CABEND  POSI1_X =                  0.0 / the orbital position in X at CABEND            POSI1_Y =                  0.0 / the orbital position in Y at CABEND            POSI1_Z =                  0.0 / the orbital position in Z at CABEND            VELO1_X =                  0.0 / The orbital velocity in X at CABEND            VELO1_Y =                  0.0 / The orbital velocity in Y at CABEND            VELO1_Z =                  0.0 / The orbital velocity in Z at CABEND            EULER1_1=                  0.0 / Euler angle 1 at  CABEND                       EULER1_2=                  0.0 / Euler angle 2 at  CABEND                       EULER1_3=                  0.0 / Euler angle 3 at  CABEND                       RA_PNT1 =                  0.0 / RA of the pointing (degrees) at CABEND         DEC_PNT1=                  0.0 / DEC of the pointing (degrees) at CABEND        EXPTIME =                150.0 / exposure duration                              EPOCH   =                 2000 / coordinate epoch                               COMMENT Other information                                                       COMMENT ==================================================================      CHECKSUM= 'abcdefg '           / SHA256 checksum of global headers              END                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                             
SIMPLE  =                    T / conforms to FITS standard                      BITPIX  =                    8 / array data type                                NAXIS   =                    0 / number of array dimensions                     EXTEND  =                    T                                                  NEXTEND =                    1 / number of array dimensions                     GROUPS  =                    F / '   '                                          DATE    = '2021-03-04T09:30:00'/ the date on which this file was written        FILENAME= 'MSC_MS_210304093000_100000000_06_raw' / file name                    FILETYPE= 'SCIE    '           / observation type                               TELESCOP= 'CSST    '           / telescope used to acquire data                 INSTRUME= 'MSC     '           / instrument used to acquire data                RADECSYS= 'ICRS    '           / reference coordinates system                   EQUINOX =               2000.0 /                                                FITSCREA= 'C6'                 / FITS create software version                   COMMENT ==================================================================      COMMENT Object information                                                      COMMENT ==================================================================      OBJECT  = '00000000'           / object name                                    TARGET  = '+000000000000'      / target name (hhmmss+ddmmss)                    OBSID   = '00000000'           / observation ID                                 OBJ_RA  =            62.228226 / R.A. of the object (degrees)                   OBJ_DEC =           -42.316932 / declination of the object (degrees)            COMMENT ==================================================================      COMMENT Telescope information                                                   COMMENT ==================================================================      REFFRAME= 'CSSTGSC-1.0'        / guide star catalog version                     DATE-OBS= '2021-03-04T09:30:00'/ date of the observation (yyyy-mm-dd hh:mm:ss)  SATESWV = '0001'               / software version in the satellite              EXPSTART=              59130.5 / exposure start time (MJD)                      CABSTART=              59130.5 / (MJD)                                          SUNANGL0=                 50.0 / angle between sun and opt axis at CABSTART     MOONANG0=                 30.0 / angle between moon and opt axis at CABSTART    TEL_ALT0=                 20.0 / angle between opt axis and Elimb at CABSTART   POS_ANG0=                 20.0 / angle between y axis and NP at CABSTART        POSI0_X =                  0.0 / the orbital position in X at CABSTART          POSI0_Y =                  0.0 / the orbital position in Y at CABSTART          POSI0_Z =                  0.0 / the orbital position in Z at CABSTART          VELO0_X =                  0.0 / the orbital velocity in X at CABSTART          VELO0_Y =                  0.0 / the orbital velocity in Y at CABSTART          VELO0_Z =                  0.0 / the orbital velocity in Z at CABSTART          EULER0_1=                  0.0 / euler angle 1 at CABSTART                      EULER0_2=                  0.0 / euler angle 2 at CABSTART                      EULER0_3=                  0.0 / euler angle 3 at CABSTART                      RA_PNT0 =                  0.0 / RA of the pointing (degrees) at CABSTART       DEC_PNT0=                  0.0 / DEC of the pointing (degrees) at CABSTART      EXPEND  =                  0.0 / exposure end time (MJD)                        CABEND  =                  0.0 / (MJD)                                          SUNANGL1=                 50.0 / angle between sun and opt axis at CABEND       MOONANG1=                 30.0 / angle between moon and opt axis at CABEND      TEL_ALT1=                 20.0 / angle between opt axis and Elimb at CABEND     POS_ANG1=                 20.0 / angle between y axis and NP at CABEND          POSI1_X =                  0.0 / the orbital position in X at CABEND            POSI1_Y =                  0.0 / the orbital position in Y at CABEND            POSI1_Z =                  0.0 / the orbital position in Z at CABEND            VELO1_X =                  0.0 / the orbital velocity in X at CABEND            VELO1_Y =                  0.0 / the orbital velocity in Y at CABEND            VELO1_Z =                  0.0 / the orbital velocity in Z at CABEND            EULER1_1=                  0.0 / euler angle 1 at CABEND                        EULER1_2=                  0.0 / euler angle 2 at CABEND                        EULER1_3=                  0.0 / euler angle 3 at CABEND                        RA_PNT1 =                  0.0 / RA of the pointing (degrees) at CABEND         DEC_PNT1=                  0.0 / DEC of the pointing (degrees) at CABEND        EXPTIME =                150.0 / exposure duration                              EPOCH   =               2000.0 / coordinate epoch                               COMMENT Other information                                                       COMMENT ==================================================================      CHECKSUM= 'abcdefg '           / HDU checksum updated yyyy-mm-ddTHH:MM:SS       DATASUM = 'abcdefg '           / data unit checksum updated yyyy-mm-ddTHH:MM:SS END                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                             
+7 −1
Original line number Diff line number Diff line
@@ -3,16 +3,18 @@ import galsim
from astropy.time import Time

class Pointing(object):
    def __init__(self, id=0, ra=0., dec=0., img_pa=0., timestamp=1621915200, sat_x=0., sat_y=0., sat_z=0., sat_vx=0., sat_vy=0., sat_vz=0., exp_time=150., pointing_type='MS'):
    def __init__(self, id=0, ra=0., dec=0., img_pa=0., timestamp=1621915200, sat_x=0., sat_y=0., sat_z=0., sun_x=0., sun_y=0., sun_z=0., sat_vx=0., sat_vy=0., sat_vz=0., exp_time=150., pointing_type='MS'):
        self.id = id
        self.ra = ra
        self.dec = dec
        self.img_pa = img_pa * galsim.degrees
        self.timestamp = timestamp
        self.sat_x, self.sat_y, self.sat_z = sat_x, sat_y, sat_z
        self.sun_x, self.sun_y, self.sun_z = sun_x, sun_y, sun_z
        self.sat_vx, self.sat_vy, self.sat_vz = sat_vx, sat_vy, sat_vz
        self.exp_time = exp_time
        self.pointing_type = pointing_type
        self.jdt = 0.

    def read_pointing_columns(self, columns, id=0, t=1621915200, pointing_type='MS'):
        self.id = id
@@ -24,10 +26,14 @@ class Pointing(object):
        if col_len > 5:
            jdt = np.double(columns[5])
            t_temp = Time(jdt, format='jd')
            self.jdt = jdt
            self.timestamp = t_temp.unix
            self.sat_x = float(columns[6])
            self.sat_y = float(columns[7])
            self.sat_z = float(columns[8])
            self.sun_x = float(columns[9])
            self.sun_y = float(columns[10])
            self.sun_z = float(columns[1])
            self.sat_vx = float(columns[15])
            self.sat_vy = float(columns[16])
            self.sat_vz = float(columns[17])
+48 −41

File changed.

Preview size limit exceeded, changes collapsed.

Loading