Attachment 'HasKALnotebook.html'
DownloadHasKAL 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
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") |]
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)|]
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
In [ ]:
Attached Files
To refer to attachments on a page, use attachment:filename, as shown below in the list of files. Do NOT use the URL of the [get] link, since this is subject to change and can break easily.You are not allowed to attach a file to this page.