Download source and data
Time-height Section 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 GRIB forecast data data = read("joachim_pl.grib") # the hovmoeller view takes an area as an input. # We define the location by shrinking down the area to a point area = [47,0,47, 0] #N/W/E/S # read temperature fields and convert from K to C t = read(data: data, param: "t") t = t - 273.16 # read u and v fields and computes wind speed u = read(data: data, param: "u") v = read(data: data, param: "v") sp = sqrt(u^2 + v^2) sp = grib_set_long(sp, ["paramId", 10]) # define isoline shading for speed sp_cont = mcont( legend : "on", contour : "off", contour_level_selection_type : "interval", contour_max_level : 90, contour_min_level : 0, contour_interval : 10, contour_label : "off", contour_shade : "on", contour_shade_colour_method : "palette", contour_shade_method : "area_fill", contour_shade_palette_name : "m_purple_9" ) # define contouring for t t_cont = mcont( contour_line_style : "dash", contour_line_thickness : 3, contour_line_colour : "charcoal", contour_highlight : "off", contour_level_selection_type : "interval", contour_interval : 10, contour_label_height : 0.4 ) # define time axis time_axis = maxis( axis_type : "date", axis_tick_label_height : 0.4, axis_date_type : "hours", axis_days_label_height : 0.4, axis_hours_label : "on", axis_hours_label_quality : "high", axis_hours_label_height : 0.3 ) # define vertical axis vert_axis = maxis( axis_tick_label_height : 0.4, axis_title_text: "Pressure (hPa)", axis_title_height : 0.5 ) # define hovmoeller view view = mhovmoellerview( type : "vertical_hovm", bottom_level : 1000, top_level : 100, area: area, time_axis: time_axis, vertical_axis: vert_axis, subpage_y_position: 5 ) # define legend legend = mlegend( legend_text_font_size : 0.3, legend_text_colour: "charcoal" ) # define title title = mtext( text_font_size: 0.4, text_colour: "charcoal" ) # define the output plot file setoutput(pdf_output(output_name : 'time_height_xs')) # generate plot plot(view, sp, sp_cont, t, t_cont, legend, title)
Time-height Section Example
import metview as mv # **************************** 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 GRIB forecast data data = mv.read("joachim_pl.grib") # the hovmoeller view takes an area as an input. # We define the location by shrinking down the area to a point area = [47, 0, 47, 0] #N/W/E/S # read temperature fields and convert from K to C t = mv.read(data=data, param="t") t = t - 273.16 # read u and v fields and computes wind speed u = mv.read(data=data, param="u") v = mv.read(data=data, param="v") sp = mv.sqrt(u**2 + v**2) sp = mv.grib_set_long(sp, ["paramId", 10]) # define isoline shading for speed sp_cont = mv.mcont( legend = "on", contour = "off", contour_level_selection_type = "interval", contour_max_level = 90, contour_min_level = 0, contour_interval = 10, contour_label = "off", contour_shade = "on", contour_shade_colour_method = "palette", contour_shade_method = "area_fill", contour_shade_palette_name = "m_purple_9" ) # define contouring for t t_cont = mv.mcont( contour_line_style = "dash", contour_line_thickness = 3, contour_line_colour = "charcoal", contour_highlight = "off", contour_level_selection_type = "interval", contour_interval = 10, contour_label_height = 0.4 ) # define time axis time_axis = mv.maxis( axis_type = "date", axis_tick_label_height = 0.4, axis_date_type = "hours", axis_days_label_height = 0.4, axis_hours_label = "on", axis_hours_label_quality = "high", axis_hours_label_height = 0.3 ) # define vertical axis vert_axis = mv.maxis( axis_tick_label_height = 0.4, axis_title_text= "Pressure (hPa)", axis_title_height = 0.5 ) # define hovmoeller view view = mv.mhovmoellerview( type = "vertical_hovm", bottom_level = 1000, top_level = 100, area= area, time_axis= time_axis, vertical_axis= vert_axis, subpage_y_position= 5 ) # define legend legend = mv.mlegend( legend_text_font_size=0.3, legend_text_colour="charcoal" ) # define title title = mv.mtext( text_font_size=0.4, text_colour="charcoal" ) # define the output plot file mv.setoutput(mv.pdf_output(output_name = 'time_height_xs')) # generate plot mv.plot(view, sp, sp_cont, t, t_cont, legend, title)
6 Comments
Christos Lamaris
Hi,
Is there a way to plot wind flags (conventional wind symbols of u, v components of wind) in cross section at pressure levels?
Thanks in advance
Milana Vuckovic
Hi Christos,
would this example help you?
Cross Section 3D Parallel Wind Component Example
You can replace the arrows with flags using something like this code:
Cheers,
Milana
Christos Lamaris
Thank you for the prompt reply Milana. However, i want to plot the horizontal wind speed in flags that includes u and v components of wind and not the vertical wind speed (w).
Sandor Kertesz
Hi,
In the Cross Section 3D Parallel Wind Component Example you can see the 3D wind components projected onto the cross section plane. Unfortunately, there is no option in Metview's cross section module to render the 2D wind arrows/flags into the plot. However, there might be some non-trivial ways to generate a plot like that. I will try post a solution.
By the way, the plot in this example is a Hovmoeller diagram, although it looks similar to a cross section plot it is quite different to it. Do you want to plot the 2D wind into this type of time-heigh section diagram or into a cross section?
Kind regards,
Sandor
Christos Lamaris
Thanks for the detailed information, Sandor.
In fact, I want to plot the 2D wind into both diagrams!
Best regards,
Christos
Sandor Kertesz
Hi Christos,
I moved this whole discussion to JIRA, please see issue SUP-3440 - Getting issue details... STATUS .
Kind regards,
Sandor