How to read Cache file and Time Series Data

Cache file direction

[detchar@k1det1~]$ cd /home/detchar/Cache
[detchar@k1det1 Cache]$ ls
 K1-Cache.cache  mkCache.py  nohup.out

>>> /home/detchar/Cache/K1-Cache.cache

[user@seikai~]$ cd /home/detchar/Cache/ikagra_cache/
[user@seikai ikagra_cache]$ ls
 ikagra_cachefile.cache  mkCache.py

>>> /home/detchar/Cache/ikagra_cache/ikagra_cachefile.cache

Read Cache file

   1 from glue.lal import Cache
   2 
   3 gwf_cache = '/home/detchar/Cache/K1-Cache.cache'        # Specify 'Cache file path' here
   4 
   5 with open(gwf_cache, 'r') as fobj:                      # Read the cache file using glue.lal
   6     cache = Cache.fromfile(fobj)
   7 
   8 type(cache)                                             # type of cache is glue.lal.Cache
   9 glue.lal.Cache
  10 
  11 cache                                                   # Contants of cache
  12 [<glue.lal.CacheEntry at 0x7f8004092050>,
  13  <glue.lal.CacheEntry at 0x7f8004092110>,
  14    .
  15    .
  16    .
  17  <glue.lal.CacheEntry at 0x7f7fce88a850>,
  18  <glue.lal.CacheEntry at 0x7f7fce88a910>,
  19  ...]

Read Time Series Data

   1 import os                                               # os and sys modules are required to load gwf file using cache
   2 import sys
   3 from gwpy.timeseries import TimeSeries 
   4 
   5 ch = 'K1:LSC-MICH_CTRL_CAL_OUT_DQ'                      # Specify 'Channel Name' by string type
   6 gst = 1199756064.0                                      # Specify 'GPS start time' by float or integer type
   7 get = 1199756064.0 + 600                                # Specify 'GPS end time' by float or integer type
   8 
   9 data = TimeSeries.read(cache, ch , gst, get, format='lalframe')
  10 
  11 data                                                    # Contants of TimeSeries data
  12 <TimeSeries([-1668.97692871,-1668.96069336,-1668.91088867,...,
  13              -1872.98059082,-1872.9979248 ,-1873.01257324]
  14             unit=Unit("V"),
  15             t0=<Quantity 1199756064.0 s>,
  16             dt=<Quantity 6.103515625e-05 s>,
  17             name='K1:LSC-MICH_CTRL_CAL_OUT_DQ',
  18             channel=<Channel("K1:LSC-MICH_CTRL_CAL_OUT_DQ", 16384.0 Hz) at 0x104cd050>)>

Save Plot

If you want to save plot, please import the following modules. Because GUI is not supported.

   1 import numpy as np
   2 import matplotlib
   3 matplotlib.use('agg')                                    # This code is required because GUI is not supported.

KAGRA/Subgroups/DET/gwpy/howread (last edited 2018-01-19 20:08:15 by PJJung)