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_mci_sim
Commits
251af67c
Commit
251af67c
authored
Dec 27, 2024
by
Yan Zhaojun
Browse files
update
parent
cf7c5c51
Pipeline
#7616
failed with stage
in 0 seconds
Changes
2
Pipelines
1
Show whitespace changes
Inline
Side-by-side
csst_mci_sim/csst_mci_sim.py
View file @
251af67c
...
@@ -1447,17 +1447,15 @@ class MCIsimulator():
...
@@ -1447,17 +1447,15 @@ class MCIsimulator():
self
.
star
=
df0
[
1
].
data
self
.
star
=
df0
[
1
].
data
###
###
try
:
if
'ra'
not
in
self
.
star
.
names
:
self
.
star
[
'ra'
][
10
]
print
(
'no ra'
)
except
NameError
:
self
.
log
.
error
(
self
.
log
.
error
(
'Error,no ra data in the star_cat catlog file '
)
'Error,no ra data in the star_cat catlog file '
)
raise
ValueError
(
raise
ValueError
(
'Error,no ra data in the star_cat catlog file '
)
'Error,no ra data in the star_cat catlog file '
)
#
#
try
:
if
'dec'
not
in
self
.
star
.
names
:
self
.
star
[
'dec'
][
10
]
print
(
'no ra'
)
except
NameError
:
self
.
log
.
error
(
self
.
log
.
error
(
'Error,no dec data in the star_cat catlog file '
)
'Error,no dec data in the star_cat catlog file '
)
raise
ValueError
(
raise
ValueError
(
...
@@ -1853,10 +1851,10 @@ class MCIsimulator():
...
@@ -1853,10 +1851,10 @@ class MCIsimulator():
imag
=
self
.
star
[
'imag'
][
j
]
imag
=
self
.
star
[
'imag'
][
j
]
zmag
=
self
.
star
[
'zmag'
][
j
]
zmag
=
self
.
star
[
'zmag'
][
j
]
flag
=
(
umag
>
0
and
gmag
>
0
and
rmag
>
# if j==426:
0
and
imag
>
0
and
zmag
>
0
)
# print('debug error'
)
if
flag
is
False
:
if
np
.
isnan
(
umag
)
or
np
.
isnan
(
gmag
)
or
np
.
isnan
(
rmag
)
or
np
.
isnan
(
imag
)
or
np
.
isnan
(
zmag
)
:
continue
continue
wave
=
np
.
linspace
(
2500
,
11000
,
8501
)
wave
=
np
.
linspace
(
2500
,
11000
,
8501
)
...
@@ -1864,7 +1862,7 @@ class MCIsimulator():
...
@@ -1864,7 +1862,7 @@ class MCIsimulator():
redshift
=
0
redshift
=
0
# Loading galaxy SED template
# Loading galaxy SED template
t
=
sed
.
Gal_Temp
(
self
.
information
[
'dir_path'
])
t
=
sed
.
Gal_Temp
(
self
.
log
,
self
.
information
[
'dir_path'
])
# Calculating the magnitude (u, g, r, i, z) of each template
# Calculating the magnitude (u, g, r, i, z) of each template
t
.
toMag
(
redshift
=
redshift
)
t
.
toMag
(
redshift
=
redshift
)
# Calculating flux
# Calculating flux
...
@@ -2376,6 +2374,13 @@ class MCIsimulator():
...
@@ -2376,6 +2374,13 @@ class MCIsimulator():
srcs_sed
=
fits
.
open
(
filename
)
srcs_sed
=
fits
.
open
(
filename
)
self
.
log
.
info
(
'galaxy_Input SED path is: %s'
%
(
filename
))
self
.
log
.
info
(
'galaxy_Input SED path is: %s'
%
(
filename
))
#
if
len
(
srcs_cat
)
!=
len
(
srcs_sed
):
#
self
.
log
.
error
(
'Error,image data do not mach sed data in the input galaxy data file '
)
raise
ValueError
(
'Error,image data do not mach sed data in the input galaxy data file '
)
# ##### do Tiance Effect ###
# ##### do Tiance Effect ###
ra_list
=
[]
ra_list
=
[]
...
@@ -3887,7 +3892,8 @@ class MCIsimulator():
...
@@ -3887,7 +3892,8 @@ class MCIsimulator():
hdu_g
.
header
[
'RADECSYS'
]
=
(
hdu_g
.
header
[
'RADECSYS'
]
=
(
'ICRS'
,
'coordinate system of the object'
)
'ICRS'
,
'coordinate system of the object'
)
hdu_g
.
header
[
'EQUINOX'
]
=
(
float
(
2000.1
),
''
)
hdu_g
.
header
[
'EQUINOX'
]
=
(
float
(
2000.1
),
''
)
hdu_g
.
header
[
'FITSSWV'
]
=
(
'csst_mci_sim_3.0.0'
,
'FITS creating software version'
)
hdu_g
.
header
[
'FITSSWV'
]
=
(
'csst_mci_sim_3.0.0'
,
'FITS creating software version'
)
########################################
########################################
...
@@ -4438,7 +4444,8 @@ class MCIsimulator():
...
@@ -4438,7 +4444,8 @@ class MCIsimulator():
hdu_r
.
header
[
'RADECSYS'
]
=
(
hdu_r
.
header
[
'RADECSYS'
]
=
(
'ICRS'
,
'coordinate system of the object'
)
'ICRS'
,
'coordinate system of the object'
)
hdu_r
.
header
[
'EQUINOX'
]
=
(
float
(
2000.1
),
''
)
hdu_r
.
header
[
'EQUINOX'
]
=
(
float
(
2000.1
),
''
)
hdu_r
.
header
[
'FITSSWV'
]
=
(
'csst_mci_sim_3.0.0'
,
'FITS creating software version'
)
hdu_r
.
header
[
'FITSSWV'
]
=
(
'csst_mci_sim_3.0.0'
,
'FITS creating software version'
)
########################################
########################################
...
@@ -4989,7 +4996,8 @@ class MCIsimulator():
...
@@ -4989,7 +4996,8 @@ class MCIsimulator():
hdu_i
.
header
[
'RADECSYS'
]
=
(
hdu_i
.
header
[
'RADECSYS'
]
=
(
'ICRS'
,
'coordinate system of the object'
)
'ICRS'
,
'coordinate system of the object'
)
hdu_i
.
header
[
'EQUINOX'
]
=
(
float
(
2000.1
),
''
)
hdu_i
.
header
[
'EQUINOX'
]
=
(
float
(
2000.1
),
''
)
hdu_i
.
header
[
'FITSSWV'
]
=
(
'csst_mci_sim_3.0.0'
,
'FITS creating software version'
)
hdu_i
.
header
[
'FITSSWV'
]
=
(
'csst_mci_sim_3.0.0'
,
'FITS creating software version'
)
########################################
########################################
...
@@ -5762,7 +5770,7 @@ class MCIsimulator():
...
@@ -5762,7 +5770,7 @@ class MCIsimulator():
if
self
.
cosmicRays
:
if
self
.
cosmicRays
:
self
.
addCosmicRays
()
self
.
addCosmicRays
()
print
(
'addCosmicRays finis
t
h'
)
print
(
'addCosmicRays finish
ed
'
)
##################################################
##################################################
if
self
.
skyback
:
if
self
.
skyback
:
...
@@ -5773,7 +5781,7 @@ class MCIsimulator():
...
@@ -5773,7 +5781,7 @@ class MCIsimulator():
if
self
.
darknoise
:
if
self
.
darknoise
:
self
.
applyDarkCurrent
()
self
.
applyDarkCurrent
()
print
(
'applyDarkCurrent finis
t
h'
)
print
(
'applyDarkCurrent finish
ed
'
)
#################################################
#################################################
...
@@ -5788,7 +5796,7 @@ class MCIsimulator():
...
@@ -5788,7 +5796,7 @@ class MCIsimulator():
self
.
image_g
=
self
.
applyBleeding
(
self
.
image_g
.
copy
())
self
.
image_g
=
self
.
applyBleeding
(
self
.
image_g
.
copy
())
self
.
image_r
=
self
.
applyBleeding
(
self
.
image_r
.
copy
())
self
.
image_r
=
self
.
applyBleeding
(
self
.
image_r
.
copy
())
self
.
image_i
=
self
.
applyBleeding
(
self
.
image_i
.
copy
())
self
.
image_i
=
self
.
applyBleeding
(
self
.
image_i
.
copy
())
print
(
'apply bleeding effect finis
t
h'
)
print
(
'apply bleeding effect finish
ed
'
)
################################################
################################################
...
@@ -5828,13 +5836,13 @@ class MCIsimulator():
...
@@ -5828,13 +5836,13 @@ class MCIsimulator():
self
.
image_g
=
self
.
image_g
/
1.0
self
.
image_g
=
self
.
image_g
/
1.0
self
.
image_r
=
self
.
image_r
/
1.0
self
.
image_r
=
self
.
image_r
/
1.0
self
.
image_i
=
self
.
image_i
/
1.0
self
.
image_i
=
self
.
image_i
/
1.0
print
(
'apply gain finish'
)
print
(
'apply gain finish
ed
'
)
######################################################################
######################################################################
# size of the output image array, xsize is column, ysize is row, xsize = 9216,ysize = 9232
# size of the output image array, xsize is column, ysize is row, xsize = 9216,ysize = 9232
if
self
.
information
[
'xsize'
]
==
9216
and
self
.
information
[
'ysize'
]
==
9232
and
self
.
overscans
:
if
self
.
information
[
'xsize'
]
==
9216
and
self
.
information
[
'ysize'
]
==
9232
and
self
.
overscans
:
self
.
applyBias
()
self
.
applyBias
()
print
(
'apply bias finish'
)
print
(
'apply bias finish
ed
'
)
else
:
else
:
self
.
image_g
=
self
.
image_g
+
500.0
self
.
image_g
=
self
.
image_g
+
500.0
self
.
image_r
=
self
.
image_r
+
500.0
self
.
image_r
=
self
.
image_r
+
500.0
...
...
csst_mci_sim/support/sed.py
View file @
251af67c
...
@@ -126,7 +126,7 @@ class Gal_Temp():
...
@@ -126,7 +126,7 @@ class Gal_Temp():
Template of Galaxy SED
Template of Galaxy SED
"""
"""
def
__init__
(
self
,
path
):
def
__init__
(
self
,
log
,
path
):
#
#
...
@@ -134,6 +134,13 @@ class Gal_Temp():
...
@@ -134,6 +134,13 @@ class Gal_Temp():
self
.
path
=
path
self
.
path
=
path
hdulist
=
fits
.
open
(
hdulist
=
fits
.
open
(
self
.
path
+
'MCI_inputData/SED_Code/seddata/galaxy_temp.fits'
)
self
.
path
+
'MCI_inputData/SED_Code/seddata/galaxy_temp.fits'
)
if
len
(
hdulist
)
<
4
:
log
.
error
(
'Data error in galaxy_temp.fits file, please check!!!'
)
raise
ValueError
(
'Data error in galaxy_temp.fits file, please check!!!'
)
self
.
wave
=
hdulist
[
1
].
data
[
'wave'
]
self
.
wave
=
hdulist
[
1
].
data
[
'wave'
]
self
.
flux
=
hdulist
[
2
].
data
self
.
flux
=
hdulist
[
2
].
data
self
.
age_grid
=
hdulist
[
3
].
data
[
'logAge'
]
self
.
age_grid
=
hdulist
[
3
].
data
[
'logAge'
]
...
@@ -141,7 +148,6 @@ class Gal_Temp():
...
@@ -141,7 +148,6 @@ class Gal_Temp():
def
toMag
(
self
,
redshift
=
0
):
def
toMag
(
self
,
redshift
=
0
):
"""Calculating magnitude
"""Calculating magnitude
Args:
Args:
redshift (float, optional): redshift of spectra. Defaults to 0.
redshift (float, optional): redshift of spectra. Defaults to 0.
"""
"""
...
@@ -165,13 +171,14 @@ class Star_Temp():
...
@@ -165,13 +171,14 @@ class Star_Temp():
# parent = os.path.dirname(os.path.realpath(__file__))
# parent = os.path.dirname(os.path.realpath(__file__))
# print("获取其父目录——" + parent) # 从当前文件路径中获取目录
# print("获取其父目录——" + parent) # 从当前文件路径中获取目录
hdulist
=
fits
.
open
(
hdulist
=
fits
.
open
(
os
.
path
.
join
(
path
,
'MCI_inputData/SED_Code/seddata/stellar_temp.fits'
))
os
.
path
.
join
(
path
,
'MCI_inputData/SED_Code/seddata/stellar_temp
_wrong
.fits'
))
if
hdulist
[
1
].
data
[
'wave'
]
==
[]
or
hdulist
[
2
].
data
==
[]
or
hdulist
[
3
].
data
[
'Teff'
]
==
[]
or
hdulist
[
3
].
data
[
'FeH'
]
==
[]
:
if
len
(
hdulist
)
<
4
:
self
.
log
.
error
(
self
.
log
.
error
(
'Data error in
tellar
_temp.fits file, please check!!!'
)
'Data error in
galaxy
_temp.fits file, please check!!!'
)
raise
ValueError
(
raise
ValueError
(
'Data error in tellar_temp.fits file, please check!!!'
)
'Data error in galaxy_temp.fits file, please check!!!'
)
self
.
wave
=
hdulist
[
1
].
data
[
'wave'
]
self
.
wave
=
hdulist
[
1
].
data
[
'wave'
]
self
.
flux
=
hdulist
[
2
].
data
self
.
flux
=
hdulist
[
2
].
data
...
...
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