hgrib-0.3.1.0: Unofficial bindings for GRIB API

Copyright(c) Mattias Jakobsson 2015
LicenseGPL-3
Maintainermjakob422@gmail.com
Stabilityunstable
Portabilityportable
Safe HaskellNone
LanguageHaskell2010

Data.Grib

Contents

Description

 

Synopsis

The GRIB Monad

type GribIO = ReaderT GribEnv IO Source

The GribIO monad is a ReaderT monad transformer over the IO monad with a GribEnv environment.

runGribIO Source

Arguments

:: FilePath

a path to a GRIB file

-> GribIO a

an action to take on each GRIB message in the file

-> IO [a]

the results of the actions

Run an action on each GRIB message in a file and collect the results.

This operation may fail with:

runGribIO_ :: FilePath -> GribIO a -> IO () Source

Like runGribIO, but discard the results.

skipMessage :: GribIO a Source

Skip the current GRIB message. No result will be put in the output list of runGribIO for this message.

skipMessageIf Source

Arguments

:: (a -> Bool)

a predicate that will be given the result of the action

-> GribIO a

an action to perform

-> GribIO a 

Skip the current GRIB message if the predicate is true. No result will be put in the output list of runGribIO in this case.

skipMessageIf_ :: (a -> Bool) -> GribIO a -> GribIO () Source

Like skipMessageIf, but discard the result of the action.

Examples

Sum all grid points of the first vertical level in a GRIB message:

runGribIO "test/stage/test_uuid.grib2" $ do
  skipMessageIf_ (/= 1) $ getLong "topLevel"
  fmap sum getValues

Get values

These operations may fail with:

  • isGribException GribNotFound if the key is missing.

getDouble :: Key -> GribIO Double Source

Get the value for a key as a float.

getLong :: Key -> GribIO Int Source

Get the value for a key as an integer.

getString :: Key -> GribIO String Source

Get the value for a key as a string.

getValues :: GribIO [Double] Source

Get the data values of the GRIB message as floats.

Set values

These operations may fail with:

  • isGribException GribNotFound if the key is missing; or
  • isGribException GribReadOnly if the key is read-only.

setDouble :: Key -> Double -> GribIO () Source

Set the value of a key from a float.

setLong :: Key -> Int -> GribIO () Source

Set the value of a key from an integer.

setString :: Key -> String -> GribIO () Source

Set the value of a key from a string.

setValues :: [Double] -> GribIO () Source

Set the values of the GRIB message from floats.

Utilities

getFilename :: GribIO FilePath Source

Return the name of the file being read.

getIndex :: GribIO Int Source

Return the zero-based index of the current message in the file.

getHandle :: GribIO GribHandle Source

Return the current GribHandle for use with the Raw GRIB API bindings.

liftIO :: MonadIO m => forall a. IO a -> m a

Lift a computation from the IO monad.

Auxiliary types

data GribEnv Source

The reader environment of GribIO containing the current filename, a GribHandle, and its index in the file.

data SkipMessage Source

If this exception is raised in GribIO, the message will be discarded. Normally, you simply call skipMessage instead of throwing this exception manually.