Download source and data
NetCDF Ozone Layout 2x2 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 O3 on 70 hPa nc = read("era5_ozone_1999.nc") # this NetCDF data has the following structure: # # dimensions: # longitude = 1440 ; # latitude = 721 ; # time = 4 ; #variables: # float longitude(longitude) ; # float latitude(latitude) ; # int time(time) ; # time:units = "hours since 1900-01-01 00:00:00.0" ; # short o3(time, latitude, longitude) ; # o3:units = "kg kg**-1" ; # o3:long_name = "Ozone mass mixing ratio" ; # define contour shading cont = mcont( legend : "on", contour : "off", contour_max_level : 4E-6, contour_min_level : 5E-7, contour_label : "off", contour_shade : "on", contour_shade_colour_method : "palette", contour_shade_method : "area_fill", contour_shade_palette_name : "m_purple_9" ) # define coastlines coastlines = mcoast( map_coastline_thickness : 2, map_grid_colour : "RGB(0.349,0.349,0.349)", map_label : "off" ) # define goegraphical view view = geoview( map_projection : "polar_stereographic", map_area_definition : "corners", map_hemisphere : "south", area : [-5.23,46.28,-5.72,-132.72], coastlines : coastlines ) # create a 2x2 plot layout with the defined geoview dw = plot_superpage(pages: mvl_regular_layout(view,2,2,1,1,[5,100,10,100])) # define month names for plot titles months = ['JAN', 'APR', 'JUL', 'OCT'] # we build the plot object for each map in a loop p_obj = nil for i =1 to 4 do # define netcdf plotting vis = netcdf_visualiser( netcdf_plot_type : "geo_matrix", netcdf_latitude_variable : "latitude", netcdf_longitude_variable : "longitude", netcdf_value_variable : "o3", netcdf_dimension_setting_method : "index", netcdf_dimension_setting : ["time:" & (i-1)], netcdf_data : nc ) # define title title = mtext( text_lines : [ "<netcdf_info variable='o3' attribute='long_name'/> " & "[<netcdf_info variable='o3' attribute='units'/>] 70 hPa - 1999 " & months[i]], text_font_size : 0.3 ) # add current plot definition to the plot object p_obj = p_obj & [dw[i], vis, cont, title] end for # define output setoutput(pdf_output(output_name : 'nc_era5_ozone')) # generate plot plot(p_obj)
NetCDF Ozone Layout 2x2 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 O3 on 70 hPa nc = mv.read("era5_ozone_1999.nc") # this NetCDF data has the following structure: # # dimensions: # longitude = 1440 ; # latitude = 721 ; # time = 4 ; #variables: # float longitude(longitude) ; # float latitude(latitude) ; # int time(time) ; # time:units = "hours since 1900-01-01 00:00:00.0" ; # short o3(time, latitude, longitude) ; # o3:units = "kg kg**-1" ; # o3:long_name = "Ozone mass mixing ratio" ; # define contour shading cont = mv.mcont( legend = "on", contour = "off", contour_max_level = 4E-6, contour_min_level = 5E-7, contour_label = "off", contour_shade = "on", contour_shade_colour_method = "palette", contour_shade_method = "area_fill", contour_shade_palette_name = "m_purple_9" ) # define coastlines coastlines = mv.mcoast( map_coastline_thickness = 2, map_grid_colour = "RGB(0.349,0.349,0.349)", map_label = "off" ) # define goegraphical view view = mv.geoview( map_projection = "polar_stereographic", map_area_definition = "corners", map_hemisphere = "south", area = [-5.23,46.28,-5.72,-132.72], coastlines = coastlines ) # create a 2x2 plot layout with the defined geoview dw = mv.plot_superpage(pages=mv.mvl_regular_layout(view,2,2,1,1,[5,100,10,100])) # define month names for plot titles months = ['JAN', 'APR', 'JUL', 'OCT'] # we build the plot object for each map in a loop p_obj = [] for i in range(4): # define netcdf plotting vis = mv.netcdf_visualiser( netcdf_plot_type = "geo_matrix", netcdf_latitude_variable = "latitude", netcdf_longitude_variable = "longitude", netcdf_value_variable = "o3", netcdf_dimension_setting_method = "index", netcdf_dimension_setting = ["time:" + str(i)], netcdf_data = nc ) # define title title = mv.mtext( text_lines = [ "<netcdf_info variable='o3' attribute='long_name'/> " + "[<netcdf_info variable='o3' attribute='units'/>] 70 hPa - 1999 " + months[i]], text_font_size = 0.3 ) # add current plot definition to the plot object p_obj.append([dw[i], vis, cont, title]) # define output mv.setoutput(mv.pdf_output(output_name = 'nc_era5_ozone')) # generate plot mv.plot(p_obj)