NOAA-MDL / grib2io

Python interface to the NCEP G2C Library for reading and writing GRIB2 messages.
https://noaa-mdl.github.io/grib2io
MIT License
30 stars 11 forks source link

Provide lats and lons as attributes or property #114

Closed EricEngle-NOAA closed 7 months ago

EricEngle-NOAA commented 9 months ago

A common pattern when using grib2io is to get latitudes and longitudes for the GRIB2 message via the latlons() method. This is especially true when plotting. Therefore grib2io.Grib2Message class should have attributes or properties to access these data.

This should not cause any performance hit since lats and lons are only computed once -- they'll simply just be returned.

Expected access pattern:

import grib2io
g = grib2io.open("file.grib2")
msg = g[0]
msg.lats # Latitudes
msg.lons # Longitudes
msg.data # Data