diff --git a/csst_mci_sim/csst_mci_sim.py b/csst_mci_sim/csst_mci_sim.py index c8076ce4f2ace6568c13643734a84e639530ed63..d6a481777d008c9ba80865bc035642b08138d18d 100644 --- a/csst_mci_sim/csst_mci_sim.py +++ b/csst_mci_sim/csst_mci_sim.py @@ -213,7 +213,7 @@ def flux2ill(wave, flux): def ill2flux(E): # use template from sky_bkg (background_spec_hst.dat) - filename = '../MCI_inputData/refs/background_spec_hst.dat' + filename = self.information['dir_path']+'MCI_inputData/refs/background_spec_hst.dat' cat_spec = pd.read_csv(filename, sep='\s+', header=None, comment='#') wave0 = cat_spec[0].values # A spec0 = cat_spec[2].values # erg/s/cm^2/A/arcsec^2 @@ -276,7 +276,7 @@ def zodiacal(ra, dec, time): lamda = abs(lb_obj.lon.degree - lb_sun.lon.degree) # interpolated zodical surface brightness at 0.5 um - zodi = pd.read_csv('../MCI_inputData/refs/zodi_map.dat', sep='\s+', header=None, comment='#') + zodi = pd.read_csv(self.information['dir_path']+'MCI_inputData/refs/zodi_map.dat', sep='\s+', header=None, comment='#') beta_angle = np.array([0, 5, 10, 15, 20, 25, 30, 45, 60, 75]) lamda_angle = np.array([0, 5, 10, 15, 20, 25, 30, 35, 40, 45, 60, 75, 90, 105, 120, 135, 150, 165, 180]) @@ -289,7 +289,7 @@ def zodiacal(ra, dec, time): zodi_obj = f(beta, lamda) # # read the zodical spectrum in the ecliptic - cat_spec = pd.read_csv('../MCI_inputData/refs/solar_spec.dat', sep='\s+', header=None, comment='#') + cat_spec = pd.read_csv(self.information['dir_path']+'MCI_inputData/refs/solar_spec.dat', sep='\s+', header=None, comment='#') wave = cat_spec[0].values # A spec0 = cat_spec[1].values # zodi_norm = 252 # @@ -398,7 +398,7 @@ class StrayLight(object): self.equator = coord.SkyCoord(radec[0]*u.degree, radec[1]*u.degree,frame='icrs') self.ecliptic = self.equator.transform_to('barycentrictrueecliptic') self.pointing = transRaDec2D(radec[0], radec[1]) - self.slcdll = ctypes.CDLL('../MCI_inputData/refs/libstraylight.so') #dylib + self.slcdll = ctypes.CDLL(self.information['dir_path']+'MCI_inputData/refs/libstraylight.so') #dylib self.slcdll.Calculate.argtypes = [ctypes.c_double, ctypes.POINTER(ctypes.c_double), ctypes.POINTER(ctypes.c_double), ctypes.POINTER(ctypes.c_double), @@ -1003,7 +1003,7 @@ def cal_PSF_new(channel,wfetimes,oversampling): #waven # waven=4 # fieldn=10 - file='../MCI_inputData/MCI_wavefront/wave_'+str(waven+1)+'/wavefront/opd_'+str(i+1)+'.mat' + file=self.information['dir_path']+'MCI_inputData/MCI_wavefront/wave_'+str(waven+1)+'/wavefront/opd_'+str(i+1)+'.mat' data=sio.loadmat(file) opd=data['opd'] ## opd data; psf[channel][i,:,:]=opd2psf(wfetimes*opd, cwave[channel],oversampling) @@ -1031,7 +1031,7 @@ def cal_PSF_new(channel,wfetimes,oversampling): newd=fits.HDUList([hdu1,hdu2,hdu3]) - PSFfilename='../MCI_inputData/PSF/PSF_'+channel+'.fits' + PSFfilename=self.information['dir_path']+'MCI_inputData/PSF/PSF_'+channel+'.fits' newd.writeto(PSFfilename,overwrite=True) @@ -1055,7 +1055,7 @@ def cal_Filter_PSF(wfetimes): wavelist =np.array([255, 337,419,501,583,665,747,829,911,1000]) - filterP=np.load('../MCI_inputData/MCI_filters/mci_filterPWTC.npy',allow_pickle=True).item() + filterP=np.load(self.information['dir_path']+'MCI_inputData/MCI_filters/mci_filterPWTC.npy',allow_pickle=True).item() fn=np.arange(1,101,1) ### PSF field point ffx= 0.1+ 0.02222222*((fn-1)%10) @@ -1097,7 +1097,7 @@ def cal_Filter_PSF(wfetimes): #waven # waven=4 # fieldn=10 - file='../MCI_input/MCI_wavefront/wave_'+str(waven+1)+'/wavefront/opd_'+str(ii+1)+'.mat' + file=self.information['dir_path']+'MCI_input/MCI_wavefront/wave_'+str(waven+1)+'/wavefront/opd_'+str(ii+1)+'.mat' data=sio.loadmat(file) opd=data['opd'] ## opd data; for kk in range(7): @@ -1111,7 +1111,7 @@ def cal_Filter_PSF(wfetimes): if ii==0: psf[filtername]['psf_iwave'][kk]=wavek - np.save('../MCI_inputData/PSF/'+filtername+'_PSF.npy', psf[filtername]) + np.save(self.information['dir_path']+'mci_sim_result/'+filtername+'_PSF.npy', psf[filtername]) return @@ -1258,10 +1258,10 @@ class MCIsimulator(): self.information['I_filters']=["z", "y", "F815N", "CBI", "F925N", "F960M", "F968N", "F845M" ,"F850LP" ,"F814W"] #### load telescope efficiency data - self.tel_eff=np.load('../MCI_inputData/tel_eff/tel_eff.npy',allow_pickle=True).item() + self.tel_eff=np.load(self.information['dir_path']+('MCI_inputData/tel_eff/tel_eff.npy',allow_pickle=True).item() #### load MCI filter data - self.filterP=np.load('../MCI_inputData/MCI_filters/mci_filterPWTC.npy',allow_pickle=True).item() + self.filterP=np.load(self.information['dir_path']+'MCI_inputData/MCI_filters/mci_filterPWTC.npy',allow_pickle=True).item() ########################################################################### @@ -1270,10 +1270,25 @@ class MCIsimulator(): result_day=now.strftime("%Y-%m-%d") #self.result_path='../MCI_simData_'+result_day - if os.getcwd() =='/home/zjyan/work/MCI/simulator': - self.result_path='/data/mci_simData/'+result_day ### CSST1 + # if os.getcwd() =='/home/zjyan/work/MCI/simulator': + # self.result_path='/data/mci_simData/'+result_day ### CSST1 + # else: + # self.result_path='/home/yan/MCI/simData/'+result_day ### my PC + + if self.information['dir_path'] == '/nfsdata/share/simulation-unittest/mci_sim/': + self.result_path = self.information['dir_path'] + \ + 'mci_sim_result/'+result_day else: - self.result_path='/home/yan/MCI/simData/'+result_day ### my PC + + home_path = os.environ['HOME'] + + if home_path == '/home/yan': + + self.result_path = '../MCI_simData/'+self.source+ss+result_day + else: + self.result_path = '/data/mcisimdata/'+result_day + + if os.path.isdir(self.result_path)==False: os.mkdir(self.result_path) @@ -1547,13 +1562,13 @@ class MCIsimulator(): self.filter_psf=dict() filtername=self.filter_g - self.filter_psf['g']=np.load('../MCI_inputData/PSF/'+filtername+'_PSF.npy', allow_pickle=True).item() + self.filter_psf['g']=np.load(information['dir_path']+'MCI_inputData/PSF/'+filtername+'_PSF.npy', allow_pickle=True).item() filtername=self.filter_r - self.filter_psf['r']=np.load('../MCI_inputData/PSF/'+filtername+'_PSF.npy', allow_pickle=True).item() + self.filter_psf['r']=np.load(information['dir_path']+'MCI_inputData/PSF/'+filtername+'_PSF.npy', allow_pickle=True).item() filtername=self.filter_i - self.filter_psf['i']=np.load('../MCI_inputData/PSF/'+filtername+'_PSF.npy', allow_pickle=True).item() + self.filter_psf['i']=np.load(information['dir_path']+'MCI_inputData/PSF/'+filtername+'_PSF.npy', allow_pickle=True).item() return @@ -2388,19 +2403,19 @@ class MCIsimulator(): """ # read solar template - solar_template = pd.read_csv('../MCI_inputData/refs/solar_spec.dat', sep='\s+', + solar_template = pd.read_csv(information['dir_path']+'MCI_inputData/refs/solar_spec.dat', sep='\s+', header=None, comment='#') template_wave = solar_template[0].values template_flux = solar_template[1].values # read earth shine surface brightness - earthshine_curve = pd.read_csv('../MCI_inputData/refs/earthshine.dat', + earthshine_curve = pd.read_csv(information['dir_path']+'MCI_inputData/refs/earthshine.dat', header=None, comment='#') angle = earthshine_curve[0].values surface_brightness = earthshine_curve[1].values # read V-band throughtput - cat_filter_V = pd.read_csv('../MCI_inputData/refs/filter_Bessell_V.dat', sep='\s+', + cat_filter_V = pd.read_csv(information['dir_path']+'MCI_inputData/refs/filter_Bessell_V.dat', sep='\s+', header=None, comment='#') filter_wave = cat_filter_V[0].values filter_response = cat_filter_V[1].values @@ -2467,7 +2482,7 @@ class MCIsimulator(): lamda = abs(lb_obj.lon.degree - lb_sun.lon.degree) # interpolated zodical surface brightness at 0.5 um - zodi = pd.read_csv('../MCI_inputData/refs/zodi_map.dat', sep='\s+', header=None, comment='#') + zodi = pd.read_csv(information['dir_path']+'MCI_inputData/refs/zodi_map.dat', sep='\s+', header=None, comment='#') beta_angle = np.array([0, 5, 10, 15, 20, 25, 30, 45, 60, 75]) lamda_angle = np.array([0, 5, 10, 15, 20, 25, 30, 35, 40, 45, 60, 75, 90, 105, 120, 135, 150, 165, 180]) @@ -2476,7 +2491,7 @@ class MCIsimulator(): zodi_obj = f(beta, lamda) # 10^�? W m�? sr�? um�? # read the zodical spectrum in the ecliptic - cat_spec = pd.read_csv('../MCI_inputData/refs/solar_spec.dat', sep='\s+', header=None, comment='#') + cat_spec = pd.read_csv(information['dir_path']+'MCI_inputData/refs/solar_spec.dat', sep='\s+', header=None, comment='#') wave = cat_spec[0].values # A spec0 = cat_spec[1].values # 10^-8 W m^�? sr^�? μm^�? zodi_norm = 252 # 10^-8 W m^�? sr^�? μm^�? @@ -2671,7 +2686,7 @@ class MCIsimulator(): print('k2=',k2) # - filename='../MCI_inputData/galaxy_Input/noLens_SED_IMG_0.025_230626/Lens_img_cut_IMG_'+str(k2+1)+'.fits' + filename=information['dir_path']+'MCI_inputData/galaxy_Input/Lens_SED_IMG_0.025_230626/Lens_img_cut_IMG_'+str(k2+1)+'.fits' self.log.info('galaxy_Input image path is: %s' %(filename)) @@ -2682,7 +2697,7 @@ class MCIsimulator(): srcs_cat=fits.open(filename) #### load galaxy SED fitsfile ### - filename='../MCI_inputData/galaxy_Input/noLens_SED_IMG_0.025_230626/Lens_img_cut_SED_'+str(k2+1)+'.fits' + filename=information['dir_path']+'MCI_inputData/galaxy_Input/Lens_SED_IMG_0.025_230626/Lens_img_cut_SED_'+str(k2+1)+'.fits' srcs_sed=fits.open(filename) self.log.info('galaxy_Input SED path is: %s' %(filename)) @@ -3322,7 +3337,7 @@ class MCIsimulator(): .. Warning:: This method does not work if the input file has exactly one line. """ ####################################################################### - cosmetics = np.loadtxt('../MCI_inputData/data/Cosmetics_g.txt') + cosmetics = np.loadtxt(information['dir_path']+'MCI_inputData/data/Cosmetics_g.txt') x = np.round(cosmetics[:, 0]).astype(int) ## row number y = np.round(cosmetics[:, 1]).astype(int) ## col number @@ -3339,7 +3354,7 @@ class MCIsimulator(): self.log.info('x=%i, y=%i, value=%f' % (xc, yc, val)) ###################################################################### ####################################################################### - cosmetics = np.loadtxt('../MCI_inputData/data/Cosmetics_r.txt') + cosmetics = np.loadtxt(self.information['dir_path']+'MCI_inputData/data/Cosmetics_r.txt') x = np.round(cosmetics[:, 0]).astype(int) ## row number y = np.round(cosmetics[:, 1]).astype(int) ## col number @@ -3356,7 +3371,7 @@ class MCIsimulator(): self.log.info('x=%i, y=%i, value=%f' % (xc, yc, val)) ############################################################################## ####################################################################### - cosmetics = np.loadtxt('../MCI_inputData/data/Cosmetics_i.txt') + cosmetics = np.loadtxt(self.information['dir_path']+'MCI_inputData/data/Cosmetics_i.txt') x = np.round(cosmetics[:, 0]).astype(int) ## row number y = np.round(cosmetics[:, 1]).astype(int) ## col number @@ -4000,7 +4015,7 @@ class MCIsimulator(): if self.orbit_pars[-1,0]