NAVGEM Data#
This demonstrates how to use data from the NAVGEM model from NOMADS.
Note: there are not .idx files provided, so you have to download the full file and generate the .idx file with wgrib2 (requires Linux).
[10]:
from herbie import Herbie
from toolbox import EasyMap, pc
from paint.standard2 import cm_tmp
import matplotlib.pyplot as plt
import cartopy.crs as ccrs
[11]:
H = Herbie("2022-12-10", model="navgem")
β
Found β model=navgem β product=none β 2022-Dec-10 00:00 UTC F00 β GRIB2 @ local β IDX @ None
[12]:
H.PRODUCTS
[12]:
{'none': ''}
[13]:
H.SOURCES
[13]:
{'nomads': 'https://nomads.ncep.noaa.gov/pub/data/nccf/com/fnmoc/prod/navgem.20221210/navgem_2022121000f000.grib2'}
[20]:
# no index file available. Have to download the full file.
H.download()
---------------------------------------------------------------------------
TypeError Traceback (most recent call last)
Cell In[20], line 2
1 # no index file available. Have to download the full file.
----> 2 H.download()
File ~\_GITHUB\Herbie\herbie\archive.py:911, in Herbie.download(self, searchString, source, save_dir, overwrite, verbose, errors)
907 print(f"π¨π»βπ Created directory: [{outFile.parent}]")
909 if searchString in [None, ":"] or self.idx is None:
910 # Download the full file from remote source
--> 911 urllib.request.urlretrieve(self.grib, outFile, _reporthook)
913 self.grib = outFile
914 # self.grib_source = "local"
File c:\Users\blaylock\Miniconda3\envs\herbie-dev\lib\urllib\request.py:239, in urlretrieve(url, filename, reporthook, data)
223 def urlretrieve(url, filename=None, reporthook=None, data=None):
224 """
225 Retrieve a URL into a temporary location on disk.
226
(...)
237 data file as well as the resulting HTTPMessage object.
238 """
--> 239 url_type, path = _splittype(url)
241 with contextlib.closing(urlopen(url, data)) as fp:
242 headers = fp.info()
File c:\Users\blaylock\Miniconda3\envs\herbie-dev\lib\urllib\parse.py:1039, in _splittype(url)
1036 if _typeprog is None:
1037 _typeprog = re.compile('([^/:]+):(.*)', re.DOTALL)
-> 1039 match = _typeprog.match(url)
1040 if match:
1041 scheme, data = match.groups()
TypeError: expected string or bytes-like object
[15]:
import xarray
[16]:
# Since we have the full file, we need to filter by keys to open the
# variable we want with cfgrib
x = xarray.open_dataset(
H.get_localFilePath(),
engine="cfgrib",
backend_kwargs={
"filter_by_keys": {"shortName": "2t", "typeOfLevel": "heightAboveGround"}
},
)
[17]:
ax = EasyMap(crs=x.herbie.crs, figsize=[10, 8]).ax
p = ax.pcolormesh(
x.longitude, x.latitude, x.t2m, transform=pc, **cm_tmp(units="K").cmap_kwargs
)
plt.colorbar(
p, ax=ax, orientation="horizontal", pad=0.05, **cm_tmp(units="K").cbar_kwargs
)
ax.set_title(x.t2m.GRIB_name, loc="right")
ax.set_title(f"{H.model.upper()}: {H.product_description}", loc="left")
c:\Users\blaylock\Miniconda3\envs\herbie-dev\lib\site-packages\metpy\xarray.py:355: UserWarning: More than one time coordinate present for variable "t2m".
warnings.warn('More than one ' + axis + ' coordinate present for variable'
---------------------------------------------------------------------------
AttributeError Traceback (most recent call last)
Cell In[17], line 2
1 ax = EasyMap(crs=x.herbie.crs, figsize=[8, 8])
----> 2 p = ax.pcolormesh(
3 x.longitude, x.latitude, x.t2m, transform=pc, **cm_tmp(units="K").cmap_kwargs
4 )
5 plt.colorbar(
6 p, ax=ax, orientation="horizontal", pad=0.05, **cm_tmp(units="K").cbar_kwargs
7 )
9 ax.set_title(x.t2m.GRIB_name, loc="right")
AttributeError: 'common_features' object has no attribute 'pcolormesh'
[ ]: