NAVGEM#
This demonstrates how to use public data from the NAVGEM model from NOMADS or GODAE.
Note: there are not .idx files provided, so you have to download the full file and generate the .idx file with wgrib2 (requires Linux).
NAVGEM on NOMADS#
[42]:
import cartopy.crs as ccrs
import matplotlib.pyplot as plt
from paint.standard2 import cm_tmp
from toolbox import EasyMap, pc
from herbie import Herbie
[43]:
H = Herbie("2024-01-18", model="navgem_nomads", fxx=6)
β
Found β model=navgem_nomads β product=none β 2024-Jan-18 00:00 UTC F06 β GRIB2 @ local β IDX @ None
[44]:
H.PRODUCTS
[44]:
{'none': ''}
[45]:
H.SOURCES
[45]:
{'nomads': 'https://nomads.ncep.noaa.gov/pub/data/nccf/com/fnmoc/prod/navgem.20240118/navgem_2024011800f006.grib2'}
[46]:
# no index file available. Have to download the full file.
H.download()
[46]:
PosixPath('/p/cwfs/blaylock/data/navgem_nomads/20240118/navgem_2024011800f006.grib2')
[47]:
# Since we have download the full file and don't have an index,
# we need to filter by keys to open the variable we want.
ds = H.xarray(
backend_kwargs={
"filter_by_keys": {"shortName": "2t", "typeOfLevel": "heightAboveGround"}
},
)
ds
/p/home/blaylock/BB_python/Herbie/herbie/core.py:1064: UserWarning: Will not remove GRIB file because it previously existed.
warnings.warn("Will not remove GRIB file because it previously existed.")
[47]:
<xarray.Dataset> Dimensions: (latitude: 361, longitude: 720) Coordinates: time datetime64[ns] 2024-01-18 step timedelta64[ns] 06:00:00 heightAboveGround float64 2.0 * latitude (latitude) float64 -90.0 -89.5 -89.0 ... 89.0 89.5 90.0 * longitude (longitude) float64 0.0 0.5 1.0 ... 358.5 359.0 359.5 valid_time datetime64[ns] ... Data variables: t2m (latitude, longitude) float32 ... gribfile_projection object None Attributes: GRIB_edition: 2 GRIB_centre: fnmo GRIB_centreDescription: US Navy - Fleet Numerical Oceanography Center GRIB_subCentre: 0 Conventions: CF-1.7 institution: US Navy - Fleet Numerical Oceanography Center model: navgem_nomads product: none description: Navy Global Environment Model remote_grib: /p/cwfs/blaylock/data/navgem_nomads/20240118/nav... local_grib: /p/cwfs/blaylock/data/navgem_nomads/20240118/nav... search: None
[48]:
int(ds.step.dt.total_seconds() / 60 / 60)
[48]:
6
[49]:
ax = EasyMap(crs=ds.herbie.crs, figsize=[10, 8]).ax
p = ax.pcolormesh(
ds.longitude, ds.latitude, ds.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(ds.t2m.GRIB_name, loc="right")
ax.set_title(
f'{H.model.upper()}: {ds.time.dt.strftime("%H:%M UTC %d %b %Y").item()} F{int(ds.step.dt.total_seconds() / 60 / 60):03d}',
loc="left",
)
[49]:
Text(0.0, 1.0, 'NAVGEM_NOMADS: 00:00 UTC 18 Jan 2024 F006')
After downloading the full file, you can create an index file. (Only possible if WGRIB2 is installed and in your path)
[50]:
from herbie import wgrib2
[51]:
wgrib2.create_inventory_file(H.grib)
[51]:
PosixPath('/p/cwfs/blaylock/data/navgem_nomads/20240118/navgem_2024011800f006.grib2.idx')
[52]:
H.inventory()
[52]:
grib_message | start_byte | end_byte | range | reference_time | valid_time | variable | level | forecast_time | search_this | |
---|---|---|---|---|---|---|---|---|---|---|
0 | 1 | 421 | 150741.0 | 421-150741 | 2024-01-18 | 2024-01-18 06:00:00 | ACPCP | surface | 0-6 hour acc fcst | :ACPCP:surface:0-6 hour acc fcst |
1 | 2 | 150742 | 296573.0 | 150742-296573 | 2024-01-18 | 2024-01-18 06:00:00 | APCP | surface | 0-6 hour acc fcst | :APCP:surface:0-6 hour acc fcst |
2 | 3 | 296574 | 522814.0 | 296574-522814 | 2024-01-18 | 2024-01-18 06:00:00 | TMP | max wind | 6 hour fcst | :TMP:max wind:6 hour fcst |
3 | 4 | 522815 | 791251.0 | 522815-791251 | 2024-01-18 | 2024-01-18 06:00:00 | HGT | max wind | 6 hour fcst | :HGT:max wind:6 hour fcst |
4 | 5 | 791252 | 1110273.0 | 791252-1110273 | 2024-01-18 | 2024-01-18 06:00:00 | PRES | max wind | 6 hour fcst | :PRES:max wind:6 hour fcst |
... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... |
86 | 87 | 18256249 | 18609646.0 | 18256249-18609646 | 2024-01-18 | 2024-01-18 06:00:00 | UGRD | 10 m above ground | 6 hour fcst | :UGRD:10 m above ground:6 hour fcst |
87 | 88 | 18609647 | 18961671.0 | 18609647-18961671 | 2024-01-18 | 2024-01-18 06:00:00 | VGRD | 10 m above ground | 6 hour fcst | :VGRD:10 m above ground:6 hour fcst |
88 | 89 | 18961672 | 19336231.0 | 18961672-19336231 | 2024-01-18 | 2024-01-18 06:00:00 | var discipline=0 center=58 local_table=0 parmc... | 19.5 m above ground | 6 hour fcst | :var discipline=0 center=58 local_table=0 parm... |
89 | 90 | 19336232 | 19693176.0 | 19336232-19693176 | 2024-01-18 | 2024-01-18 06:00:00 | UGRD | 19.5 m above ground | 6 hour fcst | :UGRD:19.5 m above ground:6 hour fcst |
90 | 91 | 19693177 | NaN | 19693177- | 2024-01-18 | 2024-01-18 06:00:00 | VGRD | 19.5 m above ground | 6 hour fcst | :VGRD:19.5 m above ground:6 hour fcst |
91 rows Γ 10 columns
[53]:
H.inventory().attrs
[53]:
{'url': <_io.StringIO at 0x2b1a531ef010>,
'source': 'generated',
'description': 'Inventory index file for the GRIB2 file.',
'model': 'navgem_nomads',
'product': 'none',
'lead_time': 6,
'datetime': Timestamp('2024-01-18 00:00:00')}
[54]:
H.xarray("TMP:2 m")
[54]:
<xarray.Dataset> Dimensions: (latitude: 361, longitude: 720) Coordinates: time datetime64[ns] 2024-01-18 step timedelta64[ns] 06:00:00 heightAboveGround float64 2.0 * latitude (latitude) float64 -90.0 -89.5 -89.0 ... 89.0 89.5 90.0 * longitude (longitude) float64 0.0 0.5 1.0 ... 358.5 359.0 359.5 valid_time datetime64[ns] 2024-01-18T06:00:00 Data variables: t2m (latitude, longitude) float32 243.6 244.1 ... 248.9 gribfile_projection object None Attributes: GRIB_edition: 2 GRIB_centre: fnmo GRIB_centreDescription: US Navy - Fleet Numerical Oceanography Center GRIB_subCentre: 0 Conventions: CF-1.7 institution: US Navy - Fleet Numerical Oceanography Center model: navgem_nomads product: none description: Navy Global Environment Model remote_grib: /p/cwfs/blaylock/data/navgem_nomads/20240118/nav... local_grib: /p/cwfs/blaylock/data/navgem_nomads/20240118/sub... search: TMP:2 m
NAVGEM on GODAE#
The GRIB files are organized differently, and you have to specify the level and variable. Look at the File Naming Convention
[37]:
H = Herbie(
"2023-01-12 18:00",
model="navgem_godae",
product="GMET",
level="0100_010132-000000",
variable="air_temp",
)
H, H.SOURCES
β
Found β model=navgem_godae β product=GMET β 2023-Jan-12 18:00 UTC F00 β GRIB2 @ godae β IDX @ None
[37]:
(ββHerbie NAVGEM_GODAE model GMET product initialized 2023-Jan-12 18:00 UTC F00 β source=godae,
{'godae': 'https://usgodae.org/ftp/outgoing/fnmoc/models/navgem_0.5/2023/2023011218/US058GMET-GR1mdl.0018_0056_00000F0OF2023011218_0100_010132-000000air_temp'})
[39]:
ds = H.xarray()
ds
/p/home/blaylock/BB_python/Herbie/herbie/core.py:1069: UserWarning: Will not remove GRIB file because Herbie will only remove subsetted files (not full files).
warnings.warn(
[39]:
<xarray.Dataset> Dimensions: (latitude: 361, longitude: 720) Coordinates: time datetime64[ns] 2023-01-12T18:00:00 step timedelta64[ns] 00:00:00 isobaricInhPa float64 1.013e+03 * latitude (latitude) float64 -90.0 -89.5 -89.0 ... 89.0 89.5 90.0 * longitude (longitude) float64 -0.5 0.0 0.5 ... 358.0 358.5 359.0 valid_time datetime64[ns] ... Data variables: t (latitude, longitude) float32 ... gribfile_projection object None Attributes: GRIB_edition: 1 GRIB_centre: fnmo GRIB_centreDescription: US Navy - Fleet Numerical Oceanography Center GRIB_subCentre: 0 Conventions: CF-1.7 institution: US Navy - Fleet Numerical Oceanography Center model: navgem_godae product: GMET description: Navy Global Environment Model remote_grib: /p/cwfs/blaylock/data/navgem_godae/20230112/US05... local_grib: /p/cwfs/blaylock/data/navgem_godae/20230112/US05... search: None
[40]:
ax = EasyMap(crs=ds.herbie.crs, figsize=[10, 8]).ax
p = ax.pcolormesh(
ds.longitude, ds.latitude, ds.t, 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(
f"{ds.t.GRIB_name} {float(ds[ds.t.GRIB_typeOfLevel])} {str(ds[ds.t.GRIB_typeOfLevel].units)}",
loc="right",
)
ax.set_title(
f'{H.model.upper()}: {ds.time.dt.strftime("%H:%M UTC %d %b %Y").item()} F{int(ds.step.dt.total_seconds() / 60 / 60):03d}',
loc="left",
)
[40]:
Text(0.0, 1.0, 'NAVGEM_GODAE: 18:00 UTC 12 Jan 2023 F000')
[ ]: