-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathResampling.hs
More file actions
44 lines (31 loc) · 1.19 KB
/
Resampling.hs
File metadata and controls
44 lines (31 loc) · 1.19 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
module Resampling
( downsample
, upsample
, resample
, downsampleWaveData
) where
import HasKAL.SignalProcessingUtils.FilterH
import HasKAL.SignalProcessingUtils.FilterType
import HasKAL.SignalProcessingUtils.ButterWorth
import HasKAL.TimeUtils.Function
import HasKAL.WaveUtils.Data
import Numeric.LinearAlgebra
downsample :: Double -> Double -> [Double] -> [Double]
downsample fs newfs x = y
where y = snd.unzip $ filter (\(n, _) -> n `mod` p==1) $ zip [1..] x'
p = truncate (fs/newfs)
x' = iir_df2 lpf x
lpf = butter 2 fs (newfs/2) Low
upsample :: Double -> Double -> [Double] -> [Double]
upsample fs newfs x = undefined
resample :: Double -> Double -> [Double] -> [Double]
resample fs newfs x = undefined
downsampleWaveData :: Double -> WaveData -> WaveData
downsampleWaveData newfs x = y
where y = x
samplingFrequency y = newfs
gwdata y = fromList $ snd.unzip $ filter (\(n, _) -> n `mod` p==1) $ zip [1..] gwx'
p = truncate ((samplingFrequency x)/newfs)
gwx' = iir_df2 lpf $ toList (gwdata x)
lpf = butter 2 newfs (newfs/2) Low
stopGPSTime y = formatGPS $ deformatGPS (startGPSTime x) + 1/newfs*fromIntegral (dim (gwdata x))