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
Liu Dezi
csst_msc_sim
Commits
a8ad6d38
Commit
a8ad6d38
authored
Mar 19, 2023
by
Fang Yuedong
Browse files
fix issue with big galaxy: do not apply siliconsensor module to galaxy with hlr_bulge>3
parent
1db4fa7e
Changes
2
Hide whitespace changes
Inline
Side-by-side
ObservationSim/MockObject/Galaxy.py
View file @
a8ad6d38
...
...
@@ -10,6 +10,8 @@ from ObservationSim.MockObject._util import eObs, integrate_sed_bandpass, getNor
from
ObservationSim.MockObject.SpecDisperser
import
SpecDisperser
from
ObservationSim.MockObject.MockObject
import
MockObject
# import tracemalloc
class
Galaxy
(
MockObject
):
def
__init__
(
self
,
param
,
rotation
=
None
,
logger
=
None
):
super
().
__init__
(
param
,
logger
=
logger
)
...
...
@@ -95,10 +97,13 @@ class Galaxy(MockObject):
nphotons_sum
=
0
photons_list
=
[]
xmax
,
ymax
=
0
,
0
# # [C6 TEST]
# print('hlr_disk = %.4f, hlr_bulge = %.4f'%(self.hlr_disk, self.hlr_bulge))
# tracemalloc.start()
big_galaxy
=
False
if
self
.
hlr_disk
>
3.0
:
# Very big galaxy
if
self
.
hlr_disk
>
3.0
or
self
.
hlr_bulge
>
3.0
:
# Very big galaxy
big_galaxy
=
True
# (TEST) Galsim Parameters
...
...
@@ -139,6 +144,7 @@ class Galaxy(MockObject):
continue
nphotons_sum
+=
nphotons
# # [C6 TEST]
# print("nphotons_sub-band_%d = %.2f"%(i, nphotons))
psf
,
pos_shear
=
psf_model
.
get_PSF
(
chip
=
chip
,
pos_img
=
pos_img
,
bandpass
=
bandpass
,
folding_threshold
=
folding_threshold
)
...
...
@@ -174,8 +180,8 @@ class Galaxy(MockObject):
stamp
=
gal
.
drawImage
(
wcs
=
real_wcs_local
,
method
=
'phot'
,
offset
=
offset
,
save_photons
=
True
)
xmax
=
max
(
xmax
,
stamp
.
xmax
)
ymax
=
max
(
ymax
,
stamp
.
ymax
)
xmax
=
max
(
xmax
,
stamp
.
xmax
-
stamp
.
xmin
)
ymax
=
max
(
ymax
,
stamp
.
ymax
-
stamp
.
ymin
)
photons
=
stamp
.
photons
photons
.
x
+=
x_nominal
...
...
@@ -183,7 +189,13 @@ class Galaxy(MockObject):
photons_list
.
append
(
photons
)
del
gal
# # [C6 TEST]
# print('xmax = %d, ymax = %d '%(xmax, ymax))
# # Output memory usage
# snapshot = tracemalloc.take_snapshot()
# top_stats = snapshot.statistics('lineno')
# for stat in top_stats[:10]:
# print(stat)
stamp
=
galsim
.
ImageF
(
int
(
xmax
*
1.1
),
int
(
ymax
*
1.1
))
stamp
.
wcs
=
real_wcs_local
...
...
@@ -238,7 +250,9 @@ class Galaxy(MockObject):
# # print(stamp.array.sum())
# # chip.img[bounds] += stamp[bounds]
# chip.img[bounds] = stamp[bounds]
# # print("nphotons_sum = ", nphotons_sum)
# # [C6 TEST]
# print("nphotons_sum = ", nphotons_sum)
del
photons_list
del
stamp
gc
.
collect
()
...
...
ObservationSim/ObservationSim.py
View file @
a8ad6d38
...
...
@@ -19,6 +19,8 @@ from ObservationSim.PSF import PSFGauss, FieldDistortion, PSFInterp
from
ObservationSim._util
import
get_shear_field
,
makeSubDir_PointingList
from
ObservationSim.Astrometry.Astrometry_util
import
on_orbit_obs_position
# import tracemalloc
class
Observation
(
object
):
def
__init__
(
self
,
config
,
Catalog
,
work_dir
=
None
,
data_dir
=
None
):
self
.
path_dict
=
config_dir
(
config
=
config
,
work_dir
=
work_dir
,
data_dir
=
data_dir
)
...
...
@@ -186,6 +188,7 @@ class Observation(object):
# (DEBUG)
# if j >= 10:
# break
# tracemalloc.start()
obj
=
self
.
cat
.
objs
[
j
]
...
...
@@ -336,10 +339,15 @@ class Observation(object):
chip_output
.
logger
.
error
(
e
)
pass
# [C6 TEST]
#
#
[C6 TEST]
# print("check running:1: pointing-{:} chip-{:} pid-{:} memory-{:6.2}GB".format(pointing.id, chip.chipID, os.getpid(), (psutil.Process(os.getpid()).memory_info().rss / 1024 / 1024 / 1024) ), flush=True)
# print('draw object %s'%obj.id)
# print('mag = %.3f'%obj.param['mag_use_normal'])
# # Output memory usage
# snapshot = tracemalloc.take_snapshot()
# top_stats = snapshot.statistics('lineno')
# for stat in top_stats[:10]:
# print(stat)
# Unload SED:
obj
.
unload_SED
()
...
...
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