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_msc_sim
Commits
691505e7
Commit
691505e7
authored
Nov 06, 2023
by
Zhang Xin
Browse files
update unitest model spec and straylight, ust environment parameter
parent
20b4f01c
Changes
11
Show whitespace changes
Inline
Side-by-side
tests/testData/CSST_GI2.conf
0 → 100644
View file @
691505e7
INSTRUMETN
CSSTSLS
GRATING
GI
WAVELENGTH
6200
10000
# 1 order (BEAM A) *******************
BEAMA
505
1238
MMAG_EXTRACT_A
30
MMAG_MARK_A
30
#
# Trace description
#
DYDX_ORDER_A
1
DYDX_A_0
1
.
6521968560197104
-
0
.
00023636575255565063
0
.
00014657966669906052
5
.
5353251643711546
e
-
08
-
6
.
875491197053945
e
-
09
1
.
898528225132234
e
-
09
DYDX_A_1
-
0
.
00823033845070988
8
.
828905689160072
e
-
08
-
4
.
959096708134394
e
-
07
-
1
.
9481266745599912
e
-
11
1
.
1236282464271542
e
-
11
-
7
.
748796599795913
e
-
12
#
# X and Y Offsets
#
XOFF_A
0
.
0
YOFF_A
0
.
0
#
# Dispersion solution
#
DISP_ORDER_A
1
DLDP_A_0
368
.
406778602958
0
.
003046565833724366
0
.
0008085615398225785
-
2
.
139787644130709
e
-
07
-
1
.
1201107471275321
e
-
07
-
3
.
4449662405229706
e
-
08
DLDP_A_1
8
.
461359683949652
0
.
00022163929626988009
-
6
.
114607283280979
e
-
07
7
.
123049245778616
e
-
09
1
.
99766396430199
e
-
11
2
.
5539201322842942
e
-
11
#
SENSITIVITY_A
GI
.
Throughput
.
1
st
.
fits
#
# 0 order (BEAM B) *******************
BEAMB
-
121
80
MMAG_EXTRACT_B
30
MMAG_MARK_B
30
#
# Trace description
#
DYDX_ORDER_B
0
DYDX_B_0
-
0
.
15118122059806027
-
0
.
00014883011863745443
7
.
638889641475754
e
-
05
3
.
208928684076908
e
-
08
-
2
.
743527540058062
e
-
16
-
5
.
917502574749109
e
-
09
#
# X and Y Offsets
#
XOFF_B
0
.
0
YOFF_B
0
.
0
#
# Dispersion solution
#
DISP_ORDER_B
1
DLDP_B_0
-
69799
.
9181918991
7
.
954241458130043
e
-
08
-
4
.
318951729587184
e
-
08
2
.
591993568563933
e
-
12
-
5
.
884436166492418
e
-
12
3
.
83253047082687
e
-
12
DLDP_B_1
-
3799
.
99600104444
7
.
250278281031939
e
-
09
-
3
.
3418691029874735
e
-
09
-
1
.
6236581010798935
e
-
12
-
4
.
3502364485117337
e
-
13
4
.
507009220450333
e
-
13
#
SENSITIVITY_B
GI
.
Throughput
.
0
st
.
fits
#
# -1 order (BEAM C) *******************
BEAMC
-
1251
-
537
MMAG_EXTRACT_C
30
MMAG_MARK_C
30
#
# Trace description
#
DYDX_ORDER_C
1
DYDX_C_0
1
.
6274259827507076
-
0
.
00034821339283356466
0
.
0002392999867887435
1
.
5635809977657976
e
-
07
-
7
.
514174027001749
e
-
09
-
6
.
566395011125117
e
-
09
DYDX_C_1
-
5
.
3689415286860876
e
-
05
-
1
.
912489940030657
e
-
07
-
1
.
070383333548475
e
-
08
1
.
53386647062175
e
-
10
-
1
.
1208241918489809
e
-
11
3
.
406912464353884
e
-
12
#
# X and Y Offsets
#
XOFF_C
0
.
0
YOFF_C
0
.
0
#
# Dispersion solution
#
DISP_ORDER_C
1
DLDP_C_0
-
132
.
55108204545758
-
0
.
002194041658487836
-
0
.
0011882168059149318
4
.
510589778063266
e
-
08
5
.
420547634024377
e
-
08
9
.
930897689686617
e
-
08
DLDP_C_1
-
8
.
799340620412947
-
0
.
00021774440141256442
-
9
.
53499834632785
e
-
07
-
6
.
889561983057868
e
-
09
-
1
.
6142159956150814
e
-
10
1
.
0347079457327646
e
-
10
#
SENSITIVITY_C
GI
.
Throughput
.-
1
st
.
fits
#
# 2 order (BEAM D) *******************
BEAMD
1154
2507
MMAG_EXTRACT_D
30
MMAG_MARK_D
30
#
# Trace description
#
DYDX_ORDER_D
1
DYDX_D_0
6
.
882799280484086
-
0
.
00027753891131284954
0
.
0004922039820404395
3
.
082997123523641
e
-
08
-
9
.
49966186877231
e
-
09
-
2
.
3656818322711693
e
-
09
DYDX_D_1
-
0
.
011947813534498112
4
.
093696016714032
e
-
08
-
7
.
435107573317389
e
-
07
2
.
5528541317977112
e
-
12
3
.
192792142602198
e
-
12
-
2
.
453919520892182
e
-
12
#
# X and Y Offsets
#
XOFF_D
0
.
0
YOFF_D
0
.
0
#
# Dispersion solution
#
DISP_ORDER_D
1
DLDP_D_0
681
.
5215546431494
-
0
.
003828618628269481
0
.
00025066858071110036
8
.
289914582311179
e
-
08
-
8
.
404758131147936
e
-
08
2
.
9680890659588283
e
-
08
DLDP_D_1
3
.
8798704838712443
0
.
0001054229718827677
-
6
.
676804799370928
e
-
08
3
.
250115236230527
e
-
09
1
.
9094002846781994
e
-
11
-
2
.
387851784113332
e
-
11
#
SENSITIVITY_D
GI
.
Throughput
.
2
st
.
fits
#
# -2 order (BEAM E) *******************
BEAME
-
2429
-
1162
MMAG_EXTRACT_E
30
MMAG_MARK_E
30
#
# Trace description
#
DYDX_ORDER_E
1
DYDX_E_0
7
.
677233822131253
-
0
.
00048041060058740204
0
.
0004956385735024366
6
.
868585247565035
e
-
08
-
9
.
175237278696478
e
-
09
1
.
2566962458208905
e
-
09
DYDX_E_1
0
.
003983370254635055
-
1
.
232787560255339
e
-
08
2
.
1234388976109016
e
-
07
1
.
6204618268328708
e
-
11
3
.
983819645370279
e
-
12
4
.
263520014579825
e
-
12
#
# X and Y Offsets
#
XOFF_E
0
.
0
YOFF_E
0
.
0
#
# Dispersion solution
#
DISP_ORDER_E
1
DLDP_E_0
225
.
51253672373838
0
.
004993681854364764
-
0
.
0005008288340946528
-
3
.
699489889412266
e
-
07
9
.
185967746730138
e
-
10
3
.
449301385107925
e
-
08
DLDP_E_1
-
4
.
201429796832916
-
0
.
0001002659886793457
-
1
.
5067099385104427
e
-
07
-
3
.
422412459135902
e
-
09
-
4
.
7864621219451994
e
-
11
1
.
2110924433274547
e
-
11
#
SENSITIVITY_E
GI
.
Throughput
.-
2
st
.
fits
#
tests/testData/GI.Throughput.-1st.fits
0 → 100644
View file @
691505e7
File added
tests/testData/GI.Throughput.-2st.fits
0 → 100644
View file @
691505e7
File added
tests/testData/GI.Throughput.0st.fits
0 → 100755
View file @
691505e7
File added
tests/testData/GI.Throughput.1st.fits
0 → 100755
View file @
691505e7
File added
tests/testData/GI.Throughput.2st.fits
0 → 100644
View file @
691505e7
File added
tests/SLOAN_SDSS.g.fits
→
tests/
testData/
SLOAN_SDSS.g.fits
View file @
691505e7
File moved
tests/Straylight_test.dat
→
tests/
testData/
Straylight_test.dat
View file @
691505e7
File moved
tests/config_C6.yaml
→
tests/
testData/
config_C6.yaml
View file @
691505e7
File moved
tests/test_SpecDisperse.py
View file @
691505e7
...
@@ -18,6 +18,7 @@ from lmfit.models import LinearModel, GaussianModel
...
@@ -18,6 +18,7 @@ from lmfit.models import LinearModel, GaussianModel
from
ObservationSim.Config.Header
import
generateExtensionHeader
from
ObservationSim.Config.Header
import
generateExtensionHeader
import
math
import
math
import
yaml
import
yaml
import
os
def
getAngle132
(
x1
=
0
,
y1
=
0
,
z1
=
0
,
x2
=
0
,
y2
=
0
,
z2
=
0
,
x3
=
0
,
y3
=
0
,
z3
=
0
):
def
getAngle132
(
x1
=
0
,
y1
=
0
,
z1
=
0
,
x2
=
0
,
y2
=
0
,
z2
=
0
,
x3
=
0
,
y3
=
0
,
z3
=
0
):
...
@@ -136,10 +137,15 @@ def produceObj(x,y,chip, ra, dec, pa):
...
@@ -136,10 +137,15 @@ def produceObj(x,y,chip, ra, dec, pa):
class
TestSpecDisperse
(
unittest
.
TestCase
):
class
TestSpecDisperse
(
unittest
.
TestCase
):
def
__init__
(
self
,
methodName
=
'runTest'
,
conff
=
''
,
throughputf
=
''
):
def
__init__
(
self
,
methodName
=
'runTest'
):
super
(
TestSpecDisperse
,
self
).
__init__
(
methodName
)
super
(
TestSpecDisperse
,
self
).
__init__
(
methodName
)
self
.
conff
=
conff
self
.
throughputf
=
throughputf
self
.
conff
=
os
.
path
.
join
(
os
.
getenv
(
'TEST_HOME'
),
'CSST_GI2.conf'
)
self
.
throughputf
=
os
.
path
.
join
(
os
.
getenv
(
'TEST_HOME'
),
'GI.Throughput.1st.fits'
)
self
.
testDir
=
os
.
getenv
(
'TEST_HOME'
)
# self.conff = conff
# self.throughputf = throughputf
def
test_rotate901
(
self
):
def
test_rotate901
(
self
):
m
=
np
.
array
([[
1
,
2
,
3
,
4
,
5
],[
6
,
7
,
8
,
9
,
10
],[
11
,
12
,
13
,
14
,
15
],[
16
,
17
,
18
,
19
,
20
],[
21
,
22
,
23
,
24
,
25
]])
m
=
np
.
array
([[
1
,
2
,
3
,
4
,
5
],[
6
,
7
,
8
,
9
,
10
],[
11
,
12
,
13
,
14
,
15
],[
16
,
17
,
18
,
19
,
20
],[
21
,
22
,
23
,
24
,
25
]])
...
@@ -167,6 +173,7 @@ class TestSpecDisperse(unittest.TestCase):
...
@@ -167,6 +173,7 @@ class TestSpecDisperse(unittest.TestCase):
def
test_Specdistperse1
(
self
):
def
test_Specdistperse1
(
self
):
star
=
galsim
.
Gaussian
(
fwhm
=
0.39
)
star
=
galsim
.
Gaussian
(
fwhm
=
0.39
)
g_img
=
galsim
.
Image
(
100
,
100
,
scale
=
0.074
)
g_img
=
galsim
.
Image
(
100
,
100
,
scale
=
0.074
)
starImg
=
star
.
drawImage
(
image
=
g_img
)
starImg
=
star
.
drawImage
(
image
=
g_img
)
...
@@ -398,8 +405,8 @@ class TestSpecDisperse(unittest.TestCase):
...
@@ -398,8 +405,8 @@ class TestSpecDisperse(unittest.TestCase):
# work_dir = "/public/home/fangyuedong/CSST_unittest/CSST/test/"
# work_dir = "/public/home/fangyuedong/CSST_unittest/CSST/test/"
# data_dir = "/Volumes/Extreme SSD/SimData/"
# data_dir = "/Volumes/Extreme SSD/SimData/"
# data_dir = "/data/simudata/CSSOSDataProductsSims/data/"
# data_dir = "/data/simudata/CSSOSDataProductsSims/data/"
configFn
=
'config_C6.yaml'
configFn
=
os
.
path
.
join
(
self
.
testDir
,
'config_C6.yaml'
)
normFilterFn
=
"
SLOAN_SDSS.g.fits
"
normFilterFn
=
os
.
path
.
join
(
self
.
testDir
,
'
SLOAN_SDSS.g.fits
'
)
norm_star
=
Table
.
read
(
normFilterFn
)
norm_star
=
Table
.
read
(
normFilterFn
)
with
open
(
configFn
,
"r"
)
as
stream
:
with
open
(
configFn
,
"r"
)
as
stream
:
try
:
try
:
...
@@ -478,7 +485,7 @@ class TestSpecDisperse(unittest.TestCase):
...
@@ -478,7 +485,7 @@ class TestSpecDisperse(unittest.TestCase):
def
test_SLSImage_rotation
(
self
):
def
test_SLSImage_rotation
(
self
):
from
astropy.wcs
import
WCS
from
astropy.wcs
import
WCS
configFn
=
'config_C6.yaml'
configFn
=
os
.
path
.
join
(
self
.
testDir
,
'config_C6.yaml'
)
with
open
(
configFn
,
"r"
)
as
stream
:
with
open
(
configFn
,
"r"
)
as
stream
:
try
:
try
:
...
@@ -684,17 +691,19 @@ class TestSpecDisperse(unittest.TestCase):
...
@@ -684,17 +691,19 @@ class TestSpecDisperse(unittest.TestCase):
if
__name__
==
'__main__'
:
if
__name__
==
'__main__'
:
conff
=
'/Users/zhangxin/Work/SlitlessSim/CSST_SIM/CSST_C6/csst-simulation/ObservationSim/Instrument/data/sls_conf/CSST_GI2.conf'
throughputf
=
'/Users/zhangxin/Work/SlitlessSim/CSST_SIM/CSST_C6/csst-simulation/ObservationSim/Instrument/data/sls_conf/GI.Throughput.1st.fits'
os
.
environ
[
'TEST_HOME'
]
=
"/Users/zhangxin/Work/SlitlessSim/CSST_SIM/CSST_develop/csst-simulation/tests/testData"
testDir
=
os
.
getenv
(
'TEST_HOME'
)
# conff= os.path.join(testDir, 'CSST_GI2.conf')
# throughputf= os.path.join(testDir, 'GI.Throughput.1st.fits')
suit
=
unittest
.
TestSuite
()
suit
=
unittest
.
TestSuite
()
case1
=
TestSpecDisperse
(
'test_Specdistperse1'
,
conff
,
throughputf
)
case1
=
TestSpecDisperse
(
'test_Specdistperse1'
)
suit
.
addTest
(
case1
)
suit
.
addTest
(
case1
)
case2
=
TestSpecDisperse
(
'test_Specdistperse2'
,
conff
,
throughputf
)
case2
=
TestSpecDisperse
(
'test_Specdistperse2'
)
suit
.
addTest
(
case2
)
suit
.
addTest
(
case2
)
case3
=
TestSpecDisperse
(
'test_Specdistperse3'
,
conff
,
throughputf
)
case3
=
TestSpecDisperse
(
'test_Specdistperse3'
)
suit
.
addTest
(
case3
)
suit
.
addTest
(
case3
)
case4
=
TestSpecDisperse
(
'test_double_disperse'
,
conff
,
throughputf
)
case4
=
TestSpecDisperse
(
'test_double_disperse'
)
suit
.
addTest
(
case4
)
suit
.
addTest
(
case4
)
case5
=
TestSpecDisperse
(
'test_SLSImage_rotation'
)
case5
=
TestSpecDisperse
(
'test_SLSImage_rotation'
)
suit
.
addTest
(
case5
)
suit
.
addTest
(
case5
)
...
...
tests/test_Straylight.py
View file @
691505e7
...
@@ -10,6 +10,8 @@ from scipy import interpolate
...
@@ -10,6 +10,8 @@ from scipy import interpolate
import
matplotlib.pyplot
as
plt
import
matplotlib.pyplot
as
plt
import
os
hubbleAverZodiacal
=
{
'nuv'
:
0.0035
,
'u'
:
0.0163
,
'g'
:
0.1109
,
'r'
:
0.1471
,
'i'
:
0.1568
,
'z'
:
0.0953
,
'y'
:
0.0283
}
hubbleAverZodiacal
=
{
'nuv'
:
0.0035
,
'u'
:
0.0163
,
'g'
:
0.1109
,
'r'
:
0.1471
,
'i'
:
0.1568
,
'z'
:
0.0953
,
'y'
:
0.0283
}
hubbleAverEarthShine
=
{
'nuv'
:
0.00024
,
'u'
:
0.0051
,
'g'
:
0.0506
,
'r'
:
0.0591
,
'i'
:
0.0568
,
'z'
:
0.0315
,
'y'
:
0.0090
}
hubbleAverEarthShine
=
{
'nuv'
:
0.00024
,
'u'
:
0.0051
,
'g'
:
0.0506
,
'r'
:
0.0591
,
'i'
:
0.0568
,
'z'
:
0.0315
,
'y'
:
0.0090
}
...
@@ -62,9 +64,9 @@ def calculateAnglePwithEarth(sat = np.array([0,0,0]), pointing = np.array([0,0,0
...
@@ -62,9 +64,9 @@ def calculateAnglePwithEarth(sat = np.array([0,0,0]), pointing = np.array([0,0,0
class
TestStraylight
(
unittest
.
TestCase
):
class
TestStraylight
(
unittest
.
TestCase
):
def
__init__
(
self
,
methodName
=
'runTest'
,
datFn
=
''
,
filter
=
'i'
,
grating
=
"GI"
):
def
__init__
(
self
,
methodName
=
'runTest'
,
filter
=
'i'
,
grating
=
"GI"
):
super
(
TestStraylight
,
self
).
__init__
(
methodName
)
super
(
TestStraylight
,
self
).
__init__
(
methodName
)
self
.
pointingData
=
np
.
loadtxt
(
datFn
,
dtype
=
np
.
double
)
self
.
pointingData
=
np
.
loadtxt
(
os
.
path
.
join
(
os
.
getenv
(
'TEST_HOME'
),
'Straylight_test.dat'
)
,
dtype
=
np
.
double
)
self
.
filter
=
filter
self
.
filter
=
filter
self
.
grating
=
grating
self
.
grating
=
grating
...
@@ -177,14 +179,15 @@ class TestStraylight(unittest.TestCase):
...
@@ -177,14 +179,15 @@ class TestStraylight(unittest.TestCase):
if
__name__
==
'__main__'
:
if
__name__
==
'__main__'
:
os
.
environ
[
'TEST_HOME'
]
=
"/Users/zhangxin/Work/SlitlessSim/CSST_SIM/CSST_develop/csst-simulation/tests/testData"
suit
=
unittest
.
TestSuite
()
suit
=
unittest
.
TestSuite
()
#
case1 = TestStraylight('test_EarthShineFilter',
datFn = 'Straylight_test.dat',
filter = 'i')
case1
=
TestStraylight
(
'test_EarthShineFilter'
,
filter
=
'i'
)
#
suit.addTest(case1)
suit
.
addTest
(
case1
)
#
case2 = TestStraylight('test_ZodiacalFilter',
datFn = 'Straylight_test.dat',
filter = 'i')
case2
=
TestStraylight
(
'test_ZodiacalFilter'
,
filter
=
'i'
)
#
suit.addTest(case2)
suit
.
addTest
(
case2
)
#
case3 = TestStraylight('test_StarFilter',
datFn='Straylight_test.dat',
filter='i')
case3
=
TestStraylight
(
'test_StarFilter'
,
filter
=
'i'
)
#
suit.addTest(case3)
suit
.
addTest
(
case3
)
case4
=
TestStraylight
(
'test_GratingStraylight'
,
datFn
=
'Straylight_test.dat'
,
grating
=
'GI'
)
case4
=
TestStraylight
(
'test_GratingStraylight'
,
grating
=
'GI'
)
suit
.
addTest
(
case4
)
suit
.
addTest
(
case4
)
unittest
.
TextTestRunner
(
verbosity
=
2
).
run
(
suit
)
unittest
.
TextTestRunner
(
verbosity
=
2
).
run
(
suit
)
\ No newline at end of file
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