# Slice out a single frame of grid data
grid = data.data.grid[:, :, 0]
timestamp = data.timestamp[0]
# Grab the fill value used to represent grid cells with no data
fill_val = data.data.fill_value
# Set scaling bounds for intensity
rayleighs_scale = [0,25000]
# Prep the grid data for plotting (make non-data cells transparent)
rgba_grid = at.grid_files.prep_grid_image(grid, fill_val, scale=rayleighs_scale, cmap='Greens_r')
# Create an empty map using cartopy
projection = cartopy.crs.NearsidePerspective(central_longitude=-100, central_latitude=55)
fig = plt.figure(figsize=(7, 5))
ax = fig.add_axes((0, 0, 1, 1), projection=projection)
ax.set_extent([-140, -70, 35, 75], crs=cartopy.crs.Geodetic())
ax.add_feature(cartopy.feature.OCEAN, zorder=0)
# Overlay the grid data on the map
im = plt.imshow(rgba_grid, extent=(-180, 180, -90, 90), transform=cartopy.crs.PlateCarree(), origin='lower')
plt.text(0.01, 0.925, "TREx RGB - Derived 557.7 nm", transform=ax.transAxes, fontsize=18, weight='bold')
plt.text(0.01, 0.100, timestamp.strftime("%Y/%m/%d"), transform=ax.transAxes, fontsize=18, weight='bold')
plt.text(0.01, 0.025, timestamp.strftime("%H:%M:%S")+" UT", transform=ax.transAxes, fontsize=18, weight='bold')
# Create a custom colorbar
cmap = plt.get_cmap('Greens_r')
norm = mpl.colors.Normalize(vmin=rayleighs_scale[0], vmax=rayleighs_scale[1])
sm = mpl.cm.ScalarMappable(cmap=cmap, norm=norm)
sm.set_array([])
cbar = plt.colorbar(sm, orientation='vertical', ax=ax, pad=0.05, shrink=0.75)
cbar.set_ticks([sum(rayleighs_scale) * (i/5.0) for i in range(0,6)])
cbar.set_ticklabels(['0 kR', '5 kR', '10 kR', '15 kR', '20 kR', '25 kR'])
# Display the plot
plt.show()