A Script to Speedup your BWR Route Optimisation by Trimming the Grib

This is actually a small Tcl script for Bluewater Racing wraps up 2 console functions that some of you may already use – and for those who don’t it will make using them a whole lot easier. The 2 functions being extracting a subset of the data from a grib file, and then saving that to a new grib file.

Download (see end of post) into your Bluewater installation folder, and then open the console. Type: source trim.tcl and you should see basic instructions like the following:

The purpose of this script is to allow you to easily trim unneccessary wind data from the grib file, before you optimise your route. You want to do this because it speeds up the routing, sometimes considerably. To determine the grib ID to use, consult the Grib Manager with the grib file open, but typically the first grib you open will always have in ID of ‘g0’:

From inspecting the routing tree resulting from a route optimisation (see 2nd last image below), it appears the BWR routes to the edges of the grib data, regardless of what route you are actually interested in. So reducing the bounds will speed up route optimisation and allow you to use higher resolution grid values (smaller ‘time resolution’ & ‘grid size’ and larger ‘max distance’)
You do need to be careful not to trim too much though, as it will effect how the wind is interpolated. To check, I find it useful to set the original wind to ‘visible=true’ and ‘Use for routing=false’, then enable contour display. When you load the trimmed grib file, also enable contour display, but make them a different colour – say blue and orange. You want them to correspond well:

Click for Full Size

The Suedsee Runt race (used in the pics here) is a perfect example of a race that benefits a lot from trimming the grib data – I timed routing with the full grib and one trimmed using the command: ‘trim g0 55.5 54 12.25 9.25‘ and it pretty much halved the time BWR took to compute a route. If you follow this procedure, and use a Course file downloaded from the 2012 Races page here, you could change the routing parameters to ‘Grid size=1, Max Dist.=8’ to compute a more accurate route in about the same time it took with the original values. For longer courses (requiring larger values for ‘Time Resolution’, you could also reduce this paramter).

To use, type the function name, followed by the internal grib ID and then the bounds as N S E W, all in decimal degrees like the following:

When deciding on the exact values for the new grib bounds, always take a look at the values for the original grib ‘Lat. step and Lon. step’ in the ‘Grib Header’ information shown in the Grib Manager. In the 2nd screenshot above (or the one below), you can see it 2 lines above the line marked showing the ‘Internal ID’ of the grib file – and showing values of 0.25° for each. SOL will have a sqaure grid like this every race, but the size will increase as the area of the weather increases, for example one of the very large VOR legs may use a 2°x2° weather grid. Anyway, regardless of the specific value – ALWAYS use a multiple of this value when setting the boundary of the trimmed grib. With this particular grib, you dont want to set an East longitude of 12.33° for example.

Then you load the trimmed grib file, and you need to tell Bluewater NOT to use the original for routing purposes. You do this by selecting the ‘Wind’ data in the Grib Mabnager and de-selecting the ‘Use for Routing’ option:

If you leave BWR open between forecast updates, then the next Grib you load will have a different ‘grib ID’ – probably ‘g2’, the original being g0 and the first trimmed grib being g1. If you reload another trimmed grib, you will see 2 ‘Wind’ entries under the ‘trimmed.grb’ file listed in the Grib Manager. Once again you must ensure only the most recent is ‘Enabled for Routing’ – and ALL other weather sources have been ‘Disabled for Routing’ (uncheck the ‘Use for Routing’ option). You can also see the internal grib ID under the ‘GN’ column in the ‘Summary View’ of the Grib Manager below:

Note: I recommend before a race starts, or after you have travelled a ways in a long leg like VOR7 that you experiment a little to find the smallest area that still has contours that do not significantly deviate from the original. A few minutes spent here can result in much less time looking at the ‘Optimizing’ progress bar – or allow you to generate far more optimal routes.

Below show the routing tree resulting from using a trimmed grib file (overlayed on the full grib data)

Finally, there is actually a 2nd version of the function included in the script called ‘trim0’. This function assumes the internal grib id you want to trim is ‘g0’ (ie the very first grib loaded into a BWR ‘session’) so you do not need to specify the grib ID, only the new boundary:

It is provided purely for convenience – so unless you routinely leave BWR running accross multiple forecast updates (recording path using GPS input or something?) it is probably simpler to just use this function. You really only need the ‘trim’ function when you have multiple gribs open and need to specify which one to trim.

Download here, and enjoy!

  1. Leave a comment

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

%d bloggers like this: