Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

linePlot: use enumDouble, remove some helpers

  • Loading branch information...
commit d504292660e0d94f454b6a9b3771691b334a2bad 1 parent 2264435
Conrad Parker authored

Showing 2 changed files with 6 additions and 18 deletions. Show diff stats Hide diff stats

  1. +2 6 Data/ZoomCache/Gnuplot.hs
  2. +4 12 tools/zoom-cache-gnuplot.hs
8 Data/ZoomCache/Gnuplot.hs
@@ -69,12 +69,8 @@ avgPlot zsums = Plot.list Graph.lines avgs
69 69
70 70 ----------------------------------------------------------------------
71 71
72   -linePlot :: [Packet] -> Plot.T Z.TimeStamp Double
73   -linePlot = Plot.list Graph.lines . concat . map pToTD
74   - where
75   - pToTD (Packet _ _ _ _ pData pTS) = zip pTS $ extract pData
76   - extract :: ZoomRaw -> [Double]
77   - extract (ZoomRaw l) = mapMaybe cast l
  72 +linePlot :: [(Z.TimeStamp, Double)] -> Plot.T Z.TimeStamp Double
  73 +linePlot = Plot.list Graph.lines
78 74
79 75 ----------------------------------------------------------------------
80 76
16 tools/zoom-cache-gnuplot.hs
@@ -15,11 +15,10 @@ import System.Console.GetOpt
15 15 import System.Environment (getArgs)
16 16 import System.Exit (exitWith)
17 17 import System.FilePath.Posix
18   -
19 18 import qualified Data.Iteratee as I
20 19 import Data.Iteratee (Iteratee(..), stream2stream, fileDriverRandom)
21 20 import Data.Iteratee.ZoomCache (Stream)
22   -import Data.ZoomCache
  21 +import Data.ZoomCache.Numeric
23 22
24 23 import Data.ZoomCache.Gnuplot
25 24 import qualified Graphics.Gnuplot.Advanced as Plot
@@ -177,9 +176,9 @@ lineProcess :: (FilePath, TrackNo) -> IO (Plot.T TimeStamp Double)
177 176 lineProcess (fp, tn) = fileDriverRandom iter fp
178 177 where
179 178 iter :: Iteratee ByteString IO (Plot.T TimeStamp Double)
180   - iter = I.joinI . (enumCacheFile standardIdentifiers) $ do
181   - streams <- mapMaybe (isPacket tn) <$> stream2stream
182   - return $ linePlot streams
  179 + iter = I.joinI . enumCacheFile standardIdentifiers $
  180 + (I.joinI . filterTracks [tn] .
  181 + I.joinI . enumDouble $ (linePlot <$> stream2stream))
183 182
184 183 isSumLvl :: TrackNo -> Int -> Stream -> Maybe ZoomSummary
185 184 isSumLvl tn lvl str =
@@ -188,13 +187,6 @@ isSumLvl tn lvl str =
188 187 StreamSummary _ tn' zsum@(ZoomSummary sum) ->
189 188 if tn == tn' && summaryLevel sum == lvl then Just zsum else Nothing
190 189
191   -isPacket :: TrackNo -> Stream -> Maybe Packet
192   -isPacket tn str =
193   - case str of
194   - StreamSummary{} -> Nothing
195   - StreamPacket _ tn' p ->
196   - if tn == tn' then Just p else Nothing
197   -
198 190 data UnrecognisedFormatException = UnrecognisedFormatException
199 191 deriving (Show, Typeable)
200 192

0 comments on commit d504292

Please sign in to comment.
Something went wrong with that request. Please try again.