Metview's documentation is now on readthedocs!

Download source and data


NetCDF Wind Example
#Metview Macro

#  **************************** LICENSE START ***********************************
# 
#  Copyright 2019 ECMWF. This software is distributed under the terms
#  of the Apache License version 2.0. In applying this license, ECMWF does not
#  waive the privileges and immunities granted to it by virtue of its status as
#  an Intergovernmental Organization or submit itself to any jurisdiction.
# 
#  ***************************** LICENSE END ************************************
# 

# read ERA5 monthly mean
nc = read("era5_2000_aug.nc")

# thisNetCDF data has the following structure:
#
# dimensions:
#	longitude = 1440 ;
#	latitude = 721 ;
#	time = 1 ;
# variables:
#	float longitude(longitude) ;
#	float latitude(latitude) ;
#	int time(time) ;
#	short u10(time, latitude, longitude) ;
#	short v10(time, latitude, longitude) ;

# define netcdf plotting based on the data structure above
vis = netcdf_visualiser(
    netcdf_plot_type            : "geo_matrix_vectors",
    netcdf_latitude_variable    : "latitude",
    netcdf_longitude_variable   : "longitude",
    netcdf_x_component_variable : "u10",
    netcdf_y_component_variable : "v10",
    netcdf_data                 : nc
    )
    
# define wind plotting
wind_plotting = mwind(
    wind_thinning_factor                  : 6,
    legend                                : "on",
    wind_advanced_method                  : "on",
    wind_advanced_colour_selection_type   : "interval",
    wind_advanced_colour_min_value        : 1,
    wind_advanced_colour_level_interval   : 1,
    wind_advanced_colour_max_level_colour : "RGB(0.9765,0.003845,0.1498)",
    wind_advanced_colour_min_level_colour : "RGB(0.1628,0.1959,0.8255)",
    wind_arrow_unit_velocity              : 8
)

# define coastlines
coastlines = mcoast(
    map_coastline_land_shade        : "on",
    map_coastline_land_shade_colour : "RGB(0.8,0.8,0.8)",
    map_coastline_sea_shade         : "on",
    map_coastline_sea_shade_colour  : "RGB(0.949,0.949,0.949)",
    map_grid_colour                 : "RGB(0.337,0.314,0.314)"
)

# define geographical view
view = geoview(
    map_projection         : "polar_stereographic",
    map_area_definition    : "corners",
    area                   : [1.77,-70.71,28.28,44.99],
    map_vertical_longitude : -40,
    coastlines          : coastlines
    )

# define title
title = mtext(
    text_lines : ["ERA5 - 10m wind - August 2000 monthly mean"],
    text_font_size : 0.4
)    

# define output
setoutput(pdf_output(output_name : 'nc_era5_wind'))

# generate plot
plot(view, vis, wind_plotting, title)
NetCDF Wind Example
#  **************************** LICENSE START ***********************************
# 
#  Copyright 2019 ECMWF. This software is distributed under the terms
#  of the Apache License version 2.0. In applying this license, ECMWF does not
#  waive the privileges and immunities granted to it by virtue of its status as
#  an Intergovernmental Organization or submit itself to any jurisdiction.
# 
#  ***************************** LICENSE END ************************************
# 

import metview as mv

# read ERA5 monthly mean
nc = mv.read("era5_2000_aug.nc")

# this NetCDF data has the following structure:
#
# dimensions:
#	longitude = 1440 ;
#	latitude = 721 ;
#	time = 1 ;
# variables:
#	float longitude(longitude) ;
#	float latitude(latitude) ;
#	int time(time) ;
#	short u10(time, latitude, longitude) ;
#	short v10(time, latitude, longitude) ;

# define netcdf plotting based on the data structure above
vis = mv.netcdf_visualiser(
    netcdf_plot_type            = "geo_matrix_vectors",
    netcdf_latitude_variable    = "latitude",
    netcdf_longitude_variable   = "longitude",
    netcdf_x_component_variable = "u10",
    netcdf_y_component_variable = "v10",
    netcdf_data                 = nc
    )

# define wind plotting
wind_plotting = mv.mwind(
    wind_thinning_factor                  = 6,
    legend                                = "on",
    wind_advanced_method                  = "on",
    wind_advanced_colour_selection_type   = "interval",
    wind_advanced_colour_min_value        = 1,
    wind_advanced_colour_level_interval   = 1,
    wind_advanced_colour_max_level_colour = "RGB(0.9765,0.003845,0.1498)",
    wind_advanced_colour_min_level_colour = "RGB(0.1628,0.1959,0.8255)",
    wind_arrow_unit_velocity              = 8
)

# define coastlines
coastlines = mv.mcoast(
    map_coastline_land_shade        = "on",
    map_coastline_land_shade_colour = "RGB(0.8,0.8,0.8)",
    map_coastline_sea_shade         = "on",
    map_coastline_sea_shade_colour  = "RGB(0.949,0.949,0.949)",
    map_grid_colour                 = "RGB(0.337,0.314,0.314)"
)

# define geographical view
view = mv.geoview(
    map_projection         = "polar_stereographic",
    map_area_definition    = "corners",
    area                   = [1.77,-70.71,28.28,44.99],
    map_vertical_longitude = -40,
    coastlines          = coastlines
    )
    

# define title
title = mv.mtext(
    text_lines = ["ERA5 - 10m wind - August 2000 monthly mean"],
    text_font_size = 0.4
)    

# define output
mv.setoutput(mv.pdf_output(output_name = 'nc_era5_wind'))

# generate plot
mv.plot(view, vis, wind_plotting, title)