Skip to content

Commit

Permalink
linePlot: use enumDouble, remove some helpers
Browse files Browse the repository at this point in the history
  • Loading branch information
kfish committed Nov 22, 2011
1 parent 2264435 commit d504292
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 18 deletions.
8 changes: 2 additions & 6 deletions Data/ZoomCache/Gnuplot.hs
Original file line number Diff line number Diff line change
Expand Up @@ -69,12 +69,8 @@ avgPlot zsums = Plot.list Graph.lines avgs

----------------------------------------------------------------------

linePlot :: [Packet] -> Plot.T Z.TimeStamp Double
linePlot = Plot.list Graph.lines . concat . map pToTD
where
pToTD (Packet _ _ _ _ pData pTS) = zip pTS $ extract pData
extract :: ZoomRaw -> [Double]
extract (ZoomRaw l) = mapMaybe cast l
linePlot :: [(Z.TimeStamp, Double)] -> Plot.T Z.TimeStamp Double
linePlot = Plot.list Graph.lines

----------------------------------------------------------------------

Expand Down
16 changes: 4 additions & 12 deletions tools/zoom-cache-gnuplot.hs
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,10 @@ import System.Console.GetOpt
import System.Environment (getArgs)
import System.Exit (exitWith)
import System.FilePath.Posix

import qualified Data.Iteratee as I
import Data.Iteratee (Iteratee(..), stream2stream, fileDriverRandom)
import Data.Iteratee.ZoomCache (Stream)
import Data.ZoomCache
import Data.ZoomCache.Numeric

import Data.ZoomCache.Gnuplot
import qualified Graphics.Gnuplot.Advanced as Plot
Expand Down Expand Up @@ -177,9 +176,9 @@ lineProcess :: (FilePath, TrackNo) -> IO (Plot.T TimeStamp Double)
lineProcess (fp, tn) = fileDriverRandom iter fp
where
iter :: Iteratee ByteString IO (Plot.T TimeStamp Double)
iter = I.joinI . (enumCacheFile standardIdentifiers) $ do
streams <- mapMaybe (isPacket tn) <$> stream2stream
return $ linePlot streams
iter = I.joinI . enumCacheFile standardIdentifiers $
(I.joinI . filterTracks [tn] .
I.joinI . enumDouble $ (linePlot <$> stream2stream))

isSumLvl :: TrackNo -> Int -> Stream -> Maybe ZoomSummary
isSumLvl tn lvl str =
Expand All @@ -188,13 +187,6 @@ isSumLvl tn lvl str =
StreamSummary _ tn' zsum@(ZoomSummary sum) ->
if tn == tn' && summaryLevel sum == lvl then Just zsum else Nothing

isPacket :: TrackNo -> Stream -> Maybe Packet
isPacket tn str =
case str of
StreamSummary{} -> Nothing
StreamPacket _ tn' p ->
if tn == tn' then Just p else Nothing

data UnrecognisedFormatException = UnrecognisedFormatException
deriving (Show, Typeable)

Expand Down

0 comments on commit d504292

Please sign in to comment.