Unofficial bindings for GRIB API https://github.com/mjakob/hgrib
|Latest on Hackage:||0.3.1.0|
This package is not currently in any snapshots. If you're interested in using it, we recommend adding it to Stackage Nightly. Doing so will make builds more reliable, and allow stackage.org to host generated Haddocks.
In this version of HGrib, a read-only monadic Haskell interface to GRIB API is provided. Raw bindings for the documented parts of GRIB API are also available. Future versions are intended to expand the higher-level Haskell interface to include, among other things, write support.
The following prerequisites are needed to build HGrib:
GRIB API >= 1.12 installed and discoverable by ghc (use cabal's
--extra-lib-dirsif it's installed at a custom location); and
Haskell base >= 4.5; and
c2hs == 0.26.*.
cabal install hgrib
HGrib provides a high-level monadic Haskell interface to GRIB API in
Data.Grib. An example of its usage is GRIB API's get.c
example re-written with HGrib:
import Control.Exception ( assert ) import Data.Grib import Text.Printf ( printf ) main :: IO () main = let filename = "test/stage/regular_latlon_surface.grib1" in runGribIO_ filename $ do setString "file" filename getLong "Ni" >>= liftIO . printf "numberOfPointsAlongAParallel=%d\n" getLong "Nj" >>= liftIO . printf "numberOfPointsAlongAMeridian=%d\n" getDouble "yFirst" >>= liftIO . printf "latitudeOfFirstGridPointInDegrees=%g\n" getDouble "xFirst" >>= liftIO . printf "longitudeOfFirstGridPointInDegrees=%g\n" getDouble "yLast" >>= liftIO . printf "latitudeOfLastGridPointInDegrees=%g\n" getDouble "xLast" >>= liftIO . printf "longitudeOfLastGridPointInDegrees=%g\n" getDouble "DyInDegrees" >>= liftIO . printf "jDirectionIncrementInDegrees=%g\n" getDouble "DxInDegrees" >>= liftIO . printf "iDirectionIncrementInDegrees=%g\n" getString "packingType" >>= liftIO . printf "packingType=%s\n" values <- getValues let numValues = length values average = sum values / fromIntegral numValues liftIO $ printf "There are %d values, average is %g\n" numValues average filename' <- getString "file" liftIO $ assert (filename' == filename) (return ())
Raw bindings for the documented part of GRIB API is also
Data.Grib.Raw. To be able to work with these bindings,
bindings for C's
fopen is provided in
is re-exported by
For more information, see HGrib's [reference documentation][HGrib Docs] generated by Haddock.
Issues, feature and pull requests are most welcome! In particular, please give suggestions on what you would like to see in the higher-level interface and let me know if there is any undocumented part of GRIB API that you would like to have included.
HGrib was created and is currently maintained by Mattias Jakobsson. It is released under the GNU General Public License v3.0. ECMWF's GRIB API is released under the Apache license. HGrib is in no way associated with ECMWF or the original library.
HGrib Change Log
Data.Grib, three functions to easily skip unwanted GRIB messages in a file.
Data.Grib, which is a higher-level abstraction for reading GRIB files over the raw bindings in
Data.Grib.Rawno longer re-exports the
Exceptionmodule mentioned above.
Maybe GribHandleinstead of a plain
Nothingis returned if no more messages could be read from the given stream.
Re-organized the test utility modules.
Data.Grib.Raw.Marshalfrom other to exposed modules, but it should still be considered an internal module and it is not included in the documentation.
Extended the compatible version range of GRIB API and the Haskell base library.
Data.Grib.Rawand removed the marshal function
and corresponding foreign function type definitions from
Data.Grib.Rawto be able to mark all remaining functions unsafe from a FFI perspective.
Marked all foreign imports unsafe.
Integrated the source code repository with Travis CI.
Abandoned the plans to include the full GRIB API in
grib_api.h(but requests to include specific parts are welcome).