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 aRuntimeError
, or'ignore'
: do nothing
Returns: Raises: - RuntimeError
if no frames are found
- site :
-
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: 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']
- match :
-
find_times
(site, frametype, gpsstart=None, gpsend=None)¶ Query the LDR for times for which files are avaliable.
Parameters: Returns: - segments :
ligo.segments.segmentlist
the list of
[start, stop)
intervals for which files are available.
- segments :
-
find_types
(site=None, match=None)¶ Query the LDR host for frame types.
Parameters: Returns: 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'
, orNone
, default: ‘file’- on_missing :
str
what to do when the requested file isn’t found, one of:
'warn'
: print a warning (default),'error'
: raise aRuntimeError
, or'ignore'
: do nothing
Returns: - frametype :
-
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.
- site :
str
- single-character name of site to match
- frametype :
str
- name of frametype to match
- gpsstart :
int
- integer GPS start time of query
- gpsend :
int
- integer GPS end time of query
- match :
str
,re.Pattern
, optional - regular expression to match against
- urltype :
str
, optional - file scheme to search for, one of ‘file’, ‘gsiftp’, or
None
, default: ‘file’ - on_gaps :
str
, optional what to do when the requested frame isn’t found, one of:
'warn'
print a warning (default), or'error'
: raise aRuntimeError
, or'ignore'
: do nothing
Returns: - site :
-
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()
- url :
-
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 emptylist
'warn'
: print warning, return emptylist
'raise'
: raiseRuntimeError
- **kwargs
other keyword arguments are passed to
HTTPConnection.get_json()
Returns: - url :
-
ping
()¶ Ping the LDR host to test for life.
Raises: - RuntimeError
if the ping fails
- host :