Commit 0db9a690 authored by Yan Zhaojun's avatar Yan Zhaojun
Browse files

Replace csst_ifs_sim.py

parent ee015212
Loading
Loading
Loading
Loading
+39 −22
Original line number Diff line number Diff line
@@ -512,6 +512,9 @@ class cosmicrays():
        cr_n = int(
            295 * self.information['exptime'] / 565. * coveringFraction / 1.4)

        if cr_n < 1:
            cr_n = 1

        covering = 0.0

        while covering < coveringFraction:
@@ -3309,14 +3312,20 @@ class IFSsimulator():
        ofd_b.header['DATE'] = (
            data_time[:21], 'written date (yyyy-mm-ddThh:mm:ss.s)')
        ofd_b.header['FILENAME'] = (filename_b[:68], '')
        ofd_b.header['FILETYPE'] = (self.source[:12],   'observation type')
        # ofd_b.header['FILETYPE'] = (self.source[:12],   'observation type')
        ofd_b.header['TELESCOP'] = ('CSST',   'telescope name')
        ofd_b.header['INSTRUME'] = ('IFS',   'instrument name')

        ofd_b.header['OBSID'] = (str(obsid),   'observation ID')

        ofd_b.header['OBSTYPE'] = (self.source[:12],   'observation type')
        ofd_b.header['DATASET'] = ('csst-ifs-C11-V1',   'dataset')

        ofd_b.header['RADECSYS'] = (
            'ICRS',   'coordinate system of the object')
        ofd_b.header['EQUINOX'] = (float(2000.0),   '')
        ofd_b.header['FITSSWV'] = (
            __version__, 'FITS creating software version')
            '4.2.1', 'FITS creating software version')
        # ########   Object information  #############
        if self.source == 'SCI' or self.source == 'COMP':
            ofd_b.header['OBJECT'] = (
@@ -3324,7 +3333,7 @@ class IFSsimulator():
            ofd_b.header['TARGET'] = (
                (self.information['target']),     'target name (hhmmss.s+ddmmss)')

            ofd_b.header['OBSID'] = (str(obsid),   'observation ID')
            # ofd_b.header['OBSID'] = (str(obsid),   'observation ID')

            ofd_b.header['RA_OBJ'] = (np.float64(
                self.information['ra_obj']),   'object RA (deg)')
@@ -3335,7 +3344,7 @@ class IFSsimulator():
            ofd_b.header['OBJECT'] = (self.source,   ' object name')
            ofd_b.header['TARGET'] = (0,   'target name (hhmmss.s+ddmmss)')

            ofd_b.header['OBSID'] = (str(obsid),   'observation ID')
            # ofd_b.header['OBSID'] = (str(obsid),   'observation ID')

            ofd_b.header['RA_OBJ'] = (np.float64(0),   'object RA (deg)')
            ofd_b.header['DEC_OBJ'] = (np.float64(0),   'object Dec (deg)')
@@ -3672,18 +3681,24 @@ class IFSsimulator():
            data_time[:21], 'written date (yyyy-mm-ddThh:mm:ss.s)')
        ofd_r.header['FILENAME'] = (filename_r[:68], '')

        ofd_r.header['FILETYPE'] = (self.source[:12],   'observation type')
        # ofd_r.header['FILETYPE'] = (self.source[:12],   'observation type')

        ofd_r.header['TELESCOP'] = ('CSST',   'telescope name')

        ofd_r.header['INSTRUME'] = ('IFS',   'instrument name')

        ofd_r.header['OBSID'] = (str(obsid),   'observation ID')

        ofd_r.header['OBSTYPE'] = (self.source[:12],   'observation type')

        ofd_r.header['DATASET'] = ('csst-ifs-C11-V1',   'dataset')

        ofd_r.header['RADECSYS'] = (
            'ICRS',   'coordinate system of the object')

        ofd_r.header['EQUINOX'] = (float(2000.0),   '')
        ofd_r.header['FITSSWV'] = (
            __version__,   'FITS creating software version')
            '4.2.1',   'FITS creating software version')

        # ########   Object information  #############
        if self.source == 'SCI' or self.source == 'COMP':
@@ -4629,11 +4644,11 @@ class IFSsimulator():

            sn = self.simnumber-1
            x_sat = float(self.bianpai_data['x_sat']
                          [sn*5+self.exptime_start_index])
                          [sn*int(self.information['exptime']/60)+self.exptime_start_index])
            y_sat = float(self.bianpai_data['y_sat']
                          [sn*5+self.exptime_start_index])
                          [sn*int(self.information['exptime']/60)+self.exptime_start_index])
            z_sat = float(self.bianpai_data['z_sat']
                          [sn*5+self.exptime_start_index])
                          [sn*int(self.information['exptime']/60)+self.exptime_start_index])

            ###
        else:
@@ -4723,18 +4738,18 @@ class IFSsimulator():

            sn = self.simnumber-1
            x_sat = float(self.bianpai_data['x_sat']
                          [sn*5+self.exptime_start_index])
                          [sn*int(self.information['exptime']/60)+self.exptime_start_index])
            y_sat = float(self.bianpai_data['y_sat']
                          [sn*5+self.exptime_start_index])
                          [sn*int(self.information['exptime']/60)+self.exptime_start_index])
            z_sat = float(self.bianpai_data['z_sat']
                          [sn*5+self.exptime_start_index])
                          [sn*int(self.information['exptime']/60)+self.exptime_start_index])

            vx_sat = float(
                self.bianpai_data['vx_sat'][sn*5+self.exptime_start_index])
                self.bianpai_data['vx_sat'][sn*int(self.information['exptime']/60)+self.exptime_start_index])
            vy_sat = float(
                self.bianpai_data['vy_sat'][sn*5+self.exptime_start_index])
                self.bianpai_data['vy_sat'][sn*int(self.information['exptime']/60)+self.exptime_start_index])
            vz_sat = float(
                self.bianpai_data['vz_sat'][sn*5+self.exptime_start_index])
                self.bianpai_data['vz_sat'][sn*int(self.information['exptime']/60)+self.exptime_start_index])

        else:

@@ -4766,18 +4781,18 @@ class IFSsimulator():
            sn = self.simnumber-1

            p1x = float(self.bianpai_data['x_sat']
                        [sn*5+self.exptime_end_index])
                        [sn*int(self.information['exptime']/60)+self.exptime_end_index])
            p1y = float(self.bianpai_data['y_sat']
                        [sn*5+self.exptime_end_index])
                        [sn*int(self.information['exptime']/60)+self.exptime_end_index])
            p1z = float(self.bianpai_data['z_sat']
                        [sn*5+self.exptime_end_index])
                        [sn*int(self.information['exptime']/60)+self.exptime_end_index])

            p1vx = float(self.bianpai_data['vx_sat']
                         [sn*5+self.exptime_end_index])
                         [sn*int(self.information['exptime']/60)+self.exptime_end_index])
            p1vy = float(self.bianpai_data['vy_sat']
                         [sn*5+self.exptime_end_index])
                         [sn*int(self.information['exptime']/60)+self.exptime_end_index])
            p1vz = float(self.bianpai_data['vz_sat']
                         [sn*5+self.exptime_end_index])
                         [sn*int(self.information['exptime']/60)+self.exptime_end_index])

        else:

@@ -5591,7 +5606,9 @@ class IFSsimulator():

                ##############################################################
                sn = self.simnumber-1
                arr = np.array(df['time'][sn*5:sn*5+5])
                Num=int(self.information['exptime']/60)

                arr = np.array(df['time'][sn*Num:sn*Num+Num])
                self.exptime_start_jd, self.exptime_start_index = find_min(arr)
                self.exptime_end_jd,  self.exptime_end_index = find_max(arr)