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
Liu Dezi
csst_msc_sim
Commits
59814d64
Commit
59814d64
authored
Apr 20, 2024
by
Wei Chengliang
Browse files
Merge branch 'develop' of
https://csst-tb.bao.ac.cn/code/csst-sims/csst_msc_sim
into develop
parents
fb74fc22
ab15c00f
Changes
5
Hide whitespace changes
Inline
Side-by-side
requirements.txt
View file @
59814d64
...
...
@@ -10,4 +10,5 @@ h5py==3.11.0
Cython
==3.0.6
numba
==0.59.1
psutil
==5.9.8
toml
==0.10.2
\ No newline at end of file
toml
==0.10.2
lmfit
==1.2.2
\ No newline at end of file
setup.py
View file @
59814d64
...
...
@@ -98,7 +98,7 @@ setup(name='CSSTSim',
'ObservationSim.Instrument.data.sls_conf'
:
[
'*.conf'
,
'*.fits'
],
'ObservationSim.Instrument.data.flatCube'
:
[
'*.fits'
],
'Catalog.data'
:
[
'*.fits'
,
'*.so'
],
'ObservationSim.Config.Header'
:[
'*.
header
'
,
'*.lst'
],
'ObservationSim.Config.Header'
:[
'*.
fits
'
,
'*.lst'
],
'ObservationSim.Straylight.data'
:
[
'*.dat'
],
'ObservationSim.Straylight.data.sky'
:
[
'*.dat'
],
'ObservationSim.Straylight.lib'
:
[
'*'
],
...
...
tests/test_SpecDisperse.py
View file @
59814d64
...
...
@@ -145,16 +145,22 @@ class TestSpecDisperse(unittest.TestCase):
def
__init__
(
self
,
methodName
=
'runTest'
):
super
(
TestSpecDisperse
,
self
).
__init__
(
methodName
)
self
.
filePath
(
'csst_
fz_gc0
'
)
self
.
filePath
(
'csst_
msc_sim/test_sls_and_straylight
'
)
# self.conff = conff
# self.throughputf = throughputf
def
filePath
(
self
,
file_name
):
fn
=
os
.
path
.
join
(
os
.
getenv
(
'UNIT_TEST_DATA_ROOT'
),
file_name
)
self
.
conff
=
os
.
path
.
join
(
fn
,
'CSST_GI2.conf'
)
self
.
throughputf
=
os
.
path
.
join
(
fn
,
'GI.Throughput.1st.fits'
)
self
.
testDir
=
fn
self
.
outDataFn
=
os
.
path
.
join
(
fn
,
'output'
)
if
os
.
path
.
isdir
(
self
.
outDataFn
):
pass
else
:
os
.
mkdir
(
self
.
outDataFn
)
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
]])
...
...
@@ -231,16 +237,16 @@ class TestSpecDisperse(unittest.TestCase):
ids1
=
wave_pix
[
ids
]
>
6500
print
(
'Spec disperse flux test'
)
self
.
assertTrue
(
np
.
mean
((
wave_flux
[
ids
][
ids1
]
-
sed_i
(
wave_pix
[
ids
][
ids1
]))
/
sed_i
(
wave_pix
[
ids
][
ids1
]))
<
0.004
)
plt
.
figure
()
plt
.
plot
(
wave_pix
,
wave_flux
)
plt
.
plot
(
sed
[
'WAVELENGTH'
],
sed
[
'FLUX'
])
plt
.
xlim
(
6200
,
10000
)
plt
.
ylim
(
1
,
3
)
plt
.
yscale
(
'log'
)
plt
.
xlabel
(
'$\lambda$'
)
plt
.
ylabel
(
'$F\lambda$'
)
plt
.
legend
([
'extracted'
,
'input'
])
plt
.
show
()
#
plt.figure()
#
plt.plot(wave_pix, wave_flux)
#
plt.plot(sed['WAVELENGTH'], sed['FLUX'])
#
plt.xlim(6200, 10000)
#
plt.ylim(1, 3)
#
plt.yscale('log')
#
plt.xlabel('$\lambda$')
#
plt.ylabel('$F\lambda$')
#
plt.legend(['extracted', 'input'])
#
plt.show()
def
test_Specdistperse2
(
self
):
...
...
@@ -303,16 +309,16 @@ class TestSpecDisperse(unittest.TestCase):
self
.
assertTrue
(
fwhmx
/
deltLamda_pix
*
pix_scale
-
psf_fwhm
<
np
.
abs
(
0.02
))
# print('error is ',np.mean((wave_flux[ids][ids1] - sed_i(wave_pix[ids][ids1]))/sed_i(wave_pix[ids][ids1])))
# self.assertTrue(np.mean((wave_flux[ids][ids1] - sed_i(wave_pix[ids][ids1]))/sed_i(wave_pix[ids][ids1]))<0.004)
plt
.
figure
()
plt
.
plot
(
wave_pix
,
wave_flux
)
plt
.
plot
(
sed
[
'WAVELENGTH'
],
sed
[
'FLUX'
])
plt
.
xlim
(
6200
,
10000
)
plt
.
ylim
(
1
,
75
)
plt
.
yscale
(
'log'
)
plt
.
xlabel
(
'$\lambda$'
)
plt
.
ylabel
(
'$F\lambda$'
)
plt
.
legend
([
'extracted'
,
'input'
])
plt
.
show
()
#
plt.figure()
#
plt.plot(wave_pix, wave_flux)
#
plt.plot(sed['WAVELENGTH'], sed['FLUX'])
#
plt.xlim(6200, 10000)
#
plt.ylim(1, 75)
#
plt.yscale('log')
#
plt.xlabel('$\lambda$')
#
plt.ylabel('$F\lambda$')
#
plt.legend(['extracted', 'input'])
#
plt.show()
def
test_Specdistperse3
(
self
):
...
...
@@ -484,7 +490,7 @@ class TestSpecDisperse(unittest.TestCase):
print
(
'Spec double disperse test'
)
from
astropy.io
import
fits
fits
.
writeto
(
'test
.fits'
,
chip
.
img
.
array
,
overwrite
=
True
)
fits
.
writeto
(
os
.
path
.
join
(
self
.
outDataFn
,
'test_sls_doubleDisp
.fits'
)
,
chip
.
img
.
array
,
overwrite
=
True
)
# plt.figure()
# plt.imshow(chip.img.array)
...
...
tests/test_Straylight.py
View file @
59814d64
...
...
@@ -74,7 +74,7 @@ class TestStraylight(unittest.TestCase):
# print(file_name)
# fn = os.path.join(os.getenv('UNIT_TEST_DATA_ROOT'), file_name)
# self.pointingData = np.loadtxt(os.path.join(fn, 'Straylight_test.dat'), dtype=np.double)
self
.
filePath
(
'csst_
fz_gc0
'
)
self
.
filePath
(
'csst_
msc_sim/test_sls_and_straylight
'
)
self
.
filter
=
filter
self
.
grating
=
grating
...
...
tests/
de
t_effect_unit
_test
.py
→
tests/
tes
t_effect_unit.py
View file @
59814d64
...
...
@@ -17,7 +17,7 @@ class DetTest(unittest.TestCase):
def
__init__
(
self
,
methodName
=
'runTest'
):
super
(
DetTest
,
self
).
__init__
(
methodName
)
self
.
filePath
(
'csst_
fz_gc0
'
)
self
.
filePath
(
'csst_
msc_sim/test_sls_and_straylight
'
)
def
filePath
(
self
,
file_name
):
self
.
datafn
=
os
.
path
.
join
(
os
.
getenv
(
'UNIT_TEST_DATA_ROOT'
),
file_name
)
...
...
@@ -138,15 +138,15 @@ class DetTest(unittest.TestCase):
newimg
.
write
(
os
.
path
.
join
(
self
.
outDataFn
,
'test_badlines.fits'
))
del
newimg
,
img
def
test_cte
(
self
):
img
=
galsim
.
Image
(
200
,
200
,
init_value
=
1000
)
img
.
array
[
50
,
80
]
=
1e4
img
.
array
[
150
,
150
]
=
3e4
newimgcol
=
Effects
.
CTE_Effect
(
copy
.
deepcopy
(
img
),
direction
=
'column'
)
newimgrow
=
Effects
.
CTE_Effect
(
copy
.
deepcopy
(
img
),
direction
=
'row'
)
newimgcol
.
write
(
os
.
path
.
join
(
self
.
outDataFn
,
'test_ctecol.fits'
))
newimgrow
.
write
(
os
.
path
.
join
(
self
.
outDataFn
,
'test_cterow.fits'
))
del
img
,
newimgcol
,
newimgrow
#
def test_cte(self):
#
img = galsim.Image(200,200,init_value=1000)
#
img.array[50,80] = 1e4
#
img.array[150,150] = 3e4
#
newimgcol = Effects.CTE_Effect(copy.deepcopy(img),direction='column')
#
newimgrow = Effects.CTE_Effect(copy.deepcopy(img),direction='row')
#
newimgcol.write(os.path.join(self.outDataFn,'test_ctecol.fits'))
#
newimgrow.write(os.path.join(self.outDataFn,'test_cterow.fits'))
#
del img,newimgcol,newimgrow
def
test_readnoise
(
self
):
img
=
galsim
.
Image
(
200
,
200
,
init_value
=
1000
)
...
...
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