Overview
Community Forums
Content Tools
This is one cell notebook example that will help you plot wind flags from grib file using Magics.
List of all mwind parameters you can find in Magics documentation.
If you don't have Magics installed, run the next cell to install Magics using conda.
# Install Magics in the current Jupyter kernel
import sys
!conda install --yes --prefix {sys.prefix} Magics
import Magics.macro as magics
# Setting the projection
australia = magics.mmap(
subpage_upper_right_longitude= 180.,
subpage_upper_right_latitude = -5.,
subpage_lower_left_longitude = 105.,
subpage_lower_left_latitude = -55.,
subpage_clipping = 'on',
subpage_map_projection = "cylindrical",
page_id_line = "off")
# Defining the coastlines
light_background = magics.mcoast(
map_coastline_sea_shade_colour = 'white',
map_coastline_land_shade_colour = 'cream',
map_grid = 'off',
map_coastline_land_shade = 'on',
map_coastline_sea_shade = 'on',
map_label = 'off',
map_coastline_colour = 'tan')
# Load the grib data
wind_from_grib = magics.mgrib(
grib_input_file_name = '../../data/uv200.grib',
grib_wind_position_1 = 1,
grib_wind_position_2 = 2)
# Defining Wind flags
wind_flags = magics.mwind(
legend = 'on',
wind_field_type = 'flags',
wind_flag_length = 0.8,
wind_thinning_factor = 10.,
wind_flag_calm_below = 15,
wind_flag_origin_marker = "circle",
wind_flag_colour = 'chestnut')
magics.plot(australia, light_background, wind_from_grib, wind_flags)
Note that these examples are only skeletons to illustrate the functionality of Magics.
You can download this Jupyter notebook and wind data from ECMWF github space.
More about projections in projection examples.
More about coastline plotting in coastline examples.
Plotting in directly in Jupyter notebooks doesn't need output to be specified. Most of the time you will want an output.
png = magics.output( output_formats = ['png'], output_name_first_page_number = "off", output_name = "wind_arrows") magics.plot(png, australia, light_background, wind_from_grib, wind_arrows, legend)