I've been working with GFS data in Python using pygrib, and have been able to download and process data stored in .grb and .grib2 file formats from the NCEP archive ftp site. When I switch over to try to open grib files from the real time analysis, however, I'm not able to. I've tried downloading manually and changing the ending of the file to .grib2 and .grb, but neither has worked. Here's the ftp site that I'm trying to access for reference: http://nomads.ncep.noaa.gov/pub/data/nccf/com/gfs/prod/gfs.2017061300/
-
1$\begingroup$ Are you sure you are using the .f000 files, and not the .f000.idx files? Also did you check if the file is blank? $\endgroup$– BarocliniCplusplusJun 13, 2017 at 21:16
-
$\begingroup$ Yeah I just tried again for the .f000 files to make sure I wasn't pulling the .idx, and get the same problem of not being able to access with pygrib.open(file.f000). The files are each ~60MB, so not blank. $\endgroup$– abe732Jun 13, 2017 at 21:30
-
$\begingroup$ Can you show what the error is? $\endgroup$– BarocliniCplusplusJun 13, 2017 at 21:33
-
4$\begingroup$ got it to work! there was a minor change in the file naming convention that I didn't pick up between the historical and real time sites. pygrib is able to open the file as .f000, doesn't need to be renamed to .grib2 $\endgroup$– abe732Jun 13, 2017 at 21:33
-
3$\begingroup$ @abe732 Maybe you could post your findings as an answer? This could help other people facing the same problem. $\endgroup$– FuzzyLeapfrogJun 15, 2017 at 8:28
1 Answer
Figured out my error: I was assuming that I needed to alter the filename endings / type in order to save as a genuine .grb or .grib2 file. The files are already in grib2 format despite the ending in .f000 so you should be able to leave them as that.
My other error was not double checking the exact filename and path when dealing with multiple grib files across the GFS datasets. Some have slight differences in the naming convention, and when loading on pygrib it will throw the same generic "import error" as if the file couldn't be read.