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
d1fefe06
Commit
d1fefe06
authored
Dec 25, 2024
by
Yan Zhaojun
Browse files
update
parent
4a697122
Changes
3
Hide whitespace changes
Inline
Side-by-side
csst_mci_sim/csst_mci_sim.py
View file @
d1fefe06
...
@@ -1397,7 +1397,30 @@ class MCIsimulator():
...
@@ -1397,7 +1397,30 @@ class MCIsimulator():
##########################################
##########################################
df2
=
pandas
.
read_csv
(
df2
=
pandas
.
read_csv
(
self
.
information
[
'dir_path'
]
+
'MCI_inputData/star_input/'
+
starcat
)
self
.
information
[
'dir_path'
]
+
'MCI_inputData/star_input/'
+
starcat
)
###
try
:
df2
[
'ra_gaia'
][
10
]
except
NameError
:
self
.
log
.
error
(
'Error,no ra data in the star_cat catlog file '
)
raise
ValueError
(
'Error,no ra data in the star_cat catlog file '
)
try
:
df2
[
'dec_gaia'
][
10
]
except
NameError
:
self
.
log
.
error
(
'Error,no dec data in the star_cat catlog file '
)
raise
ValueError
(
'Error,no dec data in the star_cat catlog file '
)
if
df2
[
'ra_gaia'
].
max
()
>
360
or
df2
[
'ra_gaia'
].
min
()
<
0
or
df2
[
'dec_gaia'
].
max
()
>
90
or
df2
[
'dec_gaia'
].
min
()
<-
90
:
self
.
log
.
error
(
'ra or dec data beyond definition,please check!'
)
raise
ValueError
(
'ra or dec data beyond definition,please check!'
)
df3
=
df2
[(
abs
(
df2
[
'ra_gaia'
]
-
df2
[
'ra_gaia'
].
mean
())
<
400
/
3600.0
)
df3
=
df2
[(
abs
(
df2
[
'ra_gaia'
]
-
df2
[
'ra_gaia'
].
mean
())
<
400
/
3600.0
)
&
(
abs
(
df2
[
'dec_gaia'
]
-
df2
[
'dec_gaia'
].
mean
())
<
400
/
3600.0
)]
&
(
abs
(
df2
[
'dec_gaia'
]
-
df2
[
'dec_gaia'
].
mean
())
<
400
/
3600.0
)]
...
@@ -1422,6 +1445,29 @@ class MCIsimulator():
...
@@ -1422,6 +1445,29 @@ class MCIsimulator():
self
.
information
[
'dir_path'
]
+
'/MCI_inputData/star_input/'
+
starcat
)
self
.
information
[
'dir_path'
]
+
'/MCI_inputData/star_input/'
+
starcat
)
self
.
star
=
df0
[
1
].
data
self
.
star
=
df0
[
1
].
data
###
try
:
self
.
star
[
'ra'
][
10
]
except
NameError
:
self
.
log
.
error
(
'Error,no ra data in the star_cat catlog file '
)
raise
ValueError
(
'Error,no ra data in the star_cat catlog file '
)
try
:
self
.
star
[
'dec'
][
10
]
except
NameError
:
self
.
log
.
error
(
'Error,no dec data in the star_cat catlog file '
)
raise
ValueError
(
'Error,no dec data in the star_cat catlog file '
)
if
self
.
star
[
'ra'
].
max
()
>
360
or
self
.
star
[
'ra'
].
min
()
<
0
or
self
.
star
[
'dec'
].
max
()
>
90
or
self
.
star
[
'dec'
].
min
()
<-
90
:
self
.
log
.
error
(
'ra or dec data beyond definition,please check!'
)
raise
ValueError
(
'ra or dec data beyond definition,please check!'
)
self
.
information
[
'ra_obj'
]
=
self
.
star
[
'ra'
].
mean
()
self
.
information
[
'ra_obj'
]
=
self
.
star
[
'ra'
].
mean
()
self
.
information
[
'dec_obj'
]
=
self
.
star
[
'dec'
].
mean
()
self
.
information
[
'dec_obj'
]
=
self
.
star
[
'dec'
].
mean
()
...
@@ -1637,8 +1683,8 @@ class MCIsimulator():
...
@@ -1637,8 +1683,8 @@ class MCIsimulator():
self
.
earthshine_wave
=
wave_mci
# A
self
.
earthshine_wave
=
wave_mci
# A
self
.
earthshine_flux
=
earthshine_mci
self
.
earthshine_flux
=
earthshine_mci
##############################################################
#########################
##############################################################
#############################################################
############################
#############################################################
self
.
cal_sky_noise
()
self
.
cal_sky_noise
()
...
@@ -2305,10 +2351,16 @@ class MCIsimulator():
...
@@ -2305,10 +2351,16 @@ class MCIsimulator():
if
not
os
.
path
.
exists
(
filename
):
if
not
os
.
path
.
exists
(
filename
):
print
(
'finish load all the input galaxy image fits files'
)
print
(
'finish load all the input galaxy image fits files'
)
self
.
log
.
error
(
'Error, when load input galaxy image fits files'
)
raise
ValueError
(
'Error, when load input galaxy image fits files'
)
break
break
srcs_cat
=
fits
.
open
(
filename
)
srcs_cat
=
fits
.
open
(
filename
)
# ### load galaxy SED fitsfile ###
# ### load galaxy SED fitsfile ###
if
self
.
lensing
:
if
self
.
lensing
:
...
@@ -2331,6 +2383,30 @@ class MCIsimulator():
...
@@ -2331,6 +2383,30 @@ class MCIsimulator():
dec_list
=
[]
dec_list
=
[]
for
kkk
in
range
(
1
,
len
(
srcs_cat
)):
for
kkk
in
range
(
1
,
len
(
srcs_cat
)):
# test input data
try
:
srcs_cat
[
kkk
].
header
[
'new_ra'
]
except
NameError
:
self
.
log
.
error
(
'Error,no ra data in the input galaxy data file '
)
raise
ValueError
(
'Error,no ra data in the input galaxy data file '
)
try
:
srcs_cat
[
kkk
].
header
[
'new_dec'
]
except
NameError
:
self
.
log
.
error
(
'Error,no dec data in the input galaxy data file '
)
raise
ValueError
(
'Error,no dec data in the input galaxy data file '
)
if
srcs_cat
[
kkk
].
header
[
'new_ra'
]
>
360
or
srcs_cat
[
kkk
].
header
[
'new_ra'
]
<
0
or
srcs_cat
[
kkk
].
header
[
'new_dec'
]
>
90
or
srcs_cat
[
kkk
].
header
[
'new_dec'
]
<-
90
:
self
.
log
.
error
(
'Gal ra or dec data beyond definition, please check!'
)
raise
ValueError
(
'Gal ra or dec data beyond definition, please check!'
)
#
t1
=
srcs_cat
[
kkk
].
header
[
'new_ra'
]
-
\
t1
=
srcs_cat
[
kkk
].
header
[
'new_ra'
]
-
\
self
.
information
[
'gal_ra'
]
+
self
.
information
[
'star_ra'
]
self
.
information
[
'gal_ra'
]
+
self
.
information
[
'star_ra'
]
ra_list
.
append
(
float
(
t1
))
ra_list
.
append
(
float
(
t1
))
...
@@ -2380,7 +2456,19 @@ class MCIsimulator():
...
@@ -2380,7 +2456,19 @@ class MCIsimulator():
# # SED of j-th galaxy ,# unit of 10-17 erg/s/A/cm2
# # SED of j-th galaxy ,# unit of 10-17 erg/s/A/cm2
# here is k1+1, not k1, k1 begins with 0
# here is k1+1, not k1, k1 begins with 0
gal_flux
=
srcs_sed
[
k1
+
1
].
data
gal_flux
=
srcs_sed
[
k1
+
1
].
data
if
gal_flux
.
min
()
<
0
or
len
(
gal_flux
)
<
100
:
self
.
log
.
error
(
'Galaxy SED data error, please check!'
)
raise
ValueError
(
'Galaxy SED data error, please check!'
)
if
srcs_cat
[
k1
+
1
].
data
.
min
()
<
0
or
srcs_cat
[
k1
+
1
].
data
.
max
==
0
or
srcs_cat
[
k1
+
1
].
data
.
ndim
!=
2
:
self
.
log
.
error
(
'Galaxy image data error, please check!'
)
raise
ValueError
(
'Galaxy image data error, please check!'
)
################################
################################
# ## rotate the lensed_images_g ###
# ## rotate the lensed_images_g ###
if
abs
(
theta
.
deg
)
>
0
:
if
abs
(
theta
.
deg
)
>
0
:
...
@@ -3608,7 +3696,7 @@ class MCIsimulator():
...
@@ -3608,7 +3696,7 @@ class MCIsimulator():
'ICRS'
,
'coordinate system of the object'
)
'ICRS'
,
'coordinate system of the object'
)
ofd_g
.
header
[
'EQUINOX'
]
=
(
float
(
2000.0
),
''
)
ofd_g
.
header
[
'EQUINOX'
]
=
(
float
(
2000.0
),
''
)
ofd_g
.
header
[
'FITSSWV'
]
=
(
ofd_g
.
header
[
'FITSSWV'
]
=
(
'mci_sim_
0.8.03
'
,
'FITS creating software version'
)
'
csst_
mci_sim_
3.0.0
'
,
'FITS creating software version'
)
##############################################################################
##############################################################################
# ######## Object information #########################################
# ######## Object information #########################################
ofd_g
.
header
[
'OBJECT'
]
=
(
ofd_g
.
header
[
'OBJECT'
]
=
(
...
@@ -3800,7 +3888,7 @@ class MCIsimulator():
...
@@ -3800,7 +3888,7 @@ 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'
]
=
(
'
4.2.1
'
,
'FITS creating software version'
)
hdu_g
.
header
[
'FITSSWV'
]
=
(
'
csst_mci_sim_3.0.0
'
,
'FITS creating software version'
)
########################################
########################################
...
@@ -4209,7 +4297,7 @@ class MCIsimulator():
...
@@ -4209,7 +4297,7 @@ class MCIsimulator():
'ICRS'
,
'coordinate system of the object'
)
'ICRS'
,
'coordinate system of the object'
)
ofd_r
.
header
[
'EQUINOX'
]
=
(
float
(
2000.0
),
''
)
ofd_r
.
header
[
'EQUINOX'
]
=
(
float
(
2000.0
),
''
)
ofd_r
.
header
[
'FITSSWV'
]
=
(
ofd_r
.
header
[
'FITSSWV'
]
=
(
'mci_sim_
0.8.03
'
,
'FITS creating software version'
)
'
csst_
mci_sim_
3.0.0
'
,
'FITS creating software version'
)
# ######## Object information #########################################
# ######## Object information #########################################
ofd_r
.
header
[
'OBJECT'
]
=
(
ofd_r
.
header
[
'OBJECT'
]
=
(
self
.
information
[
'name_obj'
][:
30
],
'object name'
)
self
.
information
[
'name_obj'
][:
30
],
'object name'
)
...
@@ -4351,7 +4439,7 @@ class MCIsimulator():
...
@@ -4351,7 +4439,7 @@ 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'
]
=
(
'
4.2.1
'
,
'FITS creating software version'
)
hdu_r
.
header
[
'FITSSWV'
]
=
(
'
csst_mci_sim_3.0.0
'
,
'FITS creating software version'
)
########################################
########################################
...
@@ -4757,7 +4845,7 @@ class MCIsimulator():
...
@@ -4757,7 +4845,7 @@ class MCIsimulator():
'ICRS'
,
'coordinate system of the object'
)
'ICRS'
,
'coordinate system of the object'
)
ofd_i
.
header
[
'EQUINOX'
]
=
(
float
(
2000.0
),
''
)
ofd_i
.
header
[
'EQUINOX'
]
=
(
float
(
2000.0
),
''
)
ofd_i
.
header
[
'FITSSWV'
]
=
(
ofd_i
.
header
[
'FITSSWV'
]
=
(
'mci_sim_
0.8.03
'
,
'FITS creating software version'
)
'
csst_
mci_sim_
3.0.0
'
,
'FITS creating software version'
)
##############################################################################
##############################################################################
# ######## Object information #########################################
# ######## Object information #########################################
ofd_i
.
header
[
'OBJECT'
]
=
(
ofd_i
.
header
[
'OBJECT'
]
=
(
...
@@ -4902,7 +4990,7 @@ class MCIsimulator():
...
@@ -4902,7 +4990,7 @@ 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'
]
=
(
'
4.2.1
'
,
'FITS creating software version'
)
hdu_i
.
header
[
'FITSSWV'
]
=
(
'
csst_mci_sim_3.0.0
'
,
'FITS creating software version'
)
########################################
########################################
...
@@ -5453,7 +5541,6 @@ class MCIsimulator():
...
@@ -5453,7 +5541,6 @@ class MCIsimulator():
self
.
log
.
info
(
'dis_ra(in pixel)=%f, dis_dec(in pixel)=%f, sky_rot(in deg)=%f'
%
(
self
.
log
.
info
(
'dis_ra(in pixel)=%f, dis_dec(in pixel)=%f, sky_rot(in deg)=%f'
%
(
dis_ra
*
3600
/
0.05
,
dis_dec
*
3600
/
0.05
,
theta
.
deg
))
dis_ra
*
3600
/
0.05
,
dis_dec
*
3600
/
0.05
,
theta
.
deg
))
###################################################################
###################################################################
##################################################################
##################################################################
# ######## simulate star images from star SED data ###########
# ######## simulate star images from star SED data ###########
...
@@ -5468,12 +5555,12 @@ class MCIsimulator():
...
@@ -5468,12 +5555,12 @@ class MCIsimulator():
# fits.writeto(self.result_path+'/ori_Sky/starimg_C2_'+str(simnumber)+'.fits',starimg['r'], overwrite=True)
# fits.writeto(self.result_path+'/ori_Sky/starimg_C2_'+str(simnumber)+'.fits',starimg['r'], overwrite=True)
# fits.writeto(self.result_path+'/ori_Sky/starimg_C3_'+str(simnumber)+'.fits',starimg['i'], overwrite=True)
# fits.writeto(self.result_path+'/ori_Sky/starimg_C3_'+str(simnumber)+'.fits',starimg['i'], overwrite=True)
self
.
img_fits_save
(
#
self.img_fits_save(
starimg
[
'g'
],
'star_ori_C1_'
+
str
(
simnumber
))
#
starimg['g'], 'star_ori_C1_'+str(simnumber))
self
.
img_fits_save
(
#
self.img_fits_save(
starimg
[
'r'
],
'star_ori_C2_'
+
str
(
simnumber
))
#
starimg['r'], 'star_ori_C2_'+str(simnumber))
self
.
img_fits_save
(
#
self.img_fits_save(
starimg
[
'i'
],
'star_ori_C3_'
+
str
(
simnumber
))
#
starimg['i'], 'star_ori_C3_'+str(simnumber))
print
(
'star image finished'
)
print
(
'star image finished'
)
...
@@ -5492,12 +5579,12 @@ class MCIsimulator():
...
@@ -5492,12 +5579,12 @@ class MCIsimulator():
# fits.writeto(self.result_path+'/ori_Sky/galimg_C2_'+str(simnumber)+'.fits',losimg['r'], overwrite=True)
# fits.writeto(self.result_path+'/ori_Sky/galimg_C2_'+str(simnumber)+'.fits',losimg['r'], overwrite=True)
# fits.writeto(self.result_path+'/ori_Sky/galimg_C3_'+str(simnumber)+'.fits',losimg['i'], overwrite=True)
# fits.writeto(self.result_path+'/ori_Sky/galimg_C3_'+str(simnumber)+'.fits',losimg['i'], overwrite=True)
self
.
img_fits_save
(
#
self.img_fits_save(
losimg
[
'g'
],
'gal_ori_C1_'
+
str
(
simnumber
))
#
losimg['g'], 'gal_ori_C1_'+str(simnumber))
self
.
img_fits_save
(
#
self.img_fits_save(
losimg
[
'r'
],
'gal_ori_C2_'
+
str
(
simnumber
))
#
losimg['r'], 'gal_ori_C2_'+str(simnumber))
self
.
img_fits_save
(
#
self.img_fits_save(
losimg
[
'i'
],
'gal_ori_C3_'
+
str
(
simnumber
))
#
losimg['i'], 'gal_ori_C3_'+str(simnumber))
##################################################################
##################################################################
...
@@ -5566,9 +5653,9 @@ class MCIsimulator():
...
@@ -5566,9 +5653,9 @@ class MCIsimulator():
self
.
information
[
'dec_pnt0'
]
=
0
self
.
information
[
'dec_pnt0'
]
=
0
self
.
information
[
'target'
]
=
'FLAT'
self
.
information
[
'target'
]
=
'FLAT'
self
.
image_g
+=
5
000
*
self
.
information
[
'simnumber'
]
self
.
image_g
+=
10
000
*
self
.
information
[
'simnumber'
]
self
.
image_r
+=
5
000
*
self
.
information
[
'simnumber'
]
self
.
image_r
+=
10
000
*
self
.
information
[
'simnumber'
]
self
.
image_i
+=
5
000
*
self
.
information
[
'simnumber'
]
self
.
image_i
+=
10
000
*
self
.
information
[
'simnumber'
]
elif
self
.
source
==
'DARK'
:
elif
self
.
source
==
'DARK'
:
...
@@ -5726,8 +5813,8 @@ class MCIsimulator():
...
@@ -5726,8 +5813,8 @@ class MCIsimulator():
self
.
applyRadiationDamage
()
self
.
applyRadiationDamage
()
print
(
'applyRadiationDamage()'
)
print
(
'applyRadiationDamage()'
)
#####################################################################
#
#####################################################################
#
##### apply readoutNoise ######
##### apply readoutNoise ######
if
self
.
readoutNoise
:
if
self
.
readoutNoise
:
self
.
applyReadoutNoise
()
self
.
applyReadoutNoise
()
...
@@ -5739,9 +5826,9 @@ class MCIsimulator():
...
@@ -5739,9 +5826,9 @@ class MCIsimulator():
print
(
'apply 1-16 zone by different gain '
)
print
(
'apply 1-16 zone by different gain '
)
else
:
else
:
self
.
image_g
=
self
.
image_g
/
1.
5
self
.
image_g
=
self
.
image_g
/
1.
0
self
.
image_r
=
self
.
image_r
/
1.
5
self
.
image_r
=
self
.
image_r
/
1.
0
self
.
image_i
=
self
.
image_i
/
1.
5
self
.
image_i
=
self
.
image_i
/
1.
0
print
(
'apply gain finish'
)
print
(
'apply gain finish'
)
######################################################################
######################################################################
# 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
...
...
csst_mci_sim/mci_so/__pycache__/__init__.cpython-311.pyc
0 → 100644
View file @
d1fefe06
File added
csst_mci_sim/support/sed.py
View file @
d1fefe06
...
@@ -165,7 +165,14 @@ class Star_Temp():
...
@@ -165,7 +165,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
(
path
+
'MCI_inputData/SED_Code/seddata/stellar_temp.fits'
)
os
.
path
.
join
(
path
,
'MCI_inputData/SED_Code/seddata/stellar_temp.fits'
))
if
hdulist
[
1
].
data
[
'wave'
]
==
[]
or
hdulist
[
2
].
data
==
[]
or
hdulist
[
3
].
data
[
'Teff'
]
==
[]
or
hdulist
[
3
].
data
[
'FeH'
]
==
[]:
self
.
log
.
error
(
'Data error in tellar_temp.fits file, please check!!!'
)
raise
ValueError
(
'Data error in tellar_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
.
Teff_grid
=
hdulist
[
3
].
data
[
'Teff'
]
self
.
Teff_grid
=
hdulist
[
3
].
data
[
'Teff'
]
...
...
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