Using Global Forecast System from THREDDS Data Server or Google Earth Engine with Python

Global Forecast System, as the name implies, is a global weather prediction model produced by the National Centers for Environmental Prediction. Among the many variables available to be used, the most common parameters are temperature, wind speed and direction, precipitation, and relative humidity. GFS provides weather forecast up to 384 hours after the model is run. This model is run 4 times a day, at 00 UTC, 06 UTC, 12 UTC, and 18 UTC. It usually takes around 5 hours for the model to complete.

GFS data can be downloaded directly from the FTP / HTTPS server provided by the National Oceanic and Atmospheric Administration, for free, since it’s funded by American taxpayers. However, manually downloading a whole (global) file just to work with a subset of data is not ideal, this is why I would recommend using one of the two options I will be explaining here, Google Earth Engine or THREDDS Data Server.

Google Earth Engine is the easiest to work with, you can either use the JavaScript Code Editor or use the Python API with Jupyter Lab environment to begin development. However, there’s an ingestion delay required to convert the GFS in GRIB-2 format to a raster image in the Google Earth Engine platform, if you need the data as soon as it’s generated, you might want to look somewhere else.

Thematic Real-time Environmental Distributed Data Services (THREDDS) Data Server is a way to distribute environmental data for research use. GFS data in its original GRIB-2 format can also be accessed through this THREDDS Data Server (TDS). The data is usually available in the TDS Catalog within 5 hours of the model generation time. TDS has a NetCDF subset service, that allows us to download a specific area of interest (using a rectangular bounding box), variables of interest, and specify the time range (or single time reference).

Both access can be done with Python, using these modules:

  1. earthengine-api (recommended install: geemap, eemont)
  2. siphon (TDS Catalog API)
  3. xarray (ndarray to work with NetCDF)
  4. netCDF4 (NetCDF backend on Python)

You can use Anaconda to create an environment with all these modules and the Jupyter Lab environment:

$ conda create -n geo python=3.9
$ conda activate geo
$ conda install -c conda-forge geemap eemont siphon xarray[complete] netCDF4

Once you’re done, you can use my Notebook example on my GitHub to begin how to access the Global Forecast System on Google Earth Engine:

Published by josefmtd

Electronics Engineer

Leave a Reply

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

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

Facebook photo

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

Connecting to %s

%d bloggers like this: