Package pylal :: Module frutils :: Class FrameCache
[hide private]
[frames] | no frames]

Class FrameCache

source code

object --+
         |
        FrameCache


FrameCache is a transparent interface to LSC data. The user provides a LAL-
formatted cache file and the returned FrameCache object allows repeated
queries for channels and time, even across frame files. It also supports
smart, lazy local caching. Limitations: It only works for one-dimensional
time-series data.

Constructor:
    FrameCache(cache_entries=None, scratchdir=None, verbose=False)

Inputs:
    cache is a list of glue.lal.CacheEntry objects or a glue.lal.Cache.
    Data will be retrieved from the frame files described within.

    Scratchdir determines where to locally cache frames.  If None, no
    caching is performed.

Example:
>>> from glue import lal
>>> from pylal import frutils
>>> c = lal.Cache.fromfile(open("test.cache"))
>>> d = frutils.FrameCache(c, scratchdir="/tmp", verbose=True)
>>> data = d.fetch("H1:LSC-STRAIN", 861417967, 861417969)
Copying /Users/nvf/temp/H-H1_RDS_C03_L2-861417967-128.gwf -->
          /tmp/H-H1_RDS_C03_L2-861417967-128.gwf.
>>> print(data)
[  1.68448009e-16   1.69713183e-16   1.71046196e-16 ...,   1.80974629e-16
   1.80911765e-16   1.80804879e-16] {'dt': 6.103515625e-05, 'segments': [segment(861417967, 861417969)], 'comments': [], 'name': 'H1:LSC-STRAIN'}
>>> exit()
Removing /tmp/H-H1_RDS_C03_L2-861417967-128.gwf.

Instance Methods [hide private]
 
__init__(self, cache_entries=None, scratchdir=None, verbose=False)
Initializes interface to frame data.
source code
 
add_cache(self, cache_entries)
Add information from some cache entries.
source code
 
__del__(self)
Clear cache in local scratch.
source code
 
fetch(self, channel, start, end)
Retrieve data, caching file locations and the files themselves.
source code
 
_query(self, channel, start, end)
Do we know where the frame file is?
source code
 
_fetch(self, channel, start, end, comments=[])
Internal method to actually retrieve and return data as TimeSeries, assuming that self._framefiles is all set.
source code
 
unfetch(self, start, end)
Removes files from local scratch space based on start, end pairs.
source code
 
_unfetch(self, filename, seg)
Internal method to actually remove a file from cache.
source code

Inherited from object: __delattr__, __format__, __getattribute__, __hash__, __new__, __reduce__, __reduce_ex__, __repr__, __setattr__, __sizeof__, __str__, __subclasshook__

Properties [hide private]

Inherited from object: __class__

Method Details [hide private]

__init__(self, cache_entries=None, scratchdir=None, verbose=False)
(Constructor)

source code 

Initializes interface to frame data. See .__class__.__doc__

Overrides: object.__init__

_fetch(self, channel, start, end, comments=[])

source code 

Internal method to actually retrieve and return data as TimeSeries, assuming that self._framefiles is all set. Does not check boundaries.

unfetch(self, start, end)

source code 

Removes files from local scratch space based on start, end pairs. Silently ignores non-existent times. Remove if file end is between start and end. This is biased to prevent cache misses for future fetches being in the future. (Processing frames in chronological order)