示例#1
0
 def __init__(self, *args, **kwargs):
     from tractor.cache import Cache
     rounding = kwargs.pop('rounding', 100)
     super(CachingPsfEx, self).__init__(*args, **kwargs)
     self.cache = Cache(maxsize=100)
     # round pixel coordinates to the nearest...
     self.rounding = rounding
示例#2
0
class CachingPsfEx(PsfEx):
    @staticmethod
    def fromPsfEx(psfex, **kwargs):
        c = CachingPsfEx(None,
                         psfex.W,
                         psfex.H,
                         nx=psfex.nx,
                         ny=psfex.ny,
                         scale=psfex.scale,
                         K=psfex.K,
                         psfClass=psfex.psfclass,
                         **kwargs)
        for k in [
                'sampling', 'xscale', 'yscale', 'x0', 'y0', 'degree', 'radius',
                'psfbases', 'splinedata', 'splines'
        ]:
            setattr(c, k, getattr(psfex, k, None))
        return c

    def __init__(self, *args, **kwargs):
        from tractor.cache import Cache
        rounding = kwargs.pop('rounding', 100)
        super(CachingPsfEx, self).__init__(*args, **kwargs)
        self.cache = Cache(maxsize=100)
        # round pixel coordinates to the nearest...
        self.rounding = rounding

    def __str__(self):
        return '%s: rounding %i, %s' % (getClassName(self), self.rounding,
                                        super(CachingPsfEx, self).__str__())

    # For pickling
    def __getstate__(self):
        self.cache.clear()
        return self.__dict__

    def psfAt(self, x, y):
        # Center of rounding cell:
        cx = int(x / self.rounding) * self.rounding + self.rounding / 2
        cy = int(y / self.rounding) * self.rounding + self.rounding / 2
        key = (cx, cy)
        mog = self.cache.get(key, None)
        if mog is not None:
            return mog
        mog = super(CachingPsfEx, self).psfAt(cx, cy)
        #print 'CachingPsf: getting PSF at', cx,cy, '->', mog
        self.cache.put(key, mog)
        return mog
示例#3
0
 def __init__(self, *args, **kwargs):
     from tractor.cache import Cache
     rounding = kwargs.pop('rounding', 100)
     super(CachingPsfEx, self).__init__(*args, **kwargs)
     self.cache = Cache(maxsize=100)
     # round pixel coordinates to the nearest...
     self.rounding = rounding
示例#4
0
文件: psfex.py 项目: eddienko/tractor
class CachingPsfEx(PsfEx):
    @staticmethod
    def fromPsfEx(psfex, **kwargs):
        c = CachingPsfEx(
            None,
            psfex.W,
            psfex.H,
            nx=psfex.nx,
            ny=psfex.ny,
            scale=psfex.scale,
            K=psfex.K,
            psfClass=psfex.psfclass,
            **kwargs
        )
        for k in ["sampling", "xscale", "yscale", "x0", "y0", "degree", "radius", "psfbases", "splinedata", "splines"]:
            setattr(c, k, getattr(psfex, k, None))
        return c

    def __init__(self, *args, **kwargs):
        from tractor.cache import Cache

        rounding = kwargs.pop("rounding", 100)
        super(CachingPsfEx, self).__init__(*args, **kwargs)
        self.cache = Cache(maxsize=100)
        # round pixel coordinates to the nearest...
        self.rounding = rounding

    def __str__(self):
        return "%s: rounding %i, %s" % (getClassName(self), self.rounding, super(CachingPsfEx, self).__str__())

    # For pickling
    def __getstate__(self):
        self.cache.clear()
        return self.__dict__

    def psfAt(self, x, y):
        # Center of rounding cell:
        cx = int(x / self.rounding) * self.rounding + self.rounding / 2
        cy = int(y / self.rounding) * self.rounding + self.rounding / 2
        key = (cx, cy)
        mog = self.cache.get(key, None)
        if mog is not None:
            return mog
        mog = super(CachingPsfEx, self).psfAt(cx, cy)
        # print 'CachingPsf: getting PSF at', cx,cy, '->', mog
        self.cache.put(key, mog)
        return mog