From cffedd63918c9e7edb873f9e3709afa30e279130 Mon Sep 17 00:00:00 2001 From: yan Date: Tue, 16 Apr 2024 09:35:01 +0800 Subject: [PATCH] debug --- csst_ifs_sim/csst_ifs_sim.py | 148 +++++++++++++++++------------------ tests/test_ifs_sim.py | 2 +- 2 files changed, 73 insertions(+), 77 deletions(-) diff --git a/csst_ifs_sim/csst_ifs_sim.py b/csst_ifs_sim/csst_ifs_sim.py index e8d2134..20823ef 100644 --- a/csst_ifs_sim/csst_ifs_sim.py +++ b/csst_ifs_sim/csst_ifs_sim.py @@ -1339,28 +1339,24 @@ class IFSsimulator(): self.section, 'save_cosmicrays') self.sky_noise = self.config.getboolean(self.section, 'sky_noise') - try: - self.nonlinearity = self.config.getboolean( - self.section, 'nonlinearity') - except: - self.nonlinearity = False - - try: - self.flatfieldM = self.config.getboolean( - self.section, 'flatfieldM') - except: - self.flatfieldM = False - - try: - self.readoutNoise = self.config.getboolean( - self.section, 'readoutnoise') - except: - self.readoutNoise = True - - try: - self.intscale = self.config.getboolean(self.section, 'intscale') - except: - self.intscale = True + + self.nonlinearity = self.config.getboolean( + self.section, 'nonlinearity') + + + + self.flatfieldM = self.config.getboolean( + self.section, 'flatfieldM') + + + + self.readoutNoise = self.config.getboolean( + self.section, 'readoutnoise') + + + + self.intscale = self.config.getboolean(self.section, 'intscale') + ###################################################################### @@ -1673,7 +1669,7 @@ class IFSsimulator(): result_day = now.strftime("%Y-%m-%d") - self.information['holemask'] + # self.information['holemask'] if self.source == 'LAMP': if self.information['holemask'] == 'yes': @@ -2100,13 +2096,13 @@ class IFSsimulator(): self.log.info( 'The cosmic ray in red channel covering factor is %i pixels ' % area_cr_r) - if self.save_cosmicrays: + # if self.save_cosmicrays: - self.log.info('Saved the cosmicRays fits...') - fits.writeto(self.result_path+'/calibration_Data/cosmicMap_B_SN_'+str( - self.simnumber)+'_exp_'+str(idk)+'.fits', np.int32(CCD_cr_b), overwrite=True) - fits.writeto(self.result_path+'/calibration_Data/cosmicMap_R_SN_'+str( - self.simnumber)+'_exp_'+str(idk)+'.fits', np.int32(CCD_cr_r), overwrite=True) + # self.log.info('Saved the cosmicRays fits...') + # fits.writeto(self.result_path+'/calibration_Data/cosmicMap_B_SN_'+str( + # self.simnumber)+'_exp_'+str(idk)+'.fits', np.int32(CCD_cr_b), overwrite=True) + # fits.writeto(self.result_path+'/calibration_Data/cosmicMap_R_SN_'+str( + # self.simnumber)+'_exp_'+str(idk)+'.fits', np.int32(CCD_cr_r), overwrite=True) ########################################################## ######################################################################### @@ -2229,33 +2225,33 @@ class IFSsimulator(): ############################################################################## - def applyCosmicBackground(self): - """ + # def applyCosmicBackground(self): + # """ - Returns - ------- - None. + # Returns + # ------- + # None. - """ - """ - Apply dark the cosmic background. Scales the background with the exposure time. + # """ + # """ + # Apply dark the cosmic background. Scales the background with the exposure time. - Additionally saves the image without noise to a FITS file. - """ + # Additionally saves the image without noise to a FITS file. + # """ - # add background - bcgr = self.information['exptime'] * self.information['cosmic_bkgd'] + # # add background + # bcgr = self.information['exptime'] * self.information['cosmic_bkgd'] - self.image_b += bcgr - self.image_r += bcgr + # self.image_b += bcgr + # self.image_r += bcgr - self.log.info('Added cosmic background = %f' % bcgr) + # self.log.info('Added cosmic background = %f' % bcgr) - if self.cosmicRays: - #self.imagenoCR += bcgr - self.imagenoCR_b += bcgr - self.imagenoCR_r += bcgr + # if self.cosmicRays: + + # self.imagenoCR_b += bcgr + # self.imagenoCR_r += bcgr ########################################################################## @@ -2895,35 +2891,35 @@ class IFSsimulator(): ############################################################################## - def applyImageRotate(self): - """ + # def applyImageRotate(self): + # """ - Returns - ------- - None. - - """ - np.random.seed(10*self.simnumber) - ud = np.random.random() # Choose a random rotation - angle = 2 * (ud-0.5) * self.information['tel_rotmax'] - - inputimg = self.image_b.copy() - # here we choose reshape=False, the rotated image will - rotimg = ndimage.rotate( - inputimg, angle+self.information['rotate_b'], order=1, reshape=False) - self.image_b = rotimg - - inputimg = self.image_r.copy() - # here we choose reshape=False, the rotated image will - rotimg = ndimage.rotate( - inputimg, angle+self.information['rotate_r'], order=1, reshape=False) - self.image_r = rotimg - - self.information['Tel_rot'] = angle + # Returns + # ------- + # None. - self.log.info( - 'Applied telescope rotation with angle (in degree)= %f.', angle) + # """ + # np.random.seed(10*self.simnumber) + # ud = np.random.random() # Choose a random rotation + # angle = 2 * (ud-0.5) * self.information['tel_rotmax'] + + # inputimg = self.image_b.copy() + # # here we choose reshape=False, the rotated image will + # rotimg = ndimage.rotate( + # inputimg, angle+self.information['rotate_b'], order=1, reshape=False) + # self.image_b = rotimg + + # inputimg = self.image_r.copy() + # # here we choose reshape=False, the rotated image will + # rotimg = ndimage.rotate( + # inputimg, angle+self.information['rotate_r'], order=1, reshape=False) + # self.image_r = rotimg + + # self.information['Tel_rot'] = angle + + # self.log.info( + # 'Applied telescope rotation with angle (in degree)= %f.', angle) ############################################################################### def CCDreadout(self): @@ -3058,8 +3054,8 @@ class IFSsimulator(): )*self.information['exposuretimes'] write_end = self.dt.utcnow()+timedelta(seconds=tt) - write_time_utc = write_end.strftime("%Y-%m-%dT%H:%M:%S") - write_time_str = end.strftime("%Y-%m-%dT%H:%M:%S") + # write_time_utc = write_end.strftime("%Y-%m-%dT%H:%M:%S") + # write_time_str = end.strftime("%Y-%m-%dT%H:%M:%S") if self.source == 'SCI' or self.source == 'COMP': if self.source == 'SCI': diff --git a/tests/test_ifs_sim.py b/tests/test_ifs_sim.py index 2e9feec..ec3ec52 100644 --- a/tests/test_ifs_sim.py +++ b/tests/test_ifs_sim.py @@ -181,7 +181,7 @@ class TestDemoFunction(unittest.TestCase): print(configfile) debug=True - csst_ifs_sim.runIFSsim(sourcein, configfile, dir_path, 1, debug,'no') + csst_ifs_sim.runIFSsim(sourcein, configfile, dir_path, 1, debug,'yes') self.assertEqual( 1 , 1, "case 5: sim passes.", -- GitLab