Commit a3c2766c authored by Fang Yuedong's avatar Fang Yuedong
Browse files

* Restrict the saturation bleeding trails and bad columns. So they cannot go across channels.

* Add free_mem method in CatalogBase.py. Thus class that inhrits this base class can then implement this function to free used memory.
parent b01c72c9
Pipeline #7396 failed with stage
in 0 seconds
......@@ -468,6 +468,10 @@ class Catalog(CatalogBase):
0., 0., 0., 0., 0., 0., 0., 0., 0., -1, 0.)
self.objs.append(obj)
def free_mem(self, **kward):
self.starDDL.freeGlobeData()
del self.starDLL
def _load(self, **kwargs):
self.objs = []
......
......@@ -84,7 +84,7 @@ def BadColumns(GSImage, seed=20240309, chipid=1, logger=None):
rgdn = Generator(PCG64(int(seed*1.3)))
nbadsecA, nbadsecD = rgn.integers(low=1, high=5, size=2)
collen = rgcollen.integers(low=int(ysize*0.1), high=int(ysize*0.7), size=(nbadsecA+nbadsecD))
collen = rgcollen.integers(low=int(ysize*0.1), high=int(ysize*0.5), size=(nbadsecA+nbadsecD))
xposit = rgxpos.integers(low=int(xsize*0.05), high=int(xsize*0.95), size=(nbadsecA+nbadsecD))
if logger is not None:
logger.info(xposit+1)
......@@ -350,8 +350,12 @@ def MakeTrail(imgarr, satuyxtuple, charge, fullwell=9e4, direction='up', trailcu
imgarr[yi, xi] = fullwell
if direction == 'up':
yi -= 1
if yi == (imgarr.shape[0]//2 - 1):
break
elif direction == 'down':
yi += 1
if yi == (imgarr.shape[0]//2):
break
yy += 1
else:
if trail_frac < trailcutfrac:
......@@ -363,8 +367,12 @@ def MakeTrail(imgarr, satuyxtuple, charge, fullwell=9e4, direction='up', trailcu
if direction == 'up':
yi -= 1
if yi == (imgarr.shape[0]//2 - 1):
break
elif direction == 'down':
yi += 1
if yi == (imgarr.shape[0]//2):
break
yy += 1
return imgarr
......
......@@ -12,6 +12,9 @@ class CatalogBase(metaclass=ABCMeta):
def __init__(self):
pass
def free_mem(self, **kward):
pass
@abstractmethod
def load_sed(self, obj, **kward):
pass
......
......@@ -102,6 +102,7 @@ def add_objects(self, chip, filt, tel, pointing, catalog, obs_param):
# # [DEBUG] [TODO]
# if j >= 10:
# break
obj = cat.objs[j]
if not self._is_obj_valid(obj):
......@@ -133,7 +134,6 @@ def add_objects(self, chip, filt, tel, pointing, catalog, obs_param):
continue
# [TODO] Testing
# print(obj.param["mag_%s" % filt.filter_type.lower()], obj.param["mag_%s" % cut_filter.filter_type.lower()])
# self.chip_output.Log_info("mag_%s = %.3f"%(filt.filter_type.lower(), obj.param["mag_%s"%filt.filter_type.lower()]))
# Exclude very bright/dim objects (for now)
......@@ -242,8 +242,8 @@ def add_objects(self, chip, filt, tel, pointing, catalog, obs_param):
obj.unload_SED()
del obj
# gc.collect()
cat.starDDL.freeGlobeData()
del cat.starDDL
cat.free_mem
del cat
if chip.survey_type == "spectroscopic" and not self.overall_config["run_option"]["out_cat_only"] and chip.slsPSFOptim:
# from observation_sim.instruments.chip import chip_utils as chip_utils
......
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