Commit 8c97ea31 authored by Fang Yuedong's avatar Fang Yuedong
Browse files

Merge branch 'C6_codes' of https://csst-tb.bao.ac.cn/code/csst_sim/csst-simulation into HEAD

parents 832c0004 5f61cfd0
Loading
Loading
Loading
Loading
+71 −27
Original line number Diff line number Diff line
@@ -325,42 +325,52 @@ def generatePrimaryHeader(xlen = 9216, ylen = 9232, pointNum = '1', ra = 60, dec
    h_prim = fits.Header()
    h_prim = fits.Header.fromfile(g_header_fn)

    h_prim['PIXSIZE1'] = xlen
    h_prim['PIXSIZE2'] = ylen

    h_prim['DATE'] = '20'+date[0:2]+'-' + date[2:4]+'-'+date[4:6]
    h_prim['TIME'] = time_obs[0:2]+':'+time_obs[2:4]+':'+time_obs[4:6]
    h_prim['DATE-OBS'] = '20'+date[0:2]+'-' + date[2:4]+'-'+date[4:6]
    h_prim['TIME-OBS'] = time_obs[0:2]+':'+time_obs[2:4]+':'+time_obs[4:6]
    h_prim['DETECTOR'] = 'CHIP'+CCDID[k-1].rjust(2,'0')
    h_prim['RA_OBJ'] = ra
    h_prim['DEC_OBJ'] = dec
    # h_prim['PIXSIZE1'] = xlen
    # h_prim['PIXSIZE2'] = ylen

    h_prim['DATE'] = '20'+date[0:2]+'-' + date[2:4]+'-'+date[4:6] + 'T' + time_obs[0:2]+':'+time_obs[2:4]+':'+time_obs[4:6]
    # h_prim['TIME'] = time_obs[0:2]+':'+time_obs[2:4]+':'+time_obs[4:6]
    h_prim['DATE-OBS'] = '20'+date[0:2]+'-' + date[2:4]+'-'+date[4:6] + 'T' + time_obs[0:2]+':'+time_obs[2:4]+':'+time_obs[4:6]
    # h_prim['TIME-OBS'] = time_obs[0:2]+':'+time_obs[2:4]+':'+time_obs[4:6]
    # h_prim['DETECTOR'] = 'CHIP'+CCDID[k-1].rjust(2,'0')
    h_prim['OBJ_RA'] = ra
    h_prim['OBJ_DEC'] = dec
    h_prim['OBJECT'] = '1'+ str(int(project_cycle)) + pointNum.rjust(7,'0')
    h_prim['OBSID'] = '1'+ str(int(project_cycle)) + pointNum.rjust(7,'0')
    h_prim['TELFOCUS'] = 'f/14'
    # h_prim['TELFOCUS'] = 'f/14'
    h_prim['EXPTIME'] = exptime
    
    # Define file types
    file_type = {'SCI':'sci', 'BIAS':'bias', 'DARK':'dark', 'FLAT':'flat', 'CRS':'cosmic_ray', 'CRD':'cosmic_ray'}
    h_prim['OBSTYPE'] = file_type[im_type]

    co = coord.SkyCoord(ra, dec, unit='deg')
    # co = coord.SkyCoord(ra, dec, unit='deg')
    #
    # ra_hms = format(co.ra.hms.h, '02.0f') + ':' + format(co.ra.hms.m, '02.0f') + ':' + format(co.ra.hms.s, '05.2f')
    # dec_hms = format(co.dec.dms.d, '02.0f') + ':' + format(abs(co.dec.dms.m), '02.0f') + ':' + format(abs(co.dec.dms.s),
    #                                                                                                   '05.2f')
    #
    # h_prim['RA_NOM'] = ra_hms
    # h_prim['DEC_NOM'] = dec_hms

    h_prim['RA_PNT0'] = ra
    h_prim['DEC_PNT0'] = dec
    h_prim['RA_PNT1'] = ra
    h_prim['DEC_PNT1'] = dec

    ra_hms = format(co.ra.hms.h, '02.0f') + ':' + format(co.ra.hms.m, '02.0f') + ':' + format(co.ra.hms.s, '05.2f')
    dec_hms = format(co.dec.dms.d, '02.0f') + ':' + format(abs(co.dec.dms.m), '02.0f') + ':' + format(abs(co.dec.dms.s),
                                                                                                      '05.2f')

    h_prim['RA_NOM'] = ra_hms
    h_prim['DEC_NOM'] = dec_hms
    h_prim['PIXSCAL1'] = psize
    h_prim['PIXSCAL2'] = psize

    ttt = h_prim['DATE'] + 'T' + h_prim['TIME']
    # h_prim['PIXSCAL1'] = psize
    # h_prim['PIXSCAL2'] = psize

    ttt = h_prim['DATE']
    tstart = Time(ttt)
    h_prim['EXPSTART'] = round(tstart.mjd, 5)
    h_prim['CABSTART'] = h_prim['EXPSTART']
    # tend = Time(tstart.cxcsec + h_prim['EXPTIME'], format="cxcsec")
    tend = Time(tstart.mjd + h_prim['EXPTIME']/86400., format="mjd")
    h_prim['EXPEND'] = round(tend.mjd, 5)
    h_prim['CABEND'] = h_prim['EXPEND']

    file_start_time = '20' + date[0:6] + time_obs[0:6]
    end_time_str = str(tend.datetime)
@@ -376,13 +386,13 @@ def generatePrimaryHeader(xlen = 9216, ylen = 9232, pointNum = '1', ra = 60, dec
    h_prim['VELO0_X'] = sat_vel[0]
    h_prim['VELO0_Y'] = sat_vel[1]
    h_prim['VELO0_Z'] = sat_vel[2]
    h_prim['RA_PNT0'] = ra_hms
    h_prim['DEC_PNT0'] = dec_hms
    # h_prim['RA_PNT0'] = ra_hms
    # h_prim['DEC_PNT0'] = dec_hms
    
    # 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['SIM_VER'] = (get_distribution("CSSTSim").version, "Version of CSST MSC simulation software")
    h_prim['FITSCREA'] = get_distribution("CSSTSim").version

    return h_prim

@@ -405,15 +415,49 @@ def generateExtensionHeader(xlen = 9216, ylen = 9232,ra = 60, dec = -40, pa = -2

    h_ext = fits.Header.fromfile(e_header_fn)

    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['NAXIS1'] = xlen
    h_ext['NAXIS2'] = ylen
    h_ext['EXTNAME'] = extName
    h_ext['GAIN1'] = gain
    h_ext['RDNOISE1'] = readout
    h_ext['CCDCHIP'] =  'ccd' + CCDID[k-1].rjust(2,'0')
    h_ext['POS_ANG'] = pa
    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['PIXSCAL1'] = psize
    h_ext['PIXSCAL2'] = psize

    # h_ext['POS_ANG'] = pa
    header_wcs = WCS_def(xlen=xlen, ylen=ylen, gapy=898.0, gapx1=534, gapx2=1309, ra=ra, dec=dec, pa=pa, psize=psize,
                         row_num=row_num, col_num=col_num, filter = h_ext['FILTER'])

+1 −1
Original line number Diff line number Diff line
XTENSION= 'IMAGE   '           / Image extension                                BITPIX  =                   16 / array data type                                NAXIS   =                    2 / number of array dimensions                     NAXIS1  =                 9216 / length of first array axis                     NAXIS2  =                 9232 / length of second array axis                    PCOUNT  =                    0                                                  GCOUNT  =                    1                                                  EXTNAME = 'SCI     '                                                            EXTVER  =                    1                                                  BSCALE  =                    1                                                  BZERO   =                32768                                                  BUNIT   = 'ADU     '                                                            COMMENT ==================================================================      COMMENT CCD chip information                                                    COMMENT ==================================================================      NCHAN   =                   16 / Number of readout channels                     NCHAN1  =                    8 / Number of horizintal channels                  NCHAN2  =                    2 / Number of vertical channels                    DETSIZE = '[1:9216:9232]'      / detector size                                  BIASSEC = '[9216:9217,9232:9234]' / bias section                                CCDCHIP =                    6 / CCD chip ID                                    CCDLABEL= 'y-1     '           / CCD chip label                                 PSCAN1  =                   27 / horizontal prescan width                       PSCAN2  =                    8 / vertical prescan height                        OSCAN1  =                   16 / horizontal overscan width                      OSCAN2  =                    8 / vertical overscan height                       FILTER  = 'y       '           / filter name                                    COMMENT ==================================================================      COMMENT WORLD COORDINATE SYSTEM AND RELATED PARAMETERS                          COMMENT ==================================================================      WCSDIM  =                    2 / Number of World Coordinate System axes         CRPIX1  =             -10017.0 / Coordinate reference pixel of x                CRPIX2  =              24876.0 / Coordinate reference pixel of y                CRVAL1  =            62.228226 / Coordinate reference value of x                CRVAL2  =           -42.316932 / Coordinate reference value of y                CTYPE1  = 'RA---TAN'           / the coordinate type                            CTYPE2  = 'DEC--TAN'           / the coordinate type                            CD1_1   = 1.88602083707394E-05 / partial of first axis coordinate of x          CD2_1   = -8.1745583617600E-06 / partial of first axis coordinate of y          CD1_2   = 8.17455836176000E-06 / partial of second axis coordinate of x         CD2_2   = 1.88602083707394E-05 / partial of second axis coordinate of y         POS_ANG =                 30.0 / Positon angle of detector array                COMMENT ==================================================================      COMMENT Readout information                                                     COMMENT ==================================================================      GAIN1   =                  1.1 / CCD gain                                       RDNOISE1=                  5.0 / read noise                                     READTIME=                 40.0 / read time (sec)                                RDSPEED =                 10.0 / read speed (in MHz)                            CHIPTEMP=                173.0 / chip temperature (in K)                        COMMENT ==================================================================      COMMENT Other information                                                       COMMENT ==================================================================      CHECKSUM= '''abcde'''          / SHA256 checksum of global headers              END                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                             
XTENSION= 'IMAGE   '           / extension type                                 BITPIX  =                   16 / bits per data value                            NAXIS   =                    2 / number of data axes                            NAXIS1  =                 9216 / length of first array axis                     NAXIS2  =                 9232 / length of second array axis                    PCOUNT  =                    0                                                  GCOUNT  =                    1                                                  EXTNAME = 'SCI     '                                                            EXTVER  =                    1                                                  BSCALE  =                    1                                                  BZERO   =                32768                                                  BUNIT   = 'ADU     '            / physical unit of array values                 COMMENT ==================================================================      COMMENT Detector information                                                    COMMENT ==================================================================      DETECOR = 'CCD'                 / detector name                                 DETTEMP1=                   173 / detector temperature at EXPSTART              DETTEMP2=                   173 / detector temperature at EXPEND                DETTEMP3=                   173 / detector temperature when readout is finished DETSIZE = '9560x9264'           / detector size                                 DATASEC = '9216x9232'           / data size                                     PIXSCAL1=                 0.074 / pixel scale for axis 1                        PIXSCAL2=                 0.074 / pixel scale for axis 2                        PIXSIZE1=                    10 / pixel size  for axis 1                        PIXSIZE2=                    10 / pixel size  for axis 1                        COMMENT ==================================================================      COMMENT CCD chip information                                                    COMMENT ==================================================================      CCDCHIP =                     8 / CCD chip ID                                   CCDLABEL= 'y-1'                 / CCD chip label                                FILTER  = 'y'                   / filter name                                   NCHAN   =                    16 / Number of readout channels                    NCHAN1  =                     8 / Number of horizintal channels                 NCHAN2  =                     2 / Number of vertical channels                   PSCAN1  =                    27 / horizontal prescan width, per readout channel PSCAN2  =                     8 / horizontal prescan width, per readout channel OSCAN1  =                    16 / horizontal overscan width,per readout channel OSCAN2  =                    16 / horizontal overscan width,per readout channel COMMENT ==================================================================      COMMENT WORLD COORDINATE SYSTEM AND RELATED PARAMETERS                          COMMENT ==================================================================      WCSAXES =                    2 / Number of World Coordinate System axes         CRPIX1  =             -10017.0 / x-coordinate of reference pixel                CRPIX2  =              24876.0 / y-coordinate of reference pixel                CRVAL1  =            62.228226 / first axis value at reference pixel            CRVAL2  =           -42.316932 / second axis value at reference pixel           CTYPE1  = 'RA---TAN'           / the coordinate type for the first axis         CTYPE2  = 'DEC--TAN'           / the coordinate type for the second axis        CD1_1   = 1.88602083707394E-05 / partial of first axis coordinate w.r.t. x      CD2_1   = -8.1745583617600E-06 / partial of first axis coordinate w.r.t. x      CD1_2   = 8.17455836176000E-06 / partial of second axis coordinate w.r.t. x     CD2_2   = 1.88602083707394E-05 / partial of second axis coordinate w.r.t. x     OTHERS  =                 ''   /                                                COMMENT ==================================================================      COMMENT Readout information                                                     COMMENT ==================================================================      GAIN1   =                  1.1 / CCD gain (channel 1)                           GAIN2   =                  1.1 / CCD gain (channel 2)                           GAIN3   =                  1.1 / CCD gain (channel 3)                           GAIN4   =                  1.1 / CCD gain (channel 4)                           GAIN5   =                  1.1 / CCD gain (channel 5)                           GAIN6   =                  1.1 / CCD gain (channel 6)                           GAIN7   =                  1.1 / CCD gain (channel 7)                           GAIN8   =                  1.1 / CCD gain (channel 8)                           GAIN9   =                  1.1 / CCD gain (channel 9)                           GAIN10  =                  1.1 / CCD gain (channel 10)                          GAIN11  =                  1.1 / CCD gain (channel 11)                          GAIN12  =                  1.1 / CCD gain (channel 12)                          GAIN13  =                  1.1 / CCD gain (channel 13)                          GAIN14  =                  1.1 / CCD gain (channel 14)                          GAIN15  =                  1.1 / CCD gain (channel 15)                          GAIN16  =                  1.1 / CCD gain (channel 16)                          RDNOIS1 =                  5.0 / read noise  (channel 1)                        RDNOIS2 =                  5.0 / read noise  (channel 2)                        RDNOIS3 =                  5.0 / read noise  (channel 3)                        RDNOIS4 =                  5.0 / read noise  (channel 4)                        RDNOIS5 =                  5.0 / read noise  (channel 5)                        RDNOIS6 =                  5.0 / read noise  (channel 6)                        RDNOIS7 =                  5.0 / read noise  (channel 7)                        RDNOIS8 =                  5.0 / read noise  (channel 8)                        RDNOIS9 =                  5.0 / read noise  (channel 9)                        RDNOIS10=                  5.0 / read noise  (channel 10)                       RDNOIS11=                  5.0 / read noise  (channel 11)                       RDNOIS12=                  5.0 / read noise  (channel 12)                       RDNOIS13=                  5.0 / read noise  (channel 13)                       RDNOIS14=                  5.0 / read noise  (channel 14)                       RDNOIS15=                  5.0 / read noise  (channel 15)                       RDNOIS16=                  5.0 / read noise  (channel 16)                       RDSPEED =                 10.0 / read speed (in MHz)                            COMMENT ==================================================================      COMMENT Shutter information                                                     COMMENT ==================================================================      SHUTSTAT=                    T / shutter status                                 SHTOPEN0=                  0.0 / shutter open time (begin)                      SHTOPEN1=                  0.0 / shutter open time (end)                        SHTCLOS0=                  0.0 / shutter close time (begin)                     SHTCLOS1=                  0.0 / shutter close time (end)                       COMMENT ==================================================================      COMMENT LED information                                                         COMMENT ==================================================================      LEDSTAT1= '0000000000000000000000000000' / main LED status                      LEDEXP1 =                  0.0 / main LED flash time (s)                        LEDSTAT2= '0000000000000000000000000000' / backup LED status                    LEDEXP2 =                  0.0 / backup LED flash time (s)                      LEDTEMPA=                173.0 / LED temperature (main LED in K)                LEDTEMPB=                173.0 / LED temperature (backup LED in K)              COMMENT ==================================================================      COMMENT Other information                                                       COMMENT ==================================================================      CHECKSUM= '''abcde'''          / SHA256 checksum of global headers              END                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                          
+1 −1

File changed.

Preview size limit exceeded, changes collapsed.

+3 −1
Original line number Diff line number Diff line
@@ -314,7 +314,7 @@ class Galaxy(MockObject):

            origin_star = [y_nominal - (starImg.center.y - starImg.ymin),
                           x_nominal - (starImg.center.x - starImg.xmin)]

            starImg.setOrigin(0, 0)
            gal_origin = [origin_star[0], origin_star[1]]
            gal_end = [origin_star[0] + starImg.array.shape[0] - 1, origin_star[1] + starImg.array.shape[1] - 1]

@@ -324,6 +324,7 @@ class Galaxy(MockObject):

                subImg_p1 = starImg.array[:, 0:subSlitPos]
                star_p1 = galsim.Image(subImg_p1)
                star_p1.setOrigin(0, 0)
                origin_p1 = origin_star
                xcenter_p1 = min(x_nominal,grating_split_pos_chip-1) - 0
                ycenter_p1 = y_nominal-0
@@ -340,6 +341,7 @@ class Galaxy(MockObject):

                subImg_p2 = starImg.array[:, subSlitPos+1:starImg.array.shape[1]]
                star_p2 = galsim.Image(subImg_p2)
                star_p2.setOrigin(0, 0)
                origin_p2 = [origin_star[0], grating_split_pos_chip]
                xcenter_p2 = max(x_nominal, grating_split_pos_chip - 1) - 0
                ycenter_p2 = y_nominal - 0
+3 −1
Original line number Diff line number Diff line
@@ -358,7 +358,7 @@ class MockObject(object):

            origin_star = [y_nominal - (starImg.center.y - starImg.ymin),
                           x_nominal - (starImg.center.x - starImg.xmin)]

            starImg.setOrigin(0,0)
            gal_origin = [origin_star[0], origin_star[1]]
            gal_end = [origin_star[0] + starImg.array.shape[0] - 1, origin_star[1] + starImg.array.shape[1] - 1]

@@ -369,6 +369,7 @@ class MockObject(object):
                subImg_p1 = starImg.array[:, 0:subSlitPos]
                star_p1 = galsim.Image(subImg_p1)
                origin_p1 = origin_star
                star_p1.setOrigin(0,0)
                xcenter_p1 = min(x_nominal, grating_split_pos_chip - 1) - 0
                ycenter_p1 = y_nominal - 0

@@ -384,6 +385,7 @@ class MockObject(object):

                subImg_p2 = starImg.array[:, subSlitPos + 1:starImg.array.shape[1]]
                star_p2 = galsim.Image(subImg_p2)
                star_p2.setOrigin(0, 0)
                origin_p2 = [origin_star[0], grating_split_pos_chip]
                xcenter_p2 = max(x_nominal, grating_split_pos_chip - 1) - 0
                ycenter_p2 = y_nominal - 0