Commit d1fefe06 authored by Yan Zhaojun's avatar Yan Zhaojun
Browse files

update

parent 4a697122
Loading
Loading
Loading
Loading
+119 −32
Original line number Diff line number Diff line
@@ -1397,6 +1397,29 @@ class MCIsimulator():
            ##########################################
            df2 = pandas.read_csv(
                self.information['dir_path']+'MCI_inputData/star_input/'+starcat)
            ###
          
            try:
                df2['ra_gaia'][10]
            except NameError:
                self.log.error(
                    'Error,no ra data in the star_cat catlog file ')
                raise ValueError(
                   'Error,no ra data in the star_cat catlog file ')    
                
            try:
                df2['dec_gaia'][10]
            except NameError:
                self.log.error(
                    'Error,no dec data in the star_cat catlog file ')
                raise ValueError(
                   'Error,no dec data in the star_cat catlog file ') 
                    
            if df2['ra_gaia'].max()>360 or df2['ra_gaia'].min()<0 or df2['dec_gaia'].max()>90 or df2['dec_gaia'].min()<-90 :
                self.log.error(
                    'ra or dec data beyond definition,please check!')
                raise ValueError(
                   'ra or dec data beyond definition,please check!')
    
            df3 = df2[(abs(df2['ra_gaia']-df2['ra_gaia'].mean()) < 400/3600.0)
                      & (abs(df2['dec_gaia']-df2['dec_gaia'].mean()) < 400/3600.0)]
@@ -1422,6 +1445,29 @@ class MCIsimulator():
                self.information['dir_path']+'/MCI_inputData/star_input/'+starcat)

            self.star = df0[1].data
            ###

            try:
                self.star['ra'][10]
            except NameError:
                self.log.error(
                    'Error,no ra data in the star_cat catlog file ')
                raise ValueError(
                   'Error,no ra data in the star_cat catlog file ')  
                
            try:
                self.star['dec'][10]
            except NameError:
                self.log.error(
                    'Error,no dec data in the star_cat catlog file ')
                raise ValueError(
                   'Error,no dec data in the star_cat catlog file ')                  

            if self.star['ra'].max()>360 or self.star['ra'].min()<0 or self.star['dec'].max()>90 or self.star['dec'].min()<-90 :
                self.log.error(
                    'ra or dec data beyond definition,please check!')
                raise ValueError(
                   'ra or dec data beyond definition,please check!')

            self.information['ra_obj'] = self.star['ra'].mean()
            self.information['dec_obj'] = self.star['dec'].mean()
@@ -1637,8 +1683,8 @@ class MCIsimulator():
        self.earthshine_wave = wave_mci      # A
        self.earthshine_flux = earthshine_mci

        #######################################################################################
        #########################################################################################
        ##############################################################
        #############################################################

        self.cal_sky_noise()

@@ -2305,6 +2351,12 @@ class MCIsimulator():

            if not os.path.exists(filename):
                print('finish load all the input galaxy image fits files')
                
                self.log.error(
                    'Error, when load input galaxy image fits files')
                raise ValueError(
                    'Error, when load input galaxy image fits files')
                
                break

            srcs_cat = fits.open(filename)
@@ -2331,6 +2383,30 @@ class MCIsimulator():
            dec_list = []

            for kkk in range(1, len(srcs_cat)):
                
                # test input data
                try:
                    srcs_cat[kkk].header['new_ra']
                except NameError:
                    self.log.error(
                        'Error,no ra data in the input galaxy data  file ')
                    raise ValueError(
                       'Error,no ra data in the input galaxy data  file ')
          
                try:
                    srcs_cat[kkk].header['new_dec']
                except NameError:
                    self.log.error(
                        'Error,no dec data in the input galaxy data  file ')
                    raise ValueError(
                       'Error,no dec data in the input galaxy data  file ')

                if srcs_cat[kkk].header['new_ra']>360 or srcs_cat[kkk].header['new_ra']<0 or srcs_cat[kkk].header['new_dec']>90 or srcs_cat[kkk].header['new_dec']<-90 :
                    self.log.error(
                        'Gal ra or dec data beyond definition, please check!')
                    raise ValueError(
                       'Gal ra or dec data beyond definition, please check!')
                #    
                t1 = srcs_cat[kkk].header['new_ra'] - \
                    self.information['gal_ra'] + self.information['star_ra']
                ra_list.append(float(t1))
@@ -2381,6 +2457,18 @@ class MCIsimulator():
                # here is k1+1, not k1, k1 begins with 0
                gal_flux = srcs_sed[k1+1].data
                
                if gal_flux.min()<0 or len(gal_flux)<100:
                    self.log.error(
                        'Galaxy SED data error, please check!')
                    raise ValueError(
                       'Galaxy SED data error, please check!')
                    
                if srcs_cat[k1+1].data.min()<0 or srcs_cat[k1+1].data.max==0 or srcs_cat[k1+1].data.ndim !=2:
                    self.log.error(
                        'Galaxy image data error, please check!')
                    raise ValueError(
                       'Galaxy image data error, please check!')
                    
                ################################
                # ## rotate the lensed_images_g  ###
                if abs(theta.deg) > 0:
@@ -3608,7 +3696,7 @@ class MCIsimulator():
            'ICRS',   'coordinate system of the object')
        ofd_g.header['EQUINOX'] = (float(2000.0),   '')
        ofd_g.header['FITSSWV'] = (
            'mci_sim_0.8.03',   'FITS creating software version')
            'csst_mci_sim_3.0.0',   'FITS creating software version')
        ##############################################################################
        # ########   Object information  #########################################
        ofd_g.header['OBJECT'] = (
@@ -3800,7 +3888,7 @@ class MCIsimulator():
        hdu_g.header['RADECSYS'] = (
            'ICRS',   'coordinate system of the object')
        hdu_g.header['EQUINOX'] = (float(2000.1),   '')
        hdu_g.header['FITSSWV'] = ('4.2.1',   'FITS creating software version')
        hdu_g.header['FITSSWV'] = ('csst_mci_sim_3.0.0',   'FITS creating software version')

        ########################################

@@ -4209,7 +4297,7 @@ class MCIsimulator():
            'ICRS',   'coordinate system of the object')
        ofd_r.header['EQUINOX'] = (float(2000.0),   '')
        ofd_r.header['FITSSWV'] = (
            'mci_sim_0.8.03',   'FITS creating software version')
            'csst_mci_sim_3.0.0',   'FITS creating software version')
        # ########   Object information  #########################################
        ofd_r.header['OBJECT'] = (
            self.information['name_obj'][:30],   'object name')
@@ -4351,7 +4439,7 @@ class MCIsimulator():
        hdu_r.header['RADECSYS'] = (
            'ICRS',   'coordinate system of the object')
        hdu_r.header['EQUINOX'] = (float(2000.1),   '')
        hdu_r.header['FITSSWV'] = ('4.2.1',   'FITS creating software version')
        hdu_r.header['FITSSWV'] = ('csst_mci_sim_3.0.0',   'FITS creating software version')

        ########################################

@@ -4757,7 +4845,7 @@ class MCIsimulator():
            'ICRS',   'coordinate system of the object')
        ofd_i.header['EQUINOX'] = (float(2000.0),   '')
        ofd_i.header['FITSSWV'] = (
            'mci_sim_0.8.03',   'FITS creating software version')
            'csst_mci_sim_3.0.0',   'FITS creating software version')
        ##############################################################################
        # ########   Object information  #########################################
        ofd_i.header['OBJECT'] = (
@@ -4902,7 +4990,7 @@ class MCIsimulator():
        hdu_i.header['RADECSYS'] = (
            'ICRS',   'coordinate system of the object')
        hdu_i.header['EQUINOX'] = (float(2000.1),   '')
        hdu_i.header['FITSSWV'] = ('4.2.1',   'FITS creating software version')
        hdu_i.header['FITSSWV'] = ('csst_mci_sim_3.0.0',   'FITS creating software version')

        ########################################

@@ -5453,7 +5541,6 @@ class MCIsimulator():
            self.log.info('dis_ra(in pixel)=%f, dis_dec(in pixel)=%f, sky_rot(in deg)=%f' % (
                dis_ra*3600/0.05, dis_dec*3600/0.05, theta.deg))
###################################################################

##################################################################
# ########   simulate star images from star SED data   ###########

@@ -5468,12 +5555,12 @@ class MCIsimulator():
                    # fits.writeto(self.result_path+'/ori_Sky/starimg_C2_'+str(simnumber)+'.fits',starimg['r'], overwrite=True)
                    # fits.writeto(self.result_path+'/ori_Sky/starimg_C3_'+str(simnumber)+'.fits',starimg['i'], overwrite=True)

                    self.img_fits_save(
                        starimg['g'], 'star_ori_C1_'+str(simnumber))
                    self.img_fits_save(
                        starimg['r'], 'star_ori_C2_'+str(simnumber))
                    self.img_fits_save(
                        starimg['i'], 'star_ori_C3_'+str(simnumber))
                    # self.img_fits_save(
                    #     starimg['g'], 'star_ori_C1_'+str(simnumber))
                    # self.img_fits_save(
                    #     starimg['r'], 'star_ori_C2_'+str(simnumber))
                    # self.img_fits_save(
                    #     starimg['i'], 'star_ori_C3_'+str(simnumber))

                    print('star image finished')

@@ -5492,12 +5579,12 @@ class MCIsimulator():
                    # fits.writeto(self.result_path+'/ori_Sky/galimg_C2_'+str(simnumber)+'.fits',losimg['r'], overwrite=True)
                    # fits.writeto(self.result_path+'/ori_Sky/galimg_C3_'+str(simnumber)+'.fits',losimg['i'], overwrite=True)

                    self.img_fits_save(
                        losimg['g'], 'gal_ori_C1_'+str(simnumber))
                    self.img_fits_save(
                        losimg['r'], 'gal_ori_C2_'+str(simnumber))
                    self.img_fits_save(
                        losimg['i'], 'gal_ori_C3_'+str(simnumber))
                    # self.img_fits_save(
                    #     losimg['g'], 'gal_ori_C1_'+str(simnumber))
                    # self.img_fits_save(
                    #     losimg['r'], 'gal_ori_C2_'+str(simnumber))
                    # self.img_fits_save(
                    #     losimg['i'], 'gal_ori_C3_'+str(simnumber))

            ##################################################################

@@ -5566,9 +5653,9 @@ class MCIsimulator():
            self.information['dec_pnt0'] = 0
            self.information['target'] = 'FLAT'

            self.image_g += 5000*self.information['simnumber']
            self.image_r += 5000*self.information['simnumber']
            self.image_i += 5000*self.information['simnumber']
            self.image_g += 10000*self.information['simnumber']
            self.image_r += 10000*self.information['simnumber']
            self.image_i += 10000*self.information['simnumber']

        elif self.source == 'DARK':

@@ -5726,8 +5813,8 @@ class MCIsimulator():

                self.applyRadiationDamage()
                print('applyRadiationDamage()')
        ######################################################################
        # ##### apply readoutNoise   ######
        #####################################################################
        ##### apply readoutNoise   ######

        if self.readoutNoise:
            self.applyReadoutNoise()
@@ -5739,9 +5826,9 @@ class MCIsimulator():
            print('apply 1-16 zone by different gain ')

        else:
            self.image_g = self.image_g/1.5
            self.image_r = self.image_r/1.5
            self.image_i = self.image_i/1.5
            self.image_g = self.image_g/1.0
            self.image_r = self.image_r/1.0
            self.image_i = self.image_i/1.0
            print('apply gain finish')
        ######################################################################
        # size of the output image array, xsize is column, ysize is row, xsize = 9216,ysize = 9232
+187 B

File added.

No diff preview for this file type.

+8 −1
Original line number Diff line number Diff line
@@ -165,7 +165,14 @@ class Star_Temp():
        # parent = os.path.dirname(os.path.realpath(__file__))
        # print("获取其父目录——" + parent)  # 从当前文件路径中获取目录
        hdulist = fits.open(
            path+'MCI_inputData/SED_Code/seddata/stellar_temp.fits')
            os.path.join(path, 'MCI_inputData/SED_Code/seddata/stellar_temp.fits'))

        if hdulist[1].data['wave'] == [] or hdulist[2].data == [] or hdulist[3].data['Teff'] == [] or hdulist[3].data['FeH'] == []:
            self.log.error(
                'Data error in tellar_temp.fits file, please check!!!')
            raise ValueError(
                'Data error in tellar_temp.fits file, please check!!!')

        self.wave = hdulist[1].data['wave']
        self.flux = hdulist[2].data
        self.Teff_grid = hdulist[3].data['Teff']