:ext QuasiQuotes
import qualified H.Prelude as H
H.initialize H.defaultConfig
let fname = "/home/kazu/work/data/gw150914/H-H1_LOSC_4_V1-1126259446-32.gwf"
let chname = "H1:LOSC-STRAIN"
import HasKAL.FrameUtils.Function (readFrameWaveData')
import HasKAL.DetectorUtils.Detector(Detector(..))
maybewave <- readFrameWaveData' General chname fname
import Data.Maybe (fromJust)
let x = fromJust maybewave
import HasKAL.WaveUtils.Data(WaveData(..))
import qualified Data.Vector.Storable as V
let y = V.toList $ gwdata x
print $ take 5 y
import HasKAL.TimeUtils.Signature
import HasKAL.TimeUtils.Function
import HasKAL.WaveUtils.Signature
let ylen = length y
t0 = deformatGPS $ startGPSTime x
fs = samplingFrequency x
dat = zip [t0,t0+1/fs..] y
tv = take (length y) [0,1/fs..] :: [Double]
[r| require("ggplot2") |]
[r| require("scales") |]
[rgraph|
Xv <- tv_hs
Yv <- y_hs
z <- data.frame (Xv,Yv)
p <- ggplot(z, aes(x = Xv, y = Yv)) + geom_line(color="red")
plabs <- p + labs(title = "GW150914", x = "time[s]", y = "strain")
black.bold.text <- element_text(size=20,face = "bold", color = "black")
pfin1 <- plabs + theme(title = black.bold.text
, axis.title = black.bold.text
, axis.text = black.bold.text
, axis.ticks.length = unit(.5, "cm")
, axis.ticks = element_line(size = 2))
pfin2 <- pfin1 + coord_cartesian(xlim = c(10,20), ylim = NULL)
yformatter <- function (x) {
ind <-floor(log10(x))
sprintf('%3.1E',x)
}
pfin <- pfin2 + scale_y_continuous(label=yformatter)
|]
[r|ggsave(file = "gw150914.png", plot = pfin, dpi = 100, width = 6.4, height = 4.8)|]
import HasKAL.SpectrumUtils.SpectrumUtils (gwpsdV,gwOnesidedPSDWaveData)
import HasKAL.SignalProcessingUtils.LinearPrediction (lpefCoeffV,whiteningWaveData')
import qualified Data.Vector.Storable as V
let p = 1000
nfft = floor fs
spec = gwpsdV (gwdata x) nfft fs
lpefc = lpefCoeffV p spec
whnx = whiteningWaveData' lpefc x
let whnspe = gwOnesidedPSDWaveData 1 whnx
freV = V.toList . fst $ whnspe
speV = V.toList . snd $ whnspe
return $ take 5 freV