How to use the cfgrib.bindings.codes_keys_iterator_new function in cfgrib

To help you get started, we’ve selected a few cfgrib examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github ecmwf / cfgrib / tests / test_10_bindings.py View on Github external
def test_codes_keys_iterator():
    grib = bindings.codes_grib_new_from_file(open(TEST_DATA))

    iterator = bindings.codes_keys_iterator_new(grib)

    assert bindings.codes_keys_iterator_next(iterator) == 1
    assert bindings.codes_keys_iterator_get_name(iterator) == 'globalDomain'
    assert bindings.codes_keys_iterator_next(iterator) == 1
    assert bindings.codes_keys_iterator_get_name(iterator) == 'GRIBEditionNumber'

    bindings.codes_keys_iterator_delete(iterator)

    iterator = bindings.codes_keys_iterator_new(grib, namespace='time')

    assert bindings.codes_keys_iterator_next(iterator) == 1
    assert bindings.codes_keys_iterator_get_name(iterator) == 'dataDate'
    assert bindings.codes_keys_iterator_next(iterator) == 1
    assert bindings.codes_keys_iterator_get_name(iterator) == 'dataTime'

    bindings.codes_keys_iterator_delete(iterator)
github ecmwf / cfgrib / tests / test_10_bindings.py View on Github external
def test_codes_keys_iterator():
    grib = bindings.codes_grib_new_from_file(open(TEST_DATA))

    iterator = bindings.codes_keys_iterator_new(grib)

    assert bindings.codes_keys_iterator_next(iterator) == 1
    assert bindings.codes_keys_iterator_get_name(iterator) == 'globalDomain'
    assert bindings.codes_keys_iterator_next(iterator) == 1
    assert bindings.codes_keys_iterator_get_name(iterator) == 'GRIBEditionNumber'

    bindings.codes_keys_iterator_delete(iterator)

    iterator = bindings.codes_keys_iterator_new(grib, namespace='time')

    assert bindings.codes_keys_iterator_next(iterator) == 1
    assert bindings.codes_keys_iterator_get_name(iterator) == 'dataDate'
    assert bindings.codes_keys_iterator_next(iterator) == 1
    assert bindings.codes_keys_iterator_get_name(iterator) == 'dataTime'

    bindings.codes_keys_iterator_delete(iterator)
github ecmwf / cfgrib / cfgrib / messages.py View on Github external
def message_grib_keys(self, namespace=None):
        # type: (str) -> T.Generator[str, None, None]
        iterator = eccodes.codes_keys_iterator_new(self.codes_id, namespace=namespace)
        while eccodes.codes_keys_iterator_next(iterator):
            yield eccodes.codes_keys_iterator_get_name(iterator)
        eccodes.codes_keys_iterator_delete(iterator)