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
633fbbab
Commit
633fbbab
authored
Jan 18, 2024
by
Fang Yuedong
Browse files
first test
parent
8d77fcd3
Changes
11
Expand all
Hide whitespace changes
Inline
Side-by-side
ObservationSim/Config/Header/ImageHeader.py
View file @
633fbbab
...
@@ -342,7 +342,7 @@ def WCS_def(xlen = 9216, ylen = 9232, gapy = 898.0, gapx1 = 534, gapx2 = 1309, r
...
@@ -342,7 +342,7 @@ def WCS_def(xlen = 9216, ylen = 9232, gapy = 898.0, gapx1 = 534, gapx2 = 1309, r
#TODO project_cycle is temporary, is not in header defined, delete in future
#TODO project_cycle is temporary, is not in header defined, delete in future
def
generatePrimaryHeader
(
xlen
=
9216
,
ylen
=
9232
,
pointNum
=
'1'
,
ra
=
60
,
dec
=
-
40
,
pixel_scale
=
0.074
,
date
=
'200930'
,
time_obs
=
'120000'
,
im_type
=
'
M
S'
,
exptime
=
150.
,
sat_pos
=
[
0.
,
0.
,
0.
],
sat_vel
=
[
0.
,
0.
,
0.
],
project_cycle
=
6
,
run_counter
=
0
,
chip_name
=
"01"
):
def
generatePrimaryHeader
(
xlen
=
9216
,
ylen
=
9232
,
pointNum
=
'1'
,
ra
=
60
,
dec
=
-
40
,
pixel_scale
=
0.074
,
date
=
'200930'
,
time_obs
=
'120000'
,
im_type
=
'S
CIE
'
,
exptime
=
150.
,
sat_pos
=
[
0.
,
0.
,
0.
],
sat_vel
=
[
0.
,
0.
,
0.
],
project_cycle
=
6
,
run_counter
=
0
,
chip_name
=
"01"
):
# array_size1, array_size2, flux, sigma = int(argv[1]), int(argv[2]), 1000.0, 5.0
# array_size1, array_size2, flux, sigma = int(argv[1]), int(argv[2]), 1000.0, 5.0
...
@@ -391,7 +391,8 @@ def generatePrimaryHeader(xlen = 9216, ylen = 9232, pointNum = '1', ra = 60, dec
...
@@ -391,7 +391,8 @@ def generatePrimaryHeader(xlen = 9216, ylen = 9232, pointNum = '1', ra = 60, dec
# # Define file types
# # Define file types
# file_type = {'SCI':'SCIE', 'BIAS':'BIAS', 'DARK':'DARK', 'FLAT':'FLAT', 'CRS':'CRS', 'CRD':'CRD','CALS':'CALS','CALF':'CALF'}
# file_type = {'SCI':'SCIE', 'BIAS':'BIAS', 'DARK':'DARK', 'FLAT':'FLAT', 'CRS':'CRS', 'CRD':'CRD','CALS':'CALS','CALF':'CALF'}
# h_prim['FILETYPE'] = file_type[im_type]
# h_prim['FILETYPE'] = file_type[im_type]
h_prim
[
'FILETYPE'
]
=
get_file_type
(
img_type
=
im_type
)
# h_prim['FILETYPE'] = get_file_type(img_type=im_type)
h_prim
[
'FILETYPE'
]
=
im_type
co
=
coord
.
SkyCoord
(
ra
,
dec
,
unit
=
'deg'
)
co
=
coord
.
SkyCoord
(
ra
,
dec
,
unit
=
'deg'
)
...
@@ -450,7 +451,7 @@ def generatePrimaryHeader(xlen = 9216, ylen = 9232, pointNum = '1', ra = 60, dec
...
@@ -450,7 +451,7 @@ def generatePrimaryHeader(xlen = 9216, ylen = 9232, pointNum = '1', ra = 60, dec
return
h_prim
return
h_prim
def
generateExtensionHeader
(
chip
,
xlen
=
9216
,
ylen
=
9232
,
ra
=
60
,
dec
=
-
40
,
pa
=
-
23.433
,
gain
=
1.0
,
readout
=
5.0
,
dark
=
0.02
,
saturation
=
90000
,
pixel_scale
=
0.074
,
pixel_size
=
1e-2
,
def
generateExtensionHeader
(
chip
,
xlen
=
9216
,
ylen
=
9232
,
ra
=
60
,
dec
=
-
40
,
pa
=
-
23.433
,
gain
=
1.0
,
readout
=
5.0
,
dark
=
0.02
,
saturation
=
90000
,
pixel_scale
=
0.074
,
pixel_size
=
1e-2
,
extName
=
'SCI'
,
row_num
=
None
,
col_num
=
None
,
xcen
=
None
,
ycen
=
None
,
timestamp
=
1621915200
,
exptime
=
150.
,
readoutTime
=
40.
):
extName
=
'SCI
E
'
,
row_num
=
None
,
col_num
=
None
,
xcen
=
None
,
ycen
=
None
,
timestamp
=
1621915200
,
exptime
=
150.
,
readoutTime
=
40.
):
e_header_fn
=
os
.
path
.
split
(
os
.
path
.
realpath
(
__file__
))[
0
]
+
'/extension_header.header'
e_header_fn
=
os
.
path
.
split
(
os
.
path
.
realpath
(
__file__
))[
0
]
+
'/extension_header.header'
f
=
open
(
os
.
path
.
split
(
os
.
path
.
realpath
(
__file__
))[
0
]
+
'/filter.lst'
)
f
=
open
(
os
.
path
.
split
(
os
.
path
.
realpath
(
__file__
))[
0
]
+
'/filter.lst'
)
...
...
ObservationSim/Config/Pointing.py
View file @
633fbbab
import
numpy
as
np
import
numpy
as
np
import
galsim
import
galsim
import
yaml
from
astropy.time
import
Time
from
astropy.time
import
Time
import
ObservationSim.Instrument._util
as
_util
import
ObservationSim.Instrument._util
as
_util
...
@@ -42,13 +43,13 @@ class Pointing(object):
...
@@ -42,13 +43,13 @@ class Pointing(object):
return
max
(
150.
,
self
.
exp_time
)
# [TODO] for FGS
return
max
(
150.
,
self
.
exp_time
)
# [TODO] for FGS
def
read_pointing_columns
(
self
,
columns
,
id
=
0
,
t
=
1621915200
,
pointing_type
=
'SCI'
):
def
read_pointing_columns
(
self
,
columns
,
id
=
0
,
t
=
1621915200
,
pointing_type
=
'SCI
E
'
):
self
.
id
=
id
self
.
id
=
id
col_len
=
len
(
columns
)
col_len
=
len
(
columns
)
self
.
ra
=
float
(
columns
[
0
])
self
.
ra
=
float
(
columns
[
0
])
self
.
dec
=
float
(
columns
[
1
])
self
.
dec
=
float
(
columns
[
1
])
self
.
img_pa
=
float
(
columns
[
4
])
*
galsim
.
degrees
self
.
img_pa
=
float
(
columns
[
4
])
*
galsim
.
degrees
self
.
pointing_type
=
pointing_type
#
self.pointing_type = pointing_type
if
col_len
>
5
:
if
col_len
>
5
:
jdt
=
np
.
double
(
columns
[
5
])
jdt
=
np
.
double
(
columns
[
5
])
t_temp
=
Time
(
jdt
,
format
=
'jd'
)
t_temp
=
Time
(
jdt
,
format
=
'jd'
)
...
@@ -68,5 +69,14 @@ class Pointing(object):
...
@@ -68,5 +69,14 @@ class Pointing(object):
# [TODO] Can also define other survey types
# [TODO] Can also define other survey types
if
is_deep
!=
-
1.0
:
if
is_deep
!=
-
1.0
:
self
.
survey_field_type
=
"DEEP"
self
.
survey_field_type
=
"DEEP"
# Load the configuration file for this particular pointing
self
.
obs_config_file
=
"/share/home/fangyuedong/20231211/csst-simulation/config/obs_config_SCI_WIDE_phot.yaml"
with
open
(
self
.
obs_config_file
,
"r"
)
as
stream
:
try
:
self
.
obs_param
=
yaml
.
safe_load
(
stream
)
except
yaml
.
YAMLError
as
exc
:
print
(
exc
)
self
.
pointing_type
=
self
.
obs_config_file
[
"obs_type"
]
else
:
else
:
self
.
timestamp
=
t
self
.
timestamp
=
t
ObservationSim/Config/_util.py
View file @
633fbbab
def
get_obs_id
(
img_type
=
'SCI'
,
project_cycle
=
6
,
run_counter
=
0
,
pointing_num
=
0
):
def
get_obs_id
(
img_type
=
'SCI
E
'
,
project_cycle
=
6
,
run_counter
=
0
,
pointing_num
=
0
):
# obs_type = {'SCI': '01', 'BIAS': '03', 'DARK': '07', 'FLAT': '11', 'CRS': '98', 'CRD': '99'}
# obs_type = {'SCI': '01', 'BIAS': '03', 'DARK': '07', 'FLAT': '11', 'CRS': '98', 'CRD': '99'}
obs_type
=
{
'SCI'
:
'01'
,
'BIAS'
:
'03'
,
'DARK'
:
'07'
,
'FLAT'
:
'11'
,
'CRS'
:
'98'
,
'CRD'
:
'99'
,
'CAL'
:
'01'
}
obs_type
=
{
'SCIE'
:
'01'
,
'BIAS'
:
'03'
,
'DARK'
:
'07'
,
'FLAT'
:
'11'
,
'CRS'
:
'98'
,
'CRD'
:
'99'
,
'CAL'
:
'01'
}
# obs_id = '1'+ obs_type[img_type] + str(int(project_cycle)) + str(int(run_counter)).rjust(2, '0') + str(pointing_num).rjust(5,'0')
obs_id
=
'1'
+
obs_type
[
img_type
]
+
str
(
int
(
project_cycle
)).
rjust
(
2
,
'0'
)
+
str
(
int
(
run_counter
))
+
str
(
pointing_num
).
rjust
(
8
,
'0'
)
obs_id
=
'1'
+
obs_type
[
img_type
]
+
str
(
int
(
project_cycle
)).
rjust
(
2
,
'0'
)
+
str
(
int
(
run_counter
))
+
str
(
pointing_num
).
rjust
(
8
,
'0'
)
return
obs_id
return
obs_id
...
...
ObservationSim/Instrument/Chip/ChipUtils.py
View file @
633fbbab
...
@@ -87,7 +87,7 @@ def generateHeader(chip, ra_cen, dec_cen, img_rot, im_type, pointing_ID, exptime
...
@@ -87,7 +87,7 @@ def generateHeader(chip, ra_cen, dec_cen, img_rot, im_type, pointing_ID, exptime
pixel_size
=
chip
.
pix_size
,
pixel_size
=
chip
.
pix_size
,
xcen
=
chip
.
x_cen
,
xcen
=
chip
.
x_cen
,
ycen
=
chip
.
y_cen
,
ycen
=
chip
.
y_cen
,
extName
=
'SCI'
,
extName
=
'SCI
E
'
,
timestamp
=
timestamp
,
timestamp
=
timestamp
,
exptime
=
exptime
,
exptime
=
exptime
,
readoutTime
=
chip
.
readout_time
)
readoutTime
=
chip
.
readout_time
)
...
...
ObservationSim/Instrument/FocalPlane.py
View file @
633fbbab
...
@@ -2,17 +2,24 @@ import galsim
...
@@ -2,17 +2,24 @@ import galsim
import
numpy
as
np
import
numpy
as
np
class
FocalPlane
(
object
):
class
FocalPlane
(
object
):
def
__init__
(
self
,
config
=
None
,
survey_type
=
'Photometric'
,
bad_chips
=
None
):
def
__init__
(
self
,
config
=
None
,
chip_list
=
None
,
survey_type
=
'Photometric'
,
bad_chips
=
None
):
"""Get the focal plane layout
"""Get the focal plane layout
"""
"""
self
.
nchips
=
42
self
.
nchips
=
42
self
.
ignore_chips
=
[]
if
bad_chips
==
None
:
if
bad_chips
==
None
:
self
.
bad_chips
=
[]
self
.
bad_chips
=
[]
else
:
else
:
self
.
bad_chips
=
bad_chips
self
.
bad_chips
=
bad_chips
for
chip_id
in
bad_chips
:
self
.
ignore_chips
.
append
(
chip_id
)
self
.
ignore_chips
=
[]
if
chip_list
is
not
None
:
if
survey_type
==
'Photometric'
:
for
i
in
range
(
42
):
if
not
(
i
+
1
in
chip_list
):
self
.
ignore_chips
.
append
(
i
+
1
)
elif
survey_type
==
'Photometric'
:
for
i
in
range
(
5
):
for
i
in
range
(
5
):
self
.
ignore_chips
.
append
(
i
+
1
)
self
.
ignore_chips
.
append
(
i
+
1
)
self
.
ignore_chips
.
append
(
i
+
26
)
self
.
ignore_chips
.
append
(
i
+
26
)
...
...
ObservationSim/ObservationSim.py
View file @
633fbbab
This diff is collapsed.
Click to expand it.
ObservationSim/SimSteps.py
0 → 100644
View file @
633fbbab
This diff is collapsed.
Click to expand it.
ObservationSim/_util.py
View file @
633fbbab
...
@@ -96,7 +96,7 @@ def make_run_dirs(work_dir, run_name, pointing_list):
...
@@ -96,7 +96,7 @@ def make_run_dirs(work_dir, run_name, pointing_list):
os
.
makedirs
(
imgDir
,
exist_ok
=
True
)
os
.
makedirs
(
imgDir
,
exist_ok
=
True
)
except
OSError
:
except
OSError
:
pass
pass
prefix
=
"MSC_"
#
prefix = "MSC_"
# for pointing in pointing_list:
# for pointing in pointing_list:
# fname=prefix + str(pointing.id).rjust(7, '0')
# fname=prefix + str(pointing.id).rjust(7, '0')
# subImgDir = os.path.join(imgDir, fname)
# subImgDir = os.path.join(imgDir, fname)
...
@@ -107,26 +107,26 @@ def make_run_dirs(work_dir, run_name, pointing_list):
...
@@ -107,26 +107,26 @@ def make_run_dirs(work_dir, run_name, pointing_list):
# pass
# pass
return
imgDir
return
imgDir
def
imgName
(
tt
=
0
):
#
def imgName(tt=0):
ut
=
datetime
.
utcnow
()
#
ut = datetime.utcnow()
eye
,
emo
,
eda
,
eho
,
emi
,
ese
=
str
(
ut
.
year
),
str
(
ut
.
month
),
str
(
ut
.
day
),
str
(
ut
.
hour
),
str
(
ut
.
minute
),
str
(
ut
.
second
)
#
eye, emo, eda, eho, emi, ese = str(ut.year), str(ut.month), str(ut.day), str(ut.hour), str(ut.minute), str(ut.second)
emse
=
str
(
ut
.
microsecond
)
#
emse = str(ut.microsecond)
if
int
(
emo
)
<
10
:
emo
=
"0%s"
%
emo
#
if int(emo)<10: emo = "0%s"%emo
if
int
(
eda
)
<
10
:
eda
=
"0%s"
%
eda
#
if int(eda)<10: eda = "0%s"%eda
if
int
(
eho
)
<
10
:
eho
=
"0%s"
%
eho
#
if int(eho)<10: eho = "0%s"%eho
if
int
(
emi
)
<
10
:
emi
=
"0%s"
%
emi
#
if int(emi)<10: emi = "0%s"%emi
if
int
(
ese
)
<
10
:
ese
=
"0%s"
%
ese
#
if int(ese)<10: ese = "0%s"%ese
if
tt
==
0
:
#
if tt==0:
namekey
=
"CSST%s%s%sT%s%s%s"
%
(
eye
,
emo
,
eda
,
eho
,
emi
,
ese
)
#
namekey = "CSST%s%s%sT%s%s%s"%(eye,emo,eda,eho,emi,ese)
elif
tt
==
1
:
#
elif tt==1:
namekey
=
"%s-%s-%sT%s:%s:%s.%s"
%
(
eye
,
emo
,
eda
,
eho
,
emi
,
ese
,
emse
)
#
namekey = "%s-%s-%sT%s:%s:%s.%s"%(eye,emo,eda,eho,emi,ese,emse)
elif
tt
==
2
:
#
elif tt==2:
namekey
=
"%s%s%s%s%s%s"
%
(
eye
,
emo
,
eda
,
eho
,
emi
,
ese
)
#
namekey = "%s%s%s%s%s%s"%(eye,emo,eda,eho,emi,ese)
else
:
#
else:
raise
ValueError
(
"!!! Give a right 'tt' value."
)
#
raise ValueError("!!! Give a right 'tt' value.")
return
namekey
#
return namekey
def
makeSubDir_PointingList
(
path_dict
,
config
,
pointing_ID
=
0
):
def
makeSubDir_PointingList
(
path_dict
,
config
,
pointing_ID
=
0
):
imgDir
=
os
.
path
.
join
(
path_dict
[
"work_dir"
],
config
[
"run_name"
])
imgDir
=
os
.
path
.
join
(
path_dict
[
"work_dir"
],
config
[
"run_name"
])
...
...
config/config_overall.yaml
View file @
633fbbab
...
@@ -73,9 +73,6 @@ obs_setting:
...
@@ -73,9 +73,6 @@ obs_setting:
# Whether to enable astrometric modeling
# Whether to enable astrometric modeling
enable_astrometric_model
:
True
enable_astrometric_model
:
True
# Whether to enable straylight model
enable_straylight_model
:
True
# Cut by saturation magnitude in which band?
# Cut by saturation magnitude in which band?
cut_in_band
:
"
z"
cut_in_band
:
"
z"
...
...
config/obs_config_SCI_WIDE.yaml
→
config/obs_config_SCI_WIDE
_phot
.yaml
View file @
633fbbab
...
@@ -11,15 +11,51 @@
...
@@ -11,15 +11,51 @@
# Observation type
# Observation type
obs_type
:
"
SCIE"
obs_type
:
"
SCIE"
# Define simulation sequence
# Define list of chips
run_chips
:
[
6
,
7
,
8
,
9
,
11
,
12
,
13
,
14
,
15
,
16
,
17
,
18
,
19
,
20
,
22
,
23
,
24
,
25
]
# Define observation sequence
call_sequence
:
call_sequence
:
#
Sky background simulation
#
Accumulate fluxes from objects
s
ky_background
:
s
cie_obs
:
exptime
:
150.
# [s]
exptime
:
150.
# [s]
shutter_effect
:
YES
shutter_effect
:
YES
flat_fielding
:
YES
flat_fielding
:
YES
scie_obs
:
field_dist
:
YES
# Accumulate fluxes from sky background
sky_background
:
exptime
:
150.
# [s]
exptime
:
150.
# [s]
shutter_effect
:
YES
shutter_effect
:
YES
flat_fielding
:
YES
flat_fielding
:
YES
enable_straylight_model
:
True
# Apply PRNU to accumulated photons
PRNU_effect
:
{}
# Accumulate photons caused by cosmic rays
cosmic_rays
:
{}
# Add Poission noise and dark current
poisson_and_dark
:
add_dark
:
YES
# Simulate brighter fatter effects
bright_fatter
:
{}
# Add detector defects: hot/warm pixels, bad columns
detector_defects
:
hot_pixels
:
YES
dead_pixels
:
YES
bad_columns
:
YES
# Apply response nonlinearity
nonlinearity
:
{}
# Apply CCD Saturation & Blooming
blooming
:
{}
# Run CTE simulation
CTE_effect
:
{}
# Add prescan and overscan
prescan_overscan
:
{}
# Add bias
bias
:
bias_16channel
:
YES
# Add readout noise
readout_noise
:
{}
# Apply gain
gain
:
gain_16channel
:
YES
...
...
\ No newline at end of file
run_sim.py
View file @
633fbbab
...
@@ -50,10 +50,10 @@ def run_sim():
...
@@ -50,10 +50,10 @@ def run_sim():
config
[
'work_dir'
]
=
args
.
work_dir
config
[
'work_dir'
]
=
args
.
work_dir
# Some default values
# Some default values
if
"bias_16channel"
not
in
config
[
"ins_effects"
]:
#
if "bias_16channel" not in config["ins_effects"]:
config
[
"ins_effects"
][
"bias_16channel"
]
=
False
#
config["ins_effects"]["bias_16channel"] = False
if
"gain_16channel"
not
in
config
[
"ins_effects"
]:
#
if "gain_16channel" not in config["ins_effects"]:
config
[
"ins_effects"
][
"gain_16channel"
]
=
False
#
config["ins_effects"]["gain_16channel"] = False
if
"mag_sat_margin"
not
in
config
[
"obs_setting"
]:
if
"mag_sat_margin"
not
in
config
[
"obs_setting"
]:
config
[
"obs_setting"
][
"mag_sat_margin"
]
=
-
2.5
config
[
"obs_setting"
][
"mag_sat_margin"
]
=
-
2.5
if
"mag_lim_margin"
not
in
config
[
"obs_setting"
]:
if
"mag_lim_margin"
not
in
config
[
"obs_setting"
]:
...
...
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