Commit 5070c190 authored by Yan Zhaojun's avatar Yan Zhaojun
Browse files

update

parent 8165a134
Pipeline #7134 failed with stage
in 0 seconds
...@@ -15,7 +15,7 @@ parameters in parallel and serial direction. ...@@ -15,7 +15,7 @@ parameters in parallel and serial direction.
import numpy as np import numpy as np
#CDM03bidir # CDM03bidir
class CDM03bidir(): class CDM03bidir():
""" """
Class to run CDM03 CTI model, class Fortran routine to perform the actual CDM03 calculations. Class to run CDM03 CTI model, class Fortran routine to perform the actual CDM03 calculations.
...@@ -27,6 +27,7 @@ class CDM03bidir(): ...@@ -27,6 +27,7 @@ class CDM03bidir():
:param log: instance to Python logging :param log: instance to Python logging
:type log: logging instance :type log: logging instance
""" """
def __init__(self, settings, data, log=None): def __init__(self, settings, data, log=None):
""" """
Class constructor. Class constructor.
...@@ -39,7 +40,8 @@ class CDM03bidir(): ...@@ -39,7 +40,8 @@ class CDM03bidir():
:type log: logging instance :type log: logging instance
""" """
self.data = data self.data = data
self.values = dict(quads=(0,1,2,3), xsize=2048, ysize=2066, dob=0.0, rdose=8.0e9) self.values = dict(quads=(0, 1, 2, 3), xsize=2048,
ysize=2066, dob=0.0, rdose=8.0e9)
self.values.update(settings) self.values.update(settings)
self.log = log self.log = log
self._setupLogger() self._setupLogger()
...@@ -51,40 +53,41 @@ class CDM03bidir(): ...@@ -51,40 +53,41 @@ class CDM03bidir():
self.params = dict(beta_p=0.6, beta_s=0.6, fwc=100000., vth=1.168e7, vg=6.e-11, t=1.0e-3, self.params = dict(beta_p=0.6, beta_s=0.6, fwc=100000., vth=1.168e7, vg=6.e-11, t=1.0e-3,
sfwc=700000., svg=1.0e-10, st=1.0e-6, parallel=1., serial=0.) sfwc=700000., svg=1.0e-10, st=1.0e-6, parallel=1., serial=0.)
#update with inputs # update with inputs
self.params.update(self.values) self.params.update(self.values)
#read in trap information # read in trap information
trapdata = np.loadtxt(self.values['dir_path']+self.values['paralleltrapfile']) trapdata = np.loadtxt(
self.values['dir_path']+self.values['paralleltrapfile'])
if trapdata.ndim > 1: if trapdata.ndim > 1:
self.nt_p = trapdata[:, 0] self.nt_p = trapdata[:, 0]
self.sigma_p = trapdata[:, 1] self.sigma_p = trapdata[:, 1]
self.taur_p = trapdata[:, 2] self.taur_p = trapdata[:, 2]
else: else:
#only one trap species # only one trap species
self.nt_p = [trapdata[0],] self.nt_p = [trapdata[0],]
self.sigma_p = [trapdata[1],] self.sigma_p = [trapdata[1],]
self.taur_p = [trapdata[2],] self.taur_p = [trapdata[2],]
trapdata = np.loadtxt(self.values['dir_path']+self.values['serialtrapfile']) trapdata = np.loadtxt(
self.values['dir_path']+self.values['serialtrapfile'])
if trapdata.ndim > 1: if trapdata.ndim > 1:
self.nt_s = trapdata[:, 0] self.nt_s = trapdata[:, 0]
self.sigma_s = trapdata[:, 1] self.sigma_s = trapdata[:, 1]
self.taur_s = trapdata[:, 2] self.taur_s = trapdata[:, 2]
else: else:
#only one trap species # only one trap species
self.nt_s = [trapdata[0],] self.nt_s = [trapdata[0],]
self.sigma_s = [trapdata[1],] self.sigma_s = [trapdata[1],]
self.taur_s = [trapdata[2],] self.taur_s = [trapdata[2],]
#scale thibaut's values # scale thibaut's values
if 'thibaut' in self.values['parallelTrapfile']: if 'thibaut' in self.values['parallelTrapfile']:
self.nt_p /= 0.576 #thibaut's values traps / pixel self.nt_p /= 0.576 # thibaut's values traps / pixel
self.sigma_p *= 1.e4 #thibaut's values in m**2 self.sigma_p *= 1.e4 # thibaut's values in m**2
if 'thibaut' in self.values['serialTrapfile']: if 'thibaut' in self.values['serialTrapfile']:
self.nt_s *= 0.576 #thibaut's values traps / pixel #should be division? self.nt_s *= 0.576 # thibaut's values traps / pixel #should be division?
self.sigma_s *= 1.e4 #thibaut's values in m**2 self.sigma_s *= 1.e4 # thibaut's values in m**2
def _setupLogger(self): def _setupLogger(self):
""" """
...@@ -94,7 +97,6 @@ class CDM03bidir(): ...@@ -94,7 +97,6 @@ class CDM03bidir():
# if self.log is None: # if self.log is None:
# self.logger = False # self.logger = False
def applyRadiationDamage(self, data, iquadrant=0): def applyRadiationDamage(self, data, iquadrant=0):
""" """
Apply radian damage based on FORTRAN CDM03 model. The method assumes that Apply radian damage based on FORTRAN CDM03 model. The method assumes that
...@@ -133,7 +135,7 @@ class CDM03bidir(): ...@@ -133,7 +135,7 @@ class CDM03bidir():
:return: image that has been run through the CDM03 model :return: image that has been run through the CDM03 model
:rtype: ndarray :rtype: ndarray
""""" """""
#return data # return data
iflip = iquadrant / 2 iflip = iquadrant / 2
jflip = iquadrant % 2 jflip = iquadrant % 2
...@@ -158,8 +160,8 @@ class CDM03bidir(): ...@@ -158,8 +160,8 @@ class CDM03bidir():
self.log.info('jflip=%i' % jflip) self.log.info('jflip=%i' % jflip)
################################################################################# #################################################################################
###modify # modify
#sys.path.append('../so') # sys.path.append('../so')
from ifs_so import cdm03bidir from ifs_so import cdm03bidir
# from ifs_so.cdm03.cpython-38-x86_64-linux-gnu import cdm03bidir # from ifs_so.cdm03.cpython-38-x86_64-linux-gnu import cdm03bidir
# import cdm03bidir # import cdm03bidir
...@@ -171,14 +173,9 @@ class CDM03bidir(): ...@@ -171,14 +173,9 @@ class CDM03bidir():
params, params,
[data.shape[0], data.shape[1], len(self.nt_p), len(self.nt_s), len(self.params)]) [data.shape[0], data.shape[1], len(self.nt_p), len(self.nt_s), len(self.params)])
return np.asanyarray(CTIed) return np.asanyarray(CTIed)
################################################################################################################# #################################################################################################################
################################################################################################################# #################################################################################################################
This diff is collapsed.
...@@ -15,7 +15,7 @@ from csst_ifs_sim import csst_ifs_sim ...@@ -15,7 +15,7 @@ from csst_ifs_sim import csst_ifs_sim
import sys import sys
### sys.path.append('IFS_git/csst_ifs_sim/csst_ifs_sim') # sys.path.append('IFS_git/csst_ifs_sim/csst_ifs_sim')
class TestDemoFunction(unittest.TestCase): class TestDemoFunction(unittest.TestCase):
...@@ -35,9 +35,9 @@ class TestDemoFunction(unittest.TestCase): ...@@ -35,9 +35,9 @@ class TestDemoFunction(unittest.TestCase):
This case aims to test whether the demo function returns `1` if input is `None`. This case aims to test whether the demo function returns `1` if input is `None`.
""" """
# demo function test # demo function test
dir_path = os.path.join(os.environ['UNIT_TEST_DATA_ROOT'],'ifs_sim/') dir_path = os.path.join(os.environ['UNIT_TEST_DATA_ROOT'], 'ifs_sim/')
print(dir_path) print(dir_path)
print(sys.version ) print(sys.version)
###configfile = dir_path+'IFS_inputdata/configData/IFS_sim_C90.config' ###configfile = dir_path+'IFS_inputdata/configData/IFS_sim_C90.config'
configfile = './csst_ifs_sim/ifs_data/IFS_sim_C90.config' configfile = './csst_ifs_sim/ifs_data/IFS_sim_C90.config'
...@@ -45,14 +45,15 @@ class TestDemoFunction(unittest.TestCase): ...@@ -45,14 +45,15 @@ class TestDemoFunction(unittest.TestCase):
sourcein = 'SCI' sourcein = 'SCI'
print(configfile) print(configfile)
debug=True debug = True
result_path=dir_path+'ifs_sim_result' result_path = dir_path+'ifs_sim_result'
csst_ifs_sim.runIFSsim(sourcein, configfile, dir_path, result_path, 1, debug,'no') csst_ifs_sim.runIFSsim(sourcein, configfile,
dir_path, result_path, 1, debug, 'no')
self.assertEqual( self.assertEqual(
1 , 1, 1, 1,
"case 1: SCI sim passes.", "case 1: SCI sim passes.",
) )
...@@ -73,9 +74,9 @@ class TestDemoFunction(unittest.TestCase): ...@@ -73,9 +74,9 @@ class TestDemoFunction(unittest.TestCase):
This case aims to test whether the demo function returns `1` if input is `None`. This case aims to test whether the demo function returns `1` if input is `None`.
""" """
# demo function test # demo function test
dir_path = os.path.join(os.environ['UNIT_TEST_DATA_ROOT'],'ifs_sim/') dir_path = os.path.join(os.environ['UNIT_TEST_DATA_ROOT'], 'ifs_sim/')
print(dir_path) print(dir_path)
print(sys.version ) print(sys.version)
###configfile = dir_path+'IFS_inputdata/configData/IFS_sim_C90.config' ###configfile = dir_path+'IFS_inputdata/configData/IFS_sim_C90.config'
configfile = './csst_ifs_sim/ifs_data/IFS_sim_C90.config' configfile = './csst_ifs_sim/ifs_data/IFS_sim_C90.config'
...@@ -83,13 +84,14 @@ class TestDemoFunction(unittest.TestCase): ...@@ -83,13 +84,14 @@ class TestDemoFunction(unittest.TestCase):
sourcein = 'BIAS' sourcein = 'BIAS'
print(configfile) print(configfile)
debug=True debug = True
result_path=dir_path+'ifs_sim_result' result_path = dir_path+'ifs_sim_result'
csst_ifs_sim.runIFSsim(sourcein, configfile, dir_path, result_path, 1, debug,'no') csst_ifs_sim.runIFSsim(sourcein, configfile,
dir_path, result_path, 1, debug, 'no')
self.assertEqual( self.assertEqual(
1 , 1, 1, 1,
"case 2: sim passes.", "case 2: sim passes.",
) )
...@@ -110,9 +112,9 @@ class TestDemoFunction(unittest.TestCase): ...@@ -110,9 +112,9 @@ class TestDemoFunction(unittest.TestCase):
This case aims to test whether the demo function returns `1` if input is `None`. This case aims to test whether the demo function returns `1` if input is `None`.
""" """
# demo function test # demo function test
dir_path = os.path.join(os.environ['UNIT_TEST_DATA_ROOT'],'ifs_sim/') dir_path = os.path.join(os.environ['UNIT_TEST_DATA_ROOT'], 'ifs_sim/')
print(dir_path) print(dir_path)
print(sys.version ) print(sys.version)
###configfile = dir_path+'IFS_inputdata/configData/IFS_sim_C90.config' ###configfile = dir_path+'IFS_inputdata/configData/IFS_sim_C90.config'
configfile = './csst_ifs_sim/ifs_data/IFS_sim_C90.config' configfile = './csst_ifs_sim/ifs_data/IFS_sim_C90.config'
...@@ -120,13 +122,14 @@ class TestDemoFunction(unittest.TestCase): ...@@ -120,13 +122,14 @@ class TestDemoFunction(unittest.TestCase):
sourcein = 'DARK' sourcein = 'DARK'
print(configfile) print(configfile)
debug=True debug = True
result_path=dir_path+'ifs_sim_result' result_path = dir_path+'ifs_sim_result'
csst_ifs_sim.runIFSsim(sourcein, configfile, dir_path, result_path, 1, debug,'no') csst_ifs_sim.runIFSsim(sourcein, configfile,
dir_path, result_path, 1, debug, 'no')
self.assertEqual( self.assertEqual(
1 , 1, 1, 1,
"case 3: sim passes.", "case 3: sim passes.",
) )
...@@ -147,9 +150,9 @@ class TestDemoFunction(unittest.TestCase): ...@@ -147,9 +150,9 @@ class TestDemoFunction(unittest.TestCase):
This case aims to test whether the demo function returns `1` if input is `None`. This case aims to test whether the demo function returns `1` if input is `None`.
""" """
# demo function test # demo function test
dir_path = os.path.join(os.environ['UNIT_TEST_DATA_ROOT'],'ifs_sim/') dir_path = os.path.join(os.environ['UNIT_TEST_DATA_ROOT'], 'ifs_sim/')
print(dir_path) print(dir_path)
print(sys.version ) print(sys.version)
###configfile = dir_path+'IFS_inputdata/configData/IFS_sim_C90.config' ###configfile = dir_path+'IFS_inputdata/configData/IFS_sim_C90.config'
configfile = './csst_ifs_sim/ifs_data/IFS_sim_C90.config' configfile = './csst_ifs_sim/ifs_data/IFS_sim_C90.config'
...@@ -157,14 +160,15 @@ class TestDemoFunction(unittest.TestCase): ...@@ -157,14 +160,15 @@ class TestDemoFunction(unittest.TestCase):
sourcein = 'LAMP' sourcein = 'LAMP'
print(configfile) print(configfile)
debug=True debug = True
result_path=dir_path+'ifs_sim_result' result_path = dir_path+'ifs_sim_result'
csst_ifs_sim.runIFSsim(sourcein, configfile, dir_path, result_path, 1, debug,'no') csst_ifs_sim.runIFSsim(sourcein, configfile,
dir_path, result_path, 1, debug, 'no')
self.assertEqual( self.assertEqual(
1 , 1, 1, 1,
"case 4: sim passes.", "case 4: sim passes.",
) )
...@@ -185,9 +189,9 @@ class TestDemoFunction(unittest.TestCase): ...@@ -185,9 +189,9 @@ class TestDemoFunction(unittest.TestCase):
This case aims to test whether the demo function returns `1` if input is `None`. This case aims to test whether the demo function returns `1` if input is `None`.
""" """
# demo function test # demo function test
dir_path = os.path.join(os.environ['UNIT_TEST_DATA_ROOT'],'ifs_sim/') dir_path = os.path.join(os.environ['UNIT_TEST_DATA_ROOT'], 'ifs_sim/')
print(dir_path) print(dir_path)
print(sys.version ) print(sys.version)
###configfile = dir_path+'IFS_inputdata/configData/IFS_sim_C90.config' ###configfile = dir_path+'IFS_inputdata/configData/IFS_sim_C90.config'
configfile = './csst_ifs_sim/ifs_data/IFS_sim_C90.config' configfile = './csst_ifs_sim/ifs_data/IFS_sim_C90.config'
...@@ -195,12 +199,13 @@ class TestDemoFunction(unittest.TestCase): ...@@ -195,12 +199,13 @@ class TestDemoFunction(unittest.TestCase):
sourcein = 'LAMP' sourcein = 'LAMP'
print(configfile) print(configfile)
debug=True debug = True
result_path=dir_path+'ifs_sim_result' result_path = dir_path+'ifs_sim_result'
csst_ifs_sim.runIFSsim(sourcein, configfile, dir_path, result_path, 1, debug,'yes') csst_ifs_sim.runIFSsim(sourcein, configfile,
dir_path, result_path, 1, debug, 'yes')
self.assertEqual( self.assertEqual(
1 , 1, 1, 1,
"case 5: sim passes.", "case 5: sim passes.",
) )
...@@ -221,9 +226,9 @@ class TestDemoFunction(unittest.TestCase): ...@@ -221,9 +226,9 @@ class TestDemoFunction(unittest.TestCase):
This case aims to test whether the demo function returns `1` if input is `None`. This case aims to test whether the demo function returns `1` if input is `None`.
""" """
# demo function test # demo function test
dir_path = os.path.join(os.environ['UNIT_TEST_DATA_ROOT'],'ifs_sim/') dir_path = os.path.join(os.environ['UNIT_TEST_DATA_ROOT'], 'ifs_sim/')
print(dir_path) print(dir_path)
print(sys.version ) print(sys.version)
###configfile = dir_path+'IFS_inputdata/configData/IFS_sim_C90.config' ###configfile = dir_path+'IFS_inputdata/configData/IFS_sim_C90.config'
configfile = './csst_ifs_sim/ifs_data/IFS_sim_C90.config' configfile = './csst_ifs_sim/ifs_data/IFS_sim_C90.config'
...@@ -231,14 +236,13 @@ class TestDemoFunction(unittest.TestCase): ...@@ -231,14 +236,13 @@ class TestDemoFunction(unittest.TestCase):
sourcein = 'FLAT' sourcein = 'FLAT'
print(configfile) print(configfile)
debug=True debug = True
result_path=dir_path+'ifs_sim_result' result_path = dir_path+'ifs_sim_result'
csst_ifs_sim.runIFSsim(sourcein, configfile, dir_path, result_path, 1, debug, 'no') csst_ifs_sim.runIFSsim(sourcein, configfile,
dir_path, result_path, 1, debug, 'no')
self.assertEqual( self.assertEqual(
1 , 1, 1, 1,
"case 6: sim passes.", "case 6: sim passes.",
) )
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment