Пример #1
0
 def _subplot_label(self, axis):
     layout_num = self.layout_num if self.subplot else 1
     if self.sublabel_format and not self.adjoined and layout_num > 0:
         from mpl_toolkits.axes_grid1.anchored_artists import AnchoredText
         labels = {}
         if '{Alpha}' in self.sublabel_format:
             labels['Alpha'] = int_to_alpha(layout_num - 1)
         elif '{alpha}' in self.sublabel_format:
             labels['alpha'] = int_to_alpha(layout_num - 1, upper=False)
         elif '{numeric}' in self.sublabel_format:
             labels['numeric'] = self.layout_num
         elif '{Roman}' in self.sublabel_format:
             labels['Roman'] = int_to_roman(layout_num)
         elif '{roman}' in self.sublabel_format:
             labels['roman'] = int_to_roman(layout_num).lower()
         at = AnchoredText(self.sublabel_format.format(**labels),
                           loc=3,
                           bbox_to_anchor=self.sublabel_position,
                           frameon=False,
                           prop=dict(size=self.sublabel_size,
                                     weight='bold'),
                           bbox_transform=axis.transAxes)
         at.patch.set_visible(False)
         axis.add_artist(at)
         sublabel = at.txt.get_children()[0]
         self.handles['sublabel'] = sublabel
         self.handles['bbox_extra_artists'] += [sublabel]
Пример #2
0
def draw_text(ax):
    from mpl_toolkits.axes_grid1.anchored_artists import AnchoredText
    at = AnchoredText(
        "Figure 1a",
        loc=2,
        prop=dict(size=8),
        frameon=True,
    )
    at.patch.set_boxstyle("round,pad=0.,rounding_size=0.2")
    ax.add_artist(at)

    at2 = AnchoredText("Figure 1(b)",
                       loc=3,
                       prop=dict(size=8),
                       frameon=True,
                       bbox_to_anchor=(0., 1.),
                       bbox_transform=ax.transAxes)
    at2.patch.set_boxstyle("round,pad=0.,rounding_size=0.2")
    ax.add_artist(at2)
Пример #3
0
def lbl(axis, label, size=22):
    """ Put a figure label in an axis """
    at = AnchoredText(label, loc=2, prop=dict(size=size), frameon=True)
    at.patch.set_boxstyle("round,pad=0.,rounding_size=0.0")
    #bb = axis.get_yaxis_transform()
    #at = AnchoredText(label,
    #        loc=3, prop=dict(size=18), frameon=True,
    #        bbox_to_anchor=(-0.5,1),#(-.255, 0.90),
    #        bbox_transform=bb,#axis.transAxes
    #    )
    axis.add_artist(at)
Пример #4
0
def generate_figures(limit):
    #For each koi in the the search results, to the user-specified limit,
    for i in range(0, limit, 1):

        # if the koi is not a false positive, and its period is less than 800 days
        #     so that we can see at least two transits
        if good_kois[i].koi_disposition != "FALSE POSITIVE":
            if good_kois[i].koi_period < 800.0:

                # get the light curve flux, normalize it by dividing by the mean, and the time for each flux data point
                lcs = good_kois[i].get_light_curves(short_cadence=False,
                                                    fetch=False,
                                                    clobber=False)
                time, data = [], []
                # for each light curve file, fill time and data (flux/mean_flux) arrays
                for lc in lcs:
                    with lc.open() as f:
                        hdu_data = f[1].data
                        time = np.append(time, hdu_data["time"])
                        data = np.append(data, (hdu_data['pdcsap_flux']) /
                                         (np.nanmean(hdu_data["pdcsap_flux"])))
                # plot a new figure for plotting the data for this koi
                plt.figure(figsize=(24, 14))
                plt.plot(time, data, label='Normalized Flux')
                plt.legend()
                plt.xlabel('Time (days)')
                plt.ylabel('Normalized Flux for {}'.format(
                    good_kois[i].kepoi_name))
                plt.title("Light Curve {}".format(good_kois[i].kepoi_name))

                # State some properties of the koi in a caption box
                KOI_Properties = AnchoredText(
                    "Period: {} days\nFirst Centroid: {} days\nDisposition: {}"
                    .format(round(good_kois[i].koi_period, 1),
                            round(good_kois[i].koi_time0bk, 1),
                            good_kois[i].koi_disposition),
                    loc=2,
                    prop=dict(size=10),
                    frameon=True)
                KOI_Properties.patch.set_boxstyle(
                    "round, pad = 0.,rounding_size= 0.2")

                plt.gca().add_artist(KOI_Properties)

                #plt.show()      # ONLY UNCOMMENT THIS LINE IF YOU ARE SURE THERE ARE LESS THAN 20 GENERATED FIGURES.

                figureName = str('Kepler LC (long cadence) for ') + str(
                    good_kois[i].kepoi_name) + str('.png')
                #print "(",i+1,")",figureName
                pylab.savefig('{}.png'.format(figureName))
                plt.close()
                print "Saved ", figureName, " to working directory."
    print "Finished. Check working directory for saved figures"  #, '{}'"#.format(figureName)
Пример #5
0
def draw_text(ax, txt):
    """
    Add text in right corner that identifies the data
    """

    at = AnchoredText(
        txt,
        loc=1,
        prop=dict(size=13),
        frameon=True,
    )
    at.patch.set_boxstyle("round,pad=0.,rounding_size=0.2")
    ax.add_artist(at)
Пример #6
0
def plot_gridded(ref,
                 vel,
                 sweep,
                 fsuffix=None,
                 dir=".",
                 shapefiles=None,
                 interactive=True,
                 LatLon=None):

    # Set up colormaps

    from matplotlib.colors import BoundaryNorm

    cmapr = cm.NWSRef
    cmapr.set_bad('white', 1.0)
    cmapr.set_under('white', 1.0)

    cmapv = cm.Carbone42
    cmapv.set_bad('white', 1.)
    cmapv.set_under('black', 1.)
    cmapv.set_over('black', 1.)

    normr = BoundaryNorm(np.arange(10, 85, 5), cmapr.N)
    normv = BoundaryNorm(np.arange(-48, 50, 2), cmapv.N)

    min_dbz = _radar_parameters['min_dbz_analysis']
    xwidth = ref.xg.max() - ref.xg.min()
    ywidth = ref.yg.max() - ref.yg.min()

    # Create png file label

    if fsuffix == None:
        print(
            "\n opaws2D.grid_plot:  No output file name is given, writing to %s"
            % "VR_RF_...png")
        filename = "%s/VR_RF_%2.2d_plot.pdf" % (dir, sweep)
    else:
        filename = "%s/VR_RF_%2.2d_%s.pdf" % (dir, sweep,
                                              fsuffix.split("/")[1])

    fig, (ax1, ax2) = plt.subplots(1, 2, sharey=True, figsize=(25, 14))

    # Set up coordinates for the plots

    if LatLon == None:
        bgmap = Basemap(projection=_grid_dict['projection'], width=xwidth, \
                    height=ywidth, resolution='c', lat_0=ref.radar_lat, lon_0=ref.radar_lon, ax=ax1)
        xoffset, yoffset = bgmap(ref.radar_lon, ref.radar_lat)
        xg, yg = bgmap(ref.lons, ref.lats)
    else:
        bgmap = Basemap(projection=_grid_dict['projection'], width=xwidth, \
                    height=ywidth, resolution='c', lat_0=LatLon[0], lon_0=LatLon[1], ax=ax1)
        xoffset, yoffset = bgmap(ref.radar_lon, ref.radar_lat)
        xg, yg = bgmap(ref.lons, ref.lats)

#   print xg.min(), xg.max(), xg.shape
#   print yg.min(), yg.max(), yg.shape

    xg_2d, yg_2d = np.meshgrid(xg, yg)

    #   print xg.min(), xg_2d[0,0], xg_2d[-1,-1], xg.max(), xg.shape
    #   print yg.min(), yg.max(), yg.shape

    # fix xg, yg coordinates so that pcolormesh plots them in the center.

    dx2 = 0.5 * (ref.xg[1] - ref.xg[0])
    dy2 = 0.5 * (ref.yg[1] - ref.yg[0])

    xe = np.append(xg - dx2, [xg[-1] + dx2])
    ye = np.append(yg - dy2, [yg[-1] + dy2])

    # REFLECTVITY PLOT

    if shapefiles:
        plot_shapefiles(bgmap,
                        shapefiles=shapefiles,
                        counties=_plot_counties,
                        ax=ax1)
    else:
        plot_shapefiles(bgmap, counties=_plot_counties, ax=ax1)

    bgmap.drawparallels(range(10, 80, 1),
                        labels=[1, 0, 0, 0],
                        linewidth=0.5,
                        ax=ax1)
    bgmap.drawmeridians(range(-170, -10, 1),
                        labels=[0, 0, 0, 1],
                        linewidth=0.5,
                        ax=ax1)

    im1 = bgmap.pcolormesh(xe,
                           ye,
                           ref.data[sweep],
                           cmap=cmapr,
                           vmin=_ref_scale[0],
                           vmax=_ref_scale[1],
                           ax=ax1)
    cbar = bgmap.colorbar(im1, location='right')
    cbar.set_label('Reflectivity (dBZ)')
    ax1.set_title('Thresholded Reflectivity (Gridded)')
    bgmap.scatter(xoffset, yoffset, c='k', s=50., alpha=0.8, ax=ax1)

    at = AnchoredText(
        "Max dBZ: %4.1f" % (ref.data[sweep].max()),
        loc=4,
        prop=dict(size=12),
        frameon=True,
    )
    at.patch.set_boxstyle("round,pad=0.,rounding_size=0.2")
    ax1.add_artist(at)

    # Plot zeros as "o"

    try:
        r_mask = (ref.zero_dbz.mask == False)
        print("\n Plotting zeros from MRMS level\n")
        bgmap.scatter(xg_2d[r_mask], yg_2d[r_mask], s=25, facecolors='none', \
                      edgecolors='k', alpha=1.0, ax=ax1)

    except AttributeError:
        print("\n Plotting zeros from full 3D grid level (non-MRMS form)\n")
        r_mask = np.logical_and(ref.data[sweep] < 1.0,
                                (ref.data.mask[sweep] == False))
        bgmap.scatter(xg_2d[r_mask], yg_2d[r_mask], s=25, facecolors='none', \
                      edgecolors='k', alpha=1.0, ax=ax1)

# RADIAL VELOCITY PLOT

    if LatLon == None:
        bgmap = Basemap(projection=_grid_dict['projection'], width=xwidth, \
                    height=ywidth, resolution='c', lat_0=ref.radar_lat,lon_0=ref.radar_lon, ax=ax2)
        xoffset, yoffset = bgmap(ref.radar_lon, ref.radar_lat)
    else:
        bgmap = Basemap(projection=_grid_dict['projection'], width=xwidth, \
                    height=ywidth, resolution='c', lat_0=LatLon[0], lon_0=LatLon[1], ax=ax2)
        xoffset, yoffset = bgmap(ref.radar_lon, ref.radar_lat)

    if shapefiles:
        plot_shapefiles(bgmap,
                        shapefiles=shapefiles,
                        counties=_plot_counties,
                        ax=ax2)
    else:
        plot_shapefiles(bgmap, counties=_plot_counties, ax=ax2)

    bgmap.drawparallels(range(10, 80, 1),
                        labels=[1, 0, 0, 0],
                        linewidth=0.5,
                        ax=ax2)
    bgmap.drawmeridians(range(-170, -10, 1),
                        labels=[0, 0, 0, 1],
                        linewidth=0.5,
                        ax=ax2)

    im1 = bgmap.pcolormesh(xe,
                           ye,
                           vel.data[sweep],
                           cmap=cmapv,
                           vmin=_vr_scale[0],
                           vmax=_vr_scale[1],
                           ax=ax2)
    cbar = bgmap.colorbar(im1, location='right')
    cbar.set_label('Dealised Radial Velocity (meters_per_second)')
    ax2.set_title('Thresholded, Unfolded Radial Velocity (Gridded)')
    bgmap.scatter(xoffset, yoffset, c='k', s=50., alpha=0.8, ax=ax2)

    at = AnchoredText("Max Vr: %4.1f \nMin Vr: %4.1f " % \
                   (vel.data[sweep].max(),vel.data[sweep].min()), loc=4, prop=dict(size=12), frameon=True,)
    at.patch.set_boxstyle("round,pad=0.,rounding_size=0.2")
    ax2.add_artist(at)

    # Now plot locations of nan data

    v_mask = (vel.data.mask == True)
    bgmap.scatter(xg_2d[v_mask[sweep]],
                  yg_2d[v_mask[sweep]],
                  c='k',
                  s=1.,
                  alpha=0.5,
                  ax=ax2)

    # Get other metadata....for labeling

    instrument_name = ref.metadata['instrument_name']
    time_start = ncdf.num2date(ref.time['data'][0], ref.time['units'])
    time_text = time_start.isoformat().replace("T", " ")
    title = '\nDate:  %s   Time:  %s Z   Elevation:  %2.2f deg' % (
        time_text[0:10], time_text[10:19], ref.elevations[sweep])
    plt.suptitle(title, fontsize=24)

    plt.savefig(filename)

    if interactive: plt.show()
Пример #7
0
fig = plt.figure()
ax = fig.add_subplot(1, 1, 1)

at = AA.AnchoredText(
    "Figure 1a",
    loc=2,
    prop=dict(size=8),
    frameon=True,
)
at.patch.set_boxstyle("round,pad=0.,rounding_size=0.2")
ax.add_artist(at)

at2 = AnchoredText("Figure 1(b)",
                   loc=3,
                   prop=dict(size=8),
                   frameon=True,
                   bbox_to_anchor=(0., 1.),
                   bbox_transform=ax.transAxes)
at2.patch.set_boxstyle("round,pad=0.,rounding_size=0.2")
ax.add_artist(at2)

ada = AA.AnchoredDrawingArea(20, 20, 0, 0, loc=1, pad=0., frameon=False)
p = Circle((10, 10), 10)
ada.da.add_artist(p)
ax.add_artist(ada)

# draw an ellipse of width=0.1, height=0.15 in the data coordinate
ae = AA.AnchoredEllipse(ax.transData,
                        width=0.1,
                        height=0.15,
                        angle=0.,
Пример #8
0
def Normalize_LightCurves():
           
    # based on user input, declare the operation to acquire the light curve data. 
    print"Working..."
    lcs = koi.get_light_curves(short_cadence = True, clobber = True)

    # Initiate empty arrays into which we append data from MAST
    # time array - used extensively for data plotting and model plotting
    # flux array - used to build the fluxmean, fluxmean2 arrays
    # fluxmean(2) arrays - used for data plotting and normalization. 
    # data array - a copy of the fluxmean2 array used for plotting lc data. 
    global time, flux, fluxmean, fluxmean2, data
    
    time,data = [],[]#flux,fluxmean,fluxmean2,data =[],[],[],[],[]
    for lc in lcs:
        with lc.open() as f:
            hdu_data=f[1].data
            time=np.append(time,hdu_data["time"])
            #flux=np.append(flux,(hdu_data["pdcsap_flux"]))
            #fluxmean=np.append(fluxmean, (hdu_data['pdcsap_flux'])/(np.nanmean(hdu_data["pdcsap_flux"])))
            # Fluxmean2 is for finding the base intensity of the host star. 
            #fluxmean2=np.append(fluxmean2, (hdu_data['pdcsap_flux'])/(np.nanmean(hdu_data["pdcsap_flux"])))
            data    = np.append(data,      (hdu_data['pdcsap_flux'])/(np.nanmean(hdu_data["pdcsap_flux"])))
    print "Complete."
    print "Generating plot of normalized, preconditioned data."
    ###############################################     
    '''
    Fix all the values in the time array to be numbers on cadence with the 
    time interval of the data. There are several sections in the time array that
    are huge groups of NaN's. These need to be fixed. For each index in the time
    array, if it is a nan, re-declare it to be time[i-1]+ (time interval). This 
    should fix all NaN's in the time array.   
    '''   
    for i in range(len(time)): 
        if np.isnan(time[i]) == True:
            # point = previous time  +   time interval
            time[i] =  time[i-1]     +  (time[5]-time[4])
    ###################################################   
    '''
    Establish vertical lines in the plot to show the transits by first finding the 
    time values for the centroids of each transit. This is found by by adding the
    "first observed centriod" (as given by MAST) plus an iteration times the period, 
    for each iteration that goes from 1 to the expected number of transits. The 
    expected number of transits is found by dividing the number of days that Kepler 
    operated for the primary mission, divided by the period of the KOI in question. 
    The number of expected transits will be larger for smaller-period KOI.
    At each of these "centroid" times, a vertical line is placed on the plot from 
    y = 1 to y = (lowest observed flux value, or "min(y)"). 
    '''
    centroids = []
    for i in np.arange(0,max(time)/period):
        nextCentroid = koi.koi_time0bk+i*period
        if nextCentroid < max(time):
            centroids = np.append(centroids, nextCentroid)
    print "centriod list:", centroids
    
    try:
        # state the uncertainty of the duration as what is found by MAST. 
        durationErr1 = round(koi.koi_duration_err1,1)
        if type(durationErr1) =="NoneType":
            print "none type for durration error 1"
    except TypeError:
        # if the duration error is not given by MAST, take it as the square root of the duration ( in hours).
        durationErr1 = str("$\pm$ "+str(round(math.sqrt(koi.koi_duration),1)))
    ###############################################
    '''
    The plot of the normalized light curves:
    '''
    
    plt.figure(figsize=(24,14))
    plt.plot(time,data,label ='Normalized Flux')
    
    # a horizontal line that shows the "1" value:
    plt.hlines(1.0000,min(time), max(time),'r')
    plt.title("Light Curves for KOI {}".format(koi))
    plt.xlabel("BJD minus 2455200 (days)")
    plt.ylabel("Normalized Flux Intensity")
    ax = plt.gca()
    ax.get_xaxis().get_major_formatter().set_useOffset(False)

    ###############################################
    '''
    The "Characteristics" legend: 
    '''
    KOI_Properties = AnchoredText("            Characteristics\nPeriod: {} days\nFirst Centroid: {} days\nDisposition: {}\nDuration: {} {} hours\nKepID: {}".format(round(period,1), round(koi.koi_time0bk,1),koi.koi_disposition,round(koi.koi_duration,2),durationErr1,koi.kepid),loc= 2, prop=dict(size = 10),frameon=True)
    KOI_Properties.patch.set_boxstyle("round, pad = 0.5,rounding_size= 0.2")
    plt.gca().add_artist(KOI_Properties)
    
    plt.legend()
    plt.show()
Пример #9
0
def grid_plot(ref,
              sweep,
              plot_filename=None,
              shapefiles=None,
              interactive=False):

    # Set up colormaps

    from matplotlib.colors import BoundaryNorm

    cmapr = _ref_ctable
    cmapr.set_bad('white', 1.0)
    cmapr.set_under('white', 1.0)

    normr = BoundaryNorm(_ref_scale, cmapr.N)

    # Create png file label

    if plot_filename == None:
        print(
            "\n pyROTH.grid_plot:  No output file name is given, writing to %s"
            % "RF_...png")
        filename = "RF_%2.2d_plot.%s" % (sweep, _plot_format)
    else:
        filename = "%s.%s" % (plot_filename, _plot_format)

    fig, axes = plt.subplots(1, 2, sharey=True, figsize=(18, 10))

    # Set up coordinates for the plots

    sw_lon = ref.lons.min()
    ne_lon = ref.lons.max()
    sw_lat = ref.lats.min()
    ne_lat = ref.lats.max()

    bgmap = Basemap(projection='lcc', llcrnrlon=sw_lon,llcrnrlat=sw_lat,urcrnrlon=ne_lon,urcrnrlat=ne_lat, \
                    lat_0=0.5*(ne_lat+sw_lat), lon_0=0.5*(ne_lon+sw_lon), resolution='i', area_thresh=10., ax=axes[0])

    xg, yg = bgmap(ref.lons, ref.lats)

    yg_2d, xg_2d = np.meshgrid(yg, xg)

    yg_2d = yg_2d.transpose()
    xg_2d = xg_2d.transpose()

    # fix xg, yg coordinates so that pcolormesh plots them in the center.

    dx2 = 0.5 * (xg[1] - xg[0])
    dy2 = 0.5 * (yg[1] - yg[0])

    xe = np.append(xg - dx2, [xg[-1] + dx2])
    ye = np.append(yg - dy2, [yg[-1] + dy2])

    # CAPPI REFLECTVITY PLOT

    if shapefiles:
        plot_shapefiles(bgmap,
                        shapefiles=shapefiles,
                        counties=_plot_counties,
                        ax=axes[0])
    else:
        plot_shapefiles(bgmap, counties=_plot_counties, ax=axes[0])

# pixelated plot

    ref_data = ref.data[sweep]

    # im1  = bgmap.pcolormesh(xe, ye, ref_data, cmap=cmapr, norm=normr, vmin = _ref_min_plot, vmax = _ref_scale.max(), ax=axes[0])
    # cbar = bgmap.colorbar(im1,location='right')
    # cbar.set_label('Reflectivity (dBZ)')
    # axes[0].set_title('Pixel Reflectivity at Height:  %4.1f km' % 0.001*ref.zg[sweep])
    # at = AnchoredText("Max dBZ: %4.1f" % (ref_data.max()), loc=4, prop=dict(size=10), frameon=True,)
    # at.patch.set_boxstyle("round,pad=0.,rounding_size=0.2")
    # axes[0].add_artist(at)

    # Contour filled plot

    # bgmap = Basemap(projection='lcc', llcrnrlon=sw_lon,llcrnrlat=sw_lat,urcrnrlon=ne_lon,urcrnrlat=ne_lat, \
    #                 lat_0=0.5*(ne_lat+sw_lat), lon_0=0.5*(ne_lon+sw_lon), resolution='i', area_thresh=10.0, ax=axes[1])

    # if shapefiles:
    #     plot_shapefiles(bgmap, shapefiles=shapefiles, counties=_plot_counties, ax=axes[1])
    # else:
    #     plot_shapefiles(bgmap, counties=_plot_counties, ax=axes[1])
    #

    im1 = bgmap.contourf(xg_2d, yg_2d, ref_data, levels= _ref_scale, cmap=cmapr, norm=normr, \
                         vmin = _ref_min_plot, vmax = _ref_scale.max(), ax=axes[0])

    cbar = bgmap.colorbar(im1, location='right')
    cbar.set_label('Reflectivity (dBZ)')
    axes[0].set_title('Reflectivity at Height:  %4.1f km' %
                      (0.001 * ref.zg[sweep]))
    at = AnchoredText(
        "Max dBZ: %4.1f" % (ref_data.max()),
        loc=4,
        prop=dict(size=10),
        frameon=True,
    )
    at.patch.set_boxstyle("round,pad=0.,rounding_size=0.2")
    axes[0].add_artist(at)

    # COMPOSITE PLOT

    ref_data = ref.data.max(axis=0)
    zero_dbz = ref.zero_dbz.data

    bgmap = Basemap(projection='lcc', llcrnrlon=sw_lon,llcrnrlat=sw_lat,urcrnrlon=ne_lon,urcrnrlat=ne_lat, \
                    lat_0=0.5*(ne_lat+sw_lat), lon_0=0.5*(ne_lon+sw_lon), resolution='i', area_thresh=10.0, ax=axes[1])

    if shapefiles:
        plot_shapefiles(bgmap,
                        shapefiles=shapefiles,
                        counties=_plot_counties,
                        ax=axes[1])
    else:
        plot_shapefiles(bgmap, counties=_plot_counties, ax=axes[1])

# pixelated plot

# im1  = bgmap.pcolormesh(xe, ye, ref_data, cmap=cmapr, norm=normr, vmin = _ref_min_plot, vmax = _ref_scale.max(), ax=axes[2])
# cbar = bgmap.colorbar(im1,location='right')
# cbar.set_label('Reflectivity (dBZ)')
# axes[2].set_title('Pixel Composite Reflectivity at Height:  %4.1f km' % 0.001*ref.zg[sweep])
# at = AnchoredText("Max dBZ: %4.1f" % (ref_data.max()), loc=4, prop=dict(size=10), frameon=True,)
# at.patch.set_boxstyle("round,pad=0.,rounding_size=0.2")
# axes[2].add_artist(at)

# contoured plot

# bgmap = Basemap(projection='lcc', llcrnrlon=sw_lon,llcrnrlat=sw_lat,urcrnrlon=ne_lon,urcrnrlat=ne_lat, \
#                 lat_0=0.5*(ne_lat+sw_lat), lon_0=0.5*(ne_lon+sw_lon), resolution='i', area_thresh=10.0, ax=axes[3])

# if shapefiles:
#     plot_shapefiles(bgmap, shapefiles=shapefiles, counties=_plot_counties, ax=axes[3])
# else:
#     plot_shapefiles(bgmap, counties=_plot_counties, ax=axes[3])

    im1 = bgmap.contourf(xg_2d, yg_2d, ref_data, levels= _ref_scale, cmap=cmapr, norm=normr, \
                         vmin = _ref_min_plot, vmax = _ref_scale.max(), ax=axes[1])

    cbar = bgmap.colorbar(im1, location='right')
    cbar.set_label('Reflectivity (dBZ)')
    axes[1].set_title('Composite Reflectivity')
    at = AnchoredText(
        "Max dBZ: %4.1f" % (ref_data.max()),
        loc=4,
        prop=dict(size=10),
        frameon=True,
    )
    at.patch.set_boxstyle("round,pad=0.,rounding_size=0.2")
    axes[1].add_artist(at)

    # Plot zeros as "o"

    if zero_dbz != None:
        r_mask = (zero_dbz.mask == False)
        print("\n Number of zero reflectivity obs found:  %d" % np.sum(r_mask))
        bgmap.scatter(xg_2d[r_mask], yg_2d[r_mask], s=15, facecolors='none', \
                      edgecolors='k', alpha=0.3, ax=axes[1])

# Get other metadata....for labeling

    time_text = ref.time.strftime('%Y-%m-%d %H:%M')

    title = '\nDate:  %s   Time:  %s' % (time_text[0:10], time_text[10:19])

    plt.suptitle(title, fontsize=18)

    plt.savefig(filename)

    if interactive: plt.show()