Skip to content

Commit

Permalink
Update for _grib2io.py
Browse files Browse the repository at this point in the history
Changed method for cleaning up the unpacked data from a Grib2Message
object from "del msg.data" to "msg.flush_data()"

Some docstring cleanup.
  • Loading branch information
EricEngle-NOAA committed Feb 7, 2024
1 parent 01e3f62 commit 41b18c0
Showing 1 changed file with 13 additions and 15 deletions.
28 changes: 13 additions & 15 deletions grib2io/_grib2io.py
Original file line number Diff line number Diff line change
Expand Up @@ -798,8 +798,10 @@ def _find_class_index(n):

def pack(self):
"""
Packs GRIB2 section data into a binary message. It is the user's responsibility
to populate the GRIB2 section information with appropriate metadata.
Packs GRIB2 section array data into a binary message.
It is the user's responsibility to populate the GRIB2 section
information with appropriate metadata.
"""
# Create beginning of packed binary message with section 0 and 1 data.
self._sections = []
Expand Down Expand Up @@ -869,9 +871,7 @@ def pack(self):

@property
def data(self) -> np.array:
"""
Accessing the data attribute loads data into memmory
"""
"""Access the unpacked data values."""
if not hasattr(self,'_auto_nans'): self._auto_nans = _AUTO_NANS
if hasattr(self,'_data'):
if self._auto_nans != _AUTO_NANS:
Expand All @@ -890,11 +890,10 @@ def data(self, data):
self._data = data


@data.deleter
def data(self):
if isinstance(self._data, np.ndarray):
del self._data
self._data = self._ondiskarray
def flush_data(self):
"""Flush the unpacked data values from the Grib2Message object."""
del self._data
self._data = self._ondiskarray


def __getitem__(self, item):
Expand Down Expand Up @@ -1076,13 +1075,12 @@ def grid(self, unrotate=True):

def map_keys(self):
"""
Returns an unpacked data grid where integer grid values are replaced with
a string.in which the numeric value is a representation of.
Maps data values to a classification map.
These types of fields are cateogrical or classifications where data values
These types of data are enumerations of categorical or classification values that
do not represent an observable or predictable physical quantity. An example
of such a field field would be [Dominant Precipitation Type -
DPTYPE](https://www.nco.ncep.noaa.gov/pmb/docs/grib2/grib2_doc/grib2_table4-201.shtml)
of such a field would be [Dominant Precipitation Type -
DPTYPE](https://www.nco.ncep.noaa.gov/pmb/docs/grib2/grib2_doc/grib2_table4-201.shtml).
Returns
-------
Expand Down

0 comments on commit 41b18c0

Please sign in to comment.