NOGAPS#

This demonstrates how to download historical NOGAPS data archived at NCEI for historical analyses from 1997 to 2008 at 0.5 and 1.0 degree grids.

For NOGAPS data from GODAE, use model='navgem_godae.

[1]:
import matplotlib.pyplot as plt

from herbie import Herbie

from herbie import paint
from herbie.toolbox import EasyMap, pc
[4]:
H = Herbie("2008-07-28 12:00", model="nogaps_ncei", product="058_240")
βœ… Found β”Š model=nogaps_ncei β”Š product=058_240 β”Š 2008-Jul-28 12:00 UTC F00 β”Š GRIB2 @ ncei β”Š IDX @ ncei
[5]:
# TODO: Herbie cant read this NOGAPS inventory files

H.inventory("TMP")
---------------------------------------------------------------------------
ParserError                               Traceback (most recent call last)
Cell In[5], line 3
      1 # TODO: Herbie cant read this NOGAPS inventory files
----> 3 H.inventory("TMP")

File ~/GITHUB/Herbie/herbie/core.py:791, in Herbie.inventory(self, search, searchString, verbose)
    764 def inventory(self, search=None, *, searchString=None, verbose=None):
    765     """
    766     Inspect the GRIB2 file contents by reading the index file.
    767
   (...)
    789
    790     """
--> 791     df = self.index_as_dataframe
    793     # TODO: Remove this eventually
    794     if searchString is not None:

File ~/miniconda3/envs/herbie-dev/lib/python3.12/functools.py:995, in cached_property.__get__(self, instance, owner)
    993 val = cache.get(self.attrname, _NOT_FOUND)
    994 if val is _NOT_FOUND:
--> 995     val = self.func(instance)
    996     try:
    997         cache[self.attrname] = val

File ~/GITHUB/Herbie/herbie/core.py:643, in Herbie.index_as_dataframe(self)
    640     read_this_idx = StringIO(response.text)
    641     response.close()
--> 643 df = pd.read_csv(
    644     read_this_idx,
    645     sep=":",
    646     names=[
    647         "grib_message",
    648         "start_byte",
    649         "reference_time",
    650         "variable",
    651         "level",
    652         "forecast_time",
    653         "?",
    654         "??",
    655         "???",
    656     ],
    657 )
    659 # Format the DataFrame
    660 df["reference_time"] = pd.to_datetime(
    661     df.reference_time, format="d=%Y%m%d%H"
    662 )

File ~/miniconda3/envs/herbie-dev/lib/python3.12/site-packages/pandas/io/parsers/readers.py:1026, in read_csv(filepath_or_buffer, sep, delimiter, header, names, index_col, usecols, dtype, engine, converters, true_values, false_values, skipinitialspace, skiprows, skipfooter, nrows, na_values, keep_default_na, na_filter, verbose, skip_blank_lines, parse_dates, infer_datetime_format, keep_date_col, date_parser, date_format, dayfirst, cache_dates, iterator, chunksize, compression, thousands, decimal, lineterminator, quotechar, quoting, doublequote, escapechar, comment, encoding, encoding_errors, dialect, on_bad_lines, delim_whitespace, low_memory, memory_map, float_precision, storage_options, dtype_backend)
   1013 kwds_defaults = _refine_defaults_read(
   1014     dialect,
   1015     delimiter,
   (...)
   1022     dtype_backend=dtype_backend,
   1023 )
   1024 kwds.update(kwds_defaults)
-> 1026 return _read(filepath_or_buffer, kwds)

File ~/miniconda3/envs/herbie-dev/lib/python3.12/site-packages/pandas/io/parsers/readers.py:626, in _read(filepath_or_buffer, kwds)
    623     return parser
    625 with parser:
--> 626     return parser.read(nrows)

File ~/miniconda3/envs/herbie-dev/lib/python3.12/site-packages/pandas/io/parsers/readers.py:1923, in TextFileReader.read(self, nrows)
   1916 nrows = validate_integer("nrows", nrows)
   1917 try:
   1918     # error: "ParserBase" has no attribute "read"
   1919     (
   1920         index,
   1921         columns,
   1922         col_dict,
-> 1923     ) = self._engine.read(  # type: ignore[attr-defined]
   1924         nrows
   1925     )
   1926 except Exception:
   1927     self.close()

File ~/miniconda3/envs/herbie-dev/lib/python3.12/site-packages/pandas/io/parsers/c_parser_wrapper.py:234, in CParserWrapper.read(self, nrows)
    232 try:
    233     if self.low_memory:
--> 234         chunks = self._reader.read_low_memory(nrows)
    235         # destructive to chunks
    236         data = _concatenate_chunks(chunks)

File parsers.pyx:838, in pandas._libs.parsers.TextReader.read_low_memory()

File parsers.pyx:905, in pandas._libs.parsers.TextReader._read_rows()

File parsers.pyx:874, in pandas._libs.parsers.TextReader._tokenize_rows()

File parsers.pyx:891, in pandas._libs.parsers.TextReader._check_tokenize_status()

File parsers.pyx:2061, in pandas._libs.parsers.raise_parser_error()

ParserError: Error tokenizing data. C error: EOF inside string starting at row 74
[6]:
H = Herbie("2008-07-28 12:00", model="nogaps_ncei", product="008_240")
βœ… Found β”Š model=nogaps_ncei β”Š product=008_240 β”Š 2008-Jul-28 12:00 UTC F00 β”Š GRIB2 @ ncei β”Š IDX @ ncei
[7]:
H.inventory("TMP")
[7]:
grib_message start_byte end_byte range reference_time valid_time variable level forecast_time ? ?? ??? search_this
0 1 21 228296.0 21-228296 2008-07-28 12:00:00 2008-07-28 12:00:00 TMP 0 mb kpds=11,100,0 anl winds are N/S Temp. [K]\n2:89724:D=2008072812:HGT:0 mb:kpds=... :TMP:0 mb:kpds=11,100,0:anl:winds are N/S:Temp...
2 5 407705 644126.0 407705-644126 2008-07-28 12:00:00 2008-07-28 12:00:00 TMP 1 mb kpds=11,100,1 anl winds are N/S Temp. [K]\n6:505554:D=2008072812:HGT:1 mb:kpds... :TMP:1 mb:kpds=11,100,1:anl:winds are N/S:Temp...
4 9 823535 1068100.0 823535-1068100 2008-07-28 12:00:00 2008-07-28 12:00:00 TMP 2 mb kpds=11,100,2 anl winds are N/S Temp. [K]\n10:929528:D=2008072812:HGT:2 mb:kpd... :TMP:2 mb:kpds=11,100,2:anl:winds are N/S:Temp...
6 13 1231217 1467638.0 1231217-1467638 2008-07-28 12:00:00 2008-07-28 12:00:00 TMP 5 mb kpds=11,100,5 anl winds are N/S Temp. [K]\n14:1337210:D=2008072812:HGT:5 mb:kp... :TMP:5 mb:kpds=11,100,5:anl:winds are N/S:Temp...
[9]:
ds = H.xarray("TMP:5 mb")
ds
[9]:
<xarray.Dataset> Size: 526kB
Dimensions:              (latitude: 181, longitude: 360)
Coordinates:
    time                 datetime64[ns] 8B 2008-07-28T12:00:00
    step                 timedelta64[ns] 8B 00:00:00
    isobaricInhPa        float64 8B 5.0
  * latitude             (latitude) float64 1kB -90.0 -89.0 -88.0 ... 89.0 90.0
  * longitude            (longitude) float64 3kB -1.0 0.0 1.0 ... 357.0 358.0
    valid_time           datetime64[ns] 8B 2008-07-28T12:00:00
    gribfile_projection  object 8B None
Data variables:
    t                    (latitude, longitude) float32 261kB 210.5 ... 252.4
    gh                   (latitude, longitude) float32 261kB 3.048e+04 ... 3....
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:                   nogaps_ncei
    product:                 008_240
    description:             Navy Operational Global Atmospheric Prediction S...
    remote_grib:             https://www.ncei.noaa.gov/data/navy-operational-...
    local_grib:              /home/blaylock/data/nogaps_ncei/20080728/subset_...
    search:                  TMP:5 mb
[10]:
ax = EasyMap(crs=ds.herbie.crs, figsize=[8, 8]).ax
p = ax.pcolormesh(
    ds.longitude,
    ds.latitude,
    ds.t - 273.15,
    transform=pc,
    **paint.NWSTemperature.kwargs2,
)
plt.colorbar(
    p, ax=ax, orientation="horizontal", pad=0.01, **paint.NWSTemperature.cbar_kwargs2
)

ax.set_title(f"{ds.t.GRIB_name} {ds.isobaricInhPa.item()} hPa", loc="right")
ax.set_title(f"{H.model.upper()}: {H.product_description}", loc="left")
[10]:
Text(0.0, 1.0, 'NOGAPS_NCEI: ?')
../../_images/gallery_usnavy_models_nogaps_7_1.png