...
- the plot at the top shows a map with mean sea level pressure forecast fields overlayed with the track of Hurricane Sandy.
- the plot at the bottom contains a graph chart showing the evolution of the minimum of the mean sea level pressure forecast along the storm track.
You We will need to both work with icons interactively and write Macro code, as well. First, you we will create the two plots independently then align them together in the same page.
Info |
---|
This exercise involves:
|
Creating the map plot
Setting the
...
View
With a new Geographical View icon, set up a cylindrical projection with its area defined as
...
- the land coloured in grey
- the sea coloured as #dcf0ff (or your favourite shade of blue)
Plotting the Mean Sea Level Pressure field
Plot the GRIB file sandy_msl.grib into this your view using a new Contouring icon. Plot black isolines with an interval of 5 hPa between them. Animate through the fields to see how the forecast is evolving.
Info |
---|
The fields you visualised were taken from the model run at 2012-10-27 0UTC and containing 12 hourly forecast steps from 0 to 120 hours. |
...
The storm track data is stored in the CSV file called sandy_track.txttxt. If you open this file you will see that it contains the date, time and geographical coordinates of the track points.
...
- set the plot type to geo points
- select the columns holding storing the latitude and longitude by their index (column indexing start at 1)
- carefully specify the table delimiter and header information by setting
- table_delimiter to whitespace (enter a space character here)
- table_combine_delimiters to on (it means we allow multiple whitespaces as separators)
- table header_row to 0 (it means do not have a header in the file)
Now drag your your Table Visualiser icon the plot to overlay the mean sea level pressure forecast with the track.
Customising the storm track
The storm track in its current form does not look great so you need to customise it with needs some customisation. Use a Graph Plotting icon for it by setting the
- the track line to black and thick
- the track points to be white filled circles (their marker index is 15) with red outline.
...
To finalise the track plot you need to we will add the date/time labels to the track points. This can could be done with a Symbol Plotting icon by specifying the list of labels you we want to plot into the map. Since it would require too much editing you will learn a better (programmatic) way of doing it However, to make it reusable for other datasets as well, we will do it programmatically by using Metview Macro.
Create a new Macro and edit it. First, read the CSV file in with the Table Reader:
Code Block |
---|
tbl = read_table( table_delimiter : " ", table_combine_delimiters : "on", table_header_row : 0, table_filename : "sandy_track.txt" ) |
Info |
---|
As you can see we specified the table delimiters exactly in the same way as we did for the Table Visualiser icon. |
In the code above Here the object referenced by variable tbl
contains all the columns from the CSV file. Now read the date and time (from the first two columns) into separate vectors:
Code Block |
---|
val_date=values(tbl,1) val_time=values(tbl,2) |
Next, you need to we build the list of labels. Each label is made up from a day and an hour part separated by a slash. Use this loop to construct the list:
Code Block |
---|
labels=nil for i=1 to count(val_date) do dPart = substring(string(val_date[i]),7,8) tPart = val_time[i] label = " " & dPart & "/" & tPart labels = labels & [label] end for |
FinallyNext, define a Symbol Plotting visual definition and return itusing the text mode.
Info |
---|
Symbol Plotting in text mode is used to plot string values to the positions of the dataset it is applied to. The rule is that the first string in the list defined by |
The code you we need to add is like this:
Code Block |
---|
sym = msymb(
symbol_type : "text",
symbol_text_font_colour : "black",
symbol_text_font_size: "0.3",
symbol_text_font_style: "bold",
symbol_text_list : labels
)
|
We finish the macro by returning our Visual Definition.
Code Block |
---|
return [sym] |
Info |
---|
By returning the visual definition |
...
our Macro behaves as if it were a real Symbol Plotting icon. |
Save So save the Macro and drag it into the plot to see the labels appearing along the track.
Creating the graph plot
Setting the View
With a new Cartesian View icon, set up a view to cater for the graph showing the mean sea level pressure values in hPa units by setting
- the x-axis type to date
- the x axis minimum to 2012-10-27 and its maximum to 2012-10-31
- the y-axis label to hPa
- the y-axis minimum value to 940 and its maximum to 1000
...
Since this task is fairly complex you we will use a Macro for it. The idea goes like this:
- you we read the track points from the CSV file
- we define a lat-lon box around each point
- we read the forecast mean sea level data for the box for the corresponding time
- we compute the minimum of the pressure in the box
- from these minimum values you we can build the curve data to plot.
Create new Macro and edit it. First, read the CSV file in the very same way as before but . However, this time, on top of date and time, you we also need to read latitude and longitude into vectors:
...
The curve data requires two lists: one for the dates and one for the values. First you need to we initialise these lists:
Code Block |
---|
trVal = nil trDate = nil |
Now the main part of the macro follows: you need to we will loop through the track points and build the curve dataset. You can We will use a loop like this:
Code Block |
---|
for i=1 to count(val_date) do ... your code will go here ... endend for |
Within the loop first construct an area of e.g. 10 degrees wide centred on the current track point.
...
Finally, build the lists for the values (scaling Pa units stored in the GRIB to hPa units):
Code Block |
---|
trVal= trVal & [v/100] |
and another one for the And also build the list of dates:
Code Block |
---|
trDate = trDate & [date(val_date[i]) + hour(val_time[i])] |
...