OiO.lk Community platform!

Oio.lk is an excellent forum for developers, providing a wide range of resources, discussions, and support for those in the developer community. Join oio.lk today to connect with like-minded professionals, share insights, and stay updated on the latest trends and technologies in the development field.
  You need to log in or register to access the solved answers to this problem.
  • You have reached the maximum number of guest views allowed
  • Please register below to remove this limitation

cfgrib is failing to recognize data variable

  • Thread starter Thread starter Daniel Lassiter
  • Start date Start date
D

Daniel Lassiter

Guest
Data source: http://edc.occ-data.org/nexrad/mosaic/#data-updates

  • Using 'MRMS_PrecipRate_00.00_20010101-120000.grib2' which is the first file in the 2001 dataset

Problem: The 'PrecipRate' attribute I know to be in the grib file is unrecognized. The data are there but I'd like to preserve the metadata in the xarray dataset.

Code:
import xarray as xr

ds = xr.open_dataset('MRMS_PrecipRate_00.00_20010101-120000.grib2', engine = 'cfgrib')

print(ds)

<xarray.Dataset>
Dimensions:     (latitude: 3500, longitude: 7000)
Coordinates:
    time        datetime64[ns] 2001-01-01T12:00:00
    step        timedelta64[ns] 00:00:00
    surface     float64 0.0
  * latitude    (latitude) float64 54.99 54.98 54.98 54.97 ... 20.03 20.02 20.01
  * longitude   (longitude) float64 230.0 230.0 230.0 ... 300.0 300.0 300.0
    valid_time  datetime64[ns] 2001-01-01T12:00:00
Data variables:
    unknown     (latitude, longitude) float32 ...
Attributes:
    GRIB_edition:            2
    GRIB_centre:             161
    GRIB_centreDescription:  161
    GRIB_subCentre:          0
    Conventions:             CF-1.7
    institution:             161
    history:                 2021-05-04T13:11 GRIB to CDM+CF via cfgrib-0.9.9...
<p>Data source: <a href="http://edc.occ-data.org/nexrad/mosaic/#data-updates" rel="nofollow noreferrer">http://edc.occ-data.org/nexrad/mosaic/#data-updates</a></p>
<ul>
<li>Using 'MRMS_PrecipRate_00.00_20010101-120000.grib2' which is the first file in the 2001 dataset</li>
</ul>
<p>Problem: The 'PrecipRate' attribute I know to be in the grib file is unrecognized. The data are there but I'd like to preserve the metadata in the xarray dataset.</p>
<pre><code>import xarray as xr

ds = xr.open_dataset('MRMS_PrecipRate_00.00_20010101-120000.grib2', engine = 'cfgrib')

print(ds)

<xarray.Dataset>
Dimensions: (latitude: 3500, longitude: 7000)
Coordinates:
time datetime64[ns] 2001-01-01T12:00:00
step timedelta64[ns] 00:00:00
surface float64 0.0
* latitude (latitude) float64 54.99 54.98 54.98 54.97 ... 20.03 20.02 20.01
* longitude (longitude) float64 230.0 230.0 230.0 ... 300.0 300.0 300.0
valid_time datetime64[ns] 2001-01-01T12:00:00
Data variables:
unknown (latitude, longitude) float32 ...
Attributes:
GRIB_edition: 2
GRIB_centre: 161
GRIB_centreDescription: 161
GRIB_subCentre: 0
Conventions: CF-1.7
institution: 161
history: 2021-05-04T13:11 GRIB to CDM+CF via cfgrib-0.9.9...
</code></pre>
 

Latest posts

B
Replies
0
Views
1
Blundering Ecologist
B
Top