Commit 832c0004 authored by Fang Yuedong's avatar Fang Yuedong
Browse files

add gc to Galaxy.py

parent 99d8c5a7
import numpy as np import numpy as np
import galsim import galsim
import gc
import os, sys import os, sys
import astropy.constants as cons import astropy.constants as cons
from astropy.table import Table from astropy.table import Table
...@@ -180,6 +181,7 @@ class Galaxy(MockObject): ...@@ -180,6 +181,7 @@ class Galaxy(MockObject):
photons.x += x_nominal photons.x += x_nominal
photons.y += y_nominal photons.y += y_nominal
photons_list.append(photons) photons_list.append(photons)
del gal
# print('xmax = %d, ymax = %d '%(xmax, ymax)) # print('xmax = %d, ymax = %d '%(xmax, ymax))
...@@ -205,6 +207,7 @@ class Galaxy(MockObject): ...@@ -205,6 +207,7 @@ class Galaxy(MockObject):
sensor.accumulate(photons_list[i], stamp) sensor.accumulate(photons_list[i], stamp)
else: else:
sensor.accumulate(photons_list[i], stamp, resume=True) sensor.accumulate(photons_list[i], stamp, resume=True)
del sensor
chip.img[bounds] = stamp[bounds] chip.img[bounds] = stamp[bounds]
...@@ -238,6 +241,7 @@ class Galaxy(MockObject): ...@@ -238,6 +241,7 @@ class Galaxy(MockObject):
# # print("nphotons_sum = ", nphotons_sum) # # print("nphotons_sum = ", nphotons_sum)
del photons_list del photons_list
del stamp del stamp
gc.collect()
return True, pos_shear return True, pos_shear
def drawObj_slitless(self, tel, pos_img, psf_model, bandpass_list, filt, chip, nphotons_tot=None, g1=0, g2=0, def drawObj_slitless(self, tel, pos_img, psf_model, bandpass_list, filt, chip, nphotons_tot=None, g1=0, g2=0,
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment