Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
csst-sims
csst_ifs_sim
Commits
5070c190
Commit
5070c190
authored
Oct 28, 2024
by
Yan Zhaojun
Browse files
update
parent
8165a134
Pipeline
#7134
failed with stage
in 0 seconds
Changes
3
Pipelines
1
Expand all
Hide whitespace changes
Inline
Side-by-side
csst_ifs_sim/CTI/CTI.py
View file @
5070c190
...
...
@@ -15,7 +15,7 @@ parameters in parallel and serial direction.
import
numpy
as
np
#CDM03bidir
#
CDM03bidir
class
CDM03bidir
():
"""
Class to run CDM03 CTI model, class Fortran routine to perform the actual CDM03 calculations.
...
...
@@ -27,6 +27,7 @@ class CDM03bidir():
:param log: instance to Python logging
:type log: logging instance
"""
def
__init__
(
self
,
settings
,
data
,
log
=
None
):
"""
Class constructor.
...
...
@@ -39,7 +40,8 @@ class CDM03bidir():
:type log: logging instance
"""
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
.
log
=
log
self
.
_setupLogger
()
...
...
@@ -47,44 +49,45 @@ class CDM03bidir():
# #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,
# 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
,
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
)
#read in trap information
trapdata
=
np
.
loadtxt
(
self
.
values
[
'dir_path'
]
+
self
.
values
[
'paralleltrapfile'
])
# read in trap information
trapdata
=
np
.
loadtxt
(
self
.
values
[
'dir_path'
]
+
self
.
values
[
'paralleltrapfile'
])
if
trapdata
.
ndim
>
1
:
self
.
nt_p
=
trapdata
[:,
0
]
self
.
sigma_p
=
trapdata
[:,
1
]
self
.
taur_p
=
trapdata
[:,
2
]
else
:
#only one trap species
#
only one trap species
self
.
nt_p
=
[
trapdata
[
0
],]
self
.
sigma_p
=
[
trapdata
[
1
],]
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
:
self
.
nt_s
=
trapdata
[:,
0
]
self
.
sigma_s
=
trapdata
[:,
1
]
self
.
taur_s
=
trapdata
[:,
2
]
else
:
#only one trap species
#
only one trap species
self
.
nt_s
=
[
trapdata
[
0
],]
self
.
sigma_s
=
[
trapdata
[
1
],]
self
.
taur_s
=
[
trapdata
[
2
],]
#scale thibaut's values
#
scale thibaut's values
if
'thibaut'
in
self
.
values
[
'parallelTrapfile'
]:
self
.
nt_p
/=
0.576
#thibaut's values traps / pixel
self
.
sigma_p
*=
1.e4
#
thibaut's values in m**2
self
.
nt_p
/=
0.576
#
thibaut's values traps / pixel
self
.
sigma_p
*=
1.e4
#
thibaut's values in m**2
if
'thibaut'
in
self
.
values
[
'serialTrapfile'
]:
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
.
nt_s
*=
0.576
# thibaut's values traps / pixel #should be division?
self
.
sigma_s
*=
1.e4
# thibaut's values in m**2
def
_setupLogger
(
self
):
"""
...
...
@@ -94,7 +97,6 @@ class CDM03bidir():
# if self.log is None:
# self.logger = False
def
applyRadiationDamage
(
self
,
data
,
iquadrant
=
0
):
"""
Apply radian damage based on FORTRAN CDM03 model. The method assumes that
...
...
@@ -133,8 +135,8 @@ class CDM03bidir():
:return: image that has been run through the CDM03 model
:rtype: ndarray
"""""
#return data
#
return data
iflip
=
iquadrant
/
2
jflip
=
iquadrant
%
2
...
...
@@ -158,27 +160,22 @@ class CDM03bidir():
self
.
log
.
info
(
'jflip=%i'
%
jflip
)
#################################################################################
#
##
modify
#sys.path.append('../so')
#
modify
#
sys.path.append('../so')
from
ifs_so
import
cdm03bidir
# from ifs_so.cdm03.cpython-38-x86_64-linux-gnu import cdm03bidir
# import cdm03bidir
CTIed
=
cdm03bidir
.
cdm03
(
np
.
asfortranarray
(
data
),
jflip
,
iflip
,
self
.
values
[
'dob'
],
self
.
values
[
'rdose'
],
self
.
nt_p
,
self
.
sigma_p
,
self
.
taur_p
,
self
.
nt_s
,
self
.
sigma_s
,
self
.
taur_s
,
params
,
[
data
.
shape
[
0
],
data
.
shape
[
1
],
len
(
self
.
nt_p
),
len
(
self
.
nt_s
),
len
(
self
.
params
)])
jflip
,
iflip
,
self
.
values
[
'dob'
],
self
.
values
[
'rdose'
],
self
.
nt_p
,
self
.
sigma_p
,
self
.
taur_p
,
self
.
nt_s
,
self
.
sigma_s
,
self
.
taur_s
,
params
,
[
data
.
shape
[
0
],
data
.
shape
[
1
],
len
(
self
.
nt_p
),
len
(
self
.
nt_s
),
len
(
self
.
params
)])
return
np
.
asanyarray
(
CTIed
)
#################################################################################################################
#################################################################################################################
#################################################################################################################
csst_ifs_sim/csst_ifs_sim.py
View file @
5070c190
This diff is collapsed.
Click to expand it.
tests/test_ifs_sim.py
View file @
5070c190
...
...
@@ -15,7 +15,7 @@ from csst_ifs_sim import csst_ifs_sim
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
):
...
...
@@ -35,27 +35,28 @@ class TestDemoFunction(unittest.TestCase):
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/'
)
dir_path
=
os
.
path
.
join
(
os
.
environ
[
'UNIT_TEST_DATA_ROOT'
],
'ifs_sim/'
)
print
(
dir_path
)
print
(
sys
.
version
)
print
(
sys
.
version
)
###configfile = dir_path+'IFS_inputdata/configData/IFS_sim_C90.config'
configfile
=
'./csst_ifs_sim/ifs_data/IFS_sim_C90.config'
sourcein
=
'SCI'
print
(
configfile
)
debug
=
True
result_path
=
dir_path
+
'ifs_sim_result'
csst_ifs_sim
.
runIFSsim
(
sourcein
,
configfile
,
dir_path
,
result_path
,
1
,
debug
,
'no'
)
debug
=
True
result_path
=
dir_path
+
'ifs_sim_result'
csst_ifs_sim
.
runIFSsim
(
sourcein
,
configfile
,
dir_path
,
result_path
,
1
,
debug
,
'no'
)
self
.
assertEqual
(
1
,
1
,
1
,
1
,
"case 1: SCI sim passes."
,
)
##############################################################
def
test_ifs_sim_2
(
self
):
"""
...
...
@@ -73,26 +74,27 @@ class TestDemoFunction(unittest.TestCase):
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/'
)
dir_path
=
os
.
path
.
join
(
os
.
environ
[
'UNIT_TEST_DATA_ROOT'
],
'ifs_sim/'
)
print
(
dir_path
)
print
(
sys
.
version
)
print
(
sys
.
version
)
###configfile = dir_path+'IFS_inputdata/configData/IFS_sim_C90.config'
configfile
=
'./csst_ifs_sim/ifs_data/IFS_sim_C90.config'
sourcein
=
'BIAS'
print
(
configfile
)
debug
=
True
result_path
=
dir_path
+
'ifs_sim_result'
csst_ifs_sim
.
runIFSsim
(
sourcein
,
configfile
,
dir_path
,
result_path
,
1
,
debug
,
'no'
)
debug
=
True
result_path
=
dir_path
+
'ifs_sim_result'
csst_ifs_sim
.
runIFSsim
(
sourcein
,
configfile
,
dir_path
,
result_path
,
1
,
debug
,
'no'
)
self
.
assertEqual
(
1
,
1
,
1
,
1
,
"case 2: sim passes."
,
)
###################################################################
def
test_ifs_sim_3
(
self
):
"""
...
...
@@ -110,26 +112,27 @@ class TestDemoFunction(unittest.TestCase):
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/'
)
dir_path
=
os
.
path
.
join
(
os
.
environ
[
'UNIT_TEST_DATA_ROOT'
],
'ifs_sim/'
)
print
(
dir_path
)
print
(
sys
.
version
)
print
(
sys
.
version
)
###configfile = dir_path+'IFS_inputdata/configData/IFS_sim_C90.config'
configfile
=
'./csst_ifs_sim/ifs_data/IFS_sim_C90.config'
sourcein
=
'DARK'
print
(
configfile
)
debug
=
True
result_path
=
dir_path
+
'ifs_sim_result'
csst_ifs_sim
.
runIFSsim
(
sourcein
,
configfile
,
dir_path
,
result_path
,
1
,
debug
,
'no'
)
debug
=
True
result_path
=
dir_path
+
'ifs_sim_result'
csst_ifs_sim
.
runIFSsim
(
sourcein
,
configfile
,
dir_path
,
result_path
,
1
,
debug
,
'no'
)
self
.
assertEqual
(
1
,
1
,
1
,
1
,
"case 3: sim passes."
,
)
###################################################################
def
test_ifs_sim_4
(
self
):
"""
...
...
@@ -147,27 +150,28 @@ class TestDemoFunction(unittest.TestCase):
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/'
)
dir_path
=
os
.
path
.
join
(
os
.
environ
[
'UNIT_TEST_DATA_ROOT'
],
'ifs_sim/'
)
print
(
dir_path
)
print
(
sys
.
version
)
print
(
sys
.
version
)
###configfile = dir_path+'IFS_inputdata/configData/IFS_sim_C90.config'
configfile
=
'./csst_ifs_sim/ifs_data/IFS_sim_C90.config'
sourcein
=
'LAMP'
print
(
configfile
)
debug
=
True
result_path
=
dir_path
+
'ifs_sim_result'
csst_ifs_sim
.
runIFSsim
(
sourcein
,
configfile
,
dir_path
,
result_path
,
1
,
debug
,
'no'
)
debug
=
True
result_path
=
dir_path
+
'ifs_sim_result'
csst_ifs_sim
.
runIFSsim
(
sourcein
,
configfile
,
dir_path
,
result_path
,
1
,
debug
,
'no'
)
self
.
assertEqual
(
1
,
1
,
1
,
1
,
"case 4: sim passes."
,
)
)
###################################################################
def
test_ifs_sim_5
(
self
):
"""
...
...
@@ -185,25 +189,26 @@ class TestDemoFunction(unittest.TestCase):
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/'
)
dir_path
=
os
.
path
.
join
(
os
.
environ
[
'UNIT_TEST_DATA_ROOT'
],
'ifs_sim/'
)
print
(
dir_path
)
print
(
sys
.
version
)
print
(
sys
.
version
)
###configfile = dir_path+'IFS_inputdata/configData/IFS_sim_C90.config'
configfile
=
'./csst_ifs_sim/ifs_data/IFS_sim_C90.config'
sourcein
=
'LAMP'
print
(
configfile
)
debug
=
True
result_path
=
dir_path
+
'ifs_sim_result'
csst_ifs_sim
.
runIFSsim
(
sourcein
,
configfile
,
dir_path
,
result_path
,
1
,
debug
,
'yes'
)
debug
=
True
result_path
=
dir_path
+
'ifs_sim_result'
csst_ifs_sim
.
runIFSsim
(
sourcein
,
configfile
,
dir_path
,
result_path
,
1
,
debug
,
'yes'
)
self
.
assertEqual
(
1
,
1
,
1
,
1
,
"case 5: sim passes."
,
)
###################################################################
def
test_ifs_sim_6
(
self
):
"""
...
...
@@ -221,24 +226,23 @@ class TestDemoFunction(unittest.TestCase):
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/'
)
dir_path
=
os
.
path
.
join
(
os
.
environ
[
'UNIT_TEST_DATA_ROOT'
],
'ifs_sim/'
)
print
(
dir_path
)
print
(
sys
.
version
)
print
(
sys
.
version
)
###configfile = dir_path+'IFS_inputdata/configData/IFS_sim_C90.config'
configfile
=
'./csst_ifs_sim/ifs_data/IFS_sim_C90.config'
sourcein
=
'FLAT'
print
(
configfile
)
debug
=
True
result_path
=
dir_path
+
'ifs_sim_result'
csst_ifs_sim
.
runIFSsim
(
sourcein
,
configfile
,
dir_path
,
result_path
,
1
,
debug
,
'no'
)
debug
=
True
result_path
=
dir_path
+
'ifs_sim_result'
csst_ifs_sim
.
runIFSsim
(
sourcein
,
configfile
,
dir_path
,
result_path
,
1
,
debug
,
'no'
)
self
.
assertEqual
(
1
,
1
,
1
,
1
,
"case 6: sim passes."
,
)
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment