Example #1
0
    def _update_plot(self):
        '''Draw/Redraw the plot.'''

        # Create the plot with PyArt RadarDisplay
        self.ax.cla()  # Clear the plot axes
        self.cax.cla()  # Clear the colorbar axes

        if self.Vfield.value not in self.Vradar.value.fields.keys():
            self.canvas.draw()
            self.statusbar.setStyleSheet("QStatusBar{padding-left:8px;" +
                                         "background:rgba(255,0,0,255);" +
                                         "color:black;font-weight:bold;}")
            self.statusbar.showMessage("Field not Found in Radar", msecs=5000)
            return
        else:
            self.statusbar.setStyleSheet("QStatusBar{padding-left:8px;" +
                                         "background:rgba(0,0,0,0);" +
                                         "color:black;font-weight:bold;}")
            self.statusbar.clearMessage()

        # Reset to default title if user entered nothing w/ Title button
        if self.title == '':
            title = None
        else:
            title = self.title

        limits = self.Vlims.value
        cmap = self.Vcmap.value

        if self.plot_type == "radarAirborne":
            self.display = pyart.graph.RadarDisplay_Airborne(self.Vradar.value)

            self.plot = self.display.plot_sweep_grid(
                self.Vfield.value, vmin=cmap['vmin'],
                vmax=cmap['vmax'], colorbar_flag=False, cmap=cmap['cmap'],
                ax=self.ax, fig=self.fig, title=title)
            self.display.plot_grid_lines()

        elif self.plot_type == "radarPpi":
            self.display = pyart.graph.RadarDisplay(self.Vradar.value)
            # Create Plot
            self.plot = self.display.plot_ppi(
                self.Vfield.value, self.Vtilt.value,
                vmin=cmap['vmin'], vmax=cmap['vmax'],
                colorbar_flag=False, cmap=cmap['cmap'],
                ax=self.ax, fig=self.fig, title=self.title)
            # Add range rings
            if self.RngRing:
                self.display.plot_range_rings(self.RNG_RINGS, ax=self.ax)
            # Add radar location
            self.display.plot_cross_hair(5., ax=self.ax)

        elif self.plot_type == "radarRhi":
            self.display = pyart.graph.RadarDisplay(self.Vradar.value)
            # Create Plot
            self.plot = self.display.plot_rhi(
                self.Vfield.value, self.Vtilt.value,
                vmin=cmap['vmin'], vmax=cmap['vmax'],
                colorbar_flag=False, cmap=cmap['cmap'],
                ax=self.ax, fig=self.fig, title=self.title)
            # Add range rings
            if self.RngRing:
                self.display.plot_range_rings(self.RNG_RINGS, ax=self.ax)

        self._update_axes()
        norm = mlabNormalize(vmin=cmap['vmin'],
                             vmax=cmap['vmax'])
        self.cbar = mlabColorbarBase(self.cax, cmap=cmap['cmap'],
                                     norm=norm, orientation='horizontal')
        # colorbar - use specified units or default depending on
        # what has or has not been entered
        if self.units is None or self.units == '':
            try:
                self.units = self.Vradar.value.fields[self.field]['units']
            except:
                self.units = ''
        self.cbar.set_label(self.units)

#        print "Plotting %s field, Tilt %d in %s" % (
#            self.Vfield.value, self.Vtilt.value+1, self.name)
        self.canvas.draw()
Example #2
0
    def _update_plot(self):
        '''Draw/Redraw the plot.'''

        if self.Vradar.value is None:
            return

        # Create the plot with PyArt RadarDisplay
        self.ax.cla()  # Clear the plot axes
        self.cax.cla()  # Clear the colorbar axes

        if self.Vfield.value not in self.Vradar.value.fields.keys():
            self.canvas.draw()
            self.statusbar.setStyleSheet("QStatusBar{padding-left:8px;" +
                                         "background:rgba(255,0,0,255);" +
                                         "color:black;font-weight:bold;}")
            self.statusbar.showMessage("Field not Found in Radar", msecs=5000)
            return
        else:
            self.statusbar.setStyleSheet("QStatusBar{padding-left:8px;" +
                                         "background:rgba(0,0,0,0);" +
                                         "color:black;font-weight:bold;}")
            self.statusbar.clearMessage()

        title = self.title
        limits = self.Vlims.value
        cmap = self.Vcmap.value
        if self.gatefilterToggle.isChecked():
            gatefilter = self.Vgatefilter.value
        else:
            gatefilter = None

        if self.plot_type == "radarAirborne":
            self.display = pyart.graph.RadarDisplay_Airborne(self.Vradar.value)

            self.plot = self.display.plot_sweep_grid(
                self.Vfield.value, vmin=cmap['vmin'],
                vmax=cmap['vmax'], colorbar_flag=False, cmap=cmap['cmap'],
                mask_outside=True,
                gatefilter=gatefilter, ax=self.ax, fig=self.fig, title=title)
            self.display.plot_grid_lines()

        elif self.plot_type == "radarPpi":
            self.display = pyart.graph.RadarDisplay(self.Vradar.value)
            # Create Plot
            self.plot = self.display.plot_ppi(
                self.Vfield.value, self.Vtilt.value,
                vmin=cmap['vmin'], vmax=cmap['vmax'],
                colorbar_flag=False, cmap=cmap['cmap'], mask_outside=True,
                gatefilter=gatefilter, ax=self.ax, fig=self.fig, title=title)
            # Add range rings
            if self.RngRing:
                self.display.plot_range_rings(self.RNG_RINGS, ax=self.ax)
            # Add radar location
            self.display.plot_cross_hair(5., ax=self.ax)

        elif self.plot_type == "radarRhi":
            self.display = pyart.graph.RadarDisplay(self.Vradar.value)
            # Create Plot
            self.plot = self.display.plot_rhi(
                self.Vfield.value, self.Vtilt.value,
                vmin=cmap['vmin'], vmax=cmap['vmax'],
                colorbar_flag=False, cmap=cmap['cmap'], mask_outside=True,
                gatefilter=gatefilter, ax=self.ax, fig=self.fig, title=title)
            # Add range rings
            if self.RngRing:
                self.display.plot_range_rings(self.RNG_RINGS, ax=self.ax)

        self._update_axes()
        norm = mlabNormalize(vmin=cmap['vmin'],
                             vmax=cmap['vmax'])
        self.cbar = mlabColorbarBase(self.cax, cmap=cmap['cmap'],
                                     norm=norm, orientation='horizontal')
        self.cbar.set_label(self.units)

#        print "Plotting %s field, Tilt %d in %s" % (
#            self.Vfield.value, self.Vtilt.value+1, self.name)
        self.canvas.draw()
Example #3
0
    def _update_plot(self):
        '''Renew the plot'''
        # This is a bit of a hack to ensure that the viewer works with files
        # withouth "standard" output as defined by PyArt
        # Check to see if the field 'reflectivity' exists for the initial open
        self._check_default_field()
    
        # Create the plot with PyArt RadarDisplay 
        # Always intitiates at lowest elevation angle
        self.ax.cla()

        # Reset to default title if user entered nothing w/ Title button
        if self.title == '':
            self.title = None
        
        # If Zoom/Pan selected, Set up the zoom/pan functionality
        if self.ToolSelect == "Zoom/Pan":
            scale = 1.1
            self.zp = ZoomPan(self.ax, self.limits, base_scale = scale)
            #figZoom = self.zp.zoom()
            #figPan = self.zp.pan_factory(self.limits)
            self.zp.connect()
        
        if self.airborne:
            self.display = pyart.graph.RadarDisplay_Airborne(self.radar)
            
            self.plot = self.display.plot_sweep_grid(self.field, \
                                vmin=self.limits['vmin'], vmax=self.limits['vmax'],\
                                colorbar_flag=False, cmap=self.CMAP,\
                                ax=self.ax, title=self.title)
            self.display.set_limits(xlim=(self.limits['xmin'], self.limits['xmax']),\
                                    ylim=(self.limits['ymin'], self.limits['ymax']),\
                                    ax=self.ax)
            self.display.plot_grid_lines()
        else:
            self.display = pyart.graph.RadarDisplay(self.radar)
            if self.radar.scan_type != 'rhi':
                # Create Plot
                if self.tilt < len(self.rTilts):
                    pass
                else:
                    self.tilt = 0
                self.plot = self.display.plot_ppi(self.field, self.tilt,\
                                vmin=self.limits['vmin'], vmax=self.limits['vmax'],\
                                colorbar_flag=False, cmap=self.CMAP,\
                                ax=self.ax, title=self.title)
                # Set limits
                self.display.set_limits(xlim=(self.limits['xmin'], self.limits['xmax']),\
                                        ylim=(self.limits['ymin'], self.limits['ymax']),\
                                        ax=self.ax)
                # Add range rings
                if self.RngRing:
                    self.display.plot_range_rings(self.RNG_RINGS, ax=self.ax)
                # Add radar location
                self.display.plot_cross_hair(5., ax=self.ax)
            else:
                self.plot = self.display.plot_rhi(self.field, self.tilt,\
                                vmin=self.limits['vmin'], vmax=self.limits['vmax'],\
                                colorbar_flag=False, cmap=self.CMAP,\
                                ax=self.ax, title=self.title)
                self.display.set_limits(xlim=(self.limits['xmin'], self.limits['xmax']),\
                                        ylim=(self.limits['ymin'], self.limits['ymax']),\
                                        ax=self.ax)
                # Add range rings
                if self.RngRing:
                    self.display.plot_range_rings(self.RNG_RINGS, ax=self.ax)
        
        norm = mlabNormalize(vmin=self.limits['vmin'],\
                                           vmax=self.limits['vmax'])
        self.cbar=mlabColorbarBase(self.cax, cmap=self.CMAP,\
                                                norm=norm, orientation='horizontal')
        # colorbar - use specified units or default depending on
        # what has or has not been entered
        if self.units is None or self.units == '':
            try:
                self.units = self.radar.fields[self.field]['units']
            except:
                self.units = ''
        self.cbar.set_label(self.units)
        
        print "Plotting %s field, Tilt %d" % (self.field, self.tilt+1)
        self.canvas.draw()
Example #4
0
    def _update_plot(self):
        '''Draw/Redraw the plot.'''

        if self.Vgrid.value is None:
            return

        # Create the plot with PyArt GridMapDisplay
        self.ax.cla()  # Clear the plot axes
        self.cax.cla()  # Clear the colorbar axes

        if self.Vfield.value not in self.Vgrid.value.fields.keys():
            self.canvas.draw()
            self.statusbar.setStyleSheet("QStatusBar{padding-left:8px;" +
                                         "background:rgba(255,0,0,255);" +
                                         "color:black;font-weight:bold;}")
            self.statusbar.showMessage("Field not Found in Radar", msecs=5000)
            return
        else:
            self.statusbar.setStyleSheet("QStatusBar{padding-left:8px;" +
                                         "background:rgba(0,0,0,0);" +
                                         "color:black;font-weight:bold;}")
            self.statusbar.clearMessage()

        title = self.title
        limits = self.Vlimits.value
        cmap = self.Vcolormap.value
        display = self.VpyartDisplay.value

        if 'norm' in cmap:
            norm = cmap['norm']
        else:
            norm = None

        # Create Plot
        if self.plot_type == "gridZ":
            display.plot_basemap(
                self.lat_lines, self.lon_lines, ax=self.ax)
            self.basemap = display.get_basemap()
            self.plot = display.plot_grid(
                self.Vfield.value, self.VlevelZ.value, vmin=cmap['vmin'],
                vmax=cmap['vmax'], cmap=cmap['cmap'], norm=norm,
                colorbar_flag=False, title=title, ax=self.ax, fig=self.fig)
        elif self.plot_type == "gridY":
            self.basemap = None
            self.plot = display.plot_latitudinal_level(
                self.Vfield.value, self.VlevelY.value, vmin=cmap['vmin'],
                vmax=cmap['vmax'], cmap=cmap['cmap'], norm=norm,
                colorbar_flag=False, title=title, ax=self.ax, fig=self.fig)
            self.ax.set_aspect('auto')
        elif self.plot_type == "gridX":
            self.basemap = None
            self.plot = display.plot_longitudinal_level(
                self.Vfield.value, self.VlevelX.value, vmin=cmap['vmin'],
                vmax=cmap['vmax'], cmap=cmap['cmap'], norm=norm,
                colorbar_flag=False, title=title, ax=self.ax, fig=self.fig)
            self.ax.set_aspect('auto')

        limits = self.Vlimits.value
        x = self.ax.get_xlim()
        y = self.ax.get_ylim()
        limits['xmin'] = x[0]
        limits['xmax'] = x[1]
        limits['ymin'] = y[0]
        limits['ymax'] = y[1]

        self._update_axes()
        if norm is None:
            norm = mlabNormalize(vmin=cmap['vmin'],
                                 vmax=cmap['vmax'])
        if self.colormapToggle.isChecked():
            self.cbar = mlabColorbarBase(self.cax, cmap=cmap['cmap'],
                                        norm=norm, orientation='vertical')
            self.cbar.set_label(self.units)
            self.cax.set_visible(True)
        else:
            self.cax.set_visible(False)

        if self.plot_type == "gridZ":
            print("Plotting %s field, Z level %d in %s" % (
                self.Vfield.value, self.VlevelZ.value+1, self.name))
        elif self.plot_type == "gridY":
            print("Plotting %s field, Y level %d in %s" % (
                self.Vfield.value, self.VlevelY.value+1, self.name))
        elif self.plot_type == "gridX":
            print("Plotting %s field, X level %d in %s" % (
                self.Vfield.value, self.VlevelX.value+1, self.name))

        self.canvas.draw()
Example #5
0
    def _update_plot(self):
        '''Draw/Redraw the plot.'''
        self._check_default_field()

        # Create the plot with PyArt GridMapDisplay
        self.ax.cla()  # Clear the plot axes
        self.cax.cla()  # Clear the colorbar axes

        if self.Vfield.value not in self.Vgrid.value.fields.keys():
            self.canvas.draw()
            return

        # Reset to default title if user entered nothing w/ Title button
        # TODO convert title to grid
        #if self.title == '':
        #    title = None
        #else:
        #    title = self.title

        limits = self.Vlims.value
        cmap = self.Vcmap.value

        self.display = pyart.graph.GridMapDisplay(self.Vgrid.value)
        # Create Plot
        if self.plot_type == "gridZ":
            self.display.plot_basemap(self.lat_lines, self.lon_lines,
                                      ax=self.ax)
            self.plot = self.display.plot_grid(
                    self.Vfield.value, self.VlevelZ.value, vmin=cmap['vmin'],
                    vmax=cmap['vmax'],cmap=cmap['cmap'])
        elif self.plot_type == "gridY":
             self.plot = self.display.plot_latitude_slice(
                    self.Vfield.value, vmin=cmap['vmin'],
                    vmax=cmap['vmax'],cmap=cmap['cmap'])
        elif self.plot_type == "gridX":
             self.plot = self.display.plot_longitude_slice(
                    self.Vfield.value, vmin=cmap['vmin'],
                    vmax=cmap['vmax'],cmap=cmap['cmap'])

        limits = self.Vlims.value
        x = self.ax.get_xlim()
        y = self.ax.get_ylim()
        limits['xmin'] = x[0]
        limits['xmax'] = x[1]
        limits['ymin'] = y[0]
        limits['ymax'] = y[1]

        self._update_axes()
        norm = mlabNormalize(vmin=cmap['vmin'],
                             vmax=cmap['vmax'])
        self.cbar = mlabColorbarBase(self.cax, cmap=cmap['cmap'],
                                     norm=norm, orientation='horizontal')
        # colorbar - use specified units or default depending on
        # what has or has not been entered
        if self.units is None or self.units == '':
            try:
                self.units = self.Vgrid.value.fields[self.field]['units']
            except:
                self.units = ''
        self.cbar.set_label(self.units)

        if self.plot_type == "gridZ":
            print("Plotting %s field, Z level %d in %s" % (
                self.Vfield.value, self.VlevelZ.value+1, self.name))
        elif self.plot_type == "gridY":
            print("Plotting %s field, Y level %d in %s" % (
                self.Vfield.value, self.VlevelY.value+1, self.name))
        elif self.plot_type == "gridX":
            print("Plotting %s field, X level %d in %s" % (
                self.Vfield.value, self.VlevelX.value+1, self.name))


        self.canvas.draw()
Example #6
0
    def _update_plot(self):
        '''Draw/Redraw the plot.'''

        if self.Vgrid.value is None:
            return

        # Create the plot with PyArt GridMapDisplay
        self.ax.cla()  # Clear the plot axes
        self.cax.cla()  # Clear the colorbar axes

        if self.Vfield.value not in self.Vgrid.value.fields.keys():
            self.canvas.draw()
            self.statusbar.setStyleSheet("QStatusBar{padding-left:8px;" +
                                         "background:rgba(255,0,0,255);" +
                                         "color:black;font-weight:bold;}")
            self.statusbar.showMessage("Field not Found in Radar", msecs=5000)
            return
        else:
            self.statusbar.setStyleSheet("QStatusBar{padding-left:8px;" +
                                         "background:rgba(0,0,0,0);" +
                                         "color:black;font-weight:bold;}")
            self.statusbar.clearMessage()

        title = self.title
        limits = self.Vlims.value
        cmap = self.Vcmap.value

        self.display = pyart.graph.GridMapDisplay(self.Vgrid.value)
        # Create Plot
        if self.plot_type == "gridZ":
            self.display.plot_basemap(
                self.lat_lines, self.lon_lines, ax=self.ax)
            self.basemap = self.display.get_basemap()
            self.plot = self.display.plot_grid(
                self.Vfield.value, self.VlevelZ.value, vmin=cmap['vmin'],
                vmax=cmap['vmax'], cmap=cmap['cmap'], colorbar_flag=False,
                title=title, ax=self.ax, fig=self.fig)
        elif self.plot_type == "gridY":
            self.basemap = None
            self.plot = self.display.plot_latitudinal_level(
                self.Vfield.value, self.VlevelY.value, vmin=cmap['vmin'],
                vmax=cmap['vmax'], cmap=cmap['cmap'], colorbar_flag=False,
                title=title, ax=self.ax, fig=self.fig)
        elif self.plot_type == "gridX":
            self.basemap = None
            self.plot = self.display.plot_longitudinal_level(
                self.Vfield.value, self.VlevelX.value, vmin=cmap['vmin'],
                vmax=cmap['vmax'], cmap=cmap['cmap'], colorbar_flag=False,
                title=title, ax=self.ax, fig=self.fig)

        limits = self.Vlims.value
        x = self.ax.get_xlim()
        y = self.ax.get_ylim()
        limits['xmin'] = x[0]
        limits['xmax'] = x[1]
        limits['ymin'] = y[0]
        limits['ymax'] = y[1]

        self._update_axes()
        norm = mlabNormalize(vmin=cmap['vmin'],
                             vmax=cmap['vmax'])
        self.cbar = mlabColorbarBase(self.cax, cmap=cmap['cmap'],
                                     norm=norm, orientation='vertical')
        self.cbar.set_label(self.units)

        if self.plot_type == "gridZ":
            print("Plotting %s field, Z level %d in %s" % (
                self.Vfield.value, self.VlevelZ.value+1, self.name))
        elif self.plot_type == "gridY":
            print("Plotting %s field, Y level %d in %s" % (
                self.Vfield.value, self.VlevelY.value+1, self.name))
        elif self.plot_type == "gridX":
            print("Plotting %s field, X level %d in %s" % (
                self.Vfield.value, self.VlevelX.value+1, self.name))

        self.canvas.draw()
Example #7
0
    def _update_plot(self):
        '''Draw/Redraw the plot.'''

        if self.Vpoints.value is None:
            return

        # Create the plot with PyArt PlotDisplay
        self.ax.cla()  # Clear the plot axes

        # Reset to default title if user entered nothing w/ Title button

        colorbar_flag = False

        points = self.Vpoints.value
        field = self.Vfield.value
        cmap = self.Vcolormap.value

        if field not in points.fields.keys():
            self.canvas.draw()
            self.statusbar.setStyleSheet("QStatusBar{padding-left:8px;" +
                                         "background:rgba(255,0,0,255);" +
                                         "color:black;font-weight:bold;}")
            self.statusbar.showMessage("Field not Found", msecs=5000)
            return
        else:
            self.statusbar.setStyleSheet("QStatusBar{padding-left:8px;" +
                                         "background:rgba(0,0,0,0);" +
                                         "color:black;font-weight:bold;}")
            self.statusbar.clearMessage()

        if self.plot_type == "histogram" and len(
                points.fields[field]['data']) > 0:
            self.plot = self.ax.hist(points.fields[field]['data'],
                                     bins=25,
                                     range=(cmap['vmin'], cmap['vmax']),
                                     figure=self.fig)
            self.ax.set_ylabel("Counts")

            # If limits exists, update the axes otherwise retrieve
            # self._update_axes()
            self._update_limits()

            # If the colorbar flag is thrown, create it
            if colorbar_flag:
                # Clear the colorbar axes
                self.cax.cla()
                self.cax = self.fig.add_axes([0.2, 0.10, 0.7, 0.02])
                norm = mlabNormalize(vmin=cmap['vmin'], vmax=cmap['vmax'])
                self.cbar = mlabColorbarBase(self.cax,
                                             cmap=self.cm_name,
                                             norm=norm,
                                             orientation='horizontal')
                # colorbar - use specified units or default depending on
                # what has or has not been entered
                self.cbar.set_label(self.units)

            self.canvas.draw()

        elif self.plot_type == 'statistics':
            if (self.Vpoints.value is None
                    or self.Vfield.value not in self.Vpoints.value.fields):
                common.ShowWarning("Please select Region and Field first")
            else:
                points = self.Vpoints.value
                field = self.Vfield.value
                SelectRegionstats = common._array_stats(
                    points.fields[field]['data'])
                text = ("<b>Basic statistics for the selected Region</b>"
                        "<br><br>")
                for stat in SelectRegionstats:
                    text += ("<i>%s</i>: %5.2f<br>" %
                             (stat, SelectRegionstats[stat]))
                if self.statistics is not None:
                    self.layout.removeWidget(self.statistics)
                    self.statistics.close()
                self.statistics = QtWidgets.QDialog()
                layout = QtWidgets.QGridLayout(self.statistics)
                self.statistics = QtWidgets.QTextEdit("")
                self.statistics.setAcceptRichText(True)
                self.statistics.setReadOnly(True)
                self.statistics.setText(text)
                self.layout.addWidget(self.statistics, 0)

        elif self.plot_type == "table":
            if self.Vpoints.value is not None:
                # Instantiate Table
                if self.table is not None:
                    self.layout.removeWidget(self.table)
                    self.table.close()
                self.table = common.CreateTable(self.Vpoints.value)
                self.layout.addWidget(self.table, 0)
                self.table.display()
                # Show the table
                self.table.show()
            else:
                common.ShowWarning("Please select or open Region first")
Example #8
0
    def _update_plot(self):
        '''Draw/Redraw the plot.'''

        # Create the plot with PyArt PlotDisplay
        self.ax.cla()  # Clear the plot axes

        # Reset to default title if user entered nothing w/ Title button
        if self.title == '':
            title = None
        else:
            title = self.title

        colorbar_flag=False

        self.cmap = {'vmin': self.data.min(), 'vmax': self.data.max(),
                     'cmap': 'pyart_RefDiff'}

        if self.plot_type == "hist":
            self.plot = self.ax.hist(self.data, bins=25,
                range = (self.cmap['vmin'], self.cmap['vmax']),
                figure=self.fig)
            self.ax.set_ylabel("Counts")
            if self.xlabel:
                self.ax.set_xlabel(self.xlabel)

        elif self.plot_type == "hist2d":
            # Check that y data was provided
            if self.ydata:
                y = self.ydata
            # Create Plot
            self.plot = self.ax.hist2d(self.data, y,
                bins=[25, 20],
                range=[[self.cmap['vmin'], self.cmap['vmax']],
                       [y.min(), y.max()]],
                cmap=self.cm_name,
                figure=self.fig)
            colorbar_flag=True

        elif self.plot_type == "plot":
            # Check that y data was provided
            if self.ydata:
                y = self.ydata
            # Create Plot
            self.plot = self.ax.plot(self.data, y,
                figure=self.fig)

        # Set the axis labels if arguments passed
        if self.xlabel:
            self.ax.set_xlabel(self.xlabel)
        if self.ylabel:
            self.ax.set_ylabel(self.ylabel)

        # If limits exists, update the axes otherwise retrieve
        if self.limits:
            self._update_axes()
        else:
            self._get_axes_limits()

        # Set the title if passed
        if title is not None:
            self.ax.set_title(title)

        # If the colorbar flag is thrown, create it
        if colorbar_flag:
            # Clear the colorbar axes
            self.cax.cla()
            self.cax = self.fig.add_axes([0.2, 0.10, 0.7, 0.02])
            norm = mlabNormalize(vmin=self.cmap['vmin'],
                                 vmax=self.cmap['vmax'])
            self.cbar = mlabColorbarBase(self.cax, cmap=self.cm_name,
                                         norm=norm, orientation='horizontal')
            # colorbar - use specified units or default depending on
            # what has or has not been entered
            if self.units is None or self.units == '':
                self.units = ''
            self.cbar.set_label(self.units)

        self.canvas.draw()
Example #9
0
    def _update_plot(self):
        '''Draw/Redraw the plot.'''

        # Create the plot with PyArt PlotDisplay
        self.ax.cla()  # Clear the plot axes

        # Reset to default title if user entered nothing w/ Title button
        if self.title == '':
            title = None
        else:
            title = self.title

        colorbar_flag = False

        self.cmap = {'vmin': self.data.min(), 'vmax': self.data.max(),
                     'cmap': 'pyart_RefDiff'}

        if self.plot_type == "hist":
            self.plot = self.ax.hist(
                self.data, bins=25,
                range=(self.cmap['vmin'], self.cmap['vmax']),
                figure=self.fig)
            self.ax.set_ylabel("Counts")
            if self.xlabel:
                self.ax.set_xlabel(self.xlabel)

        elif self.plot_type == "hist2d":
            # Check that y data was provided
            if self.ydata:
                y = self.ydata
            # Create Plot
            self.plot = self.ax.hist2d(
                self.data, y, bins=[25, 20],
                range=([self.cmap['vmin'], self.cmap['vmax']],
                       [y.min(), y.max()]),
                cmap=self.cm_name,
                figure=self.fig)
            colorbar_flag = True

        elif self.plot_type == "plot":
            # Check that y data was provided
            if self.ydata:
                y = self.ydata
            # Create Plot
            self.plot = self.ax.plot(self.data, y, figure=self.fig)

        # Set the axis labels if arguments passed
        if self.xlabel:
            self.ax.set_xlabel(self.xlabel)
        if self.ylabel:
            self.ax.set_ylabel(self.ylabel)

        # If limits exists, update the axes otherwise retrieve
        if self.limits:
            self._update_axes()
        else:
            self._get_axes_limits()

        # Set the title if passed
        if title is not None:
            self.ax.set_title(title)

        # If the colorbar flag is thrown, create it
        if colorbar_flag:
            # Clear the colorbar axes
            self.cax.cla()
            self.cax = self.fig.add_axes([0.2, 0.10, 0.7, 0.02])
            norm = mlabNormalize(vmin=self.cmap['vmin'],
                                 vmax=self.cmap['vmax'])
            self.cbar = mlabColorbarBase(self.cax, cmap=self.cm_name,
                                         norm=norm, orientation='horizontal')
            # colorbar - use specified units or default depending on
            # what has or has not been entered
            if self.units is None or self.units == '':
                self.units = ''
            self.cbar.set_label(self.units)

        self.canvas.draw()
Example #10
0
    def _update_plot(self):
        '''Draw/Redraw the plot.'''

        if self.Vpoints.value is None:
            return

        # Create the plot with PyArt PlotDisplay
        self.ax.cla()  # Clear the plot axes

        # Reset to default title if user entered nothing w/ Title button

        colorbar_flag = False

        points = self.Vpoints.value
        field = self.Vfield.value
        cmap = self.Vcmap.value

        if field not in points.fields.keys():
            self.canvas.draw()
            self.statusbar.setStyleSheet("QStatusBar{padding-left:8px;" +
                                         "background:rgba(255,0,0,255);" +
                                         "color:black;font-weight:bold;}")
            self.statusbar.showMessage("Field not Found", msecs=5000)
            return
        else:
            self.statusbar.setStyleSheet("QStatusBar{padding-left:8px;" +
                                         "background:rgba(0,0,0,0);" +
                                         "color:black;font-weight:bold;}")
            self.statusbar.clearMessage()

        if self.plot_type == "histogram":
            self.plot = self.ax.hist(
                points.fields[field]['data'], bins=25,
                range=(cmap['vmin'], cmap['vmax']),
                figure=self.fig)
            self.ax.set_ylabel("Counts")

            # If limits exists, update the axes otherwise retrieve
            # self._update_axes()
            self._update_limits()

            # If the colorbar flag is thrown, create it
            if colorbar_flag:
                # Clear the colorbar axes
                self.cax.cla()
                self.cax = self.fig.add_axes([0.2, 0.10, 0.7, 0.02])
                norm = mlabNormalize(vmin=cmap['vmin'],
                                     vmax=cmap['vmax'])
                self.cbar = mlabColorbarBase(self.cax, cmap=self.cm_name,
                                             norm=norm,
                                             orientation='horizontal')
                # colorbar - use specified units or default depending on
                # what has or has not been entered
                self.cbar.set_label(self.units)

            self.canvas.draw()

        elif self.plot_type == 'statistics':
            if (self.Vpoints.value is None or
                self.Vfield.value not in self.Vpoints.value.fields):
                common.ShowWarning("Please select Region and Field first")
            else:
                points = self.Vpoints.value
                field = self.Vfield.value
                SelectRegionstats = common._array_stats(
                    points.fields[field]['data'])
                text = "<b>Basic statistics for the selected Region</b><br><br>"
                for stat in SelectRegionstats:
                    text += ("<i>%s</i>: %5.2f<br>" %
                             (stat, SelectRegionstats[stat]))
                self.statistics = QtGui.QDialog()
                layout = QtGui.QGridLayout(self.statistics)
                self.statistics = QtGui.QTextEdit("")
                self.statistics.setAcceptRichText(True)
                self.statistics.setReadOnly(True)
                self.statistics.setText(text)
                self.layout.addWidget(self.statistics, 0)

        elif self.plot_type == "table":
            if self.Vpoints.value is not None:
                # Instantiate Table
                self.table = common.CreateTable(self.Vpoints.value)
                self.layout.addWidget(self.table, 0)
                self.table.display()
                # Show the table
                self.table.show()
            else:
                common.ShowWarning("Please select or open Region first")