Download GFS forecast

We would like to run WRF forecasts driven by global forecast data from NOAA’s Global Forecast System (GFS: http://www.emc.ncep.noaa.gov/index.php?branch=GFS).

To download a subset of the GFS data use NOMADS g2subs:

http://nomads.ncep.noaa.gov

  • Select the “grib filter” link for the dataset you want.
  • Use “make subregion”: e.g. lon:-55 to 25, lat: 25 to 70
  • Don’t use the analysis data file – it doesn’t contain soil data.
  • You can see which fields are in the GFS file by using the g2print.exe command in the WPS/util directory.
  • Using all levels, all variables, and subregion (lon:-55 to 25, lat: 25 to 70) reduced the size of the analysis file from 176M to 24M. The file size becomes even smaller by requesting less variables.
  • If you want to download a lot of data, you should tick the “Show the URL only for web programming” box, and write a bash script to change the URL for the dates you want, with variable output file name: curl $URL -o ${EM}${FT}.grb

How do you write that bash script?

Say you end up with a URL like this:

URL=http://nomads.ncep.noaa.gov/cgi-bin/filter_gfs_0p25_1hr.pl?file=gfs.t12z.pgrb2.0p25.f000&lev_surface=on&var_TMP=on&subregion=&leftlon=-7&rightlon=-5&toplat=54&bottomlat=52&dir=%2Fgfs.2017041712

This code contains different parts:

  • file=gfs.t12z.pgrb2.0p25.f000 – this is the base file name: model GFS, forecast initial time 12Z, …, forecast hour is 000. The forecast hour is probably what we want to change.
  • dir=%2Fgfs.2017041712 – this is the year, month, day and hour of the forecast initial time. All forecast data are inside this directory.
  • We don’t want to change the rest of the URL: forecast model, level, variables, subregion. If you want to change these, go through the grib_filter web page again and generate a new URL.

If we want to download multiple forecast hours for the same forecast initial time, we could do so with a bash script like this:

#!/bin/bash

# set the base URL in two parts: URL1 and URL2
# leave our forecast hour:

URL1='http://nomads.ncep.noaa.gov/cgi-bin/filter_gfs_0p25_1hr.pl?file=gfs.t12z.pgrb2.0p25.f'

URL2='&lev_surface=on&var_TMP=on&subregion=&leftlon=-7&rightlon=-5&toplat=54&bottomlat=52&dir=%2Fgfs.2017041712'

# Let forecast hour vary from 0 to 24.
# It needs to have three digits, so we start with 1000:

for i in {0..24}
do
  echo $i
  TFCH=`expr 1000 + $i`
  FCH=`echo $TFCH | cut -c2-4`
  URL=${URL1}${FCH}${URL2}
  curl $URL -o GFS${FCH}.grb
done

Note: make sure you are using backticks (`) not single quotes (‘) on the TFCH= and FCH= lines. Single quotes don’t evaluate anything in between them. Backticks run the command between the backticks and return the result, which is what we want here.

Instead of typing these commands into the terminal, you can simply save all of the above into a file, say “getGFS.bash” and then in the terminal type:

bash getGFS.bash

 


Posted

in

by

Tags: