I’ve started a new thread for this because the script has moved on a long way from the original. I’ve also renamed the script to avoid confusion between the old and new.
NOTE: There are currently two versions of this script. The version attached to this post is v1.4 which plots 3 hourly charts. Elsewhere in the thread you will find v1.3 which plots hourly charts. There is some evidence that the hourly data source is less reliable that the 3 hourly source so unless you need hourly charts then I would suggest that you use the 3 hourly version.
Before I go further with the description of what this version does I should add a warning that I’ve done a lot of testing on it but there could still be bugs I’ve not spotted, especially as there are many different combinations of setting that can be selected. I’d welcome people testing it and reporting either success or any bugs they find.
To use the script (attached) you need to…
- Install OpenGrads. It’s available for various platforms. I’m not going to re-iterate the installation instructions provided with it. I found them easy to understand and I got it working on Linux without problems.
- Download the weather-watch-1-4-3hr.gs.txt script and rename it to weather-watch-1-4-3hr.gs or a name of your choice with a .gs extension.
- Download the cbarm.gs.txt script and rename it to cbarm.gs. Do not give this a different name, or if you want to then you will also need to modify the main script to change the filename there too. This is a Grads library script so it may be used with this standard name in other scripts so it’s worth keeping the correct name.
- Configure the script by editing it and changing the options described below.
- Run the script in Opengrads. The following command works for me - ‘grads -lcbx weather-watch-1-4-3hr.gs’ - but you might choose a different way based on how you want to use Opengrads. You will be prompted for five values (see below for a description of these values). If you want to automate the running of the script, these five values can be entered from the command line, e.g. from a Linux shell script or Windows batch/cmd file.
- The script will download the relevant GFS data and then generate a variety of .PNG images named ‘gfs_xxx_nn.png’ where ‘xxx’ is the type of map, e.g. ‘slp’ = Sea Level Pressure, and ‘nn’ is the map sequence number (1 to however many maps you want to create).
- Use the map .PNG files as you wish. Display them locally. Upload to a web server. The choice is yours.
The five parameters passed into the main script are:
- The GFS run date you want to use (YYYYMMDD), e.g. 20220503. This is likely to be the current or previous date
- The GFS run hour (00z/06z/12z/18z)
- An offset of hours to start generating maps from. The offset is because the GFS data doesn’t become available for some time after the run time, so the 00z run data may not be available until 05z and there’s not much point generating maps for 00z or 03z which may be 2 to 5 hours before your charts are created. This value must be a multiple of 3.
- An hour step value which must be one of 3, 6, 12 or 24. This is the increment used between charts, e.g. if you choose an offset of 6 and a step of 6 you will get charts starting from 06z, then 12z, then 18z, etc.
- The number of charts you want to plot for each variable. For example, if you set offset to 6, hour step to 3 and number of charts to 5, you will get 5 charts at 06z, 09z, 12z, 15z and 18z. The highest hour chart you can create is 384 for 3 hourly data or 121 for hourly data so make sure that you select sensible values for offset, step and number of charts. The script tries to trap invalid selections.
The following options can be set in the script file for the hourly script.:
- [li]* How many hourly maps to generate
maps = 5
This will create 5 maps starting at ‘offset hour’ (see above). The more maps you create the longer the script takes to run and the more image files you create. This value is set from a parameter/prompt if using the 3 hourly script.
[/li]
[li]* Map copyright text
_map_copyright = ‘Map (c) My WX-server/mywxdomain.com’
Choose the copyright text to add onto the bottom of each map.
[/li]
[li]* Map Projection - See GrADS Command: set mproj
_map_proj = ‘scaled’
This selects the projection/style of map to generate. You should read the documentation at the listed URL to find out more if you want to change this.
[/li]
[li]* Map lon/lat to plot - See http://cola.gmu.edu/grads/gadoc/gradcomdsetlatlonlevtimeens.html
_map_lon = ‘-25 25’
_map_lat = ‘35 65’
The ‘edges’ of the map to be plotted. Negative values for West and South. More information is available from the URL listed. If you choose a projection that isn’t ‘scaled’ then you need to think carefully about these values (and the following value). I’m not going to try to describe this here…you really need to see the documentation to understand this better!
- Reference lon/lat for polar stereographic plots - See http://cola.gmu.edu/grads/gadoc/gradcomdsetmpvals.html
- Not used for latlon/scaled
_map_vals = ‘15 52 54 71’
[/li]
[li] Choose which map types to plot by changing the values of the following variables to ‘1’ (or ‘0’ to disable)
plot_t_2m = 1 // 2m Temperature
plot_t_sfc = 0 // Surface Temperature
plot_lcl = 0 // Temperature Lifting Condensation level
plot_wc = 0 // Windchill Temperature
plot_psl_10m = 0 // Sea Level Pressure and 10m Wind contours
plot_10m_wind = 0 // 10m Wind Speed
plot_500h_wind = 0 // Wind speed at 500hPa level
plot_850h_wind = 0 // Wind speed at 850hPa level
plot_dewpt_2m = 0 // 2m Dewpoint
plot_precip = 0 // Precipitation
plot_cloud = 0 // Cloud coverage
plot_4lli = 0 // 4 Layer Lifted Index
plot_cape = 0 // CAPE (Convective Available Potential Energy)
plot_sf_cinh = 0 // Convective Inhibition
plot_storm_ind = 0 // Storm Index
plot_instab = 0 // Potential Instability
plot_low_shr = 0 // Low Level Shear
plot_deep_shr = 0 // Deep Level Shear
plot_srh = 0 // Storm Relative Helicity
If you’re not sure which ones to pick, set maps=1 and enable every map type. Then you can look at each one to decide which ones you want to produce on a regular basis.
[/li]
[li]* Define which units to use
- _units_temp can be C=Celsius, F=Fahrenheit or K=Kelvin
_units_temp = “C”
- _units_press can be H=hPa, K=kPa, B=mbar, M=mmHg or I=inHg
_units_press = “H”
- _units_wind can be M=m/s, N=knot, K=km/h, I=mph or F=fps
_units_wind = “M”
- _units_rain can be M=mm or I=Inch
_units_rain = “M”
These are set for all maps so if you select temperatures in Fahrenheit then you can’t have one map in Celcius without creating a copy of the script with different settings.
Note: Some maps, e.g. CAPE, SRH, CINH, have fixed units. These tend to be specialist maps and probably something viewed in the default units. They could probably be changed but I’d need to get my head round convering J/kg into kilocalories/pound or BTU/grain??
[/li]
Note: There are some differences from the original nordic.gs script that will trip you up if you just replace the old script with this one. The biggest changes are that the .PNG file names have changed. They now follow a more standard format. Also you will probably need to edit the file to make it reflect which maps you want to create and what setting you want to use. There are considerably more options than in the old script.
Finally, feel free to modify the script. There are loads of other changes you could make. Change the colour schemes, add maps, change the text, etc. However, I suspect for many people the script will create more maps that they would normally need.
Finally, finally, please let me know if you use the script. It would be good just to know that it’s working OK for people.
cbarm.gs.txt (7.13 KB)
weather-watch-1-4-3hr.gs.txt (37.1 KB)
Can you post a link to show us what these maps look like? I don’t know what a GFS map is actually… :oops:
Downloaded OpenGrADS this afternoon and got it working just fine with your script, Chris.
I used your batch file from the other thread to run it and had a play to see if I could get it automated, but no luck yet.
I did find an old post by Hennka with the script for the batch file he was using. I tried to alter it to get it to work with your script. It would open a cmd window, do the calculation of the date, time & hour, then close it and start OpenGrADS, but each time would ask for the date, time & hours figure, like it didn’t load that from previous cmd window.
Is there any way to use similar code to Henkka’s, but at the start of the script to produce the “20200523 18 6” for the GFS run data?
I’m not up on batch file scripting so it may be possible to do it there, Hennka had it working once, but things seem to have changed as I can’t get it to work now, with my limited knowledge.
I haven’t checked the logic of Hennka’s setting of T and the GFS Run Date based on the current date/time but I assume that’s is still OK. The batch file below worked for me when I tested it just before 10am.
Once all the glitches are ironed out and understood I think we need a FAQ to pull this all together.
@echo off
set PATH=%SystemRoot%\system32;%SystemRoot%;%SystemDrive%;D:\OpenGrADS-2.2\Contents\Cygwin\Versions\2.2.1.oga.1\i686
set GADDIR=D:\OpenGrADS-2.2\Contents\Resources\SupportData\
set HourOffset=6
set FileDate=%date:~6,4%%date:~3,2%%date:~0,2%
set FileTime=%time:~0,2%
if /i %FileTime% gtr 00 (
set T=12
set /a FD=%FileDate% - 1
)
if /i %FileTime% gtr 01 (
set T=18
set /a FD=%FileDate% - 1
)
if /i %FileTime% gtr 07 (
set T=00
set FD=%FileDate%
)
if /i %FileTime% gtr 13 (set T=06)
if /i %FileTime% gtr 19 (set T=12)
@echo GFS Date = %FD%
@echo GFS Run = %T%z
@echo Hour Offset = %HourOffset%
opengrads.exe -lcbx "weather-watch-1.gs %FD% %T% %HourOffset%"
PS. I’m glad you got it working. I was thinking it would only work for me after Dave didn’t manage to get it to work on his PC!
They make quite a large files but you can animate the PNGs - https://wxd2.weather-watch.com/gfs_animated.png
Note: Animated PNGs may not display in all browsers. This one works in Chrome, MS Edge (new Chromium version) and Firefox.
That new batch file runs fine for me as well.
I ran it at 12:06 BST but with the 6 hour offset it produced maps from 05:00 until 09:00 for today, so I changed the offset to 12 hours and it now runs from 11:00 to 15:00. I’ve currently got it set to produce 5 of each map.
I’ll run it periodically through the day to see if it maintains those timings.
I like the animated map and it also runs in Opera on Windows. I have FireFox, Chrome, Edge & Opera for testing my own website.
I’ll have to look into the animation script, I had a brief look over the document yesterday but I wasn’t concerned with that at the time. It would be interesting to see if it can be created as an animated GIF, or whether PHP could animate a smaller file for those with slower broadband speeds.
I’ll build some pages for my website and upload the maps on to there and post the link later today.
I think I may have got the hour offset wrong in the script. I need to check that later today. I think with an hour offset of 6 it’s generating the first map at GFS_run_time+5 hours, i.e. 05z for the 00z run.
The animation I created was just using a GUI PNG to APNG assembler. It would need other work doing to run it from the command line or a different application to generate animated GIFs or other formats. I tried installing ImageMagic but got an error at the end of the install so I don’t know if it’s properly installed. That’s something else to check later on. The idea of a PHP script to step through the individual images crossed my mind too, although each image is a fair size on its own so I don’t know how smooth it would be on a slow Internet connection. I tend not to think about that too much with a 200Mbps link.
This all assumes that my laptop doesn’t die on me! It’s been acting badly lately…almost daily green screens of death…taking 20-30 minutes to start up…killing the Bluetooth drivers so that the only way to get my mouse working again is to reboot (with the subsequent startup delay).
Well, I’ve got the following pages up & running:
Precipitation
CAPE
Convective Inhibition
Sea Level Pressure
2m Temp
I reduced the map size to 700x525 px in the script as I don;t need 1700x1275px.
While doing so I noticed that you’ve got a double image size setting in the Convective Inhibition settings in your script.
I’ll have a look at the PHP script I have and see if it can be modified to animate the maps. But that’s for tomorrow, got a soil sensor to “plant” as the rain has finally stopped!
I’ve got a new version (not uploaded yet) that fixes the double dimensions for CINH and also sorts out the ‘hour_offset’ problem (it was originally supposed to be the start hour but I changed what I was using it for part way through).
I think I’ll also make a couple of mods…
- To allow the map dimensions to be changed once as a config variable
- To add an hour step value parameter, e.g. produce a map at each three hour increment…6, 9, 12, etc
Not sure if this helps, but it was mentioned elsewhere on the forum and it sounded relevant - Documentation for the HTML5 Image AnimationS WebApp - HAniS
I’ve not had a chance to look at it very much yet though.
Here’s the latest version of the grads script and associated .BAT files. Changes between v1.0 and 1.1 are:
- Fixed a bug where the hour offset was an hour wrong. So if you had an hour_offset of 6 the first map was Run_Time+5.
- Fixed a double definition of map dimensions in CINH
- Added a fourth parameter - Hour_Step. This is optional and if not included in the parameters list it defaults to 1. This defines the number of hours between maps, e.g. if Hours_Offset is 6 and Hours_Step is 2 then you will get maps at hours 6, 8, 10, 12, etc.
- Made the third parameter (Hour_Offset) optional. If not provided it defaults to zero, i.e. no offset. If you want to use the Hour_Step option this parameter is not optional and must be included in the parameter list.
- The map size is now defined as a variable in the ‘user definable variables’ section at the top of the script, i.e. “map_size = ‘x1700 y1275’”. Define the x and y dimensions in pixels to suit your requirements.
- Provided grads_manual.bat. This runs the weather-watch.gs script (Note: no version numbers) with a minimum of 2 parameters and a maximum of 4. Parameters are, GFS_Run_Date (Mandatory) e.g. 20200524, GFS_Run_Hour (Mandatory) e.g. (00), Hour_Offset (Optional) - start hour from GFS_Run_Hour and Hour_Step (Optional) - number of hours between each map).This script is to allow you to generate maps from previous dates/time (assuming the data is still available).
- Provided grads_auto.bat. This is intended to be used for scheduled runs of the weather-watch.gs script (Note: no version numbers). No parameters are needed…it calculates the nearest previous GFS_Run_Date and GFS_Run_Hour. If you want to change the default Hour_Offset and Hour_Step values these can be modified in the .BAT file. This .BAT file doesn’t have to be scheduled - it works just as well from the command line.
Note: The .BAT files no longer include a version number for the .gs script. This is to ease upgrades so that I don’t have to release new .BAT files each time the .gs script changes. After downloading the weather-watch-1-1.txt file, rename it to weather-watch.gs before you run the .BAT files.
Note 2: The forum doesn’t allow files with extensions of .gs and .bat so they’re all uploaded as .txt files. Rename them accordingly after downloading
I’ve done testing, but can’t easily exercise every possible combination of options. If you find a problem, please let me know.
grads_auto.txt (751 Bytes)
grads_manual.txt (240 Bytes)
It does indeed help!
Still playing with it but I’ve got to this stage so far: Test page
That looks good. I’ll have to investigate further. I have too many retirement projects running at once though so I’ll need to work out where it can fit into the plans :lol:
I’ll put a “How Too” together shortly, so others can use it if they want too.
All my maps are now animated and on the links posted earlier in this thread.
I’ve also created a folder containing all the files needed to animate the OpenGrADS maps plus a ReadMe file telling you how to do it.
I’ve attached the folder to this thread but it can also be downloaded from [HERE](https://www.lochaberwx.co.uk/OpenGrADS Animation.zip).
Chris,
I’ve downloaded and tested your latest versions of the weather-watch.gs and grads_auto.bat scripts and they’re working well and fully automated with System Scheduler. :thumbright: =D>
OpenGrADS Animation.zip (30.8 KB)
Chris and Martin, I have been lurking watching your great progress and and am happy to report all working here on test machine. I have yet to try the new animation which looks easier to set up that my old page that was using Henkas script. I do have one observation in that the precipitation plots are supposed to be hourly precipitation, but if one looks at a whole series it is cumulative (if you look at a whole series your will see areas of precipitation not moving but getting darker and darker as the series proceeds. This was noticed last year by Tony (BeaumarisWX) for those of us using scripts based on nordic.gs. Many thanks for your fine updating work.
Chris
Good to know it works for you Chris.
I’d noticed the effect of cumulative rainfall in Budgie’s animation but without giving it much thought just assumed it was how the rain was for that four hour animation. I’ll take a look and try to figure out how to get hourly values (actually hour step values) instead of the cumulative. I think I know how to do it but need to test it on a time series of data to prove that my thoughts are right.
I was playing again last night and added a 300 mb Level Jet Stream map: See here
I wanted the 300mb level wind as that seems to be the standard for reporting the North Atlantic Jet Stream
For this I copied the original script, added the 300mb level wind to it (hopefully I got everything right [-o<) and created a second bat file to run it. I did this one separately because I made this with 10 images, where as the others only have 6.
I want to try to reduce the number of contour lines as it looks quite busy. So that’s my job for this evening.