Loading csst_mci_sim/CTI/CTI.py +0 −5 Original line number Diff line number Diff line Loading @@ -171,10 +171,5 @@ class CDM03bidir(): return np.asanyarray(CTIed) ################################################################################################################# ################################################################################################################# csst_mci_sim/support/MCIinstrumentModel.py +10 −10 Original line number Diff line number Diff line Loading @@ -49,19 +49,19 @@ def MCIinformation(): return out def CCDnonLinearityModel(data, beta=6e-7): """ # def CCDnonLinearityModel(data, beta=6e-7): # """ The non-linearity is modelled based on the results presented. :param data: data to which the non-linearity model is being applied to :type data: ndarray # The non-linearity is modelled based on the results presented. # :param data: data to which the non-linearity model is being applied to # :type data: ndarray :return: input data after conversion with the non-linearity model :rtype: float or ndarray """ out = data-beta*data**2 # :return: input data after conversion with the non-linearity model # :rtype: float or ndarray # """ # out = data-beta*data**2 return out # return out ################################################################### # if __name__ == '__main__': Loading csst_mci_sim/support/logger.py +15 −15 Original line number Diff line number Diff line Loading @@ -38,18 +38,18 @@ def setUpLogger(log_filename, loggername='logger'): return logger class SimpleLogger(object): """ A simple class to create a log file or print the information on screen. """ def __init__(self, filename, verbose=False): self.file = open(filename, 'w') self.verbose = verbose def write(self, text): """ Writes text either to file or screen. """ print >> self.file, text if self.verbose: print( text) # class SimpleLogger(object): # """ # A simple class to create a log file or print the information on screen. # """ # def __init__(self, filename, verbose=False): # self.file = open(filename, 'w') # self.verbose = verbose # def write(self, text): # """ # Writes text either to file or screen. # """ # print >> self.file, text # if self.verbose: print( text) csst_mci_sim/support/sed.py +1 −2 Original line number Diff line number Diff line Loading @@ -156,7 +156,6 @@ class Star_Temp(): self.path=path ####parent = os.path.dirname(os.path.realpath(__file__)) ###print("获取其父目录——" + parent) # 从当前文件路径中获取目录 hdulist = fits.open(path+'MCI_inputData/SED_Code/seddata/stellar_temp.fits') self.wave = hdulist[1].data['wave'] self.flux = hdulist[2].data Loading tests/test_mci_sim.py +144 −123 Original line number Diff line number Diff line Loading @@ -11,12 +11,9 @@ Modified-History: import unittest import os from csst_mci_sim import csst_mci_sim import sys import faulthandler from csst_mci_sim import csst_mci_sim class TestDemoFunction(unittest.TestCase): def test_mci_sim_1(self): Loading @@ -42,9 +39,8 @@ class TestDemoFunction(unittest.TestCase): print(dir_path) # 获取当前工作目录 current_path = os.getcwd() print("当前路径:", current_path) # current_path = os.getcwd() # print("当前路径:", current_path) configfile = dir_path+'MCI_inputData/configData/mci_all_9K.config' Loading @@ -55,138 +51,163 @@ class TestDemoFunction(unittest.TestCase): self.assertEqual( 1 , 1, "case 1: SCI sim passes.", "case 1: EXDF sim passes.", ) ############################################# def test_mci_sim_2(self): """ Aim --- Test mci sim function: STAR case. # def test_ifs_sim_2(self): # """ # Aim # --- # Test ifs sim function: BIAS case. Criteria -------- Pass if the demo function returns `1`. Details ------- The demo function returns the length of the input argument list. This case aims to test whether the demo function returns `1` if input is `None`. """ faulthandler.enable() # demo function test dir_path = os.path.join(os.environ['UNIT_TEST_DATA_ROOT'],'mci_sim/') print(dir_path) # 获取当前工作目录 # current_path = os.getcwd() # print("当前路径:", current_path) configfile = dir_path+'MCI_inputData/configData/mci_all_9K.config' sourcein = 'STAR' print(configfile) csst_mci_sim.runMCIsim(sourcein, configfile, dir_path, 1) self.assertEqual( 1 , 1, "case 2: STAR sim passes.", ) ######################################################### def test_mci_sim_3(self): """ Aim --- Test mci sim function: BIAS case. Criteria -------- Pass if the demo function returns `1`. Details ------- The demo function returns the length of the input argument list. This case aims to test whether the demo function returns `1` if input is `None`. """ faulthandler.enable() # demo function test dir_path = os.path.join(os.environ['UNIT_TEST_DATA_ROOT'],'mci_sim/') print(dir_path) # 获取当前工作目录 # current_path = os.getcwd() # print("当前路径:", current_path) configfile = dir_path+'MCI_inputData/configData/mci_all_9K.config' sourcein = 'BIAS' print(configfile) csst_mci_sim.runMCIsim(sourcein, configfile, dir_path, 1) self.assertEqual( 1 , 1, "case 3: BIAS sim passes.", ) ######################################################### def test_mci_sim_4(self): """ Aim --- Test mci sim function: DARK case. Criteria -------- Pass if the demo function returns `1`. Details ------- The demo function returns the length of the input argument list. This case aims to test whether the demo function returns `1` if input is `None`. """ faulthandler.enable() # demo function test dir_path = os.path.join(os.environ['UNIT_TEST_DATA_ROOT'],'mci_sim/') print(dir_path) # 获取当前工作目录 # current_path = os.getcwd() # print("当前路径:", current_path) configfile = dir_path+'MCI_inputData/configData/mci_all_9K.config' sourcein = 'DARK' print(configfile) csst_mci_sim.runMCIsim(sourcein, configfile, dir_path, 1) self.assertEqual( 1 , 1, "case 4: DARK sim passes.", ) ######################################################### def test_mci_sim_5(self): """ Aim --- Test mci sim function: FLAT case. Criteria -------- Pass if the demo function returns `1`. Details ------- The demo function returns the length of the input argument list. This case aims to test whether the demo function returns `1` if input is `None`. """ faulthandler.enable() # demo function test dir_path = os.path.join(os.environ['UNIT_TEST_DATA_ROOT'],'mci_sim/') print(dir_path) # 获取当前工作目录 # current_path = os.getcwd() # print("当前路径:", current_path) configfile = dir_path+'MCI_inputData/configData/mci_all_9K.config' sourcein = 'FLAT' print(configfile) csst_mci_sim.runMCIsim(sourcein, configfile, dir_path, 1) self.assertEqual( 1 , 1, "case 5: FLAT sim passes.", ) # Criteria # -------- # Pass if the demo function returns `1`. # Details # ------- # The demo function returns the length of the input argument list. # This case aims to test whether the demo function returns `1` if input is `None`. # """ # # demo function test # dir_path=os.path.join(os.environ['UNIT_TEST_DATA_ROOT'],'ifs_sim') # csst_ifs_sim(dir_path,BIAS) # self.assertTrue( # 1 == 1, # "case 2 :BIAS sim passes.", # ) # def test_ifs_sim_3(self): # """ # Aim # --- # Test ifs sim function: DARK case. # Criteria # -------- # Pass if the demo function returns `1`. # Details # ------- # The demo function returns the length of the input argument list. # This case aims to test whether the demo function returns `1` if input is `None`. # """ # # demo function test # dir_path=os.path.join(os.environ['UNIT_TEST_DATA_ROOT'],'ifs_sim') # csst_ifs_sim(dir_path,'DARK') # self.assertTrue( # 1 == 1, # "case 3 :DARK sim passes.", # ) # def test_ifs_sim_4(self): # """ # Aim # --- # Test ifs sim function: LAMP case. # Criteria # -------- # Pass if the demo function returns `1`. # Details # ------- # The demo function returns the length of the input argument list. # This case aims to test whether the demo function returns `1` if input is `None`. # """ # # demo function test # dir_path=os.path.join(os.environ['UNIT_TEST_DATA_ROOT'],'ifs_sim') # csst_ifs_sim(dir_path,'LAMP') # self.assertTrue( # 1 == 1, # "case 4 :LAMP sim passes.", # ) # def test_ifs_sim_5(self): # """ # Aim # --- # Test ifs sim function: FLAT case. # Criteria # -------- # Pass if the demo function returns `1`. # Details # ------- # The demo function returns the length of the input argument list. # This case aims to test whether the demo function returns `1` if input is `None`. # """ # # demo function test # dir_path=os.path.join(os.environ['UNIT_TEST_DATA_ROOT'],'ifs_sim') # csst_ifs_sim(dir_path,'FLAT') # self.assertTrue( # 1 == 1, # "case 5 :FLAT sim passes.", # ) # def test_ifs_sim_6(self): # """ # Aim # --- # Test ifs sim function: hole case. # Criteria # -------- # Pass if the demo function returns `1`. # Details # ------- # The demo function returns the length of the input argument list. # This case aims to test whether the demo function returns `1` if input is `None`. # """ # # demo function test # dir_path=os.path.join(os.environ['UNIT_TEST_DATA_ROOT'],'ifs_sim') # csst_ifs_sim(dir_path,'LAMP', 'yes') # self.assertTrue( # 1 == 1, # "case 6 :Hole sim passes.", # ) ############################################################################ No newline at end of file Loading
csst_mci_sim/CTI/CTI.py +0 −5 Original line number Diff line number Diff line Loading @@ -171,10 +171,5 @@ class CDM03bidir(): return np.asanyarray(CTIed) ################################################################################################################# #################################################################################################################
csst_mci_sim/support/MCIinstrumentModel.py +10 −10 Original line number Diff line number Diff line Loading @@ -49,19 +49,19 @@ def MCIinformation(): return out def CCDnonLinearityModel(data, beta=6e-7): """ # def CCDnonLinearityModel(data, beta=6e-7): # """ The non-linearity is modelled based on the results presented. :param data: data to which the non-linearity model is being applied to :type data: ndarray # The non-linearity is modelled based on the results presented. # :param data: data to which the non-linearity model is being applied to # :type data: ndarray :return: input data after conversion with the non-linearity model :rtype: float or ndarray """ out = data-beta*data**2 # :return: input data after conversion with the non-linearity model # :rtype: float or ndarray # """ # out = data-beta*data**2 return out # return out ################################################################### # if __name__ == '__main__': Loading
csst_mci_sim/support/logger.py +15 −15 Original line number Diff line number Diff line Loading @@ -38,18 +38,18 @@ def setUpLogger(log_filename, loggername='logger'): return logger class SimpleLogger(object): """ A simple class to create a log file or print the information on screen. """ def __init__(self, filename, verbose=False): self.file = open(filename, 'w') self.verbose = verbose def write(self, text): """ Writes text either to file or screen. """ print >> self.file, text if self.verbose: print( text) # class SimpleLogger(object): # """ # A simple class to create a log file or print the information on screen. # """ # def __init__(self, filename, verbose=False): # self.file = open(filename, 'w') # self.verbose = verbose # def write(self, text): # """ # Writes text either to file or screen. # """ # print >> self.file, text # if self.verbose: print( text)
csst_mci_sim/support/sed.py +1 −2 Original line number Diff line number Diff line Loading @@ -156,7 +156,6 @@ class Star_Temp(): self.path=path ####parent = os.path.dirname(os.path.realpath(__file__)) ###print("获取其父目录——" + parent) # 从当前文件路径中获取目录 hdulist = fits.open(path+'MCI_inputData/SED_Code/seddata/stellar_temp.fits') self.wave = hdulist[1].data['wave'] self.flux = hdulist[2].data Loading
tests/test_mci_sim.py +144 −123 Original line number Diff line number Diff line Loading @@ -11,12 +11,9 @@ Modified-History: import unittest import os from csst_mci_sim import csst_mci_sim import sys import faulthandler from csst_mci_sim import csst_mci_sim class TestDemoFunction(unittest.TestCase): def test_mci_sim_1(self): Loading @@ -42,9 +39,8 @@ class TestDemoFunction(unittest.TestCase): print(dir_path) # 获取当前工作目录 current_path = os.getcwd() print("当前路径:", current_path) # current_path = os.getcwd() # print("当前路径:", current_path) configfile = dir_path+'MCI_inputData/configData/mci_all_9K.config' Loading @@ -55,138 +51,163 @@ class TestDemoFunction(unittest.TestCase): self.assertEqual( 1 , 1, "case 1: SCI sim passes.", "case 1: EXDF sim passes.", ) ############################################# def test_mci_sim_2(self): """ Aim --- Test mci sim function: STAR case. # def test_ifs_sim_2(self): # """ # Aim # --- # Test ifs sim function: BIAS case. Criteria -------- Pass if the demo function returns `1`. Details ------- The demo function returns the length of the input argument list. This case aims to test whether the demo function returns `1` if input is `None`. """ faulthandler.enable() # demo function test dir_path = os.path.join(os.environ['UNIT_TEST_DATA_ROOT'],'mci_sim/') print(dir_path) # 获取当前工作目录 # current_path = os.getcwd() # print("当前路径:", current_path) configfile = dir_path+'MCI_inputData/configData/mci_all_9K.config' sourcein = 'STAR' print(configfile) csst_mci_sim.runMCIsim(sourcein, configfile, dir_path, 1) self.assertEqual( 1 , 1, "case 2: STAR sim passes.", ) ######################################################### def test_mci_sim_3(self): """ Aim --- Test mci sim function: BIAS case. Criteria -------- Pass if the demo function returns `1`. Details ------- The demo function returns the length of the input argument list. This case aims to test whether the demo function returns `1` if input is `None`. """ faulthandler.enable() # demo function test dir_path = os.path.join(os.environ['UNIT_TEST_DATA_ROOT'],'mci_sim/') print(dir_path) # 获取当前工作目录 # current_path = os.getcwd() # print("当前路径:", current_path) configfile = dir_path+'MCI_inputData/configData/mci_all_9K.config' sourcein = 'BIAS' print(configfile) csst_mci_sim.runMCIsim(sourcein, configfile, dir_path, 1) self.assertEqual( 1 , 1, "case 3: BIAS sim passes.", ) ######################################################### def test_mci_sim_4(self): """ Aim --- Test mci sim function: DARK case. Criteria -------- Pass if the demo function returns `1`. Details ------- The demo function returns the length of the input argument list. This case aims to test whether the demo function returns `1` if input is `None`. """ faulthandler.enable() # demo function test dir_path = os.path.join(os.environ['UNIT_TEST_DATA_ROOT'],'mci_sim/') print(dir_path) # 获取当前工作目录 # current_path = os.getcwd() # print("当前路径:", current_path) configfile = dir_path+'MCI_inputData/configData/mci_all_9K.config' sourcein = 'DARK' print(configfile) csst_mci_sim.runMCIsim(sourcein, configfile, dir_path, 1) self.assertEqual( 1 , 1, "case 4: DARK sim passes.", ) ######################################################### def test_mci_sim_5(self): """ Aim --- Test mci sim function: FLAT case. Criteria -------- Pass if the demo function returns `1`. Details ------- The demo function returns the length of the input argument list. This case aims to test whether the demo function returns `1` if input is `None`. """ faulthandler.enable() # demo function test dir_path = os.path.join(os.environ['UNIT_TEST_DATA_ROOT'],'mci_sim/') print(dir_path) # 获取当前工作目录 # current_path = os.getcwd() # print("当前路径:", current_path) configfile = dir_path+'MCI_inputData/configData/mci_all_9K.config' sourcein = 'FLAT' print(configfile) csst_mci_sim.runMCIsim(sourcein, configfile, dir_path, 1) self.assertEqual( 1 , 1, "case 5: FLAT sim passes.", ) # Criteria # -------- # Pass if the demo function returns `1`. # Details # ------- # The demo function returns the length of the input argument list. # This case aims to test whether the demo function returns `1` if input is `None`. # """ # # demo function test # dir_path=os.path.join(os.environ['UNIT_TEST_DATA_ROOT'],'ifs_sim') # csst_ifs_sim(dir_path,BIAS) # self.assertTrue( # 1 == 1, # "case 2 :BIAS sim passes.", # ) # def test_ifs_sim_3(self): # """ # Aim # --- # Test ifs sim function: DARK case. # Criteria # -------- # Pass if the demo function returns `1`. # Details # ------- # The demo function returns the length of the input argument list. # This case aims to test whether the demo function returns `1` if input is `None`. # """ # # demo function test # dir_path=os.path.join(os.environ['UNIT_TEST_DATA_ROOT'],'ifs_sim') # csst_ifs_sim(dir_path,'DARK') # self.assertTrue( # 1 == 1, # "case 3 :DARK sim passes.", # ) # def test_ifs_sim_4(self): # """ # Aim # --- # Test ifs sim function: LAMP case. # Criteria # -------- # Pass if the demo function returns `1`. # Details # ------- # The demo function returns the length of the input argument list. # This case aims to test whether the demo function returns `1` if input is `None`. # """ # # demo function test # dir_path=os.path.join(os.environ['UNIT_TEST_DATA_ROOT'],'ifs_sim') # csst_ifs_sim(dir_path,'LAMP') # self.assertTrue( # 1 == 1, # "case 4 :LAMP sim passes.", # ) # def test_ifs_sim_5(self): # """ # Aim # --- # Test ifs sim function: FLAT case. # Criteria # -------- # Pass if the demo function returns `1`. # Details # ------- # The demo function returns the length of the input argument list. # This case aims to test whether the demo function returns `1` if input is `None`. # """ # # demo function test # dir_path=os.path.join(os.environ['UNIT_TEST_DATA_ROOT'],'ifs_sim') # csst_ifs_sim(dir_path,'FLAT') # self.assertTrue( # 1 == 1, # "case 5 :FLAT sim passes.", # ) # def test_ifs_sim_6(self): # """ # Aim # --- # Test ifs sim function: hole case. # Criteria # -------- # Pass if the demo function returns `1`. # Details # ------- # The demo function returns the length of the input argument list. # This case aims to test whether the demo function returns `1` if input is `None`. # """ # # demo function test # dir_path=os.path.join(os.environ['UNIT_TEST_DATA_ROOT'],'ifs_sim') # csst_ifs_sim(dir_path,'LAMP', 'yes') # self.assertTrue( # 1 == 1, # "case 6 :Hole sim passes.", # ) ############################################################################ No newline at end of file