예제 #1
0
def OLDprepareFrames(mos,
                     frame0=1,
                     R=23,
                     medianN=23,
                     onlyVisits=[],
                     force=False):
    """Prepare frames to have their radial profiles measured.
Subtract the first quartile
Set a radius R circle about the centre of Arcturus to NaN
Set a chip with a bad QE value to NaN
Median filter with a medianN x medianN filter

The result is set as mos[-visit]

If onlyVisits is specified, only process those chips [n.b. frame0 is still obeyed]
    """

    visits = sorted(position.keys())

    width, height = mos[visits[0]].getDimensions()

    X, Y = np.meshgrid(np.arange(width), np.arange(height))

    frame = frame0 - 1
    for v in visits:
        frame += 1
        if onlyVisits and v not in onlyVisits:
            continue

        print("Processing %d" % v)

        im = mos[v].clone()
        im[2121:2230, 590:830] = np.nan  # QE for this chip is bad

        ima = im.getArray()
        im[:] -= np.percentile(ima, 25)

        xc, yc = position[v]
        xc -= im.getX0()
        yc -= im.getY0()

        ima[np.hypot(X - xc, Y - yc) < R] = np.nan

        if force or -v not in mos:
            im = utils.medianFilterImage(im, medianN)
            mos[-v] = im
        else:
            im = mos[-v]

        if True:
            ds9.mtv(im, title=v, frame=frame)
        else:
            ds9.erase(frame=frame)
        ds9.dot("o",
                xc,
                yc,
                size=R,
                frame=frame,
                ctype=ds9.GREEN if yc < im.getHeight() else ds9.RED)
예제 #2
0
def OLDprepareFrames(mos, frame0=1, R=23, medianN=23, onlyVisits=[], force=False):
    """Prepare frames to have their radial profiles measured.
Subtract the first quartile
Set a radius R circle about the centre of Arcturus to NaN
Set a chip with a bad QE value to NaN
Median filter with a medianN x medianN filter

The result is set as mos[-visit]

If onlyVisits is specified, only process those chips [n.b. frame0 is still obeyed]
    """

    visits = sorted(position.keys())

    width, height = mos[visits[0]].getDimensions()

    X, Y = np.meshgrid(np.arange(width), np.arange(height))

    frame = frame0 - 1
    for v in visits:
        frame += 1
        if onlyVisits and v not in onlyVisits:
            continue

        print("Processing %d" % v)

        im = mos[v].clone()
        im[2121:2230, 590:830] = np.nan  # QE for this chip is bad

        ima = im.getArray()
        im[:] -= np.percentile(ima, 25)

        xc, yc = position[v]
        xc -= im.getX0()
        yc -= im.getY0()

        ima[np.hypot(X - xc, Y - yc) < R] = np.nan

        if force or -v not in mos:
            im = utils.medianFilterImage(im, medianN)
            mos[-v] = im
        else:
            im = mos[-v]

        disp = afwDisplay.Display(frame=frame)
        if True:
            disp.mtv(im, title=v)
        else:
            disp.erase()
        disp.dot("o", xc, yc, size=R, ctype=afwDisplay.GREEN if yc < im.getHeight() else afwDisplay.RED)
예제 #3
0
 def __call__(self, v):
     print "Median filtering visit %d" % v
     return v, utils.medianFilterImage(self.mos[-v], self.medianN)
예제 #4
0
 def __call__(self, v):
     print("Median filtering visit %d" % v)
     return v, utils.medianFilterImage(self.mos[-v], self.medianN)