Grib2io

Latest version: v2.3.0

Safety actively analyzes 688512 Python packages for vulnerabilities to keep your Python projects secure.

Scan your dependencies

Page 6 of 6

0.9.2

grib2io Version 0.9.2 Release Notes

* In `setup.py`, added support to automatically find JPEG and PNG library and include paths when the `setup.cfg` and/or library-specific environment variables are not used. This will allow for JPEG and PNG compression support out-of-the-box when installed by package systems like `pip`. This has been tested on macOS 12 (Monterey) and Linux (Fedora, openSUSE, and Ubuntu).

* New module function, `show_config()`, to print information about compression support and external compression library information.

* Implementation of a wgrib2-formatted level/layer string generated by new function, `grib2io.tables.get_wgrib2_level_string()`. The string is stored in `grib2io.open._index['levelString']`and in instances of `Grib2Message` as the `level` attribute. This allows for level **_and_** layer matching. (13)

* New table dictionary , `wgrib2_level_string`, containing level code values as keys. Values are a list containing formatting string given a level or layer. The contents of this table dictionary are replicated from wgrib2 source file, [Level.c](https://github.com/NOAA-EMC/NCEPLIBS-wgrib2/blob/develop/wgrib2/Level.c).

* Added new attribute, `levels`, to the `grib2io.open` class that holds a tuple of unique wgrib2-formatted level/layer strings.

0.9.1

grib2io Version 0.9.1 Release Notes


New Features:
* Added JPEG compression support with the [OpenJPEG Library](https://www.openjpeg.org). `grib2io` now supports building the bundled g2c library using either Jasper or OpenJPEG libs.
* Added support to select GRIB2 fields at the ground/surface level. (12)


Bug Fixes
* Added missing `Grib2Message` attribute, `scaledValueOfSecondFixedSurface` (11)

0.9.0

grib2io Version 0.9.0 Release Notes

This is a minor pre-release. Alot of the code amd documentation has been cleaned up. At this release, the Python package classifier Development Status has been bumped to level 4 - Beta.

New Features:
* Added ability to write a GRIB2 Local Use Section (Section 2) to new Grib2Message objects using new Grib2Message method, `addlocal()`. The GRIB2 Local Use Section can contain **_anything_** you wish to put into the GRIB2 Message. (9)

* All Grib2Message class attributes that originate from a GRIB2 metadata and link to a GRIB2 code table are now a Grib2Metadata object. This gives users the choice to work with metadata as the coded value (`Grib2Metadata.value`) or the definition (`Grib2Metadata.definition`).

* Added ability to select GRIB2 messages from `grib2io.open` file object via the `shortName`

python
import grib2io
g = grib2io.open('test.grib2')
msgs = g['APCP'] Returns all GRIB2 message with shortName = 'APCP'


Class Updates:

`grib2io.Grib2Message`

* new method, `to_bytes()`, that returns the GRIB2 Message as a `bytes` object.

* new method, `addlocal()`, to add a Local Use Section (Section 2) to the new Grib2Message object. In order for this to work, a few function, `grib2_addlocal()` in `g2clib.pyx` was created to interface to the g2c function, `g2_addlocal()`.

* updated `__getitem__()` to allow for key of type `str`.

Changes / Updates:
* Python 3.10 support

* GitPod support

* Added [NCEP GRIB2 Table 4.228](https://www.nco.ncep.noaa.gov/pmb/docs/grib2/grib2_doc/grib2_table4-228.shtml)

0.8.0

Release Notes

**New Features:**

- `Grib2Message` creation from "scratch" (i.e. not read from an existing file). The logic to create a GRIB2 message remains largely the same from grib2io's predecessor, [ncepgrib2](https://github.com/jswhit/ncepgrib2). However, with `grib2io`, the creation of a new GRIB2 message is done through instantiation of the `grib2io.Grib2Message` class. When the class is instantiated with appropriate values to the keyword arguments `discipline` and `idsect`, an empty instance of `Grib2Message` is created. Then you call `Grib2Message` methods: `addgrid()` to add the grid definition section; `addfield()` to add the production definition, data representation, bitmap, and data sections; and finally `end()` to formally end the GRIB2 message.

- Write GRIB2 message to file. Class `grib2io.open` now contains a `write()` method that accepts a `Grib2Message` object.

- Decode GRIB2 messages that contain MDL (Gridded MOS) and NDFD Weather Strings. The gridded data are integer values that represent an index of a lookup table that contain weather strings. The lookup table is unique for each GRIB2 message and is stored in section 2 (Local Use Section) of each message. New functions, `utils.decode_mdl_wx_strings()` and `utils.decode_ndfd_wx_strings()` have been created to perform the decoding of the lookup tables. Different functions are required because the decoding is slightly different between MDL and NDFD. To decode weather strings while unpacking data, provide `Grib2Message.data()` method with the `map_keys=True` keyword argument.

- GRIB2 metadata attributes of the `Grib2Message` can now hold their coded integer value ***and*** the plain language defintion for that value. Where necessary, `Grib2Message` object attributes will be of type `Grib2Metadata` which stores the code value in `value` and the plain language definition in `definition`. See the following example using the `Grib2Message.discipline`:

python
>>> import grib2io
>>> g = grib2io.open('test.grib2')
>>> msg = g[50][0] Get the 50th GRIB2 message
>>> type(msg.discipline)
<class 'grib2io._grib2io.Grib2Metadata'>
>>> msg.discipline.value
0
>>> msg.discipline.definition
'Meteorological Products'
>>> msg.discipline == 0
True
>>> 'Met' in msg.discipline.definition
True
>>> print(msg.discipline)
0 - Meteorological Products
>>> msg.discipline()
0


**Class Updates:**

`grib2io.Grib2Message`

- new method, `unpack()`. This method handles the unpacking of the binary data from the GRIB2 message and creates the GRIB2 section values.

- new method, `decode()`. This method performs the decoding of packed GRIB2 values from each section into metadata variables (i.e. instance variables of `Grib2Message`). Where available, the code values are futher deciphered into their plain language defintions. Both the code value its definition are stored as an instance of class `Grib2Metadata`.

- new method, `addgrid()`. Adds Grid Definition Section information.

- new method, `addfield()`. Adds the Production Definition, Data Representation, Bitmap, and Data Sections.

- new method, `end()`. Add the End Section. This formally terminates the packed GRIB2 message.

- updated `__init__` to accommodate `discipline` and `idsect` keyword arguments (both have the default value of `None`). When both of these are specified ***and are not*** `None`, an empty `Grib2Message` object is created. ***NOTE: all other keyword arguments are ignored.***

- updated `data()` to add `map_keys` keyword for decoding data values to MDL or NDFD Wx Strings.

`grib2io.Grib2Metadata` ***(NEW)***

- New class to store decoded GRIB2 metadata as the coded value in instance vairable `value` and its plain language definition in instance variable `definition`.
- Class comparison methods use the `value` attribute. For `__contains__`, the `definition` atrribute is used. For `__call__`, `value` is returned.

**Changes:**

- Renamed `utils.get_varname_from_table()` to `utils.get_varinfo_from_table()`.
- `utils.get_table()` now returns an empty dictionary when the specified table is not found.
- `utils.get_value_from_table()` now returns `['Unknown','Unknown','Unknown']` when a value from a table is not found.
- Updates to docstrings
- NCEP GRIB2 tables updated to latest as of 8/31/2021. Logic added to table generation scripts to remove "(See Note *)" strings.
- Included [NCEP G2C](https://github.com/NOAA-EMC/NCEPLIBS-g2c) Library updated to verison 1.6.2.

**Bug Fixes:**

- Set ONE_MB to the correct value representing 1 MB in units of bytes.
- Fixed issues with decoding metadata for GRIB2 messages with production definition template number = 9.

0.3.0

Release Notes

**Class grib2io.open():**

- New `select()` method for selection/filtering of GRIB2 Messages. Currently supported keyword arguments are: `‘duration’`, `‘leadTime’`, `‘level’`, `'refDate'`, and `‘shortName’`. These arguments only accept single values at this time. Please see documentation for usage of these keyword arguments. The `level` keyword, only supports the following surfaces: isobaric surface, height above/below ground, and sigma are supported at this time. A future update will allow for multiple values per keyword. The following example will select GRIB2 Messages that are Geopotential Height at the 500mb level, with a lead time of 24-hours.

python
>>> import grib2io
>>> g = grib2io.open("test.grib2")
>>> msgs = g.select(shortName="HGT",level="500mb",leadTime=24)


- New `_find_level()` “private” method to parse the user provided level= kwarg in the select() method. The value is parsed and searched for.

- New class attribute, `‘shortNames’`, containing a tuple of unique shortName strings contained in the GRIB2 file.

**Class grib2io.Grib2Message():**

- New `latlons()` method that will return latitude and longitude values of the `grib2io.Grib2Message` instance. An alias for this method named `grid()` is also available.

- Fixed an issue where the incorrect lead time would be set for GRIB2 message using Product Definition Templates 4.8,9,10,11,12. There are time interval messages (i.e. Accumulated Precipitation; "APCP").

**Sub-module grib2io.utils:**

- New `getleadtime()` function to compute the lead time given GRIB2 Indentification Section (1), Product Definition Template (section 4) and Number. For time interval messages, the lead time value returned here is the ending hour.

- New `getduration()` function to compute the duration time given GRIB2 Product Definition Template (Section 4) and Number. GRIB2 Messages describing data at an instance in time have a duration = 0.

**Miscellaneous:**

- Added directory `make_grib2_tables/` at the repository root that contains shell and Python scripts to scrape the NCEP GRIB2 HTML tables and generate Python dictionary-based tables. **IMPORTANT:** The Python scripts use Pandas for HTML reading and processing, but Pandas is *_not_* required for `grib2io`. Releases of `grib2io` will contain the latest version of the tables at the time of release. The ability to update tables is provided here.

- Documentation generation has been changed to use [pdoc](https://pdoc.dev).

- Applied a temporary patch in grib2.h in the bundled NCEP g2c library. The patch adds function definitions for g2_unpack* functions. This allow for successful build using Apple's LLVM clang.

0.2.0

This is the first release of grib2io. Version 0.2.0 is also available on [PyPI](https://pypi.org/project/grib2io/). As of this release grib2io can perform the following major functions:

* Read a file containing GRIB2 Messages. If a GRIB2 Message contains sub messages, grib2io will "flatten" into multiple GRIB2 Messages.
* When read, the GRIB2 file will "indexed". This is not the same as a GRIB2 Index file. The indexing keeps track of the location of a GRIB2 Message in the file and catalogs most GRIB2 metadata for filtering/parsing (***to be implemented in a future release***) and allows for reading of GRIB2 Messages in a random-access manner.
* Unpack GRIB2 data
* Where possible, GRIB2 integer code values are translated into descriptive text via NCEP GRIB2 tables.

**IMPORTANT:** At this time, grib2io ***cannot*** create a new GRIB2 Message nor can it write to a new file (***to be implemented in a future release***).

Page 6 of 6

© 2024 Safety CLI Cybersecurity Inc. All Rights Reserved.