hgrib-0.1.0.0: Unofficial bindings for GRIB API

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

Data.Grib.Raw.Value

Contents

Description

Access GRIB header and data values.

Most of the documentation herein was copied from the official documentation of grib_api.

Synopsis

Get values

gribGetLong :: GribHandle -> Key -> IO Int Source

Get a long value from a key, if several keys of the same name are present, the last one is returned.

This operation may fail with:

  • isGribException GribNotFound if the key is missing.

gribGetDouble :: GribHandle -> Key -> IO Double Source

Get a double value from a key, if several keys of the same name are present, the last one is returned.

This operation may fail with:

  • isGribException GribNotFound if the key is missing.

gribGetLongArray Source

Arguments

:: GribHandle

the handle to get the data from

-> Key

the key to be searched

-> Ptr CLong

the address of a long array where the data will be retrieved

-> Int

the allocated length of the long array

-> IO [Int]

an IO action that will return the data in a list

Get long array values from a key.

If several keys of the same name are present, the last one is returned.

This operation may fail with:

  • isGribException GribNotFound if the key is missing; or
  • isGribException GribArrayTooSmall if the allocated array is too small.

This function takes an allocated array and its length, which is used to retrieve the list returned by the IO action. The array is not automatically allocated by this function since it could potentially be re-used between multiple calls and the length is not known beforehand.

gribGetDoubleArray Source

Arguments

:: GribHandle

the handle to get the data from

-> Key

the key to be searched

-> Ptr CDouble

the address of a double array where the data will be retrieved

-> Int

the allocated length of the double array

-> IO [Double]

an IO action that will return the data in a list

Get double array values from a key.

If several keys of the same name are present, the last one is returned.

This operation may fail with:

  • isGribException GribNotFound if the key is missing; or
  • isGribException GribArrayTooSmall if the allocated array is too small.

This function takes an allocated array and its length, which is used to retrieve the list returned by the IO action. The array is not automatically allocated by this function since it could potentially be re-used between multiple calls and the length is not known beforehand.

gribGetDoubleElement :: GribHandle -> Key -> Int -> IO Double Source

Get as double the i-th element of the "key" array.

This operation may fail with:

  • isGribException GribNotFound if the key is missing.

WARNING! There is no check if the index is out of bounds.

gribGetDoubleElements :: GribHandle -> Key -> [Int] -> IO [Double] Source

Get as double array the elements of the "key" array whose indexes are listed in the input array i.

This operation may fail with:

  • isGribException GribNotFound if the key is missing.

WARNING! There is no check if the indices are out of bounds.

gribGetString Source

Arguments

:: GribHandle

the handle to get the data from

-> Key

the key to be searched

-> CString

the address of a string where the data will be retrieved

-> Int

the allocated length of the string

-> IO String

an IO action that will return the string

Get a string value from a key, if several keys of the same name are present, the last one is returned.

This operation may fail with:

  • isGribException GribNotFound if the key is missing; or
  • isGribException GribBufferTooSmall if the allocated string is too small.

This function takes an allocated CString and its length, which is used to retrieve the string returned by the IO action. The CString is not automatically allocated by this function since it could potentially be re-used between multiple calls and the length is not known beforehand.

gribGetBytes Source

Arguments

:: GribHandle

the handle to get the data from

-> Key

the key to be searched

-> Bytes

the address of a byte array where the data will be retrieved

-> Int

the allocated length of the byte array

-> IO (Bytes, Int)

an IO action that will return the address of the byte array and the number of bytes retrieved

Get raw bytes values from a key.

If several keys of the same name are present, the last one is returned.

This operation may fail with:

  • isGribException GribNotFound if the key is missing; or
  • isGribException GribArrayTooSmall if the allocated array is too small.

gribGetOffset :: GribHandle -> Key -> IO Int Source

Get the number offset of a key in a message if several keys of the same name are present, the offset of the last one is returned.

This operation may fail with:

  • isGribException GribNotFound if the key is missing.

gribGetSize :: GribHandle -> Key -> IO Int Source

Get the number of coded value from a key, if several keys of the same name are present, the total sum is returned.

This operation may fail with:

  • isGribException GribNotFound if the key is missing.

gribGetLength :: GribHandle -> Key -> IO Int Source

Get the length of the string representation of the key, if several keys of the same name are present, the maximum length is returned.

This operation may fail with:

  • isGribException GribNotFound if the key is missing.

Set values

gribSetLong :: GribHandle -> Key -> Int -> IO () Source

Set a long value from a key.

If several keys of the same name are present, the last one is set.

This operation may fail with:

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

gribSetDouble :: GribHandle -> Key -> Double -> IO () Source

Set a double value from a key.

If several keys of the same name are present, the last one is set.

This operation may fail with:

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

gribSetLongArray :: GribHandle -> Key -> [Int] -> IO () Source

Set a long array from a key.

If several keys of the same name are present, the last one is set.

This operation may fail with:

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

gribSetDoubleArray :: GribHandle -> Key -> [Double] -> IO () Source

Set a double array from a key.

If several keys of the same name are present, the last one is set.

This operation may fail with:

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

WARNING! Strange things seem to happen if an empty list is passed in.

gribSetString :: GribHandle -> Key -> String -> IO Int Source

Set a string value from a key and return the actual packed length.

If several keys of the same name are present, the last one is set.

This operation may fail with:

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

gribSetBytes :: GribHandle -> Key -> Bytes -> Int -> IO Int Source

Set a bytes array from a key and return the actual packed length.

If several keys of the same name are present, the last one is set.

This operation may fail with:

  • isGribException GribNotFound if the key is missing.

Copy values

gribCopyNamespace Source

Arguments

:: GribHandle

destination handle

-> Maybe String

namespace (pass Nothing to copy all keys)

-> GribHandle

source handle

-> IO ()

an IO action that will copy the keys

Copy the keys belonging to a given namespace from a source handle to a destination handle.

This operation may fail with:

  • isGribException GribNotImplemented.