Metview's documentation is now on readthedocs!

Download source and data


Anomalies Plot Example
# Metview Macro

#  **************************** LICENSE START ***********************************
# 
#  Copyright 2020 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 ************************************

# -------------------------------------------------------------------------
# Description: Demonstrates how to plot anomalies from GRIB data (ERA5 here)
# -------------------------------------------------------------------------

# read the GRIB data into a Fieldset
diff = read("1month_anomaly_Global_ea_2t_201805_v02.grib")

# compute the absolute maximum value and compute a scale for the contouring
maxdiff = maxvalue(abs(diff))
levels_relative = [-1, -0.75, -0.5, -0.25, -0.1, 0.1, 0.25, 0.5, 0.75, 1]
levels = maxdiff * levels_relative

# generate a contouring definition
# - we must set grib_scaling_of_retrieved_fields=off in order
# - to prevent scaling from K to C
diff_cont = mcont(
    legend                       : "on",
    contour                      : "off",
    contour_level_selection_type : "level_list",
    contour_level_list           : levels,
    contour_shade                : "on",
    contour_shade_technique      : "grid_shading",
    contour_shade_colour_method  : "palette",
    contour_shade_palette_name   : "eccharts_blue_white_red_9",
    grib_scaling_of_retrieved_fields : "off"
    )

# increase font size in the legend (cm)
legend = mlegend(legend_text_font_size : 0.3)

# define the output plot file
setoutput(pdf_output(output_name : 'field_anomalies'))

# generate the plot
plot(diff, diff_cont, legend)
Anomalies Plot Example
#  **************************** LICENSE START ***********************************
# 
#  Copyright 2020 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 ************************************

# -------------------------------------------------------------------------
# Description: Demonstrates how to plot anomalies from GRIB data (ERA5 here)
# -------------------------------------------------------------------------

import metview as mv

# read the GRIB data into a Fieldset
diff = mv.read("1month_anomaly_Global_ea_2t_201805_v02.grib")

# compute the absolute maximum value and compute a scale for the contouring
maxdiff = mv.maxvalue(abs(diff))
levels_relative = [-1, -0.75, -0.5, -0.25, -0.1, 0.1, 0.25, 0.5, 0.75, 1]
levels = [lev * maxdiff for lev in levels_relative]

# generate a contouring definition
# - we must set grib_scaling_of_retrieved_fields=off in order
# - to prevent scaling from K to C
diff_cont = mv.mcont(
    legend                       = "on",
    contour                      = "off",
    contour_level_selection_type = "level_list",
    contour_level_list           = levels,
    contour_shade                = "on",
    contour_shade_technique      = "grid_shading",
    contour_shade_colour_method  = "palette",
    contour_shade_palette_name   = "eccharts_blue_white_red_9",
    grib_scaling_of_retrieved_fields = "off"
    )

# increase font size in the legend (cm)
legend = mv.mlegend(legend_text_font_size = 0.3)

# define the output plot file
mv.setoutput(mv.pdf_output(output_name = 'field_anomalies'))

# generate the plot
mv.plot(diff, diff_cont, legend)