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()
...@@ -47,44 +49,45 @@ class CDM03bidir(): ...@@ -47,44 +49,45 @@ class CDM03bidir():
# #default CDM03 settings # #default CDM03 settings
# self.params = dict(beta_p=0.6, beta_s=0.6, fwc=200000., vth=1.168e7, vg=6.e-11, t=20.48e-3, # self.params = dict(beta_p=0.6, beta_s=0.6, fwc=200000., vth=1.168e7, vg=6.e-11, t=20.48e-3,
# sfwc=730000., svg=1.0e-10, st=5.0e-6, parallel=1., serial=1.) # sfwc=730000., svg=1.0e-10, st=5.0e-6, parallel=1., serial=1.)
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,8 +135,8 @@ class CDM03bidir(): ...@@ -133,8 +135,8 @@ 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,27 +160,22 @@ class CDM03bidir(): ...@@ -158,27 +160,22 @@ 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
CTIed = cdm03bidir.cdm03(np.asfortranarray(data), CTIed = cdm03bidir.cdm03(np.asfortranarray(data),
jflip, iflip, jflip, iflip,
self.values['dob'], self.values['rdose'], self.values['dob'], self.values['rdose'],
self.nt_p, self.sigma_p, self.taur_p, self.nt_p, self.sigma_p, self.taur_p,
self.nt_s, self.sigma_s, self.taur_s, self.nt_s, self.sigma_s, self.taur_s,
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,27 +35,28 @@ class TestDemoFunction(unittest.TestCase): ...@@ -35,27 +35,28 @@ 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'
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.",
) )
############################################################## ##############################################################
def test_ifs_sim_2(self): def test_ifs_sim_2(self):
""" """
...@@ -73,26 +74,27 @@ class TestDemoFunction(unittest.TestCase): ...@@ -73,26 +74,27 @@ 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'
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.",
) )
################################################################### ###################################################################
def test_ifs_sim_3(self): def test_ifs_sim_3(self):
""" """
...@@ -110,26 +112,27 @@ class TestDemoFunction(unittest.TestCase): ...@@ -110,26 +112,27 @@ 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'
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.",
) )
################################################################### ###################################################################
def test_ifs_sim_4(self): def test_ifs_sim_4(self):
""" """
...@@ -147,27 +150,28 @@ class TestDemoFunction(unittest.TestCase): ...@@ -147,27 +150,28 @@ 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'
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.",
) )
################################################################### ###################################################################
def test_ifs_sim_5(self): def test_ifs_sim_5(self):
""" """
...@@ -185,25 +189,26 @@ class TestDemoFunction(unittest.TestCase): ...@@ -185,25 +189,26 @@ 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'
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.",
) )
################################################################### ###################################################################
def test_ifs_sim_6(self): def test_ifs_sim_6(self):
""" """
...@@ -221,24 +226,23 @@ class TestDemoFunction(unittest.TestCase): ...@@ -221,24 +226,23 @@ 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'
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