diff --git a/catalog/C9_Catalog.py b/catalog/C9_Catalog.py index 7081abcd65972d69301f6faa70b750b3a1fa54d9..8dc629fe6bf4414e3266c861b0a9d619d7a89c3c 100644 --- a/catalog/C9_Catalog.py +++ b/catalog/C9_Catalog.py @@ -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 = [] diff --git a/observation_sim/instruments/chip/effects.py b/observation_sim/instruments/chip/effects.py index 7c4c7dcc81d57b332c1d6bed124488f2d41ac717..0f835d2262e8d7042bc0160c22a860cf92a9b4a9 100644 --- a/observation_sim/instruments/chip/effects.py +++ b/observation_sim/instruments/chip/effects.py @@ -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 diff --git a/observation_sim/mock_objects/CatalogBase.py b/observation_sim/mock_objects/CatalogBase.py index 106e4e751d2ca2ac0ba5d9f1118991bd734cd0de..ea94b775dcf16dd7368332bd4e2459cb2dd5a8ff 100644 --- a/observation_sim/mock_objects/CatalogBase.py +++ b/observation_sim/mock_objects/CatalogBase.py @@ -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 diff --git a/observation_sim/sim_steps/add_objects.py b/observation_sim/sim_steps/add_objects.py index 81cb5892128f0be3870d57089b2949b1de4485a1..b35325b28889be3c3c695fbad693aad9229c0586 100644 --- a/observation_sim/sim_steps/add_objects.py +++ b/observation_sim/sim_steps/add_objects.py @@ -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