HasKAL Programming Interface

In [2]:
:ext QuasiQuotes
In [3]:
import qualified H.Prelude as H
H.initialize H.defaultConfig

In [4]:
let fname = "/home/kazu/work/data/gw150914/H-H1_LOSC_4_V1-1126259446-32.gwf"
let chname = "H1:LOSC-STRAIN"
In [5]:
import HasKAL.FrameUtils.Function (readFrameWaveData')
import HasKAL.DetectorUtils.Detector(Detector(..))
In [6]:
maybewave <- readFrameWaveData' General chname fname

In [7]:
import Data.Maybe (fromJust)
let x = fromJust maybewave
In [8]:
import HasKAL.WaveUtils.Data(WaveData(..))
import qualified Data.Vector.Storable as V
let y = V.toList $ gwdata x
print $ take 5 y
[2.263866304639571e-19,2.4506253852248475e-19,2.607349243822363e-19,2.395651992756503e-19,2.358857603350546e-19]
In [9]:
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]
In [10]:
[r| require("ggplot2") |]
[r| require("scales") |]
0x00007fcbe8003338
0x00007fcbe8003338
In [11]:
[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)
  |]
In [12]:
[r|ggsave(file = "gw150914.png", plot = pfin, dpi = 100, width = 6.4, height = 4.8)|]
0x00007fcbe8002b98
In [13]:
import HasKAL.SpectrumUtils.SpectrumUtils (gwpsdV,gwOnesidedPSDWaveData)
import HasKAL.SignalProcessingUtils.LinearPrediction (lpefCoeffV,whiteningWaveData')
import qualified Data.Vector.Storable as V
In [14]:
let p = 1000
    nfft = floor fs
    spec = gwpsdV (gwdata x) nfft fs
    lpefc = lpefCoeffV p spec
    whnx = whiteningWaveData' lpefc x
In [18]:
let whnspe = gwOnesidedPSDWaveData 1 whnx
    freV = V.toList . fst $ whnspe
    speV = V.toList . snd $ whnspe
return $ take 5 freV
[0.0,1.0,2.0,3.0,4.0]
In [ ]: