Loading csst_ifs_sim/csst_ifs_sim.py +94 −80 Original line number Original line Diff line number Diff line Loading @@ -260,15 +260,7 @@ class CDM03bidir(): return np.asanyarray(CTIed) return np.asanyarray(CTIed) ################################################################################################################# ################################################################################################################# """ These functions can be used for logging information. .. Warning:: logger is not multiprocessing safe. :version: 0.3 """ def lg(log_filename, loggername='logger'): def lg(log_filename, loggername='logger'): """ """ Sets up a logger. Sets up a logger. Loading Loading @@ -297,7 +289,7 @@ def lg(log_filename, loggername='logger'): logger.addHandler(handler) logger.addHandler(handler) return logger return logger ############################################################################## def IFSinformation(): def IFSinformation(): """ """ Loading Loading @@ -772,7 +764,8 @@ class StrayLight(object): self.PSTFn = os.path.join(self.path, "IFS_inputdata/refs/PST") self.PSTFn = os.path.join(self.path, "IFS_inputdata/refs/PST") self.RFn = os.path.join(self.path, "IFS_inputdata/refs/R") self.RFn = os.path.join(self.path, "IFS_inputdata/refs/R") self.ZolFn = os.path.join(self.path, "IFS_inputdata/refs/Zodiacal") self.ZolFn = os.path.join(self.path, "IFS_inputdata/refs/Zodiacal") self.brightStarTabFn = os.path.join(self.path,"IFS_inputdata/refs/BrightGaia_with_csst_mag") self.brightStarTabFn = os.path.join( self.path, "IFS_inputdata/refs/BrightGaia_with_csst_mag") self.slcdll.Init(str.encode(self.deFn), str.encode( self.slcdll.Init(str.encode(self.deFn), str.encode( self.PSTFn), str.encode(self.RFn), str.encode(self.ZolFn)) self.PSTFn), str.encode(self.RFn), str.encode(self.ZolFn)) Loading Loading @@ -1991,12 +1984,13 @@ class IFSsimulator(): else: else: ss = '_' ss = '_' # # # ##create result father path; # ##create result father path; if os.path.isdir(self.information['result_path']) is False: if os.path.isdir(self.information['result_path']) is False: os.mkdir(self.information['result_path']) os.mkdir(self.information['result_path']) self.result_path=os.path.join(self.information['result_path'], self.source+ss+result_day) self.result_path = os.path.join( self.information['result_path'], self.source+ss+result_day) print(self.result_path) print(self.result_path) if os.path.isdir(self.result_path) is False: if os.path.isdir(self.result_path) is False: Loading Loading @@ -2036,7 +2030,8 @@ class IFSsimulator(): self.HgArsigma = self.light_FWHM/2.35 # sigma value of the light source self.HgArsigma = self.light_FWHM/2.35 # sigma value of the light source # load system optical and CCD efficiency data # load system optical and CCD efficiency data matfn0 = os.path.join(self.information['dir_path'],'IFS_inputdata/TotalQ200923.mat') matfn0 = os.path.join( self.information['dir_path'], 'IFS_inputdata/TotalQ200923.mat') self.log.info('Optical optical efficiency file path is: %s' % (matfn0)) self.log.info('Optical optical efficiency file path is: %s' % (matfn0)) da0 = sio.loadmat(matfn0) da0 = sio.loadmat(matfn0) # optical efficiency of blue channel # optical efficiency of blue channel Loading @@ -2047,7 +2042,8 @@ class IFSsimulator(): # load all useful data; # load all useful data; # load wavefront data; # load wavefront data; matfn2 = os.path.join(self.information['dir_path'],'IFS_inputdata/opd/opd_638nm.mat') matfn2 = os.path.join( self.information['dir_path'], 'IFS_inputdata/opd/opd_638nm.mat') self.log.info('OPD0 file path is: %s' % (matfn2)) self.log.info('OPD0 file path is: %s' % (matfn2)) da2 = sio.loadmat(matfn2) da2 = sio.loadmat(matfn2) opd0 = da2['opd'] # opd unit is in meter opd0 = da2['opd'] # opd unit is in meter Loading @@ -2055,17 +2051,20 @@ class IFSsimulator(): self.pupil = abs(opd0) > 0.0 self.pupil = abs(opd0) > 0.0 #################### #################### matfn2 = os.path.join(self.information['dir_path'],'IFS_inputdata/opd/opd1.fits') matfn2 = os.path.join( self.information['dir_path'], 'IFS_inputdata/opd/opd1.fits') da = fits.open(matfn2) da = fits.open(matfn2) self.opd1 = da[0].data self.opd1 = da[0].data self.log.info('OPD1 file path is: %s' % (matfn2)) self.log.info('OPD1 file path is: %s' % (matfn2)) matfn2 = os.path.join(self.information['dir_path'],'IFS_inputdata/opd/opd2.fits') matfn2 = os.path.join( self.information['dir_path'], 'IFS_inputdata/opd/opd2.fits') self.log.info('OPD2 file path is: %s' % (matfn2)) self.log.info('OPD2 file path is: %s' % (matfn2)) da = fits.open(matfn2) da = fits.open(matfn2) self.opd2 = da[0].data self.opd2 = da[0].data matfn2 = os.path.join(self.information['dir_path'],'IFS_inputdata/opd/opd3.fits') matfn2 = os.path.join( self.information['dir_path'], 'IFS_inputdata/opd/opd3.fits') self.log.info('OPD3 file path is: %s' % (matfn2)) self.log.info('OPD3 file path is: %s' % (matfn2)) da = fits.open(matfn2) da = fits.open(matfn2) self.opd3 = da[0].data self.opd3 = da[0].data Loading Loading @@ -2452,7 +2451,6 @@ class IFSsimulator(): # ############################################################################# # ############################################################################# def applyPoissonNoise(self): def applyPoissonNoise(self): """ """ Returns Returns ------- ------- Loading Loading @@ -3422,11 +3420,13 @@ class IFSsimulator(): filename_b = 'CSST_IFS_B_'+self.source+'_'+exp_start_str + \ filename_b = 'CSST_IFS_B_'+self.source+'_'+exp_start_str + \ '_'+exp_end_str+'_'+str(obsid)+'_B_L0_V'+sim_ver '_'+exp_end_str+'_'+str(obsid)+'_B_L0_V'+sim_ver self.file_b = self.result_path+'/sky_Data/'+filename_b+'.fits' self.file_b = os.path.join( self.result_path, 'sky_Data/'+filename_b+'.fits') filename_r = 'CSST_IFS_R_'+self.source+'_'+exp_start_str + \ filename_r = 'CSST_IFS_R_'+self.source+'_'+exp_start_str + \ '_'+exp_end_str+'_'+str(obsid)+'_R_L0_V'+sim_ver '_'+exp_end_str+'_'+str(obsid)+'_R_L0_V'+sim_ver self.file_r = self.result_path+'/sky_Data/'+filename_r + '.fits' self.file_r = os.path.join( self.result_path, 'sky_Data/'+filename_r + '.fits') else: else: Loading @@ -3441,11 +3441,13 @@ class IFSsimulator(): filename_b = 'CSST_IFS_B_'+self.source+'_'+exp_start_str + \ filename_b = 'CSST_IFS_B_'+self.source+'_'+exp_start_str + \ '_'+exp_end_str+'_'+str(obsid)+'_B_L0_V'+sim_ver '_'+exp_end_str+'_'+str(obsid)+'_B_L0_V'+sim_ver self.file_b = os.path.join(self.result_path,'calibration_Data/'+filename_b+'.fits') self.file_b = os.path.join( self.result_path, 'calibration_Data/'+filename_b+'.fits') filename_r = 'CSST_IFS_R_'+self.source+'_'+exp_start_str + \ filename_r = 'CSST_IFS_R_'+self.source+'_'+exp_start_str + \ '_'+exp_end_str+'_'+str(obsid)+'_R_L0_V'+sim_ver '_'+exp_end_str+'_'+str(obsid)+'_R_L0_V'+sim_ver self.file_r = os.path.join(self.result_path,'calibration_Data/'+filename_r+'.fits') self.file_r = os.path.join( self.result_path, 'calibration_Data/'+filename_r+'.fits') # create a new FITS file, using HDUList instance # create a new FITS file, using HDUList instance # #### layer 0 #### # #### layer 0 #### Loading Loading @@ -4411,21 +4413,24 @@ class IFSsimulator(): ################################################################ ################################################################ # ######## # ######## # #### load slicer_Qe1K.fits #### # #### load slicer_Qe1K.fits #### slicerfile = os.path.join(self.information['dir_path'],'IFS_inputdata/Flatfield/slicer_QE_1K_230625.fits') slicerfile = os.path.join( self.information['dir_path'], 'IFS_inputdata/Flatfield/slicer_QE_1K_230625.fits') da = fits.open(slicerfile) da = fits.open(slicerfile) self.log.info('hole Sim and slicer 1K QE file:%s' % (slicerfile)) self.log.info('hole Sim and slicer 1K QE file:%s' % (slicerfile)) slicer_Qe = da[0].data slicer_Qe = da[0].data # #### load hole mask ###### # #### load hole mask ###### # load hole mask matrix # load hole mask matrix file = os.path.join(self.information['dir_path'], 'IFS_inputdata/Hole/holemask_230612.fits') file = os.path.join( self.information['dir_path'], 'IFS_inputdata/Hole/holemask_230612.fits') self.log.info('hole mask file is %s' % (file)) self.log.info('hole mask file is %s' % (file)) da = fits.open(file) da = fits.open(file) HoleMask = da[self.simnumber].data HoleMask = da[self.simnumber].data # load HgAr data; # load HgAr data; matfn3 = os.path.join(self.information['dir_path'],'IFS_inputdata/HgAr.mat') matfn3 = os.path.join( self.information['dir_path'], 'IFS_inputdata/HgAr.mat') self.log.info('lamp flux file is : %s' % (matfn3)) self.log.info('lamp flux file is : %s' % (matfn3)) da3 = sio.loadmat(matfn3) da3 = sio.loadmat(matfn3) HgArst = da3['HgArst'] # opd unit is in meter HgArst = da3['HgArst'] # opd unit is in meter Loading Loading @@ -4674,10 +4679,11 @@ class IFSsimulator(): data_time = now.strftime("%Y-%m-%d") data_time = now.strftime("%Y-%m-%d") # write the actual file # write the actual file bluefile = os.path.join(self.result_path,'original_Calibration/IFS_'+self.source + \ bluefile = os.path.join(self.result_path, 'original_Calibration/IFS_' + '_'+data_time+'_'+str(self.simnumber)+'_B_original.fits') self.source + '_' + d ata_time + '_' + redfile = os.path.join(self.result_path,'original_Calibration/IFS_'+self.source + \ str(self.simnumber)+'_B_original.fits') '_'+data_time+'_'+str(self.simnumber)+'_R_original.fits') redfile = os.path.join(self.result_path, 'original_Calibration/IFS_' + self.source+'_'+data_time+'_'+str(self.simnumber)+'_R_original.fits') fits.writeto(bluefile, blue_img.array, overwrite=True) fits.writeto(bluefile, blue_img.array, overwrite=True) fits.writeto(redfile, red_img.array, overwrite=True) fits.writeto(redfile, red_img.array, overwrite=True) Loading @@ -4697,7 +4703,8 @@ class IFSsimulator(): newd = fits.HDUList([hdu1, hdu2]) newd = fits.HDUList([hdu1, hdu2]) filename = os.path.join(self.result_path,'calibration_Data/'+self.source+'_flux.fits') filename = os.path.join( self.result_path, 'calibration_Data/'+self.source+'_flux.fits') if self.simnumber == 1: if self.simnumber == 1: newd.writeto(filename, overwrite=True) newd.writeto(filename, overwrite=True) Loading Loading @@ -4738,7 +4745,8 @@ class IFSsimulator(): ############################################################################ ############################################################################ # consider the slice optical efficiency in different slicer channel # consider the slice optical efficiency in different slicer channel slicer_QE_file = os.path.join(self.information['dir_path'],'IFS_inputdata/Flatfield/slicer_QE230625.fits') slicer_QE_file = os.path.join( self.information['dir_path'], 'IFS_inputdata/Flatfield/slicer_QE230625.fits') da = fits.open(slicer_QE_file) da = fits.open(slicer_QE_file) self.log.info('slicer_QE_file path is: %s' % (slicer_QE_file)) self.log.info('slicer_QE_file path is: %s' % (slicer_QE_file)) slicer_Qe = da[0].data slicer_Qe = da[0].data Loading Loading @@ -4942,7 +4950,8 @@ class IFSsimulator(): # orbit parameters are not in currenct txt file # orbit parameters are not in currenct txt file if self.orbit_pars[-1, 0] < t2jd: if self.orbit_pars[-1, 0] < t2jd: self.orbit_file_num = self.orbit_file_num+1 self.orbit_file_num = self.orbit_file_num+1 fn = os.path.join(self.information['dir_path'] , 'IFS_inputdata/TianCe/orbit20160925/'+str(self.orbit_file_num)+'.txt') fn = os.path.join( self.information['dir_path'], 'IFS_inputdata/TianCe/orbit20160925/'+str(self.orbit_file_num)+'.txt') self.orbit_pars = np.loadtxt(fn) self.orbit_pars = np.loadtxt(fn) self.orbit_exp_num = 0 self.orbit_exp_num = 0 Loading Loading @@ -5119,8 +5128,10 @@ class IFSsimulator(): # PSFfilename='/media/yan//IFSsim/IFSsim Data/rot_shift_Img.fits' # PSFfilename='/media/yan//IFSsim/IFSsim Data/rot_shift_Img.fits' # fits.writeto('/media/yan//IFSsim/IFSsim Data/rot_shift_subImg.fits',image0.array[50-32:50+32,50-32:50+32],overwrite=True ) # fits.writeto('/media/yan//IFSsim/IFSsim Data/rot_shift_subImg.fits',image0.array[50-32:50+32,50-32:50+32],overwrite=True ) hdu1.writeto(os.path.join(self.result_path,'shift_rot_sky/rot_shift_subImg_'+str(simnumber)+'.fits'), overwrite=True) hdu1.writeto(os.path.join( fits.writeto(os.path.join(self.result_path,'shift_rot_sky/original_Img_'+str(simnumber)+'.fits'), Nimg, overwrite=True) self.result_path, 'shift_rot_sky/rot_shift_subImg_'+str(simnumber)+'.fits'), overwrite=True) fits.writeto(os.path.join( self.result_path, 'shift_rot_sky/original_Img_'+str(simnumber)+'.fits'), Nimg, overwrite=True) ##################################################################### ##################################################################### # ## do convolve image0 with PSF0 from primay CSST ### # ## do convolve image0 with PSF0 from primay CSST ### Loading Loading @@ -5285,7 +5296,6 @@ class IFSsimulator(): ######################################################## ######################################################## ##################################################################### ##################################################################### # stray light will cover 2% of input total light; # stray light will cover 2% of input total light; if self.sky_noise: if self.sky_noise: Loading @@ -5300,9 +5310,9 @@ class IFSsimulator(): self.image_r = red_img.array self.image_r = red_img.array obsid = simnumber obsid = simnumber bluefile = os.path.join(self.result_path,'original_sky/IFS_' + \ bluefile = os.path.join(self.result_path, 'original_sky/IFS_' + self.source+'_'+str(obsid)+'_B.fits') self.source+'_'+str(obsid)+'_B.fits') redfile = os.path.join(self.result_path,'original_sky/IFS_' + \ redfile = os.path.join(self.result_path, 'original_sky/IFS_' + self.source+'_'+str(obsid)+'_R.fits') self.source+'_'+str(obsid)+'_R.fits') fits.writeto(bluefile, blue_img.array, overwrite=True) fits.writeto(bluefile, blue_img.array, overwrite=True) Loading Loading @@ -5333,13 +5343,15 @@ class IFSsimulator(): # load HgAr data; # load HgAr data; if self.source == 'LAMP': if self.source == 'LAMP': matfn3 = os.path.join(self.information['dir_path'],'IFS_inputdata/HgAr.mat') matfn3 = os.path.join( self.information['dir_path'], 'IFS_inputdata/HgAr.mat') self.log.info('lamp flux file is : %s' % (matfn3)) self.log.info('lamp flux file is : %s' % (matfn3)) da3 = sio.loadmat(matfn3) da3 = sio.loadmat(matfn3) HgArst = da3['HgArst'] # opd unit is in meter HgArst = da3['HgArst'] # opd unit is in meter # load flat data # load flat data if self.source == 'FLAT': if self.source == 'FLAT': matfn3 = os.path.join(self.information['dir_path'],'IFS_inputdata/flat_light.mat') matfn3 = os.path.join( self.information['dir_path'], 'IFS_inputdata/flat_light.mat') self.log.info('flat flux file is : %s' % (matfn3)) self.log.info('flat flux file is : %s' % (matfn3)) da3 = sio.loadmat(matfn3) da3 = sio.loadmat(matfn3) flat_light = da3['flat_light'] # opd unit is in meter flat_light = da3['flat_light'] # opd unit is in meter Loading Loading @@ -5622,10 +5634,10 @@ class IFSsimulator(): data_time = now.strftime("%Y-%m-%d") data_time = now.strftime("%Y-%m-%d") # write the actual file # write the actual file bluefile = os.path.join(self.result_path,'original_Calibration/IFS_'+self.source + \ bluefile = os.path.join(self.result_path, 'original_Calibration/IFS_'+self.source + '_'+data_time+'_'+str(self.simnumber)+'_B_original.fits') '_'+data_time+'_'+str(self.simnumber)+'_B_original.fits') redfile = os.path.join(self.result_path,'original_Calibration/IFS_'+self.source + \ redfile = os.path.join(self.result_path, 'original_Calibration/IFS_'+self.source + '_'+data_time+'_'+str(self.simnumber)+'_R_original.fits') '_'+data_time+'_'+str(self.simnumber)+'_R_original.fits') fits.writeto(bluefile, blue_img.array, overwrite=True) fits.writeto(bluefile, blue_img.array, overwrite=True) Loading @@ -5646,7 +5658,8 @@ class IFSsimulator(): newd = fits.HDUList([hdu1, hdu2]) newd = fits.HDUList([hdu1, hdu2]) filename = os.path.join(self.result_path,'calibration_Data/'+self.source+'_flux.fits') filename = os.path.join( self.result_path, 'calibration_Data/'+self.source+'_flux.fits') if self.simnumber == 1: if self.simnumber == 1: newd.writeto(filename, overwrite=True) newd.writeto(filename, overwrite=True) Loading Loading @@ -5715,7 +5728,8 @@ class IFSsimulator(): if simnumber <= 200 and simnumber > 150: if simnumber <= 200 and simnumber > 150: self.information['exptime'] = 1200 self.information['exptime'] = 1200 self.skyfilepath = os.path.join(self.information['dir_path'],self.information['sky_fitsin']) self.skyfilepath = os.path.join( self.information['dir_path'], self.information['sky_fitsin']) print('self.skyfilepath = ', self.skyfilepath) print('self.skyfilepath = ', self.skyfilepath) Loading Loading
csst_ifs_sim/csst_ifs_sim.py +94 −80 Original line number Original line Diff line number Diff line Loading @@ -260,15 +260,7 @@ class CDM03bidir(): return np.asanyarray(CTIed) return np.asanyarray(CTIed) ################################################################################################################# ################################################################################################################# """ These functions can be used for logging information. .. Warning:: logger is not multiprocessing safe. :version: 0.3 """ def lg(log_filename, loggername='logger'): def lg(log_filename, loggername='logger'): """ """ Sets up a logger. Sets up a logger. Loading Loading @@ -297,7 +289,7 @@ def lg(log_filename, loggername='logger'): logger.addHandler(handler) logger.addHandler(handler) return logger return logger ############################################################################## def IFSinformation(): def IFSinformation(): """ """ Loading Loading @@ -772,7 +764,8 @@ class StrayLight(object): self.PSTFn = os.path.join(self.path, "IFS_inputdata/refs/PST") self.PSTFn = os.path.join(self.path, "IFS_inputdata/refs/PST") self.RFn = os.path.join(self.path, "IFS_inputdata/refs/R") self.RFn = os.path.join(self.path, "IFS_inputdata/refs/R") self.ZolFn = os.path.join(self.path, "IFS_inputdata/refs/Zodiacal") self.ZolFn = os.path.join(self.path, "IFS_inputdata/refs/Zodiacal") self.brightStarTabFn = os.path.join(self.path,"IFS_inputdata/refs/BrightGaia_with_csst_mag") self.brightStarTabFn = os.path.join( self.path, "IFS_inputdata/refs/BrightGaia_with_csst_mag") self.slcdll.Init(str.encode(self.deFn), str.encode( self.slcdll.Init(str.encode(self.deFn), str.encode( self.PSTFn), str.encode(self.RFn), str.encode(self.ZolFn)) self.PSTFn), str.encode(self.RFn), str.encode(self.ZolFn)) Loading Loading @@ -1991,12 +1984,13 @@ class IFSsimulator(): else: else: ss = '_' ss = '_' # # # ##create result father path; # ##create result father path; if os.path.isdir(self.information['result_path']) is False: if os.path.isdir(self.information['result_path']) is False: os.mkdir(self.information['result_path']) os.mkdir(self.information['result_path']) self.result_path=os.path.join(self.information['result_path'], self.source+ss+result_day) self.result_path = os.path.join( self.information['result_path'], self.source+ss+result_day) print(self.result_path) print(self.result_path) if os.path.isdir(self.result_path) is False: if os.path.isdir(self.result_path) is False: Loading Loading @@ -2036,7 +2030,8 @@ class IFSsimulator(): self.HgArsigma = self.light_FWHM/2.35 # sigma value of the light source self.HgArsigma = self.light_FWHM/2.35 # sigma value of the light source # load system optical and CCD efficiency data # load system optical and CCD efficiency data matfn0 = os.path.join(self.information['dir_path'],'IFS_inputdata/TotalQ200923.mat') matfn0 = os.path.join( self.information['dir_path'], 'IFS_inputdata/TotalQ200923.mat') self.log.info('Optical optical efficiency file path is: %s' % (matfn0)) self.log.info('Optical optical efficiency file path is: %s' % (matfn0)) da0 = sio.loadmat(matfn0) da0 = sio.loadmat(matfn0) # optical efficiency of blue channel # optical efficiency of blue channel Loading @@ -2047,7 +2042,8 @@ class IFSsimulator(): # load all useful data; # load all useful data; # load wavefront data; # load wavefront data; matfn2 = os.path.join(self.information['dir_path'],'IFS_inputdata/opd/opd_638nm.mat') matfn2 = os.path.join( self.information['dir_path'], 'IFS_inputdata/opd/opd_638nm.mat') self.log.info('OPD0 file path is: %s' % (matfn2)) self.log.info('OPD0 file path is: %s' % (matfn2)) da2 = sio.loadmat(matfn2) da2 = sio.loadmat(matfn2) opd0 = da2['opd'] # opd unit is in meter opd0 = da2['opd'] # opd unit is in meter Loading @@ -2055,17 +2051,20 @@ class IFSsimulator(): self.pupil = abs(opd0) > 0.0 self.pupil = abs(opd0) > 0.0 #################### #################### matfn2 = os.path.join(self.information['dir_path'],'IFS_inputdata/opd/opd1.fits') matfn2 = os.path.join( self.information['dir_path'], 'IFS_inputdata/opd/opd1.fits') da = fits.open(matfn2) da = fits.open(matfn2) self.opd1 = da[0].data self.opd1 = da[0].data self.log.info('OPD1 file path is: %s' % (matfn2)) self.log.info('OPD1 file path is: %s' % (matfn2)) matfn2 = os.path.join(self.information['dir_path'],'IFS_inputdata/opd/opd2.fits') matfn2 = os.path.join( self.information['dir_path'], 'IFS_inputdata/opd/opd2.fits') self.log.info('OPD2 file path is: %s' % (matfn2)) self.log.info('OPD2 file path is: %s' % (matfn2)) da = fits.open(matfn2) da = fits.open(matfn2) self.opd2 = da[0].data self.opd2 = da[0].data matfn2 = os.path.join(self.information['dir_path'],'IFS_inputdata/opd/opd3.fits') matfn2 = os.path.join( self.information['dir_path'], 'IFS_inputdata/opd/opd3.fits') self.log.info('OPD3 file path is: %s' % (matfn2)) self.log.info('OPD3 file path is: %s' % (matfn2)) da = fits.open(matfn2) da = fits.open(matfn2) self.opd3 = da[0].data self.opd3 = da[0].data Loading Loading @@ -2452,7 +2451,6 @@ class IFSsimulator(): # ############################################################################# # ############################################################################# def applyPoissonNoise(self): def applyPoissonNoise(self): """ """ Returns Returns ------- ------- Loading Loading @@ -3422,11 +3420,13 @@ class IFSsimulator(): filename_b = 'CSST_IFS_B_'+self.source+'_'+exp_start_str + \ filename_b = 'CSST_IFS_B_'+self.source+'_'+exp_start_str + \ '_'+exp_end_str+'_'+str(obsid)+'_B_L0_V'+sim_ver '_'+exp_end_str+'_'+str(obsid)+'_B_L0_V'+sim_ver self.file_b = self.result_path+'/sky_Data/'+filename_b+'.fits' self.file_b = os.path.join( self.result_path, 'sky_Data/'+filename_b+'.fits') filename_r = 'CSST_IFS_R_'+self.source+'_'+exp_start_str + \ filename_r = 'CSST_IFS_R_'+self.source+'_'+exp_start_str + \ '_'+exp_end_str+'_'+str(obsid)+'_R_L0_V'+sim_ver '_'+exp_end_str+'_'+str(obsid)+'_R_L0_V'+sim_ver self.file_r = self.result_path+'/sky_Data/'+filename_r + '.fits' self.file_r = os.path.join( self.result_path, 'sky_Data/'+filename_r + '.fits') else: else: Loading @@ -3441,11 +3441,13 @@ class IFSsimulator(): filename_b = 'CSST_IFS_B_'+self.source+'_'+exp_start_str + \ filename_b = 'CSST_IFS_B_'+self.source+'_'+exp_start_str + \ '_'+exp_end_str+'_'+str(obsid)+'_B_L0_V'+sim_ver '_'+exp_end_str+'_'+str(obsid)+'_B_L0_V'+sim_ver self.file_b = os.path.join(self.result_path,'calibration_Data/'+filename_b+'.fits') self.file_b = os.path.join( self.result_path, 'calibration_Data/'+filename_b+'.fits') filename_r = 'CSST_IFS_R_'+self.source+'_'+exp_start_str + \ filename_r = 'CSST_IFS_R_'+self.source+'_'+exp_start_str + \ '_'+exp_end_str+'_'+str(obsid)+'_R_L0_V'+sim_ver '_'+exp_end_str+'_'+str(obsid)+'_R_L0_V'+sim_ver self.file_r = os.path.join(self.result_path,'calibration_Data/'+filename_r+'.fits') self.file_r = os.path.join( self.result_path, 'calibration_Data/'+filename_r+'.fits') # create a new FITS file, using HDUList instance # create a new FITS file, using HDUList instance # #### layer 0 #### # #### layer 0 #### Loading Loading @@ -4411,21 +4413,24 @@ class IFSsimulator(): ################################################################ ################################################################ # ######## # ######## # #### load slicer_Qe1K.fits #### # #### load slicer_Qe1K.fits #### slicerfile = os.path.join(self.information['dir_path'],'IFS_inputdata/Flatfield/slicer_QE_1K_230625.fits') slicerfile = os.path.join( self.information['dir_path'], 'IFS_inputdata/Flatfield/slicer_QE_1K_230625.fits') da = fits.open(slicerfile) da = fits.open(slicerfile) self.log.info('hole Sim and slicer 1K QE file:%s' % (slicerfile)) self.log.info('hole Sim and slicer 1K QE file:%s' % (slicerfile)) slicer_Qe = da[0].data slicer_Qe = da[0].data # #### load hole mask ###### # #### load hole mask ###### # load hole mask matrix # load hole mask matrix file = os.path.join(self.information['dir_path'], 'IFS_inputdata/Hole/holemask_230612.fits') file = os.path.join( self.information['dir_path'], 'IFS_inputdata/Hole/holemask_230612.fits') self.log.info('hole mask file is %s' % (file)) self.log.info('hole mask file is %s' % (file)) da = fits.open(file) da = fits.open(file) HoleMask = da[self.simnumber].data HoleMask = da[self.simnumber].data # load HgAr data; # load HgAr data; matfn3 = os.path.join(self.information['dir_path'],'IFS_inputdata/HgAr.mat') matfn3 = os.path.join( self.information['dir_path'], 'IFS_inputdata/HgAr.mat') self.log.info('lamp flux file is : %s' % (matfn3)) self.log.info('lamp flux file is : %s' % (matfn3)) da3 = sio.loadmat(matfn3) da3 = sio.loadmat(matfn3) HgArst = da3['HgArst'] # opd unit is in meter HgArst = da3['HgArst'] # opd unit is in meter Loading Loading @@ -4674,10 +4679,11 @@ class IFSsimulator(): data_time = now.strftime("%Y-%m-%d") data_time = now.strftime("%Y-%m-%d") # write the actual file # write the actual file bluefile = os.path.join(self.result_path,'original_Calibration/IFS_'+self.source + \ bluefile = os.path.join(self.result_path, 'original_Calibration/IFS_' + '_'+data_time+'_'+str(self.simnumber)+'_B_original.fits') self.source + '_' + d ata_time + '_' + redfile = os.path.join(self.result_path,'original_Calibration/IFS_'+self.source + \ str(self.simnumber)+'_B_original.fits') '_'+data_time+'_'+str(self.simnumber)+'_R_original.fits') redfile = os.path.join(self.result_path, 'original_Calibration/IFS_' + self.source+'_'+data_time+'_'+str(self.simnumber)+'_R_original.fits') fits.writeto(bluefile, blue_img.array, overwrite=True) fits.writeto(bluefile, blue_img.array, overwrite=True) fits.writeto(redfile, red_img.array, overwrite=True) fits.writeto(redfile, red_img.array, overwrite=True) Loading @@ -4697,7 +4703,8 @@ class IFSsimulator(): newd = fits.HDUList([hdu1, hdu2]) newd = fits.HDUList([hdu1, hdu2]) filename = os.path.join(self.result_path,'calibration_Data/'+self.source+'_flux.fits') filename = os.path.join( self.result_path, 'calibration_Data/'+self.source+'_flux.fits') if self.simnumber == 1: if self.simnumber == 1: newd.writeto(filename, overwrite=True) newd.writeto(filename, overwrite=True) Loading Loading @@ -4738,7 +4745,8 @@ class IFSsimulator(): ############################################################################ ############################################################################ # consider the slice optical efficiency in different slicer channel # consider the slice optical efficiency in different slicer channel slicer_QE_file = os.path.join(self.information['dir_path'],'IFS_inputdata/Flatfield/slicer_QE230625.fits') slicer_QE_file = os.path.join( self.information['dir_path'], 'IFS_inputdata/Flatfield/slicer_QE230625.fits') da = fits.open(slicer_QE_file) da = fits.open(slicer_QE_file) self.log.info('slicer_QE_file path is: %s' % (slicer_QE_file)) self.log.info('slicer_QE_file path is: %s' % (slicer_QE_file)) slicer_Qe = da[0].data slicer_Qe = da[0].data Loading Loading @@ -4942,7 +4950,8 @@ class IFSsimulator(): # orbit parameters are not in currenct txt file # orbit parameters are not in currenct txt file if self.orbit_pars[-1, 0] < t2jd: if self.orbit_pars[-1, 0] < t2jd: self.orbit_file_num = self.orbit_file_num+1 self.orbit_file_num = self.orbit_file_num+1 fn = os.path.join(self.information['dir_path'] , 'IFS_inputdata/TianCe/orbit20160925/'+str(self.orbit_file_num)+'.txt') fn = os.path.join( self.information['dir_path'], 'IFS_inputdata/TianCe/orbit20160925/'+str(self.orbit_file_num)+'.txt') self.orbit_pars = np.loadtxt(fn) self.orbit_pars = np.loadtxt(fn) self.orbit_exp_num = 0 self.orbit_exp_num = 0 Loading Loading @@ -5119,8 +5128,10 @@ class IFSsimulator(): # PSFfilename='/media/yan//IFSsim/IFSsim Data/rot_shift_Img.fits' # PSFfilename='/media/yan//IFSsim/IFSsim Data/rot_shift_Img.fits' # fits.writeto('/media/yan//IFSsim/IFSsim Data/rot_shift_subImg.fits',image0.array[50-32:50+32,50-32:50+32],overwrite=True ) # fits.writeto('/media/yan//IFSsim/IFSsim Data/rot_shift_subImg.fits',image0.array[50-32:50+32,50-32:50+32],overwrite=True ) hdu1.writeto(os.path.join(self.result_path,'shift_rot_sky/rot_shift_subImg_'+str(simnumber)+'.fits'), overwrite=True) hdu1.writeto(os.path.join( fits.writeto(os.path.join(self.result_path,'shift_rot_sky/original_Img_'+str(simnumber)+'.fits'), Nimg, overwrite=True) self.result_path, 'shift_rot_sky/rot_shift_subImg_'+str(simnumber)+'.fits'), overwrite=True) fits.writeto(os.path.join( self.result_path, 'shift_rot_sky/original_Img_'+str(simnumber)+'.fits'), Nimg, overwrite=True) ##################################################################### ##################################################################### # ## do convolve image0 with PSF0 from primay CSST ### # ## do convolve image0 with PSF0 from primay CSST ### Loading Loading @@ -5285,7 +5296,6 @@ class IFSsimulator(): ######################################################## ######################################################## ##################################################################### ##################################################################### # stray light will cover 2% of input total light; # stray light will cover 2% of input total light; if self.sky_noise: if self.sky_noise: Loading @@ -5300,9 +5310,9 @@ class IFSsimulator(): self.image_r = red_img.array self.image_r = red_img.array obsid = simnumber obsid = simnumber bluefile = os.path.join(self.result_path,'original_sky/IFS_' + \ bluefile = os.path.join(self.result_path, 'original_sky/IFS_' + self.source+'_'+str(obsid)+'_B.fits') self.source+'_'+str(obsid)+'_B.fits') redfile = os.path.join(self.result_path,'original_sky/IFS_' + \ redfile = os.path.join(self.result_path, 'original_sky/IFS_' + self.source+'_'+str(obsid)+'_R.fits') self.source+'_'+str(obsid)+'_R.fits') fits.writeto(bluefile, blue_img.array, overwrite=True) fits.writeto(bluefile, blue_img.array, overwrite=True) Loading Loading @@ -5333,13 +5343,15 @@ class IFSsimulator(): # load HgAr data; # load HgAr data; if self.source == 'LAMP': if self.source == 'LAMP': matfn3 = os.path.join(self.information['dir_path'],'IFS_inputdata/HgAr.mat') matfn3 = os.path.join( self.information['dir_path'], 'IFS_inputdata/HgAr.mat') self.log.info('lamp flux file is : %s' % (matfn3)) self.log.info('lamp flux file is : %s' % (matfn3)) da3 = sio.loadmat(matfn3) da3 = sio.loadmat(matfn3) HgArst = da3['HgArst'] # opd unit is in meter HgArst = da3['HgArst'] # opd unit is in meter # load flat data # load flat data if self.source == 'FLAT': if self.source == 'FLAT': matfn3 = os.path.join(self.information['dir_path'],'IFS_inputdata/flat_light.mat') matfn3 = os.path.join( self.information['dir_path'], 'IFS_inputdata/flat_light.mat') self.log.info('flat flux file is : %s' % (matfn3)) self.log.info('flat flux file is : %s' % (matfn3)) da3 = sio.loadmat(matfn3) da3 = sio.loadmat(matfn3) flat_light = da3['flat_light'] # opd unit is in meter flat_light = da3['flat_light'] # opd unit is in meter Loading Loading @@ -5622,10 +5634,10 @@ class IFSsimulator(): data_time = now.strftime("%Y-%m-%d") data_time = now.strftime("%Y-%m-%d") # write the actual file # write the actual file bluefile = os.path.join(self.result_path,'original_Calibration/IFS_'+self.source + \ bluefile = os.path.join(self.result_path, 'original_Calibration/IFS_'+self.source + '_'+data_time+'_'+str(self.simnumber)+'_B_original.fits') '_'+data_time+'_'+str(self.simnumber)+'_B_original.fits') redfile = os.path.join(self.result_path,'original_Calibration/IFS_'+self.source + \ redfile = os.path.join(self.result_path, 'original_Calibration/IFS_'+self.source + '_'+data_time+'_'+str(self.simnumber)+'_R_original.fits') '_'+data_time+'_'+str(self.simnumber)+'_R_original.fits') fits.writeto(bluefile, blue_img.array, overwrite=True) fits.writeto(bluefile, blue_img.array, overwrite=True) Loading @@ -5646,7 +5658,8 @@ class IFSsimulator(): newd = fits.HDUList([hdu1, hdu2]) newd = fits.HDUList([hdu1, hdu2]) filename = os.path.join(self.result_path,'calibration_Data/'+self.source+'_flux.fits') filename = os.path.join( self.result_path, 'calibration_Data/'+self.source+'_flux.fits') if self.simnumber == 1: if self.simnumber == 1: newd.writeto(filename, overwrite=True) newd.writeto(filename, overwrite=True) Loading Loading @@ -5715,7 +5728,8 @@ class IFSsimulator(): if simnumber <= 200 and simnumber > 150: if simnumber <= 200 and simnumber > 150: self.information['exptime'] = 1200 self.information['exptime'] = 1200 self.skyfilepath = os.path.join(self.information['dir_path'],self.information['sky_fitsin']) self.skyfilepath = os.path.join( self.information['dir_path'], self.information['sky_fitsin']) print('self.skyfilepath = ', self.skyfilepath) print('self.skyfilepath = ', self.skyfilepath) Loading