def getAlignment(self,w=None):
        print type(w)
        if type(w)==type(""):
            print "notype"
            data=FITS.Read(w)
            subapLocation=data[1]
            self.npxlx=numpy.array(eval(data[0]["parsed"]["npxlx"]))
            self.npxly=numpy.array(eval(data[0]["parsed"]["npxly"]))
            self.nsub=numpy.array(eval(data[0]["parsed"]["nsub"]))
            self.subflag=data[3]
        else:
            print "->type"
            c=controlCorba.controlClient(self.prefix)
            subapLocation=c.Get("subapLocation")
            subapLocation.shape=subapLocation.size/6,6
            self.subflag=c.Get("subapFlag")
            self.nsub=c.Get("nsub")
            self.npxlx=c.Get("npxlx")
            self.npxly=c.Get("npxly")
        self.ncam=self.nsub.size
        self.adjustment.set_upper(self.ncam-1)

        self.orig=subapLocation.copy()
        self.pixbuf=gtk.gdk.Pixbuf(gtk.gdk.COLORSPACE_RGB,False,8,self.npxlx[self.cam]*2,self.npxly[self.cam]*2)
        
        self.arr=self.pixbuf.get_pixels_array()
        self.arr[:]=0xff
        self.img.set_from_pixbuf(self.pixbuf)

        subapLocation=self.subapToSingle(subapLocation)
        subapLocation*=2
        self.subapLocation=subapLocation
        self.selected=numpy.ones((self.subapLocation.shape[0],),numpy.int8)
        self.draw()
 def showRaw(self,w):
     w=gtk.Window()
     c=controlCorba.controlClient(self.prefix)
     #f = Figure(figsize=(5,4), dpi=72)
     bg = c.Get("bgImage")
     data = bg.reshape(480,640)
     f = plt.figure(1)
     plt.imshow(data)
     plt.gca().invert_yaxis()
     #plt.show()
     canvas = FigureCanvas(f)
     w.add(canvas)
     w.show_all()
    def setAlignment(self,w):
        c=controlCorba.controlClient(self.prefix)
#        s=self.makeSubapLocation(allcam=1)
        fname="%ssubapLocation.fits"%self.prefix
        data=FITS.Read(fname)
        subapLocation=data[1]
        subflag=data[3]
        pxlcnt=self.count(data[1])
        print "set"
        print "subapLocation"
        print subapLocation
        print "subapFlag"
        print subflag
        print "pxlCnt"
        print pxlcnt
        c.set("subapLocation",subapLocation,swap=1,check=1,copy=1)
        c.set("subapFlag",subflag,swap=1,check=1,copy=1)
        c.set("pxlCnt",pxlcnt,swap=1,check=1,copy=1)
import FITS
import numpy
import matplotlib.pyplot as plt
import controlCorba

#darcmagic get -name=subapLocation --prefix=main
#darcmagic get -name=subapFlag --prefix=main
#darcmagic get -name=bgImage --prefix=main
initial = numpy.zeros((15,15), numpy.int32)
print "################"
print initial
print "################"
initial = initial.reshape(225)
print initial
print "################"
c=controlCorba.controlClient("main")
subapflag = c.Get("subapFlag")
print subapflag
print type(subapflag)
print subapflag.dtype
c.Set("subapFlag",initial,com="",swap=1,check=1,copy=1)
print "########### despues del set ##"
subapflag = c.Get("subapFlag")
print "----------------"
pxl = c.Get("pxlCnt")
print pxl
print type(pxl)
print pxl.size
print pxl.shape
print pxl.reshape(11,11)
print "----------------"