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
6326829d
Commit
6326829d
authored
Apr 10, 2024
by
Yan Zhaojun
Browse files
update setup.py
parent
97ee4bb5
Pipeline
#3976
passed with stage
in 0 seconds
Changes
1
Pipelines
1
Show whitespace changes
Inline
Side-by-side
csst_ifs_sim/csst_ifs_sim.py
View file @
6326829d
...
@@ -14,45 +14,47 @@ This file contains an image simulator for the CSST IFS.
...
@@ -14,45 +14,47 @@ This file contains an image simulator for the CSST IFS.
The approximate sequence of events in the simulator is as follows:
The approximate sequence of events in the simulator is as follows:
#. Read in a configuration file, which defines for example,
#. Read in a configuration file, which defines for example,
detector characteristics (bias, dark and readout noise, gain,
detector characteristics (bias, dark and readout noise, gain,
plate scale and pixel scale, oversampling factor, exposure time etc.).
plate scale and pixel scale, oversampling factor, exposure time etc.).
#. Read in another file containing charge trap definitions (for CTI modelling).
#. Read in another file containing charge trap definitions (for CTI modelling).
#. Read in a file defining the cosmic rays (trail lengths and cumulative distributions).
#. Read in a file defining the cosmic rays (trail lengths and
#. Read in CCD offset information, displace the image, and modify
cumulative distributions).
#. Read in CCD offset information, displace the image, and modify
the output file name to contain the CCD and quadrant information
the output file name to contain the CCD and quadrant information
#. Load the wavefront aberration data used to calculate PSF with defined
wavelength and field of view.
#. Loop over the number of exposures to co-add and for each object in the
object catalog:
#. Load the wavefront aberration data used to calculate PSF with defined wavelength and field of view.
* determine the number of electrons an object should have by scaling the
object's magnitude
#. Loop over the number of exposures to co-add and for each object in the object catalog:
with the given zeropoint and exposure time.
* determine the number of electrons an object should have by scaling the object's magnitude
with the given zeropoint and exposure time.
* determine whether the object lands on to the detector or not and if it is
* determine whether the object lands on to the detector or not and if it is
a star or an extended source (i.e. a galaxy).
a star or an extended source (i.e. a galaxy).
* if object is extended determine the size (using a size-magnitude relation)
and scale counts,
* if object is extended determine the size (using a size-magnitude relation)
convolve with the PSF, and finally overlay onto the
detector according to its position.
and scale counts,
convolve with the PSF, and finally overlay onto the
* if object is a star, scale counts
according to
the derived
detector
according to
its position.
scaling (first step), and finally overlay onto the detector according to its position.
* if object is a star, scale counts according to the derived scaling
*
a
d
d
a ghost of image of the object (scaled to the peak pixel of the object) [op
tion
al]
.
(first step),
a
n
d
finally overlay onto the detector according to its posi
tion.
#. Apply calibration unit flux to mimic flat field exposures [optional].
#. Apply calibration unit flux to mimic flat field exposures [optional].
#. Apply a multiplicative flat-field map to emulate pixel-to-pixel non-uniformity [optional].
#. Apply a multiplicative flat-field map to emulate pixel-to-pixel non-uniformity [optional].
#. Add a charge injection line (horizontal and/or vertical) [optional].
#. Add a charge injection line (horizontal and/or vertical) [optional].
#. Add cosmic ray tracks onto the CCD with random positions but known distribution [optional].
#. Add cosmic ray tracks onto the CCD with random positions but known distribution [optional].
#. Apply detector charge bleeding in column direction [optional].
#. Apply detector charge bleeding in column direction [optional].
#. Add constant dark current and background light from Zodiacal light [optional].
#. Add constant dark current and background light from Zodiacal light [optional].
#. Include spatially uniform scattered light to the pixel grid [optional].
#. Include spatially uniform scattered light to the pixel grid [optional].
#. Add photon (Poisson) noise [optional]
#. Add photon (Poisson) noise [optional]
#. Add cosmetic defects from an input file [optional].
#. Add cosmetic defects from an input file [optional].
#. Add pre- and overscan regions in the serial direction [optional].
#. Add pre- and overscan regions in the serial direction [optional].
#. Apply the CDM03 radiation damage model [optional].
#. Apply the CDM03 radiation damage model [optional].
#. Apply CCD273 non-linearity model to the pixel data [optional].
#. Apply CCD273 non-linearity model to the pixel data [optional].
#. Add readout noise selected from a Gaussian distribution [optional].
#. Add readout noise selected from a Gaussian distribution [optional].
#. Convert from electrons to ADUs using a given gain factor.
#. Convert from electrons to ADUs using a given gain factor.
#. Add a given bias level and discretise the counts (the output is going to be in 16bit unsigned integers).
#. Add a given bias level and discretise the counts (the output is going to be in 16bit unsigned integers).
#. Finally the simulated image is converted to a FITS file, a WCS is assigned
#. Finally the simulated image is converted to a FITS file, a WCS is assigned
and the output is saved to the current working directory.
and the output is saved to the current working directory.
.. Warning:: The code is still work in progress and new features are being added.
.. Warning:: The code is still work in progress and new features are being added.
...
@@ -1389,14 +1391,20 @@ class IFSsimulator():
...
@@ -1389,14 +1391,20 @@ class IFSsimulator():
else
:
else
:
ss
=
'_'
ss
=
'_'
# if currentpath =='/home/yan/IFS':
if
self
.
information
[
'dir_path'
]
==
'/nfsdata/share/simulation-unittest/ifs_sim/'
:
self
.
result_path
=
self
.
information
[
'dir_path'
]
+
'ifs_sim_result/'
+
self
.
source
+
ss
+
result_day
else
:
home_path
=
os
.
environ
[
'HOME'
]
if
home_path
==
'/home/yan'
:
self
.
result_path
=
'../IFS_simData_'
+
self
.
source
+
ss
+
result_day
else
:
self
.
result_path
=
'/data/ifspip/CCD_ima/IFS_simData_'
+
self
.
source
+
ss
+
result_day
# self.result_path='../IFS_simData_'+self.source+ss+result_day
# else:
# self.result_path='/data/ifspip/CCD_ima/IFS_simData_'+self.source+ss+result_day
self
.
result_path
=
self
.
information
[
'dir_path'
]
+
'ifs_sim_result/'
+
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
)
...
@@ -5018,18 +5026,12 @@ class IFSsimulator():
...
@@ -5018,18 +5026,12 @@ class IFSsimulator():
self
.
log
.
info
(
'%s = %s'
%
(
key
,
value
))
self
.
log
.
info
(
'%s = %s'
%
(
key
,
value
))
self
.
log
.
info
(
'Finished the ith_Exposure = %i'
%
(
simnumber
))
self
.
log
.
info
(
'Finished the ith_Exposure = %i'
%
(
simnumber
))
#print('The iLoop= % d simlaiton finished. ' %simnumber)
# print('The iLoop= % d simlaiton finished. ' %simnumber)
##############################################################################################
##############################################################################################
############################################################################
############################################################################
def
runIFSsim
(
sourcein
,
configfile
,
iLoop
,
applyhole
=
'no'
):
def
runIFSsim
(
sourcein
,
configfile
,
iLoop
,
applyhole
=
'no'
):
# opts, args = processArgs()
# opts.configfile = configfile
simulate
=
dict
()
simulate
=
dict
()
simulate
[
iLoop
]
=
IFSsimulator
(
configfile
)
simulate
[
iLoop
]
=
IFSsimulator
(
configfile
)
...
@@ -5040,12 +5042,6 @@ def runIFSsim(sourcein, configfile, iLoop, applyhole='no'):
...
@@ -5040,12 +5042,6 @@ def runIFSsim(sourcein, configfile, iLoop, applyhole='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
...
...
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