I wrote a basic program to quickly get GFS data through the command-line. I had a standard script I always used, but it was cumbersome to continuously find it, copy it and run it. I just needed a command-line-like utility to ease my life.

The most important functions I needed were:

  • access from anywhere on my laptop
  • can specify which model run I needed
  • can specify and download more than one forecast for a model run

The program relies on wget and climate data operators (CDO). If you do not have these do:

sudo apt install cdo wget

Create a ~/bin directory to store the script in. Basically I did the following:

cd ~ && mkdir bin && touch getGFS

Now there’s a getGFS file which you can edit and add the following

#!/bin/bash
gfs=http://www.ftp.ncep.noaa.gov/data/nccf/com/gfs/prod/gfs

echo "
#######################################################################
A simple command line utility to download GFS forecast data using wget.
It's not really usefull to download historical data with.
#######################################################################"

echo

# Define what data you need
echo -n "Enter date in the following format %Y%m%d (e.g. 20191231) [ENTER]: "
read date

echo -n "Enter model runtime, e.g. 06, will give you the GFS 06UTC model run [ENTER]: "
read initial

echo -n "Enter forecast times you want separated by a space (typically 00 06) [ENTER]: "
read forecast 

# Loop through the specified forecast times wanted and grab GFS data
for i in $forecast
do
    wget $gfs.$date/$initial/gfs.t$initial\z.pgrb2.0p25.f0$i
done

echo "
#######################################################################
                                Done
#######################################################################"

Change the permissions of the getGFS file

chmod +x getGFS

Append the following line to your .bashrc file

export PATH=$PATH:~/bin

And it should work after closing and opening your terminal by typing in getGFS. This is just a quick download utility so there’s minor issues. I don’t do forecasts more than an 100 hours out and the script does not allow for that, it’s an easy fix nevertheless. I’ve had some issues where it seems like the data was somehow corrupted when trying to convert to netcdf format, but then I just manually inspect it.