示例#1
0
ax = fig.add_axes([0, 0, 1, 1])
ax.set_axis_off()  # Don't want surrounding x and y axis

# Lat and lon range (in rotated-pole coordinates) for plot
ax.set_xlim(-180 / args.zoom, 180 / args.zoom)
ax.set_ylim(-90 / args.zoom, 90 / args.zoom)
ax.set_aspect('auto')

# Background
ax.add_patch(
    Rectangle((0, 0), 1, 1, facecolor=(0.6, 0.6, 0.6, 1), fill=True, zorder=1))

# Draw lines of latitude and longitude
draw_lat_lon(ax,
             lwd=0.75,
             pole_longitude=args.pole_longitude,
             pole_latitude=args.pole_latitude,
             npg_longitude=args.npg_longitude)

# Plot the T2M
t2m_pc = plot_cube(0.05, -180 / args.zoom, 180 / args.zoom, -90 / args.zoom,
                   90 / args.zoom)
t2m = t2m.regrid(t2m_pc, iris.analysis.Linear())
# Adjust to show the wind
wscale = 200
s = wind_noise_field.data.shape
wind_noise_field.data = qcut(
    wind_noise_field.data.flatten(), wscale, labels=False,
    duplicates='drop').reshape(s) - (wscale - 1) / 2

# Plot as a colour map
示例#2
0
# Define an axes to contain the plot. In this case our axes covers
#  the whole figure
ax = fig.add_axes([0, 0, 1, 1])
ax.set_axis_off()  # Don't want surrounding x and y axis

# Lat and lon range (in rotated-pole coordinates) for plot
ax.set_xlim(-180, 180)
ax.set_ylim(-90, 90)
ax.set_aspect('auto')

# Background
ax.add_patch(
    Rectangle((0, 0), 1, 1, facecolor=(0.6, 0.6, 0.6, 1), fill=True, zorder=1))

draw_lat_lon(ax)

# Plot the land mask
mask_pc = plot_cube(0.05, -180, 180, -90, 90)
mask = mask.regrid(mask_pc, iris.analysis.Linear())
lats = mask.coord('latitude').points
lons = mask.coord('longitude').points
mask_img = ax.pcolorfast(lons,
                         lats,
                         mask.data,
                         cmap=matplotlib.colors.ListedColormap(
                             ((0.4, 0.4, 0.4, 0), (0.4, 0.4, 0.4, 1))),
                         vmin=0,
                         vmax=1,
                         alpha=1.0,
                         zorder=20)
示例#3
0
def three_plot(ax, t2m, u10m, v10m, prmsl):
    ax.set_xlim(-180, 180)
    ax.set_ylim(-90, 90)
    ax.set_aspect('auto')
    ax.set_axis_off()  # Don't want surrounding x and y axis
    ax.add_patch(
        Rectangle((0, 0),
                  1,
                  1,
                  facecolor=(0.6, 0.6, 0.6, 1),
                  fill=True,
                  zorder=1))
    # Draw lines of latitude and longitude
    draw_lat_lon(ax)
    # Add the continents
    mask_pc = plot_cube(0.05)
    lsmask = iris.load_cube("%s/fixed_fields/land_mask/opfc_global_2019.nc" %
                            os.getenv('SCRATCH'))
    lsmask = lsmask.regrid(mask_pc, iris.analysis.Linear())
    lats = lsmask.coord('latitude').points
    lons = lsmask.coord('longitude').points
    mask_img = ax.pcolorfast(lons,
                             lats,
                             lsmask.data,
                             cmap=matplotlib.colors.ListedColormap(
                                 ((0.4, 0.4, 0.4, 0), (0.4, 0.4, 0.4, 1))),
                             vmin=0,
                             vmax=1,
                             alpha=1.0,
                             zorder=20)

    # Calculate the wind noise
    wind_pc = plot_cube(0.5)
    cs = iris.coord_systems.RotatedGeogCS(90, 180, 0)
    rw = iris.analysis.cartography.rotate_winds(u10m, v10m, cs)
    u10m = rw[0].regrid(wind_pc, iris.analysis.Linear())
    v10m = rw[1].regrid(wind_pc, iris.analysis.Linear())
    wind_noise_field = wind_field(u10m, v10m, z, sequence=None, epsilon=0.01)

    # Plot the temperature
    t2m_pc = plot_cube(0.05)
    t2m = t2m.regrid(t2m_pc, iris.analysis.Linear())
    t2m = quantile_normalise_t2m(t2m)
    # Adjust to show the wind
    wscale = 200
    s = wind_noise_field.data.shape
    wind_noise_field.data = qcut(
        wind_noise_field.data.flatten(),
        wscale,
        labels=False,
        duplicates='drop').reshape(s) - (wscale - 1) / 2

    # Plot as a colour map
    wnf = wind_noise_field.regrid(t2m, iris.analysis.Linear())
    t2m_img = ax.pcolorfast(lons,
                            lats,
                            t2m.data * 200 + wnf.data,
                            cmap='RdYlBu_r',
                            alpha=0.8,
                            zorder=100)

    # Plot the prmsl
    prmsl_pc = plot_cube(0.25)
    prmsl = prmsl.regrid(prmsl_pc, iris.analysis.Linear())
    lats = prmsl.coord('latitude').points
    lons = prmsl.coord('longitude').points
    lons, lats = numpy.meshgrid(lons, lats)
    CS = ax.contour(lons,
                    lats,
                    prmsl.data * 0.01,
                    colors='black',
                    linewidths=0.5,
                    alpha=1.0,
                    levels=numpy.arange(870, 1050, 10),
                    zorder=200)
示例#4
0
def three_plot(ax,t2m,u10m,v10m,prmsl,ls):
    ax.set_xlim(-180,180)
    ax.set_ylim(-90,90)
    ax.set_aspect('auto')
    ax.set_axis_off() # Don't want surrounding x and y axis
    ax.add_patch(Rectangle((0,0),1,1,facecolor=(0.6,0.6,0.6,1),
                                               fill=True,zorder=1))
    # Draw lines of latitude and longitude
    draw_lat_lon(ax)
    # Add the continents
    mask_pc = plot_cube(0.05)   
    lsmask = iris.load_cube("%s/fixed_fields/land_mask/opfc_global_2019.nc" % os.getenv('SCRATCH'))
    lsmask = lsmask.regrid(mask_pc,iris.analysis.Linear())
    lats = lsmask.coord('latitude').points
    lons = lsmask.coord('longitude').points
    mask_img = ax.pcolorfast(lons, lats, lsmask.data,
                             cmap=matplotlib.colors.ListedColormap(
                                    ((0.4,0.4,0.4,0),
                                     (0.4,0.4,0.4,1))),
                             vmin=0,
                             vmax=1,
                             alpha=1.0,
                             zorder=20)
    
    # Calculate the wind noise
    wind_pc=plot_cube(0.2)   
    cs=iris.coord_systems.RotatedGeogCS(90,180,0)
    rw=iris.analysis.cartography.rotate_winds(u10m,v10m,cs)
    u10m = rw[0].regrid(wind_pc,iris.analysis.Linear())
    v10m = rw[1].regrid(wind_pc,iris.analysis.Linear())
    seq=(dte-datetime.datetime(2000,1,1)).total_seconds()/3600
    wind_noise_field=wind_field(u10m,v10m,z,sequence=int(seq*5),epsilon=0.01)

    # Plot the temperature
    t2m=quantile_normalise_t2m(t2m)
    t2m_pc=plot_cube(0.05)   
    t2m = t2m.regrid(t2m_pc,iris.analysis.Linear())
    # Adjust to show the wind
    wscale=200
    s=wind_noise_field.data.shape
    wind_noise_field.data=qcut(wind_noise_field.data.flatten(),wscale,
                                 labels=False,
                                 duplicates='drop').reshape(s)-(wscale-1)/2

    # Plot as a colour map
    wnf=wind_noise_field.regrid(t2m,iris.analysis.Linear())
    t2m_img = ax.pcolorfast(lons, lats, t2m.data*1000+wnf.data,
                            cmap='RdYlBu_r',
                            alpha=0.8,
                            vmin=-100,
                            vmax=1100,
                            zorder=100)

    # Plot the prmsl
    prmsl_pc=plot_cube(0.25)   
    prmsl = prmsl.regrid(prmsl_pc,iris.analysis.Linear())
    lats = prmsl.coord('latitude').points
    lons = prmsl.coord('longitude').points
    lons,lats = numpy.meshgrid(lons,lats)
    CS=ax.contour(lons, lats, prmsl.data*0.01,
                               colors='black',
                               linewidths=0.5,
                               alpha=1.0,
                               levels=numpy.arange(870,1050,10),
                               zorder=200)

    # Overlay the latent-space representation in the SE Pacific
    x=numpy.linspace(-160,-120,10)
    y=numpy.linspace(-75,-75+(40*16/18),10)
    latent_img = ax.pcolorfast(x,y,ls.reshape(10,10),
                               cmap='viridis',
                                 alpha=1.0,
                                 vmin=-3,
                                 vmax=3,
                                 zorder=1000)
    # Label with the date
    ax.text(180/args.zoom-(360/args.zoom)*0.009,
            90/args.zoom-(180/args.zoom)*0.016,
            "%04d-%02d-%02d" % (args.year,args.month,args.day),
            horizontalalignment='right',
            verticalalignment='top',
            color='black',
            bbox=dict(facecolor=(0.6,0.6,0.6,0.5),
                      edgecolor='black',
                      boxstyle='round',
                      pad=0.5),
            size=14,
            clip_on=True,
            zorder=500)