HTTPConnection

class gwdatafind.HTTPConnection(host=None, port=None, timeout=<object object>, source_address=None, **kwargs)

Bases: http.client.HTTPConnection

Connect to a GWDataFind host using HTTP.

Parameters
  • host (str) – the name of the server with which to connect.

  • port (int, optional) – the port on which to connect.

  • **kwargs – other keywords are passed directly to http.client.HTTPConnection

Methods Summary

find_frame(*args, **kwargs)

DEPRECATED, use find_url() instead.

find_frame_urls(*args, **kwargs)

DEPRECATED, use find_urls() instead.

find_latest(site, frametype[, urltype, ...])

Query for the most recent file of a given type.

find_observatories([match])

Query the LDR host for observatories.

find_times(site, frametype[, gpsstart, gpsend])

Query the LDR for times for which files are avaliable.

find_types([site, match])

Query the LDR host for frame types.

find_url(framefile[, urltype, on_missing])

Query the LDR host for a single filename.

find_urls(site, frametype, gpsstart, gpsend)

Find all files of the given type in the [start, end) GPS interval.

get_json(url, **kwargs)

Perform a 'GET' request and return the decode the result as JSON

get_urls(url[, scheme, on_missing])

Perform a 'GET' request and return a list of URLs.

ping()

Ping the LDR host to test for life.

Methods Documentation

find_frame(*args, **kwargs)

DEPRECATED, use find_url() instead.

find_frame_urls(*args, **kwargs)

DEPRECATED, use find_urls() instead.

find_latest(site, frametype, urltype='file', on_missing='error')

Query for the most recent file of a given type.

Parameters
  • site (str) – single-character name of site to match

  • frametype (str) – name of frametype to match

  • urltype (str, optional) – file scheme to search for, one of ‘file’, ‘gsiftp’, or None, default: ‘file’

  • on_missing (str, optional) –

    what to do when the requested frame isn’t found, one of:

    • 'warn' print a warning (default), or

    • 'error': raise a RuntimeError, or

    • 'ignore': do nothing

Returns

latest (list with one str) – the URLs of the latest file found (all file types)

Raises

RuntimeError – if no frames are found

find_observatories(match=None)

Query the LDR host for observatories.

Parameters

match (str, re.Pattern) – restrict returned observatories to those matching a regular expression.

Returns

obs (list of str) – the list of known osbervatory prefices (and combinations)

Examples

>>> from gwdatafind import connect
>>> conn = connect()
>>> conn.find_observatories()
['AGHLT', 'G', 'GHLTV', 'GHLV', 'GHT', 'H', 'HL', 'HLT',
 'L', 'T', 'V', 'Z']
>>> conn.find_observatories("H")
['H', 'HL', 'HLT']
find_times(site, frametype, gpsstart=None, gpsend=None)

Query the LDR for times for which files are avaliable.

Parameters
  • site (str) – single-character name of site to match

  • frametype (str) – name of frametype to match

  • start (int) – GPS start time of query

  • end (int) – GPS end time of query

Returns

segments (ligo.segments.segmentlist) – the list of [start, stop) intervals for which files are available.

find_types(site=None, match=None)

Query the LDR host for frame types.

Parameters
  • site (str) – single-character name of site to match

  • match (str, re.Pattern) – regular expression to match against known types

Returns

types (list of str) – list of frame types

Examples

>>> from gwdatafind import connect
>>> conn = connect()
>>> conn.find_types("L", "RDS")
['L1_RDS_C01_LX',
 'L1_RDS_C02_LX',
 'L1_RDS_C03_L2',
 'L1_RDS_R_L1',
 'L1_RDS_R_L3',
 'L1_RDS_R_L4',
 'PEM_RDS_A6',
 'RDS_R_L1',
 'RDS_R_L2',
 'RDS_R_L3',
 'TESTPEM_RDS_A6']
find_url(framefile, urltype='file', on_missing='error')

Query the LDR host for a single filename.

Parameters
  • frametype (str) – name of frametype to match

  • urltype (str, optional) – file scheme to search for, one of 'file', 'gsiftp', or None, default: ‘file’

  • on_missing (str) –

    what to do when the requested file isn’t found, one of:

    • 'warn': print a warning (default),

    • 'error': raise a RuntimeError, or

    • 'ignore': do nothing

Returns

urls (list of str) – a list of structured file paths for all instances of filename.

find_urls(site, frametype, gpsstart, gpsend, match=None, urltype='file', on_gaps='warn')

Find all files of the given type in the [start, end) GPS interval.

sitestr

single-character name of site to match

frametypestr

name of frametype to match

gpsstartint

integer GPS start time of query

gpsendint

integer GPS end time of query

matchstr, re.Pattern, optional

regular expression to match against

urltypestr, optional

file scheme to search for, one of ‘file’, ‘gsiftp’, or None, default: ‘file’

on_gapsstr, optional

what to do when the requested frame isn’t found, one of:

  • 'warn' print a warning (default), or

  • 'error': raise a RuntimeError, or

  • 'ignore': do nothing

Returns

cache (list of str) – the list of discovered file URLs

get_json(url, **kwargs)

Perform a ‘GET’ request and return the decode the result as JSON

Parameters
  • url (str) – remote URL to query

  • **kwargs – other keyword arguments are passed to HTTPConnection._request_response()

Returns

data (object) – JSON decoded using json.loads()

get_urls(url, scheme=None, on_missing='ignore', **kwargs)

Perform a ‘GET’ request and return a list of URLs.

Parameters
  • url (str) – remote URL to query

  • scheme (str, None, optional) – the URL scheme to match, default: None

  • on_missing (str, optional) –

    how to handle an empty (but successful) response, one of

    • 'ignore': do nothing, return empty list

    • 'warn': print warning, return empty list

    • 'raise': raise RuntimeError

  • **kwargs – other keyword arguments are passed to HTTPConnection.get_json()

Returns

urls (list of str) – a list of file paths as returned from the server.

ping()

Ping the LDR host to test for life.

Raises

RuntimeError – if the ping fails