Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

The macro to use is 'plot_tr_step2.mv'. This macro is basically the same as the one in Step 1, but we have to modify and extend it a bit.

We start with loading the CSV file and determining the start date and time as before:

Code Block
#The input file
dIn="result_tr"
inFile=dIn  & "/tr_r001.csv"

#Read table (CSV) data
tbl=read_table(table_filename: inFile,
    table_header_row: "2",
    table_meta_data_rows: "1")

#Read runDate from table header
runDate=date(metadata_value(tbl,"runDate"))
runTime=number(metadata_value(tbl,"runTime"))
runDate=runDate + hour(runTime/10000)

Next The first difference is that we need to determine the middle of the release interval since the trajectory waypoint times are given in seconds elapsed since this date. The release date reading part needs to be modified like this:

Code Block
languagepy
#Read release dates from table header
startSec=number(metadata_value(tbl,"start"))
endSec=number(metadata_value(tbl,"end"))
releaseDate=runDate + second(startSec)
releaseMidDate=runDate + second((endSec+startSec)/2)

The plotting of the track is the same as in Step1:

Code Block
languagepy
titlePlotting the track
collapsetrue
#Read columns from table
mLat=tolist(values(tbl,"meanLat"))
mLon=tolist(values(tbl,"meanLon"))

#visualiser
iv_curve = input_visualiser(
	   input_plot_type	:	"geo_points",
	   input_longitude_variable	:	mLon,
	   input_latitude_variable	:	mLat	  	  
	)

#line attributes
graph_curve=mgraph(graph_line_colour: "red",
         graph_line_thickness: "3",
         graph_symbol: "on",
         graph_symbol_marker_index: 15,
         graph_symbol_height: 0.5,
         graph_symbol_colour: "white",
         graph_symbol_outline: "on"
        ) 

Then we need to add a new plotting layer for the date labels. Using the information above we can build the list of strings we want to show along the track and use the Here we use a loop to define the date labels and their plotting instructions one by one with Input Visualiser and Symbol Plotting to define the plot:

Code Block
languagepy
#Read waypoint times from table
#These are seconds elapsed since the middle of the release interval
tt=values(tbl,"time")

#Build and define the listvisualiser for ofthe date strings to be plotted 
ttLst
#The plot definitions are collected into a list
pltDateLst=nil
for i=1 to count(tt) do

    d=releaseMidDate + second(tt[i])
    ttLst = ttLst & [ label="  " & string(d,"dd") & "/" & string(d,"HH")]
end    for
    

#visualiser
    iv_date = input_visualiser(
	   input_plot_type	:	"geo_points",
	   input_longitude_variable	:	mLon[i],
	   input_latitude_variable	:	mLat[i]	   	  	  
	)
    
    #text attributes
    sym_date=msymb(symbol_type: "text",
         symbol_text_list: ttLstlabel,
         symbol_text_font_size: 0.3,
         symbol_text_font_colour: "navy"
        ) 

    pltDateLst= pltDateLst & [iv_date,sym_date]          

end for    


Note

We had to define the plot for each date label individually, instead of defining just one plot object with a list of values. This is down to a current limitation for string plotting in Metview' plotting library.

Finally we define the plot command has to be extended like thistitle and mapview in the same way as in Step 1 and generate the plot:

Code Block
languagepy
plot(view,iv_curve,graph_curve,iv_date,sym_date,pltDateLst,title)

Having run the macro we will get a plot like this:

...

Having run the macro you will get a plot like this:

kk