Loading csst_ifs_sim/csst_ifs_sim.py +72 −76 Original line number Diff line number Diff line Loading @@ -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 ###################################################################### Loading Loading @@ -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': Loading Loading @@ -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) ########################################################## ######################################################################### Loading Loading @@ -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 ########################################################################## Loading Loading @@ -2895,35 +2891,35 @@ class IFSsimulator(): ############################################################################## 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 # def applyImageRotate(self): # """ 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): Loading Loading @@ -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': Loading tests/test_ifs_sim.py +1 −1 Original line number Diff line number Diff line Loading @@ -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.", Loading Loading
csst_ifs_sim/csst_ifs_sim.py +72 −76 Original line number Diff line number Diff line Loading @@ -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 ###################################################################### Loading Loading @@ -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': Loading Loading @@ -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) ########################################################## ######################################################################### Loading Loading @@ -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 ########################################################################## Loading Loading @@ -2895,35 +2891,35 @@ class IFSsimulator(): ############################################################################## 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 # def applyImageRotate(self): # """ 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): Loading Loading @@ -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': Loading
tests/test_ifs_sim.py +1 −1 Original line number Diff line number Diff line Loading @@ -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.", Loading