ChannelList#

class gwpy.detector.ChannelList(iterable=(), /)[source]#

Bases: list

A list of channels, with parsing utilities.

Attributes Summary

ifos

The set of interferometer prefixes used in this ChannelList.

read

Read a ChannelList from a file.

write

Write this ChannelList to a file.

Methods Summary

find(name)

Find the Channel with a specific name in this ChannelList.

from_names(*names)

Create a new ChannelList from a list of names.

query(name, *[, kerberos])

Query the LIGO Channel Information System a ChannelList.

query_nds2(names, *[, host, port, ...])

Query an NDS server for channel information.

query_nds2_availability(channels, start, end)

Query for when data are available for these channels in NDS2.

sieve([name, sample_rate, sample_range, ...])

Find all channels in this list matching the specified criteria.

Attributes Documentation

ifos[source]#

The set of interferometer prefixes used in this ChannelList.

read#

Read a ChannelList from a file.

Parameters:
sourcestr, pathlib.Path, file.

File or path to read.

formatstr, optional

Source format identifier. If not given, the format will be detected if possible. See below for list of acceptable formats.

kwargs

Other keyword arguments depend on the format, See ChannelList.read.help(format=<format>) for details, or call ChannelList.read.help() to see all available formats.

Returns:
channelsChannelList

The list of channels read from the source.

write#

Write this ChannelList to a file.

Arguments and keywords depend on the output format, see the online documentation for full details for each format.

Parameters:
targetstr

Output filename.

Methods Documentation

find(name: str) int[source]#

Find the Channel with a specific name in this ChannelList.

Parameters:
namestr

name of the Channel to find

Returns:
indexint

the position of the first Channel in this ChannelList whose name matches the search key.

Raises:
ValueError

if no matching Channel is found.

classmethod from_names(*names: str) Self[source]#

Create a new ChannelList from a list of names.

The list of names can include comma-separated sets of names, in which case the return will be a flattened list of all parsed channel names.

classmethod query(name: str, *, kerberos: bool | None = None, **kwargs) Self[source]#

Query the LIGO Channel Information System a ChannelList.

Parameters:
namestr

name of channel, or part of it.

kerberosbool, optional

If True use an existing Kerberos ticket as the authentication credential. Default (None) is to check for credentials and request username and password if none are found.

kwargs

Other keyword arguments are passed directly to ciecplib.get().

Returns:
channelsChannelList

A new list containing all Channels found.

classmethod query_nds2(
names: list[str],
*,
host: str | None = None,
port: int | None = None,
connection: nds2.connection | None = None,
type: str | int | None = 127,
unique: bool = False,
) Self[source]#

Query an NDS server for channel information.

Parameters:
namesstr

Names of requested channels.

hoststr, optional

Name of NDS2 server.

portint, optional

Port number for NDS2 connection.

connectionnds2.connection, optional

Open connection to use for query.

typestr, int, optional

NDS2 channel type with which to restrict query

uniquebool, optional

If True require a unique query result for each name given. Default is False.

Returns:
channellistChannelList

list of Channels with metadata retrieved from NDS2 server

Raises:
ValueError

If multiple channels are found for a given name and unique=True is given.

Notes

Warning

One of host or connection is required.

classmethod query_nds2_availability(
channels: list[str | Channel],
start: SupportsToGps,
end: SupportsToGps,
ctype: int | str = 127,
connection: nds2.connection | None = None,
host: str | None = None,
port: int | None = None,
) SegmentListDict[source]#

Query for when data are available for these channels in NDS2.

Parameters:
channelslist of str or Channel

List of Channel or str for which to search.

startLIGOTimeGPS, float, str

GPS start time of search. Any input parseable by to_gps is fine.

endLIGOTimeGPS, float, str, optional

GPS end time of search. Any input parseable by to_gps is fine.

ctypeint, str

The NDS2 channel type name or enum ID against which to restrict results. Default is 127 which means ‘all’.

hoststr, optional

Name of NDS2 server to use.

portint, optional

Port number for NDS2 connection.

connectionnds2.connection, optional

Open connection to use for query.

Returns:
segdictSegmentListDict

dict of (name, SegmentList) pairs

sieve(
name: str | re.Pattern | None = None,
sample_rate: float | None = None,
*,
sample_range: tuple[float, float] | None = None,
exact_match: bool = False,
**others,
) Self[source]#

Find all channels in this list matching the specified criteria.

Parameters:
namestr, or regular expression

Any part of the channel name against which to match (or full name if exact_match=False is given).

sample_ratefloat

Rate (number of samples per second) to match exactly.

sample_range2-tuple

[low, high] closed interval or rates to match within.

exact_matchbool

If True return channels matching name exactly. If False (default) allow partial matches.

others:

Other (key, value) attribute pairs to match.

Returns:
newChannelList

A new ChannelList containing the matching channels.