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
Loading
Loading
Loading
Loading
Loading
+4 −0
Original line number Diff line number Diff line
@@ -469,6 +469,10 @@ class Catalog(CatalogBase):

            self.objs.append(obj)
    
    def free_mem(self, **kward):
        self.starDDL.freeGlobeData()
        del self.starDLL

    def _load(self, **kwargs):
        self.objs = []
        self.ids = 0
+9 −1
Original line number Diff line number Diff line
@@ -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
+3 −0
Original line number Diff line number Diff line
@@ -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
+3 −3
Original line number Diff line number Diff line
@@ -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