Copyright | (c) Mattias Jakobsson 2015 |
---|---|
License | GPL-3 |
Maintainer | mjakob422@gmail.com |
Stability | unstable |
Portability | portable |
Safe Haskell | None |
Language | Haskell2010 |
Access GRIB header and data values.
Most of the documentation herein was copied from the official documentation of grib_api.
- gribGetLong :: GribHandle -> Key -> IO Int
- gribGetDouble :: GribHandle -> Key -> IO Double
- gribGetLongArray :: GribHandle -> Key -> Ptr CLong -> Int -> IO [Int]
- gribGetDoubleArray :: GribHandle -> Key -> Ptr CDouble -> Int -> IO [Double]
- gribGetDoubleElement :: GribHandle -> Key -> Int -> IO Double
- gribGetDoubleElements :: GribHandle -> Key -> [Int] -> IO [Double]
- gribGetString :: GribHandle -> Key -> CString -> Int -> IO String
- gribGetBytes :: GribHandle -> Key -> Bytes -> Int -> IO (Bytes, Int)
- gribGetOffset :: GribHandle -> Key -> IO Int
- gribGetSize :: GribHandle -> Key -> IO Int
- gribGetLength :: GribHandle -> Key -> IO Int
- gribSetLong :: GribHandle -> Key -> Int -> IO ()
- gribSetDouble :: GribHandle -> Key -> Double -> IO ()
- gribSetLongArray :: GribHandle -> Key -> [Int] -> IO ()
- gribSetDoubleArray :: GribHandle -> Key -> [Double] -> IO ()
- gribSetString :: GribHandle -> Key -> String -> IO Int
- gribSetBytes :: GribHandle -> Key -> Bytes -> Int -> IO Int
- gribCopyNamespace :: GribHandle -> Maybe String -> GribHandle -> IO ()
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.
:: 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; orisGribException 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.
:: 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; orisGribException 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.
:: 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; orisGribException 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.
:: 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; orisGribException 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; orisGribException 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; orisGribException 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; orisGribException 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; orisGribException 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; orisGribException 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
:: GribHandle | destination handle |
-> Maybe String | namespace (pass |
-> 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
.