pycbc.frame package
Submodules
pycbc.frame.frame module
This modules contains functions for reading in data from frame files or caches
- class pycbc.frame.frame.DataBuffer(frame_src, channel_name, start_time, max_buffer=2048, force_update_cache=True, increment_update_cache=None, dtype=<class 'numpy.float64'>)[source]
Bases:
object
A linear buffer that acts as a FILO for reading in frame data
- advance(blocksize)[source]
Add blocksize seconds more to the buffer, push blocksize seconds from the beginning.
- Parameters:
blocksize (int) – The number of seconds to attempt to read from the channel
- attempt_advance(blocksize, timeout=10)[source]
Attempt to advance the frame buffer. Retry upon failure, except if the frame file is beyond the timeout limit.
- Parameters:
blocksize (int) – The number of seconds to attempt to read from the channel
timeout ({int, 10}, Optional) – Number of seconds before giving up on reading a frame
- Returns:
data – TimeSeries containg ‘blocksize’ seconds of frame data
- Return type:
- null_advance(blocksize)[source]
Advance and insert zeros
- Parameters:
blocksize (int) – The number of seconds to attempt to read from the channel
- update_cache()[source]
Reset the lal cache. This can be used to update the cache if the result may change due to more files being added to the filesystem, for example.
- update_cache_by_increment(blocksize)[source]
Update the internal cache by starting from the first frame and incrementing.
Guess the next frame file name by incrementing from the first found one. This allows a pattern to be used for the GPS folder of the file, which is indicated by GPSX where x is the number of digits to use.
- Parameters:
blocksize (int) – Number of seconds to increment the next frame file.
- class pycbc.frame.frame.StatusBuffer(frame_src, channel_name, start_time, max_buffer=2048, valid_mask=3, force_update_cache=False, increment_update_cache=None, valid_on_zero=False)[source]
Bases:
DataBuffer
Read state vector or DQ information from a frame file
- advance(blocksize)[source]
Add blocksize seconds more to the buffer, push blocksize seconds from the beginning.
- Parameters:
blocksize (int) – The number of seconds to attempt to read from the channel
- Returns:
status – Returns True if all of the status information if valid, False if any is not.
- Return type:
boolean
- check_valid(values, flag=None)[source]
Check if the data contains any non-valid status information
- Parameters:
values (pycbc.types.Array) – Array of status information
flag (str, optional) – Override the default valid mask with a user defined mask.
- Returns:
status –
- Returns True if all of the status information if valid,
False if any is not.
- Return type:
boolean
- indices_of_flag(start_time, duration, times, padding=0)[source]
Return the indices of the times lying in the flagged region
- Parameters:
- Returns:
indices (numpy.ndarray) – Array of indices marking the location of triggers within valid
time.
- pycbc.frame.frame.frame_paths(frame_type, start_time, end_time, server=None, url_type='file', site=None)[source]
Return the paths to a span of frame files.
- Parameters:
frame_type (string) – The string representation of the frame type (ex. ‘H1_ER_C00_L1’).
start_time (int) – The start time that we need the frames to span.
end_time (int) – The end time that we need the frames to span.
server ({None, SERVER:PORT string}, optional) – Optional string to specify the datafind server to use. By default an attempt is made to use a local datafind server.
url_type (string) – Returns only frame URLs with a particular scheme or head such as “file” or “https”. Default is “file”, which queries locally stored frames. Option can be disabled if set to None.
site (string, optional) – One-letter string specifying which site you want data from (H, L, V, etc). If not given, the site is assumed to be the first letter of frame_type, which is usually (but not always) a safe assumption.
- Returns:
paths – The list of paths to the frame files.
- Return type:
list of paths
Examples
>>> paths = frame_paths('H1_LDAS_C02_L2', 968995968, 968995968+2048)
- class pycbc.frame.frame.iDQBuffer(frame_src, idq_channel_name, idq_status_channel_name, idq_threshold, start_time, max_buffer=512, force_update_cache=False, increment_update_cache=None)[source]
Bases:
object
Read iDQ timeseries from a frame file
- advance(blocksize)[source]
Add blocksize seconds more to the buffer, push blocksize seconds from the beginning.
- Parameters:
blocksize (int) – The number of seconds to attempt to read
- Returns:
status – Returns True if advance is succesful, False if not.
- Return type:
boolean
- pycbc.frame.frame.locations_to_cache(locations, latest=False)[source]
Return a cumulative cache file build from the list of locations
- Parameters:
locations (list) – A list of strings containing files, globs, or cache files used to build a combined lal cache file object.
latest (Optional, {False, Boolean}) – Only return a cache with the most recent frame in the locations. If false, all results are returned.
- Returns:
cache – A cumulative lal cache object containing the files derived from the list of locations.
- Return type:
lal.Cache
- pycbc.frame.frame.query_and_read_frame(frame_type, channels, start_time, end_time, sieve=None, check_integrity=False)[source]
Read time series from frame data.
Query for the location of physical frames matching the frame type. Return a time series containing the channel between the given start and end times.
- Parameters:
frame_type (string) – The type of frame file that we are looking for. The string should begin with S: or SN:, in which case S is taken as the site to query. If this is not the case, the site will be guessed from the channel name or from the type in a different way, which may not work.
channels (string or list of strings) – Either a string that contains the channel name or a list of channel name strings.
start_time (LIGOTimeGPS or int) – The gps start time of the time series. Defaults to reading from the beginning of the available frame(s).
end_time (LIGOTimeGPS or int) – The gps end time of the time series. Defaults to the end of the frame.
sieve (string, optional) – Selects only frames where the frame URL matches the regular expression sieve
check_integrity (boolean) – Do an expensive checksum of the file before returning.
- Returns:
Frame Data – A TimeSeries or a list of TimeSeries, corresponding to the data from the frame file/cache for a given channel or channels.
- Return type:
TimeSeries or list of TimeSeries
Examples
>>> ts = query_and_read_frame('H1_LDAS_C02_L2', 'H1:LDAS-STRAIN', >>> 968995968, 968995968+2048)
- pycbc.frame.frame.read_frame(location, channels, start_time=None, end_time=None, duration=None, check_integrity=False, sieve=None)[source]
Read time series from frame data.
Using the location, which can either be a frame file “.gwf” or a frame cache “.gwf”, read in the data for the given channel(s) and output as a TimeSeries or list of TimeSeries.
- Parameters:
location (string) – A source of gravitational wave frames. Either a frame filename (can include pattern), a list of frame files, or frame cache file.
channels (string or list of strings) – Either a string that contains the channel name or a list of channel name strings.
start_time ({None, LIGOTimeGPS}, optional) – The gps start time of the time series. Defaults to reading from the beginning of the available frame(s).
end_time ({None, LIGOTimeGPS}, optional) – The gps end time of the time series. Defaults to the end of the frame. Note, this argument is incompatible with duration.
duration ({None, float}, optional) – The amount of data to read in seconds. Note, this argument is incompatible with end.
check_integrity ({True, bool}, optional) – Test the frame files for internal integrity.
sieve (string, optional) – Selects only frames where the frame URL matches the regular expression sieve
- Returns:
Frame Data – A TimeSeries or a list of TimeSeries, corresponding to the data from the frame file/cache for a given channel or channels.
- Return type:
TimeSeries or list of TimeSeries
- pycbc.frame.frame.write_frame(location, channels, timeseries)[source]
Write a list of time series to a single frame file.
- Parameters:
location (string) – A frame filename.
channels (string or list of strings) – Either a string that contains the channel name or a list of channel name strings.
timeseries (TimeSeries) – A TimeSeries or list of TimeSeries, corresponding to the data to be written to the frame file for a given channel.
pycbc.frame.gwosc module
This modules contains functions for getting data from the Gravitational Wave Open Science Center (GWOSC).
- pycbc.frame.gwosc.gwosc_frame_json(ifo, start_time, end_time)[source]
Get the information about the public data files in a duration of time.
- pycbc.frame.gwosc.gwosc_frame_urls(ifo, start_time, end_time)[source]
Get a list of URLs to GWOSC frame files.
- Parameters:
- Returns:
frame_files – A dictionary containing information about the files that span the requested times.
- Return type:
- pycbc.frame.gwosc.read_frame_gwosc(channels, start_time, end_time)[source]
Read channels from GWOSC data.
- Parameters:
- Returns:
ts – Returns a timeseries or list of timeseries with the requested data.
- Return type:
pycbc.frame.store module
This modules contains functions for reading in data from hdf stores