The following CSV file is taken from the
Storm track <gallery_storm_track>
gallery example and has the following structure:20121027 00 -76.9 27.1 20121027 12 -76.29 28.37 20121028 00 -74.64 30.2 20121028 12 -73.07 31.77 20121029 00 -70.87 33.66 ...
So this data contains no header and the separator is a whitespace. Using
Track
we can make plot in a few lines:import metview as mv filename = "sandy_track.grib" if mv.exist(filename): g = mv.read(filename) else: g = mv.gallery.load_dataset(filename) tr = mv.Track(path, sep=" ") mv.plot_maps(tr, view=mv.make_geoview(style="grey_2", area="north_america"))Compare this code to the one used in the gallery example to see how much we can simplify the plotting with
Track
.
The style for
Track
is taken from the current style configuration. The default style is a list of anmgraph
(defining the curve) and anmsymb
(defining the labels), in that order. The main difficulty is that the labels must be added as a list of str to themsymb
, therefore the style is not fixed but must always be generated from the current data. LuckilyTrack
does it automatically for you.Custom styles can also be used when plotting tracks with
plot_maps
. Due to the difficulties with the label generation the recommended way for doing it is to derive a new style by updating the default one:import metview as mv filename = "sandy_track.grib" if mv.exist(filename): g = mv.read(filename) else: g = mv.gallery.load_dataset(filename) # create track tr = mv.Track(path, sep=" ") # update style vd = tr.style().update( {"graph_line_colour": "blue", "graph_symbol_colour": "purple", "graph_symbol_height": 0.6}, verb="mgraph") vd = vd.update({"symbol_advanced_table_text_font_size": 0.6}, verb="msymb") # generate plot mv.plot_maps(tr, vd, view=mv.make_geoview(style="grey_2", area="north_america"))
Track
offers a high-level interface and uses pre-defined settings, therefore it comes with certain limitations:
- the date format must be yyyymmdd
- the time format must be hh
- the label format is hard-coded as dd/hh
- it cannot be plotted with
plot
Note
If you would like to create a fully customised track plot from CSV data see the
Storm track <gallery_storm_track>
gallery example (it usesread_table
,input_visualiser
,mgraph
andmsymb
to build the track).