0

I am attempting to plot fields from a GRIB2 file of GFS model data (example file: https://nomads.ncep.noaa.gov/pub/data/nccf/com/gfs/prod/gfs.20220202/12/atmos/gfs.t12z.pgrb2.0p25.f006 ). Normally I would just use PyGRIB and I'd have this problem solved yesterday, but I am on Windows (because it's what my employer uses, so I'm stuck with it and have to make this work on a Windows environment) and Windows and PyGRIB don't play nice. I am able to open the GRIB2 file and even plot variables over the entire domain using GDAL. The only problem is I need a way to get an array of the latitude and longitude values at each grid point (similar to in PyGRIB doing .latlons() on a GRIB message) so I can plot a subset of the domain.

Basically, I'm trying to replicate what is being done in this video, and need the data (got it using dataset.GetRasterBand(269).ReadAsArray()), then the lat/lon information.

I also tried using xarray, but Windows doesn't play nice with xarray either.

DopplerShift
  • 5,472
  • 1
  • 21
  • 20

1 Answers1

1

Given your comfort with PyGRIB, I'd say the solution is to use Conda and install it on Windows. You can use conda-forge's miniforge to install conda. Then, however you get Conda, install pygrib with:

conda install -c conda-forge pygrib
DopplerShift
  • 5,472
  • 1
  • 21
  • 20
  • Well, this seems to have done the trick. I downloaded the graphical installer for Windows, launched miniforge, then ran as you described. Once it finished, I loaded the Anaconda Navigator and switched the environment to miniforge and I was able to run pygrib. So my question is, how is it able to work here and install all the dependencies, but not in my regular base Anaconda environment? I'll also have to make sure I can install miniforge on the work PC, though fwiw, it never asked for admin privileges during the install. – soonertiger2012 Feb 03 '22 at 01:40
  • The big difference is probably using the `conda-forge` channel when installing with `conda install -c conda-forge`. If that doesn't work with Anaconda, then there's some weirdness with the environment likely. Best to create a new environment and activate (`conda create -n pygrib-test python=3.9` and `conda activate pygrib-test`), then install pygrib. You might also want to add conda-forge to your default channels with `conda config --add channels conda-forge`. – DopplerShift Feb 03 '22 at 03:35