Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Download historical GRIB files instead of CSV's #9

Open
diegormsouza opened this issue Jun 2, 2021 · 5 comments
Open

Download historical GRIB files instead of CSV's #9

diegormsouza opened this issue Jun 2, 2021 · 5 comments

Comments

@diegormsouza
Copy link

Hi Alberto,

Would it possible to download GRIB files instead of CSV's using a similar methodology?

Thanks,
Diego

@albertotb
Copy link
Owner

Writing arbitrarily GRIB files is not something that can be done with xarray (yet). See ecmwf/cfgrib#18 for a discussion. However, it is fairly easy to download files from GFS using the OpenDAP protocol and writing them to a NetCDF file (instead of GRIB2). Note that you can always download the whole GRIB2 file directly. The advantage of OpenDAP is that you can subset the file on the server, so you do not have to download all the variables/coordinates/time steps. I have create two example scripts in a new branch https://github.com/albertotb/get-gfs/tree/xarray (still a proof of concept), one for the operational server and another one for the historical server. You can see the catalogs with the available dates here:

As for the available variables, you can just navigate to any file in the previous links. To download the data, just checkout the branch and run:

./get_gfs_xarray.py --date 2021-07-24 --run 0 --hour 0 

or

./get_gfs_hist_xarray.py --date 2020-05-15 --run 6 --time 0

These scripts are still WIP and currently only download a couple of test variable for all lat/lons, but it would not be hard to improve them so that:

  • Lats and lons are subsettable
  • Variables are passed as args to the script

If this is something useful to you just let me know and I will try to make those changes.

@diegormsouza
Copy link
Author

Thanks a lot Alberto,

With this sentence: "Note that you can always download the whole GRIB2 file directly.", I realized I could use the "requests" library to download data directly from the historical servers (both analysis and forecasts):

https://www.ncei.noaa.gov/thredds/catalog/model-gfs-004-files/catalog.html
https://www.ncei.noaa.gov/thredds/catalog/model-gfs-004-files-old/catalog.html
https://www.ncei.noaa.gov/thredds/catalog/model-gfs-g4-anl-files/catalog.html
https://www.ncei.noaa.gov/thredds/catalog/model-gfs-g4-anl-files-old/catalog.html
https://www.ncei.noaa.gov/thredds/catalog/model-gfs-003-files/catalog.html
https://www.ncei.noaa.gov/thredds/catalog/model-gfs-003-files-old/catalog.html
https://www.ncei.noaa.gov/thredds/catalog/model-gfs-g3-anl-files/catalog.html
https://www.ncei.noaa.gov/thredds/catalog/model-gfs-g3-anl-files-old/catalog.html

... as I was doing with the NOMADS server. Right now I'm OK with downloading the full GRIB files from the historical servers.

I'll test the example scripts you mentioned and check the results! Thanks Alberto!

@zxdawn
Copy link

zxdawn commented Jan 26, 2022

@diegormsouza Thanks for your updates!
I'm trying to download historical GFS forecast data from 2018-2020.
According to your links, the gfs-003 is the option. However, the old one ends at 202005 and the new one begins at 202107.
Do you know why there're missing data between them?
Thanks,
Xin

@albertotb
Copy link
Owner

albertotb commented Feb 2, 2022 via email

@zxdawn
Copy link

zxdawn commented Feb 2, 2022

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants