Cache

class gwdatafind.io.Cache(items)

Bases: list

Formatted list of URIs.

Parameters:

items (list of str) – A list of URIs (str).

Returns:

cache (Cache) – A new Cache where each element is a LalCacheEntry representing a data source URI.

Attributes Summary

basenames

The list of URI base names (file name component only).

names

The list of URI names (full path without URI scheme or host).

segments

The igwn_segments.segmentlist of data covered by this cache.

urls

The list of URIs in this Cache.

Methods Summary

write(output[, format])

Write this Cache in the given format.

Attributes Documentation

basenames

The list of URI base names (file name component only).

names

The list of URI names (full path without URI scheme or host).

segments

The igwn_segments.segmentlist of data covered by this cache.

urls

The list of URIs in this Cache.

Methods Documentation

write(output, format='lal')

Write this Cache in the given format.

Parameters:
  • output (str, pathlib.Path, file) – The target filename or path, or an open IO stream to write to.

  • format (str, optional) –

    The desired format of the cache file. Choose one of

    "lal"

    The LIGO Algorithm Library format, with one line per file in the format:

    <obs> <tag> <GPS-start> <duration> <url>
    
    "omega"

    The Omega pipeline format, with one line per contiguous directory in the format

    <obs> <tag> <dir-start> <dir-end> <file-duration> <directory>
    
    "urls"

    A list of URLS, one per line.

    "names"

    A list of paths (without a URL scheme), one per line.

    "basenames"

    A list of file basenames (without any paths), one per line.

Examples

>>> urls = find_urls(
...     "L",
...     "L1_GWOSC_O2_4KHZ_R1",
...     1187008880,
...     1187008884,
...     host="datafind.gwosc.org",
...     urltype="osdf",
... )
>>> cache = Cache(urls)
>>> cache.write(sys.stdout)
L L1_GWOSC_O2_4KHZ_R1 1187008512 4096 osdf:///gwdata/O2/strain.4k/frame.v1/L1/1186988032/L-L1_GWOSC_O2_4KHZ_R1-1187008512-4096.gwf
>>> cache.write(sys.stdout, format="basenames")
L-L1_GWOSC_O2_4KHZ_R1-1187008512-4096.gwf