Exemple #1
0
    def loadcp(self,overlay=False):
        """
            Read text files 'xyr' and 'xyb' from your working 
            directory and arrange them into xyr[np,2] and xyb[np,2].
            These are the x,y positions of the control points 
            obtained when calling 'getCpoint' method from this
            XYtran class.

            @overlay: Default value is False. When True, it will
                      overlay the xyr positions into the Frame 1
                      on ds9 and xyb positions into Frame 2.
        """
            
        xrr = np.fromfile('xyr',sep=' ')
        ncp = np.size(xrr)/2
        self.xyr=xrr.reshape([ncp,2])
        xrr = np.fromfile('xyb',sep=' ')
        self.xyb=xrr.reshape([ncp,2])
        self.npin = ncp
        if overlay:
            for i in range(ncp):
                ov.circle(x=self.xyr[i][0],y=self.xyr[i][1],radius=10,\
                         color=ov.C_RED,frame=1)
            for i in range(ncp):
                ov.circle(x=self.xyb[i][0],y=self.xyb[i][1],radius=10,\
                         color=ov.C_YELLOW,frame=2)
Exemple #2
0
    def getCpoints(self):
        """
          Get control points from a pair of Red and Blue pinholes
          frames from the NICI camera.
          You already have frames 1 and 2 (red and blue)
          from a pinhole image up in DS9.
          Please select at least 6 corresponding points. 

          Once you click 'r' in the Red frame, a red circle is drawn
          around the pinhole and a Blue circle is drawn 'near' the
          blue pinhole; click 'b' there to record the position.
          Press 'q' to finish.
        """
 
        i=0; j=0
        xkey = ''
        print "*** Please get at least 6 corresponding pinholes."
        while xkey != 'q':
            cursor = ndis.readcursor(sample=0)
            ss = cursor.split()
            print ss
            xkey = ss.pop()
            if xkey not in ('r','b','q'):
               print "Please choose a control point on the 'r' or 'b' frame,"
               print " then hit 'r' for red frame or 'b' for 'blue' frame"
               continue
            im = {'r':self.imr, 'b':self.imb, 'q':0}[xkey]
            if xkey == 'q': break
            
            x,y = np.asfarray(ss[:2])
            xc,yc = gcentroid(im[y-10:y+10,x-10:x+10],10,10)
            xc,yc = x+xc[0]-10,y+yc[0]-10

            if xkey == 'r':
                #print "xc,yc: ",xc,yc,x+xc-10,y+yc-10
                self.xyr[i] = xc,yc; i+=1
                ov.circle(x=xc,y=yc,radius=10,color=ov.C_RED,frame=1)
                xn = 990.5897 - 0.9985259*x - 0.0178984*y
                yn = 37.82109 - 0.0181331*x + 0.9991414*y
                #xc,yc = gcentroid(self.imb[yn-13:y+13,xn-13:x+13],13,13)
                #xc,yc = xn+xc[0]-10,yn+yc[0]-10
                ov.circle(x=xn,y=yn,radius=10,color=ov.C_BLUE, frame=2)
                print self.xyr[i-1]
            if xkey == 'b':
                self.xyb[j] = xc,yc; j+=1
                print self.xyb[j-1]
            
        self.npin = j
        self.xyr = np.resize(self.xyr,[j,2])
        self.xyb = np.resize(self.xyb,[j,2])