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
b2028a91
Commit
b2028a91
authored
Apr 12, 2024
by
Yan Zhaojun
Browse files
redate ifs_sim
parent
c5522b44
Pipeline
#3987
passed with stage
in 0 seconds
Changes
9
Pipelines
1
Show whitespace changes
Inline
Side-by-side
csst_ifs_sim/CTI/__pycache__/CTI.cpython-38.pyc
0 → 100644
View file @
b2028a91
File added
csst_ifs_sim/CTI/__pycache__/__init__.cpython-38.pyc
0 → 100644
View file @
b2028a91
File added
csst_ifs_sim/__pycache__/csst_ifs_sim.cpython-38.pyc
View file @
b2028a91
No preview for this file type
csst_ifs_sim/csst_ifs_sim.py
View file @
b2028a91
...
@@ -45,8 +45,6 @@ from datetime import datetime, timedelta
...
@@ -45,8 +45,6 @@ from datetime import datetime, timedelta
import
pandas
as
pd
import
pandas
as
pd
from
scipy.integrate
import
simps
from
scipy.integrate
import
simps
import
galsim
import
galsim
# sys.path.append('../')
from
joblib
import
Parallel
,
delayed
from
astropy.utils.iers
import
conf
from
astropy.utils.iers
import
conf
conf
.
auto_max_age
=
None
conf
.
auto_max_age
=
None
...
@@ -1588,7 +1586,7 @@ class IFSsimulator():
...
@@ -1588,7 +1586,7 @@ class IFSsimulator():
"""
"""
self
.
log
.
info
(
'Reading in cosmic ray information from %s and %s'
%
(
self
.
information
[
'cosmicraylengths'
],
self
.
log
.
info
(
'Reading in cosmic ray information from %s and %s'
%
(
self
.
information
[
'cosmicraylengths'
],
self
.
information
[
'cosmicraydistance'
]))
self
.
information
[
'cosmicraydistance'
]))
print
(
self
.
information
)
####
print(self.information)
crLengths
=
np
.
loadtxt
(
crLengths
=
np
.
loadtxt
(
self
.
information
[
'dir_path'
]
+
self
.
information
[
'cosmicraylengths'
])
self
.
information
[
'dir_path'
]
+
self
.
information
[
'cosmicraylengths'
])
...
@@ -1733,9 +1731,9 @@ class IFSsimulator():
...
@@ -1733,9 +1731,9 @@ class IFSsimulator():
if
home_path
==
'/home/yan'
:
if
home_path
==
'/home/yan'
:
self
.
result_path
=
'../IFS_simData
_
'
+
self
.
source
+
ss
+
result_day
self
.
result_path
=
'../IFS_simData
/
'
+
self
.
source
+
ss
+
result_day
else
:
else
:
self
.
result_path
=
'/data/ifspip/CCD_ima/
IFS_simData_
'
+
self
.
source
+
ss
+
result_day
self
.
result_path
=
'/data/ifspip/CCD_ima/'
+
self
.
source
+
ss
+
result_day
if
os
.
path
.
isdir
(
self
.
result_path
)
==
False
:
if
os
.
path
.
isdir
(
self
.
result_path
)
==
False
:
os
.
mkdir
(
self
.
result_path
)
os
.
mkdir
(
self
.
result_path
)
...
@@ -4141,13 +4139,11 @@ class IFSsimulator():
...
@@ -4141,13 +4139,11 @@ class IFSsimulator():
Wave
=
np
.
zeros
(
6000
)
Wave
=
np
.
zeros
(
6000
)
if
self
.
debug
:
if
self
.
debug
:
alfa
=
1000
alfa
=
1000
else
:
else
:
alfa
=
1
alfa
=
1
#
3
#
########################################
for
klam
in
range
(
6000
):
for
klam
in
range
(
6000
):
...
@@ -4163,7 +4159,7 @@ class IFSsimulator():
...
@@ -4163,7 +4159,7 @@ class IFSsimulator():
self
.
log
.
info
(
'red image max value = %i'
%
red_img
.
array
.
max
())
self
.
log
.
info
(
'red image max value = %i'
%
red_img
.
array
.
max
())
if
ilam
>=
6000
:
if
ilam
>=
6000
:
continue
break
# the wavelength of the i-th frame data
# the wavelength of the i-th frame data
lam
=
350.0
+
(
1000
-
350
)
/
6000.0
*
ilam
lam
=
350.0
+
(
1000
-
350
)
/
6000.0
*
ilam
...
@@ -4651,10 +4647,8 @@ class IFSsimulator():
...
@@ -4651,10 +4647,8 @@ class IFSsimulator():
########################################################################################
########################################################################################
if
self
.
debug
:
if
self
.
debug
:
alfa
=
1000
alfa
=
1000
else
:
else
:
alfa
=
1
alfa
=
1
for
klam
in
range
(
6000
):
for
klam
in
range
(
6000
):
...
@@ -4662,7 +4656,7 @@ class IFSsimulator():
...
@@ -4662,7 +4656,7 @@ class IFSsimulator():
ilam
=
klam
*
alfa
ilam
=
klam
*
alfa
if
ilam
>=
6000
:
if
ilam
>=
6000
:
continue
break
# print(ilam)
# print(ilam)
...
@@ -5051,10 +5045,8 @@ class IFSsimulator():
...
@@ -5051,10 +5045,8 @@ class IFSsimulator():
####
####
if
self
.
debug
:
if
self
.
debug
:
alfa
=
1000
alfa
=
1000
else
:
else
:
alfa
=
1
alfa
=
1
for
klam
in
range
(
6000
):
for
klam
in
range
(
6000
):
...
@@ -5072,7 +5064,7 @@ class IFSsimulator():
...
@@ -5072,7 +5064,7 @@ class IFSsimulator():
self
.
log
.
info
(
'red image max value = %i'
%
red_img
.
array
.
max
())
self
.
log
.
info
(
'red image max value = %i'
%
red_img
.
array
.
max
())
if
ilam
>=
6000
:
if
ilam
>=
6000
:
continue
break
# the wavelength of the i-th frame data
# the wavelength of the i-th frame data
lam
=
350.0
+
(
1000
-
350
)
/
6000.0
*
ilam
lam
=
350.0
+
(
1000
-
350
)
/
6000.0
*
ilam
...
@@ -5586,10 +5578,6 @@ class IFSsimulator():
...
@@ -5586,10 +5578,6 @@ class IFSsimulator():
if
self
.
source
==
'SCI'
or
self
.
source
==
'COMP'
:
if
self
.
source
==
'SCI'
or
self
.
source
==
'COMP'
:
# if self.debug:
# print('Debug mode, no cosmicrays')
# else:
if
self
.
cosmicRays
:
if
self
.
cosmicRays
:
self
.
addCosmicRays
(
idk
)
self
.
addCosmicRays
(
idk
)
print
(
'Applying cosmicRays finished.......'
)
print
(
'Applying cosmicRays finished.......'
)
...
@@ -5662,7 +5650,7 @@ class IFSsimulator():
...
@@ -5662,7 +5650,7 @@ class IFSsimulator():
############################################################################
############################################################################
def
runIFSsim
(
sourcein
,
configfile
,
iLoop
,
applyhole
=
'no'
):
def
runIFSsim
(
sourcein
,
configfile
,
dir_path
,
iLoop
,
applyhole
=
'no'
):
"""
"""
...
@@ -5692,132 +5680,11 @@ def runIFSsim(sourcein, configfile, iLoop, applyhole='no'):
...
@@ -5692,132 +5680,11 @@ def runIFSsim(sourcein, configfile, iLoop, applyhole='no'):
else
:
else
:
simulate
[
iLoop
].
information
[
'holemask'
]
=
'no'
simulate
[
iLoop
].
information
[
'holemask'
]
=
'no'
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/')
simulate
[
iLoop
].
information
[
'dir_path'
]
=
dir_path
simulate
[
iLoop
].
information
[
'dir_path'
]
=
dir_path
simulate
[
iLoop
].
simulate
(
sourcein
,
iLoop
)
simulate
[
iLoop
].
simulate
(
sourcein
,
iLoop
)
return
1
return
1
############################## end ##########################################
# ########################## begin main fucntion #######################################
\ No newline at end of file
# ##############################################################################################
# ##############################################################################################
# if __name__ == "__main__":
# CSST_unittest = True
# sourcein = 'SCI'
# applyhole = 'no'
# if CSST_unittest:
# dir_path = os.path.join(os.environ['UNIT_TEST_DATA_ROOT'], 'ifs_sim/')
# else:
# dir_path = '../'
# configfile0 = dir_path+'IFS_data/IFS_sim_C90.config'
# skyfitsin = dir_path+'IFS_inputdata/FengshuaiData/NGC6397_S6102.fits'
# if len(sys.argv[:]) < 2:
# configfile = configfile0
# if len(sys.argv[:]) >= 2:
# configfile = sys.argv[1]+'IFS_inputdata/configData/IFS_sim_C90.config'
# if not os.path.exists(configfile):
# print('The given input fonfigfile path is wrong......')
# sys.exit(1)
# configfile = configfile0
# if len(sys.argv[:]) >= 3:
# sourcein = sys.argv[2]CSST_unittest
# if sourcein not in ['BIAS', 'DARK', 'LAMP', 'FLAT', 'SCI']:
# print('The input sourcein parameter input is wrong......')
# sys.exit(1)
# if len(sys.argv[:]) >= 4:
# applyhole = sys.argv[3]
# if sourcein not in ['yes', 'no']:
# print('The input applyhole parameter should be yes or no!')
# sys.exit(1)
# #############################################################
# ################## sky test ############################
# runIFSsim(sourcein, skyfitsin, configfile, 1, CSST_unittest, applyhole)
############################################################################
############################################################################
# it=range(1, exposureNum+1,1)
# if exposureNum>1:
# Parallel(n_jobs=min(5,exposureNum))(delayed(runIFSsim)(sourcein, skyfitsin, configfile, iLoop, applyhole) for iLoop in it)
# else:
# runIFSsim(sourcein, skyfitsin, configfile, 1, applyhole)
# pause
# # ############################################################
# # ############### bias , no mask ###############
# sourcein ='BIAS'
# applyhole='no'
# exposureNum=5
# it=range(1,exposureNum+1,1)
# if exposureNum>1:
# Parallel(n_jobs=exposureNum)(delayed(runIFSsim)(sourcein, skyfitsin, configfile, iLoop, applyhole) for iLoop in it)
# else:
# runIFSsim(sourcein, skyfitsin, configfile, 1, applyhole)
# pause()
# # # ##########################################################
# # ############### dark , no mask ###########
# sourcein ='DARK'
# applyhole='no'
# exposureNum=5
# it=range(1,exposureNum+1,1)
# if exposureNum>1:
# Parallel(n_jobs=exposureNum)(delayed(runIFSsim)(sourcein, skyfitsin, configfile, iLoop, applyhole) for iLoop in it)
# else:
# runIFSsim(sourcein, skyfitsin, configfile, 1, applyhole)
# # ###############################################################################
################# lamp , no mask #############
# sourcein ='LAMP'
# applyhole='no'
# exposureNum=5
# it=range(1,exposureNum+1,1)
# if exposureNum>1:
# Parallel(n_jobs=exposureNum)(delayed(runIFSsim)(sourcein, skyfitsin, configfile, iLoop, applyhole) for iLoop in it)
# else:
# runIFSsim(sourcein, skyfitsin, configfile, 1, applyhole)
############################################################
###########################################################
# # ############### flat, no mask ################
# sourcein ='FLAT'
# applyhole='no'
# exposureNum=5
# it=range(1,exposureNum+1,1)
# if exposureNum>1:
# Parallel(n_jobs=exposureNum)(delayed(runIFSsim)(sourcein, skyfitsin, configfile, iLoop, applyhole) for iLoop in it)
# else:
# runIFSsim(sourcein, skyfitsin, configfile, 1, applyhole)
# ############################################################
# ################## hole Mask simulation ###############
# sourcein ='LAMP'
# applyhole='yes'
# exposureNum=2
# it=range(1,exposureNum+1,1)
# if exposureNum>1:
# Parallel(n_jobs=exposureNum)(delayed(runIFSsim)(sourcein, skyfitsin, configfile, iLoop, applyhole) for iLoop in it)
# else:
# runIFSsim(sourcein, skyfitsin, configfile, 1, applyhole)
csst_ifs_sim/support/__pycache__/IFSinstrumentModel.cpython-38.pyc
0 → 100644
View file @
b2028a91
File added
csst_ifs_sim/support/__pycache__/__init__.cpython-38.pyc
0 → 100644
View file @
b2028a91
File added
csst_ifs_sim/support/__pycache__/cosmicrays.cpython-38.pyc
0 → 100644
View file @
b2028a91
File added
csst_ifs_sim/support/__pycache__/logger.cpython-38.pyc
0 → 100644
View file @
b2028a91
File added
tests/test_ifs_sim.py
View file @
b2028a91
...
@@ -40,7 +40,7 @@ class TestDemoFunction(unittest.TestCase):
...
@@ -40,7 +40,7 @@ class TestDemoFunction(unittest.TestCase):
sourcein
=
'SCI'
sourcein
=
'SCI'
print
(
configfile
)
print
(
configfile
)
csst_ifs_sim
.
runIFSsim
(
sourcein
,
configfile
,
1
,
'no'
)
csst_ifs_sim
.
runIFSsim
(
sourcein
,
configfile
,
dir_path
,
1
,
'no'
)
self
.
assertEqual
(
self
.
assertEqual
(
1
,
1
,
1
,
1
,
"case 1: SCI sim passes."
,
"case 1: SCI 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