habsim-0.1.0.0: High Altitude Balloon flight path simulator

Copyright(C) 2017 Ricky Elrod
License(see project LICENSE file)
MaintainerRicky Elrod <ricky@elrod.me>
Stabilityexperimental
Safe HaskellNone
LanguageHaskell2010

Data.HABSim.Grib2.CSVParse

Contents

Description

This module provides utilities for parsing and filtering data from a wgrib2-generated CSV file. Once the CSV files is generated, it can be parsed and filtered in the following way (preferably with better error handling):

  myCsv <- readFile "/path/to/csv.csv"
  case decodeGrib myCsv of
    Left str -> error str
    Right gribLines ->
      case filterGrib 38.8977 (-77.0365) 950 gribLines of
        Nothing -> error "No entry found"
        Just wh -> print wh

Synopsis

Documentation

gribLineToRaw :: GribLine -> RawGribLine #

Given any kind of GridLine (usually either a UGRDGribLine or a VGRDGribLine, but could also be an OtherGribLine), pull the raw Grib line out of it.

Keyed/HashMap-based Grib data

decodeKeyedGrib :: ByteString -> Either String (Vector KeyedGribLine) #

A helper function that primarily exists just to help type inference.

decodeKeyedGrib = decode NoHeader (where decode and NoHeader both come from Cassava).

keyedGribToHM :: Vector KeyedGribLine -> HashMap Key GribLine #

Convert a Vector of KeyedGribLine into a HashMap keyed on the latitude longitude, pressure, and direction of the grib line.

filterKeyedGrib #

Arguments

:: Latitude 
-> Longitude 
-> Int

Pressure

-> Direction

The Direction to filter for.

-> HashMap Key GribLine

Input lines

-> Maybe GribLine

Output line

Filter Grib lines from a Vector GribLine. If we for some reason don't have both UGRD and VGRD of our filter result, then we return Nothing. Otherwise we return a GribPair containing both.