Metview's documentation is now on readthedocs!

You are viewing an old version of this page. View the current version.

Compare with Current View Page History

« Previous Version 4 Next »

Preparation

In this exercise we will produce a cross section plot of relative vorticity through Hurricane Sandy. We will also create a more interesting layout which will include a geographic map showing the path of the cross section line.

XXX Download data

Verify that the data are as expected.

We will prepare the plot interactively using icons. Then, at the end, we will put it all together into a macro. Remember to give your icons useful names!

It's probably easiest to prepare the cross section and the map separately, then bring them together at the end.

Plotting the Cross Section

Use a Cross Section View icon with a logarithmic scale vertical axis.The transect line should go from XXX to XXX.

To add the title label "Pressure (hPa)", customise an Axis Plotting icon and drop it into the appropriate place in the Cross Section View icon's editor.

Devise your own colour scale with a new Contouring icon, or else use the pre-prepared one in the Solutions folder.

Use a Legend icon to move the legend to the right-hand side of the plot as shown.

Plotting the Map

Use a Geographical View icon to define the map. The map area should be XXXX and should show the line of the cross section - use an Input Visualiser icon coupled with a Graph Plotting icon to achieve this. The location of New York City (XXXX) can also be added with another Input Visualiser icon coupled with a Symbol Plotting icon. The legend will look better if customised to use the Disjoint type.

A feature which will make the map overlay better with the cross section plot is to remove the labels from its left and bottom axes (via a Coastlines icon).

Putting it all together

These two plots can be combined by using a Display Window icon. Create one, edit it and create two views inside it. Drop your Geographic View icon into one and your Cross Section View into the other. Position them in a similar way as shown in the example plot. Once saved, this icon can be visualised and the final result created by dropping the various icons into the two views in the Display Window.

Creating a Macro

Create a macro from this plot, either from the Generate Macro button in the Display Window, or by creating a new Macro icon and dropping the various icons into the Macro Editor. In either case, pay attention to the plot() command. If there is a display window variable called dw (for example) generated by the plot_superpage() command, and it has multiple pages (in this case we have two - one for each view), then we need to call the plot() command once for each page.

As an example, if we want to plot data with visdefs into the second page, we would write

plot(dw[2], data, visdefs)

Using a macro gives us an opportunity to improve the maintainability of the plot. In particular, we currently duplicate the coordinates of the cross section transect line - it is defined once in the Cross Section View icon and again in the Input Visualiser icon which is used to draw the line on the map. Put the coordinates into a variable at the top of the macro, then replace the two references to the line coordinates with this variable. Note that this may not work without another small modification - if the Cross Section View code is inside a function, then it will not be able to see any variables defined outside of the function. We can either set the variable to be global by putting the keyword global in front of it, or else pass it as an argument to the function. The second is usually the preferred option.

 

 

 

 

  • No labels