Skip to main content
Ctrl+K
Herbie 2023.12.4 documentation - Home

Site Navigation

  • User Guide
  • API Reference
  • SynopticPy
  • GOES-2-go
  • Twitter
  • GitHub
  • PyPI

Site Navigation

  • User Guide
  • API Reference
  • SynopticPy
  • GOES-2-go
  • Twitter
  • GitHub
  • PyPI

Section Navigation

Get Started

  • 🐍 Installation
  • πŸ›  Configure

Background Knowledge

  • πŸ“œ History
  • πŸ”’ What is GRIB2?
  • ☁ Data Sources
  • β„Ή Model Info
  • ⚑ What about Zarr?

Using Herbie

  • πŸ‘¨πŸ»β€πŸ’» Tutorials
    • Introduction
    • FastHerbie
    • Herbie Accessors
    • Brian’s Maps
    • 🎁 Wrapper for wgrib2
  • πŸ—Ί Model Tutorials
    • HRRR Data
    • HRRR-Alaska Data
    • RAP Data
    • HAFS Data
    • RTMA and URMA Data
    • NAM Data
    • GFS Data
    • GEFS - Global Ensemble Forecast System
    • ECMWF Open Data
    • NBM Data
    • NAVGEM Data
    • NOGAPS Data
    • HRDPS Data πŸ…±
    • RRFS Data πŸ…±
  • πŸ•ΊπŸ» Bonus Notebooks
    • ⌚ Herbie Latest
    • β˜” Precipitation Variables
    • 🧭 CRS with MetPy
    • πŸ” Plot model terrain
    • πŸ“ Nearest Points
    • β›ˆ K-Index
    • 🌡 Plot Vapor Pressure Deficit
    • 🧩 HRRR in Zarr Format
  • πŸͺ‚ Subset with searchString
  • πŸ‘·πŸ»β€β™‚οΈ Extending Herbie

Housekeeping

  • πŸ–‹ How to Cite
  • πŸ‘¨πŸ»β€πŸ­ Disclaimer
  • 🎨 Style Guide
  • πŸ€– Rclone
  • βš’ Other Tools
  • User Guide
  • πŸ—Ί Model Tutorials
  • NAVGEM Data

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'
../../_images/user_guide__model_notebooks_navgem_8_2.png
[ ]:

previous

NBM Data

next

NOGAPS Data

Edit on GitHub
Show Source

Β© Copyright 2023, Brian K. Blaylock. β™» Updated: 16:21 UTC 29 Dec 2023.

Created using Sphinx 7.2.6.

Built with the PyData Sphinx Theme 0.14.4.