Exemplo n.º 1
0
    dpi=100,
    facecolor=(0.5, 0.5, 0.5, 1),
    edgecolor=None,
    linewidth=0.0,
    frameon=False,  # Don't draw a frame
    subplotpars=None,
    tight_layout=None)
fig.set_frameon(False)
# Attach a canvas
canvas = FigureCanvas(fig)

# Projection for plotting
cs = iris.coord_systems.RotatedGeogCS(args.pole_latitude, args.pole_longitude,
                                      args.npg_longitude)

wind_pc = plot_cube(0.2, -180 / args.zoom, 180 / args.zoom, -90 / args.zoom,
                    90 / args.zoom)
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
z = make_wind_seed(resolution=0.4, seed=0)
wind_noise_field = wind_field(u10m,
                              v10m,
                              z,
                              sequence=int(seq * 5),
                              epsilon=0.01)

# 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
Exemplo n.º 2
0
import argparse

parser = argparse.ArgumentParser()
parser.add_argument("--epoch",
                    help="Epoch",
                    type=int,
                    required=False,
                    default=10)
args = parser.parse_args()

# Function to do the multivariate plot
lsmask = iris.load_cube("%s/fixed_fields/land_mask/opfc_global_2019.nc" %
                        os.getenv('DATADIR'))
# Random field for the wind noise
z = lsmask.regrid(plot_cube(0.5), iris.analysis.Linear())
(width, height) = z.data.shape
z.data = numpy.random.rand(width, height)


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,
Exemplo n.º 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)
Exemplo n.º 4
0
# Define the figure (page size, background color, resolution, ...
fig = Figure(
    figsize=(19.2, 10.8),  # Width, Height (inches)
    dpi=100,
    facecolor=(0.5, 0.5, 0.5, 1),
    edgecolor=None,
    linewidth=0.0,
    frameon=False,  # Don't draw a frame
    subplotpars=None,
    tight_layout=None)
fig.set_frameon(False)
# Attach a canvas
canvas = FigureCanvas(fig)

wind_pc = plot_cube(0.2, -180, 180, -90, 90)
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())
z = make_wind_seed(resolution=0.4)
wind_noise_field = wind_field(u10m, v10m, z, sequence=None, epsilon=0.01)

# 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)
Exemplo n.º 5
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)
Exemplo n.º 6
0
# Define the figure (page size, background color, resolution, ...
fig = Figure(
    figsize=(38.4, 21.6),  # Width, Height (inches)
    dpi=100,
    facecolor=(0.5, 0.5, 0.5, 1),
    edgecolor=None,
    linewidth=0.0,
    frameon=False,  # Don't draw a frame
    subplotpars=None,
    tight_layout=None)
fig.set_frameon(False)
# Attach a canvas
canvas = FigureCanvas(fig)

# Make the wind noise
wind_pc = plot_cube(0.2, -180 / args.zoom, 180 / args.zoom, -90 / args.zoom,
                    90 / args.zoom)
cs = iris.coord_systems.RotatedGeogCS(90.0, 180.0, 0.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
z = make_wind_seed(0.4, seed=1)
wind_noise_field = wind_field(u10m,
                              v10m,
                              z,
                              sequence=int(seq * 5),
                              epsilon=0.01)

# Define an axes to contain the plot. In this case our axes covers
#  the whole figure
ax = fig.add_axes([0, 0, 1, 1])
Exemplo n.º 7
0
# Define the figure (page size, background color, resolution, ...
fig = Figure(
    figsize=(19.2, 10.8),  # Width, Height (inches)
    dpi=100,
    facecolor=(0.5, 0.5, 0.5, 1),
    edgecolor=None,
    linewidth=0.0,
    frameon=False,  # Don't draw a frame
    subplotpars=None,
    tight_layout=None)
fig.set_frameon(False)
# Attach a canvas
canvas = FigureCanvas(fig)

wind_pc = plot_cube(0.2)
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(1969, 1, 1)).total_seconds() / 3600
z = make_wind_seed(resolution=0.4, seed=0)
wind_noise_field = wind_field(u10m,
                              v10m,
                              z,
                              sequence=int(seq * 5),
                              epsilon=0.01)

# 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
Exemplo n.º 8
0
fig=Figure(figsize=(38.4,21.6),              # Width, Height (inches)
           dpi=100,
           facecolor=(0.5,0.5,0.5,1),
           edgecolor=None,
           linewidth=0.0,
           frameon=False,                # Don't draw a frame
           subplotpars=None,
           tight_layout=None)
fig.set_frameon(False) 
# Attach a canvas
canvas=FigureCanvas(fig)

# Make the wind noise
wind_pc=plot_cube(0.2,-180/args.zoom,180/args.zoom,
                      -90/args.zoom,90/args.zoom,
                      pole_latitude=args.pole_latitude,
                      pole_longitude=args.pole_longitude,
                      npg_longitude=args.npg_longitude)   
cs=iris.coord_systems.RotatedGeogCS(args.pole_latitude,
                                    args.pole_longitude,
                                    args.npg_longitude)
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
z=plot_cube(0.25,-180/args.zoom,180/args.zoom,
                      -90/args.zoom,90/args.zoom,
                      pole_latitude=args.pole_latitude,
                      pole_longitude=args.pole_longitude,
                      npg_longitude=args.npg_longitude)