def colormap_legend(self):
     if self.legend is not None:
         self.view_box.removeItem(self.legend)
     if len(self.colorMap.children()) == 0:
         pg.QtGui.QMessageBox.information(self.main_window,'', "No Analysis ColorMap is selected, please add one and Update Results", pg.QtGui.QMessageBox.Ok)
         raise Exception("No color maps are selected.")
     cmap_item = [cmap for cmap in self.colorMap.children() if cmap['Enabled'] is True][0]
     # log_scale = self.params.child('log_scale').value()
     colors = cmap_item.value().color
     x_min = cmap_item['Min']
     x_max = cmap_item['Max']
     x = np.linspace(x_min, x_max, len(colors))
     name = cmap_item.name()
     if name.endswith('Probability'):
         log_scale = True
     else:
         log_scale = False
     # units = self.colorMap.fields[name].get('units', None)
     min_scale, _ = pg.siScale(x_min)
     max_scale, _= pg.siScale(x_max)
     scale = min_scale if (1/min_scale) < (1/max_scale) else max_scale
     # if units is not None:
     #     units = scale + units
     # else:
     #     units = ''
     self.legend = pg.GradientLegend([25, 300], [-20, -30])
     if log_scale is True:
         cmap2 = pg.ColorMap(x, colors)
         self.legend.setGradient(cmap2.getGradient())
         self.legend.setLabels({'%0.02f' % (a*scale):b for a,b in zip(cmap_item.value().pos, x)})
     else:
         self.legend.setGradient(cmap_item.value().getGradient())
         self.legend.setLabels({'%0.02f' % (a*scale):b for a,b in zip(x, cmap_item.value().pos)})
     self.view_box.addItem(self.legend)
示例#2
0
 def colormap_legend(self):
     if self.legend is not None:
         self.view_box.removeItem(self.legend)
     cmap_item = [
         cmap for cmap in self.colorMap.children()
         if cmap['Enabled'] is True
     ][0]
     log_scale = self.params.child('log_scale').value()
     colors = cmap_item.value().color
     x_min = cmap_item['Min']
     x_max = cmap_item['Max']
     x = np.linspace(x_min, x_max, len(colors))
     name = cmap_item.name()
     # units = self.colorMap.fields[name].get('units', None)
     scale, prefix = pg.siScale(x_min)
     # if units is not None:
     #     units = scale + units
     # else:
     #     units = ''
     self.legend = pg.GradientLegend([25, 300], [-20, -30])
     if log_scale is True:
         cmap2 = pg.ColorMap(x, colors)
         self.legend.setGradient(cmap2.getGradient())
         self.legend.setLabels({
             '%0.02f' % (a * scale): b
             for a, b in zip(cmap_item.value().pos, x)
         })
     else:
         self.legend.setGradient(cmap_item.value().getGradient())
         self.legend.setLabels({
             '%0.02f' % (a * scale): b
             for a, b in zip(x,
                             cmap_item.value().pos)
         })
     self.view_box.addItem(self.legend)
    def matrix(self, rows, cols, size=50, header_color='w', no_data_color='k'):
        w = pg.GraphicsLayoutWidget()
        v = w.addViewBox()
        v.setAspectLocked()
        v.invertY()

        colormap = pg.ColorMap(
            [0, 0.01, 0.03, 0.1, 0.3, 1.0],
            [(0, 0, 100), (80, 0, 80), (140, 0, 0), (255, 100, 0),
             (255, 255, 100), (255, 255, 255)],
        )
        default = no_data_color

        summary = self.connectivity_summary(cre_type=None)

        shape = (len(rows), len(cols))
        text = np.empty(shape, dtype=object)
        fgcolor = np.empty(shape, dtype=object)
        bgcolor = np.empty(shape, dtype=object)

        for i, row in enumerate(rows):
            for j, col in enumerate(cols):
                if (row, col) in summary:
                    conn = summary[(row, col)]['connected']
                    uconn = summary[(row, col)]['unconnected']
                    color = colormap.map(conn / (conn + uconn))
                else:
                    conn, uconn = 0, 0
                    color = default
                color = pg.colorTuple(pg.mkColor(color))
                bgcolor[i, j] = color
                text[i, j] = "%d/%d" % (conn, conn + uconn)
                fgcolor[i, j] = 'w' if sum(color[:3]) < 200 else 'k'
                if conn == uconn == 0:
                    fgcolor[i, j] = 0.3

        w.matrix = MatrixItem(text=text,
                              fgcolor=fgcolor,
                              bgcolor=bgcolor,
                              rows=rows.values(),
                              cols=cols.values(),
                              size=size,
                              header_color=header_color)
        v.addItem(w.matrix)

        # colormap is logarithmic; remap to linear for legend
        colors = colormap.color
        x = np.linspace(0, 1, len(colors))
        cmap2 = pg.ColorMap(x, colors)
        legend = pg.GradientLegend([25, 300], [-20, -30])
        legend.setGradient(cmap2.getGradient())
        legend.setLabels(
            {'%d' % int(a * 100): b
             for a, b in zip(colormap.pos, x)})
        v.addItem(legend)
        w.show()
        self.matrix_widget = w

        return w
    def __init__(self, pos, res=64, parent=None):

        # self.lut = init_colour_map()

        # Return a proxy object that delegates method calls to a parent or sibling class of type PlotWidget.
        super(ColourBarWidget, self).__init__(parent)

        self.gl = pg.GradientLegend((10, 200), (-10, 50))
        self.addItem(self.gl)
        self.gl.scale(1, -1)

        # Widget settings
        self.setAttribute(QtCore.Qt.WA_TransparentForMouseEvents)
        # self.getPlotItem().getAxis('left').hide()
        # self.getPlotItem().getAxis('bottom').hide()
        self.setAspectLocked(True)
        self.setMaximumWidth(res)
        self.setMaximumHeight(res)
示例#5
0
    def plotmaps_pg(self, mode=0, target=1, gfilter=0):

        pos = np.array([0.0, 0.33, 0.67, 1.0])
        color = np.array([[0, 0, 0, 255], [255, 128, 0, 255],
                          [255, 255, 0, 255], [0, 0, 0, 255]],
                         dtype=np.ubyte)
        maps = pg.ColorMap(pos, color)
        lut = maps.getLookupTable(0.0, 1.0, 256)
        # # ## Set up plots/images in window

        # self.view = pg.GraphicsView()
        # l = pg.GraphicsLayout(border=(100,100,100))
        # self.view.setCentralItem(l)
        # self.amp1View = l.addViewBox(lockAspect=True)
        # self.amp2View = l.addViewBox(lockAspect=True)
        # self.waveformPlot = l.addPlot(title="Waveforms")
        # l.nextRow()
        # self.phase1View = l.addViewBox(lockAspect=True)
        # self.phase2View = l.addViewBox(lockAspect=True)
        # self.fftPlot = l.addPlot(title="FFTs")
        # self.phiView = l.addViewBox(lockAspect=True)

        global D
        max1 = numpy.amax(self.amplitudeImage1)
        if target > 1:
            max1 = numpy.amax([max1, numpy.amax(self.amplitudeImage2)])
        max1 = 10.0 * int(max1 / 10.0)
        # pylab.figure(1)
        # pylab.subplot(2,3,1)
        # pylab.title('Amplitude Map1')
        # #scipy.ndimage.gaussian_filter(self.amplitudeImage1, 2, order=0, output=self.amplitudeImage1, mode='reflect')
        ampimg = scipy.ndimage.gaussian_filter(self.amplitudeImage1,
                                               gfilt,
                                               order=0,
                                               mode='reflect')
        #self.amp1View.addItem(pg.ImageItem(ampimg))
        self.amp1 = pg.image(ampimg,
                             title="Amplitude Map 1",
                             levels=(0.0, max1))
        #imga1 = pylab.imshow(ampimg)
        #pylab.colorbar()
        #imga1.set_clim = (0.0, max1)
        #pylab.subplot(2,3,4)
        #pylab.title('Phase Map1')
        phsmap = scipy.ndimage.gaussian_filter(self.phaseImage1,
                                               gfilt,
                                               order=0,
                                               mode='reflect')
        #self.phase1View.addItem(pg.ImageItem(phsmap))
        self.phs1 = pg.image(phsmap, title='Phase Map 1')
        #self.phs1.getHistogramWidget().item.gradient.
        #imgp1 = pylab.imshow(phsmap, cmap=matplotlib.cm.hsv)
        #pylab.colorbar()

        print "plotmaps Block 1"
        print "mode:", mode
        self.wavePlt = pg.plot(title='Waveforms')
        if mode == 0 or mode == 2:
            self.fftPlt = pg.plot(title='FFTs')

        if mode == 0:
            #pylab.subplot(2,3,3)

            # for i in range(0, self.nPhases):
            #     self.wavePlt.plot(ta.n_times, D[:,5,5].view(ndarray))
            #     #pylab.plot(ta.n_times, D[:,5,5].view(ndarray))
            #     #pylab.plot(self.n_times, D[:,i*55+20, 60])
            #     #pylab.hold('on')
            # #pylab.title('Waveforms')

            #pylab.subplot(2,3,6)
            for i in range(0, self.nPhases):
                self.fftPlt.plot(ta.n_times, self.DF[:, 5, 5].view(ndarray))
                #pylab.plot(ta.n_times, self.DF[:,5,5].view(ndarray))
                #pylab.plot(self.DF[:,i*55+20, 60])
                #pylab.hold('on')
            #pylab.title('FFTs')

        print "plotmaps Block 2"

        if mode == 1 and target > 1:
            #pylab.subplot(2,3,2)
            #pylab.title('Amplitude Map2')
            #scipy.ndimage.gaussian_filter(self.amplitudeImage2, 2, order=0, output=self.amplitudeImage2, mode='reflect')
            ampImg2 = scipy.ndimage.gaussian_filter(self.amplitudeImage2,
                                                    gfilt,
                                                    order=0,
                                                    mode='reflect')
            #imga2 = pylab.imshow(ampImg2)
            #self.amp2View.addItem(pg.ImageItem(ampImg2))
            self.amp2 = pg.image(ampImg2,
                                 title='Amplitude Map 2',
                                 levels=(0.0, max1))
            #imga2.set_clim = (0.0, max1)
            #pylab.colorbar()
            #pylab.subplot(2,3,5)
            phaseImg2 = scipy.ndimage.gaussian_filter(self.phaseImage2,
                                                      gfilt,
                                                      order=0,
                                                      mode='reflect')
            #self.phase2View.addItem(pg.ImageItem(phaseImg2))
            self.phs2 = pg.image(phaseImg2,
                                 title="Phase Map 2",
                                 levels=(-np.pi / 2.0, np.pi / 2.0))
            #imgp2 = pylab.imshow(phaseImg2, cmap=matplotlib.cm.hsv)
            #pylab.colorbar()
            #imgp2.set_clim=(-numpy.pi/2.0, numpy.pi/2.0)
            #pylab.title('Phase Map2')
            ### doubled phase map
            #pylab.subplot(2,3,6)
            #scipy.ndimage.gaussian_filter(self.phaseImage2, 2, order=0, output=self.phaseImage2, mode='reflect')
            np1 = scipy.ndimage.gaussian_filter(self.phaseImage1,
                                                gfilt,
                                                order=0,
                                                mode='reflect')
            np2 = scipy.ndimage.gaussian_filter(self.phaseImage2,
                                                gfilt,
                                                order=0,
                                                mode='reflect')
            dphase = np1 + np2
            print 'shape of dphase', dphase.shape
            #dphase = self.phaseImage1 - self.phaseImage2
            print 'min phase', np.amin(dphase)
            print 'max phase', np.amax(dphase)
            for i in range(dphase.shape[0]):
                for j in range(dphase.shape[1]):
                    #for k in range(dphase.shape[2]):
                    if dphase[i, j] < 0:
                        dphase[i, j] = dphase[i, j] + 2 * np.pi

            print 'min phase', np.amin(dphase)
            print 'max phase', np.amax(dphase)

            self.win = pg.GraphicsWindow()
            view = self.win.addViewBox()
            view.setAspectLocked(True)
            item = pg.ImageItem(dphase)
            view.addItem(item)
            item.setLookupTable(lut)
            item.setLevels([0, 2 * np.pi])

            # self.colorlevels = pg.GradientEditorItem()
            # self.colorlevels.getLookupTable(17)
            # self.colorlevels.setColorMode('rgb')
            # self.colorlevels.setOrientation('right')
            # self.colorlevels.setPos(-10,0)
            # view.addItem(self.colorlevels)
            gradlegend = pg.GradientLegend((10, 100), (0, 0))
            #gradlegend.setIntColorScale(0,255)
            #gradlegend.setGradient(self.creategradient())
            gradlegend.setGradient(maps.getGradient())
            view.addItem(gradlegend)
            #self.phiView.addItem(pg.ImageItem(dphase))
            self.phi = pg.image(dphase,
                                title="2x Phi map",
                                levels=(0, 2 * np.pi))

            #imgpdouble = pylab.imshow(dphase, cmap=matplotlib.cm.hsv)
            #pylab.title('2x Phi map')
            #pylab.colorbar()
            #imgpdouble.set_clim=(-numpy.pi, numpy.pi)

        print "plotmaps Block 3"

        # if mode == 2 or mode == 1:
        #     # if self.phasex == []:
        #     #     self.phasex = numpy.random.randint(0, high=D.shape[1], size=D.shape[1])
        #     #     self.phasey = numpy.random.randint(0, high=D.shape[2], size=D.shape[2])

        #     #pylab.subplot(2,3,3)
        #     sh = D.shape
        #     spr = sh[2]/self.nPhases
        #     wvfms=[]
        #     for i in range(0, self.nPhases):
        #         Dm = self.avgimg[i*spr,i*spr] # diagonal run
        #         wvfms=self.n_times, 100.0*(D[:,self.phasex[i], self.phasey[i]]/Dm)
        #         #pylab.plot(self.n_times, 100.0*(D[:,self.phasex[i], self.phasey[i]]/Dm))
        #         self.wavePlt.plot(self.n_times, 100.0*(D[:,self.phasex[i], self.phasey[i]]/Dm))
        #         #pylab.hold('on')
        #         self.plotlist.append(pg.image(wvfms, title="Waveforms"))
        #         print "it worked"
        #     pylab.title('Waveforms')

        # print "plotmaps Block 4"

        if mode == 2:
            #pylab.subplot(2,3,6)
            for i in range(0, self.nPhases):
                #pylab.plot(self.DF[1:,80, 80])
                spectrum = np.abs(self.DF)**2
                self.fftPlt.plot(spectrum[1:, 80, 80])
                #pyqtgraph.intColor(index, hues=17, values=1, maxValue=255, minValue=150, maxHue=360, minHue=0, sat=255, alpha=255, **kargs)

                #self.fftPlt.plot(self.DF[1:,80,80]) ## causing errors and i'm not sure what the desired thing is, Exception: Can not plot complex data types.
                #pass
                #pylab.hold('on')
                # self.plotlist.append(pg.image(wvfms, title="Waveforms"))
                print "waveform plotting worked"
            # pylab.title('Waveforms')

        print "plotmaps Block 4"

        # if mode == 2:
        #     #pylab.subplot(2,3,6)
        #     for i in range(0, self.nPhases):
        #         #pylab.plot(self.DF[1:,80, 80])
        #         spectrum = np.abs(self.DF)**2
        #         self.fftPlt.plot(spectrum[1:,80,80])
        #         #pyqtgraph.intColor(index, hues=17, values=1, maxValue=255, minValue=150, maxHue=360, minHue=0, sat=255, alpha=255, **kargs)

        #         #self.fftPlt.plot(self.DF[1:,80,80]) ## causing errors and i'm not sure what the desired thing is, Exception: Can not plot complex data types.
        #         #pass
        #         #pylab.hold('on')
        #     #pylab.title('FFTs')

        # print "plotmaps Block 5"
        # print "plotting complete"
        return
    def matrix(self,
               rows,
               cols,
               size=50,
               header_color='k',
               no_data_color=0.9,
               mode='connectivity'):
        w = pg.GraphicsLayoutWidget()
        w.setRenderHints(w.renderHints() | pg.QtGui.QPainter.Antialiasing)
        v = w.addViewBox()
        v.setBackgroundColor('w')
        v.setAspectLocked()
        v.invertY()

        if mode == 'connectivity':
            colormap = pg.ColorMap(
                [0, 0.01, 0.03, 0.1, 0.3, 1.0],
                [(0, 0, 100), (80, 0, 80), (140, 0, 0), (255, 100, 0),
                 (255, 255, 100), (255, 255, 255)],
            )
        else:
            colormap = pg.ColorMap(
                [0, 0.25, 0.5, 0.75, 1.0],
                [(0, 0, 100), (80, 0, 80), (140, 0, 0), (255, 100, 0),
                 (255, 255, 100)],
            )
        default = no_data_color

        summary = self.connectivity_summary(cre_type=None)

        shape = (len(rows), len(cols))
        text = np.empty(shape, dtype=object)
        fgcolor = np.empty(shape, dtype=object)
        bgcolor = np.empty(shape, dtype=object)
        bordercolor = np.empty(shape, dtype=object)

        for i, row in enumerate(rows):
            for j, col in enumerate(cols):
                if (row, col) in summary:
                    conn = summary[(row, col)]['connected']
                    uconn = summary[(row, col)]['unconnected']
                else:
                    conn, uconn = 0, 0
                probed = conn + uconn

                if probed == 0:
                    color = default
                else:
                    if mode == 'connectivity':
                        color = default if probed == 0 else colormap.map(
                            conn / probed)
                        color = pg.colorTuple(pg.mkColor(color))
                        bgcolor[i, j] = color
                    elif mode == 'progress':
                        prg = max(probed / 80., conn / 10.)
                        color = pg.colorTuple(pg.mkColor(colormap.map(prg)))

                bordercolor[i, j] = 0.8 if probed == 0 else 'k'
                bgcolor[i, j] = color
                fgcolor[i, j] = 0.6 if probed == 0 else (
                    'w' if sum(color[:3]) < 200 else 'k')
                text[i, j] = "%d/%d" % (conn, probed) if probed > 0 else ''

        w.matrix = MatrixItem(text=text,
                              fgcolor=fgcolor,
                              bgcolor=bgcolor,
                              border_color=bordercolor,
                              rows=rows.values(),
                              cols=cols.values(),
                              size=size,
                              header_color=header_color)
        v.addItem(w.matrix)

        # colormap is logarithmic; remap to linear for legend
        colors = colormap.color
        x = np.linspace(0, 1, len(colors))
        cmap2 = pg.ColorMap(x, colors)
        legend = pg.GradientLegend([25, 300], [-20, -30])
        legend.setGradient(cmap2.getGradient())
        legend.setLabels(
            {'%d' % int(a * 100): b
             for a, b in zip(colormap.pos, x)})
        v.addItem(legend)
        w.show()
        self.matrix_widget = w

        return w
示例#7
0
w4 = view.addPlot(title="residual Sugar vs Density in white Wines")
print("Generating data, this takes a few seconds...")

## 1: pH vs Alcohol red wines  (color = quality)
x = np.cos(np.linspace(0, 2 * np.pi, 1000))
data = np.sin(np.linspace(0, 4 * np.pi, 1000))

c1 = w1.plot(pen="r")
c2 = w1.plot(pen="y")
c1.setData(data)
c2.setData(2 * data)

## 2: pH vs Alcohol  white(color = quality)
w2.plot(data)

## 3: pH vs Alcohol  red(color = quality)
w3.plot(data)

## 4: pH vs Alcohol  whites(color = quality)
#w4.addItem(s4)

gl = pg.GradientLegend((10, 100), (300, 10))
gl.setIntColorScale(0, 100)
gl.scale(1, -1)
w4.addItem(gl)

## Start Qt event loop unless running in interactive mode.
if __name__ == '__main__':
    import sys
    if (sys.flags.interactive != 1) or not hasattr(QtCore, 'PYQT_VERSION'):
        QtGui.QApplication.instance().exec_()
示例#8
0
    def init_graphics(self):
        """Initialise the important graphics items"""
        m, n = 1280, 1024
        self.image = pg.ImageItem(np.zeros((m,n)))
        self.zoom = pg.ImageItem(np.zeros((50,50)))
        self.residuals = pg.ImageItem(np.zeros((50,50)))
        self.residuals.setLevels(self._residual_levels)
        self.x_fit = pg.PlotDataItem(np.zeros(m), pen={'width':2})
        self.x_slice = pg.PlotDataItem(np.zeros(m), pen=None, symbol='o', pxMode=True, symbolSize=4)
        self.y_fit = pg.PlotDataItem(np.zeros(n), pen={'width':2})
        self.y_slice = pg.PlotDataItem(np.zeros(n), pen=None, symbol='o', pxMode=True, symbolSize=4)

        # Only the residuals have any sort of false color - initialise the
        # lookup table and the legend
        cmap = self.get_color_map()
        self.residual_LUT = cmap.getLookupTable(nPts=256)
        self.res_legend = pg.GradientLegend(size=(10,255), offset=(0,20))
        self.res_legend.setGradient(cmap.getGradient())
        n_ticks = 5
        self.res_legend.setLabels({"{}".format(level):val
            for (level, val) in zip(
                np.linspace(*self._residual_levels, n_ticks),
                np.linspace(0, 1, n_ticks))})

        ypen = pg.mkPen(color=(255,255,0,85), width=3)

        # Centroid position markers in main image, aligned with x,y
        self.fit_v_line = pg.InfiniteLine(pos=1, angle=90, pen=ypen)
        self.fit_h_line = pg.InfiniteLine(pos=1, angle=0, pen=ypen)

        # Plot fading recent position markers
        n_history = 5
        self.history = collections.deque(maxlen=n_history)
        self.history_plot = pg.ScatterPlotItem()
        self.history_brushes = [pg.mkBrush(
            color=(255,255,0,int((i+1)*255/n_history)))
            for i in range(n_history)]

        # User marked position
        rpen = pg.mkPen(color=(255,0,0,127), width=3, style=QtCore.Qt.DotLine)
        self.mark_v_line = pg.InfiniteLine(pos=1, angle=90, pen=rpen)
        self.mark_h_line = pg.InfiniteLine(pos=1, angle=0, pen=rpen)
        self.mark_widgets.extend([
            self.mark_v_line, self.mark_h_line,
        ])

        # Mouse cursor
        wpen = pg.mkPen(color=(255,255,255,63), width=3)
        red = pg.mkColor(255,0,0,223)
        yellow = pg.mkColor(255,255,0,223)
        self.cursor_v = pg.InfiniteLine(pos=1, angle=90, pen=wpen)
        self.cursor_h = pg.InfiniteLine(pos=1, angle=0, pen=wpen)
        self.cursor_text = pg.TextItem()
        self.cursor_delta = pg.TextItem(anchor=(-0.1, -0.1), color=red)
        self.beam_delta = pg.TextItem(anchor=(-0.1, -0.1), color=yellow)
        self.zoom_text = pg.TextItem(anchor=(-0.1, -0.1), color=yellow)
        self.residuals_text = pg.TextItem(anchor=(-0.1, -0.1))
        self.mark_widgets.append(self.cursor_delta)
        self.mark_widgets.append(self.beam_delta)

        # Centroid position markers in zoomed image, aligned with beam
        # ellipse axes
        zoom_centre = QtCore.QPointF(25,25)
        self.fit_maj_line = pg.InfiniteLine(pos=zoom_centre, angle=90, pen=ypen)
        self.fit_min_line = pg.InfiniteLine(pos=zoom_centre, angle=0, pen=ypen)

        # Shows 1/e^2 ellipse of beam
        isopen = pg.mkPen(color=(255,255,0,85), width=3, style=QtCore.Qt.DotLine)
        self.isocurve = pg.IsocurveItem(pen=isopen)
        self.isocurve.setParentItem(self.zoom)
示例#9
0
	def	__init__(self,map='map'):
		prefileMeas = sorted([x for x in [y for y in os.listdir("./")] if re.search("axion.m.[0-9]{5}$", x)])
		fileMeas = []
		for maes in prefileMeas:
			try:
				with h5py.File(maes, 'r') as f:
					if (map in f) :
						fileMeas.append(maes)
			except:
				print('Error opening file: %s'%maes)

		fileHdf5 = h5py.File(fileMeas[0], "r")

		self.Lx = fileHdf5["/"].attrs.get("Size")
		self.Ly = fileHdf5["/"].attrs.get("Size")
		self.Lz = fileHdf5["/"].attrs.get("Depth")

		self.z = fileHdf5["/"].attrs.get("z")
		self.R = self.z

		fileHdf5.close()

		self.allData = []

		self.step  = 1
		self.tStep = 100
		self.pause = False

		self.timer = pg.QtCore.QTimer()

		# Read all data

		self.i = 0
		self.size = 0

#		if os.path.exists("./Strings.PyDat"):
#			fp = gzip.open("./Strings.PyDat", "rb")
#			self.allData = pickle.load(fp)
#			fp.close()
#			self.size = len(self.allData)
#		else:
		for meas in fileMeas:
#			print(meas)
			fileHdf5 = h5py.File(meas, "r")

			Lx = fileHdf5["/"].attrs.get("Size")
			Ly = fileHdf5["/"].attrs.get("Size")
			Lz = fileHdf5["/"].attrs.get("Depth")
			zR = fileHdf5["/"].attrs.get("z")
			R  = zR
			if 'R' in fileHdf5:
				R = fileHdf5["/"].attrs.get("R")

			fl = fileHdf5["/"].attrs.get("Field type").decode()

			if self.Lx != Lx or self.Ly != Ly or self.Lz != Lz:
				print("Error: Size mismatch (%d %d %d) vs (%d %d %d)\nAre you mixing files?\n" % (Lx, Ly, Lz, self.Lx, self.Ly, self.Lz))
				exit()

			if fl == "Saxion":
				mTmp  = fileHdf5[map]['m'].value.reshape(Ly,Lx,2)
				rData = np.sqrt(mTmp[:,:,0]**2 + mTmp[:,:,1]**2)
				rMax = np.amax(rData)
				rData = rData/R
				aData = (np.arctan2(mTmp[:,:,1], mTmp[:,:,0]) + 2*np.pi)/(4.*np.pi)
			elif fl == "Axion":
				aData = fileHdf5[map]['m'].value.reshape(Ly,Lx)
#				pm = np.amax(aData)
#				print ("BMax %f" % pm)
				aData = aData/R
				rData = np.ones(aData.shape)
				pData = np.ones(aData.shape)*(2*np.pi)
				aData = (aData + pData)/(4.*np.pi)
#				iData = np.trunc(aData/(2*np.pi))
#				aData = aData - iData*(2*np.pi)
#				aData = aData - pData
#				pm = np.amax(aData)
#				print ("AMax %f" % pm)
				rMax  = R
			else:
				print("Unrecognized field type %s" % fl)
				exit()

			self.allData.append([rData, aData, zR, rMax])
			fileHdf5.close()

			self.size = self.size + 1

#			fp = gzip.open("Strings.PyDat", "wb")
#			pickle.dump(self.allData, fp, protocol=2)
#			fp.close()


		self.app  = QtGui.QApplication([])
		self.pWin = pg.GraphicsLayoutWidget()
		self.pWin.setWindowTitle('Axion / Saxion evolution')
		self.pWin.resize(1600,1600)
		pg.setConfigOptions(antialias=True)

		self.aPlot = self.pWin.addPlot(row=0, col=0)
		self.sPlot = self.pWin.addPlot(row=0, col=1)

		self.aPlot.setXRange(0,Lx*1.2)
		self.aPlot.setYRange(0,Lx*1.2)
		self.sPlot.setXRange(0,Lx*1.2)
		self.sPlot.setYRange(0,Lx*1.2)

		self.zAtxt = pg.TextItem("z=0.000000")
		self.zStxt = pg.TextItem("z=0.000000")

		data = self.allData[0]

		aPos = np.array([0.00, 0.10, 0.25, 0.4, 0.5, 0.6, 0.75, 0.9, 1.0 ])
		aCol = ['#006600', 'b', 'w', 'r', 'k', 'b', 'w', 'r', '#006600']

		vb = self.aPlot.getViewBox()

		aSzeX = vb.size().width()*0.96
		aSzeY = vb.size().height()*0.8

		self.aMap  = pg.ColorMap(aPos, np.array([pg.colorTuple(pg.Color(c)) for c in aCol]))
		self.aLut  = self.aMap.getLookupTable()
		self.aLeg  = pg.GradientLegend((aSzeX/20, aSzeY), (aSzeX, aSzeY/12.))
		self.aLeg.setLabels({ "-pi": 0.0, "-pi/2": 0.25, "0.0": 0.50, "+pi/2": 0.75, "+pi": 1.00 })
		self.aLeg.setParentItem(self.aPlot)
		self.aLeg.gradient.setColorAt(0.00, QtGui.QColor(255,255,255))
		self.aLeg.gradient.setColorAt(0.25, QtGui.QColor(255,  0,  0))
		self.aLeg.gradient.setColorAt(0.50, QtGui.QColor(  0,  0,  0))
		self.aLeg.gradient.setColorAt(0.75, QtGui.QColor(  0,  0,255))
		self.aLeg.gradient.setColorAt(1.00, QtGui.QColor(255,255,255))

		self.aImg = pg.ImageItem(lut=self.aLut)
		self.aPlot.addItem(self.aImg)
		self.aPlot.addItem(self.zAtxt)

#		sPos = np.linspace(0.0, data[3], 5)
		sPos = np.array([0.00, 0.25, 0.50, 0.75, 1.00])
		sLab = ["%.2f" % mod for mod in sPos]
		sCol = ['w', 'r', 'y', 'c', 'k']

		vs = self.sPlot.getViewBox()

		sSzeX = vs.size().width()*0.96
		sSzeY = vs.size().height()*0.8

		self.sMap  = pg.ColorMap(sPos, np.array([pg.colorTuple(pg.Color(c)) for c in sCol]))
		self.s**t  = self.sMap.getLookupTable()
		self.sLeg  = pg.GradientLegend((sSzeX/20, sSzeY), (aSzeX/0.96 + sSzeX, sSzeY/12.))
		self.sLeg.setLabels({ sLab[0]: 0.0, sLab[1]: 0.25, sLab[2]: 0.50, sLab[3]: 0.75, sLab[4]: 1.00 })
		self.sLeg.setParentItem(self.sPlot)
		self.sLeg.gradient.setColorAt(0.00, QtGui.QColor(255,255,255))
		self.sLeg.gradient.setColorAt(0.25, QtGui.QColor(255,  0,  0))
		self.sLeg.gradient.setColorAt(0.50, QtGui.QColor(255,255,  0))
		self.sLeg.gradient.setColorAt(0.75, QtGui.QColor(  0,255,255))
		self.sLeg.gradient.setColorAt(1.00, QtGui.QColor(  0,  0,  0))

		self.sImg = pg.ImageItem(lut=self.s**t)
		self.sPlot.addItem(self.sImg)
		self.sPlot.addItem(self.zStxt)


		self.sImg.setImage(data[0], levels=(0.,1.))
		self.aImg.setImage(data[1], levels=(0.,1.))

		self.pWin.show()


		self.baseKeyPress = self.pWin.keyPressEvent