diff --git a/ObservationSim/MockObject/Galaxy.py b/ObservationSim/MockObject/Galaxy.py index ae65f6230dd4f36638081e9f516f0229ef51c4f8..be20372d8e198a8551258d08a02d76e52ee6d378 100755 --- a/ObservationSim/MockObject/Galaxy.py +++ b/ObservationSim/MockObject/Galaxy.py @@ -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() diff --git a/ObservationSim/ObservationSim.py b/ObservationSim/ObservationSim.py index 38f5f367754fa8f597e93482ab931c00f8d6b6a9..5329ec8cc273e768207ff2e27e2b11fdc515fe02 100755 --- a/ObservationSim/ObservationSim.py +++ b/ObservationSim/ObservationSim.py @@ -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()