Detector Utilitiesο
Stability: Stable
Detector channel definitions, unit handling, and I/O helpers.
- class gwexpy.detector.Channel(name: str | Self, **params)[source]
Bases:
objectRepresentation of a gravitational-wave detectory data channel.
- Parameters:
name (str, Channel) β Name of this Channel (or another Channel itself). If a Channel is given, all other parameters not set explicitly will be copied over.
sample_rate (float, ~astropy.units.Quantity, optional) β Rate at which data are sampled for this channel, simple floats must be given in Hz.
unit (~astropy.units.Unit, str, optional) β Name of the unit for the data of this channel.
frequency_range (tuple of float) β
[low, high)spectral frequency range of interest for this channel.safe (bool, optional) β If True this channel is βsafeβ to use as a witness of non-gravitational-wave noise in the detector.
dtype (numpy.dtype, optional) β Numeric type of data for this channel.
frametype (str, optional) β LDAS name for frames that contain this channel.
model (str, optional) β Name of the SIMULINK front-end model that produces this channel.
Notes
The Channel structure implemented here is designed to match the data recorded in the LIGO Channel Information System (https://cis.ligo.org) for which a query interface is provided.
- MATCH = re.compile('((?:(?P<ifo>[A-Z]\\d))?|[\\w-]+):(?:(?P<system>[a-zA-Z0-9]+))?(?:[-_](?P<subsystem>[a-zA-Z0-9]+))?(?:[-_](?P<signal>[a-zA-Z0-9_-]+?))?(?:[\\.-](?P<trend>[a-z]+))?(?:,(?P<type>([a-z]-)?[a-z]+))?$')
- property name: str
Name of this channel.
This should follow the naming convention, with the following format: βIFO:SYSTEM-SUBSYSTEM_SIGNALβ
- property sample_rate: Quantity | None
Rate of samples (Hertz) for this channel.
- property unit: UnitBase | None
Data unit for this channel.
- property frequency_range: Quantity | None
Frequency range of interest (Hertz) for this channel.
- property safe: bool | None
Whether this channel is βsafeβ to use as a noise witness.
Any channel that records part or all of a GW signal as it interacts with the interferometer is not safe to use as a noise witness
A safe value of None simply indicates that the safety of this channel has not been determined
- property type: str | None
DAQ data type for this channel.
Valid values for this field are restricted to those understood by the NDS2 client sofware, namely:
βm-trendβ, βonlineβ, βrawβ, βreducedβ, βs-trendβ, βstaticβ, βtest-ptβ
- property ndstype: int
NDS type integer for this channel.
This property is mapped to the Channel.type string.
- property texname: str
Name of this channel in LaTeX printable format.
- property ndsname: str
Name of this channel as stored in the NDS database.
- classmethod query(name: str, *, kerberos: bool | None = None, **kwargs) Self[source]
Query the LIGO Channel Information System for
name.- Parameters:
name (str) β Name of channel for which to query.
kerberos (bool, 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:
channel β A new Channel containing all of the attributes set from its entry in the CIS.
- Return type:
Channel
- classmethod query_nds2(name: str, host: str | None = None, port: int | None = None, connection: nds2.connection | None = None, type: str | int | None = None) Self[source]
Query an NDS server for channel information.
- Parameters:
name (str) β Name of channel for which to query.
host (str, optional) β Name of NDS2 server.
port (int, optional) β Port number for NDS2 connection.
connection (nds2.connection) β Open connection to use for query.
type (str, int) β NDS2 channel type with which to restrict query
- Returns:
channel β Channel with metadata retrieved from NDS2 server.
- Return type:
Channel
- Raises:
ValueError β If multiple channels are found for a given name.
Notes
Warning
One of
hostorconnectionis required.
- classmethod from_nds2(nds2channel: nds2.channel) Self[source]
Generate a new channel using an existing nds2.channel object.
- classmethod from_arrakis(arrakischannel: arrakis.Channel) Self[source]
Generate a new channel using an existing arrakis.Channel.
- Parameters:
arrakischannel (arrakis.Channel) β The input channel from Arrakis to parse.
- Returns:
channel β A new Channel.
- Return type:
gwpy.detector.Channel
- classmethod parse_channel_name(name: str, *, strict: bool = True) dict[str, str | None][source]
Decompose a channel name string into its components.
This method parses channels acccording to the LIGO Channel Naming Convention
LIGO-T990033.- Parameters:
name (str) β Name to parse.
strict (bool, optional) β If True (default) require exact matching of format, with no surrounding text.
- Returns:
match β dict of channel name components with the following keys:
βifoβ: the letter-number interferometer prefix
βsystemβ: the top-level system name
βsubsystemβ: the second-level sub-system name
βsignalβ: the remaining underscore-delimited signal name
βtrendβ: the trend type
βndstypeβ: the NDS2 channel suffix
Any optional keys that arenβt found will return a value of None
- Return type:
dict
- Raises:
ValueError β if the name cannot be parsed with at least an IFO and SYSTEM
Examples
>>> Channel.parse_channel_name("L1:LSC-DARM_IN1_DQ") {'ifo': 'L1', 'ndstype': None, 'signal': 'IN1_DQ', 'subsystem': 'DARM', 'system': 'LSC', 'trend': None}
>>> Channel.parse_channel_name( ... "H1:ISI-BS_ST1_SENSCOR_GND_STS_X_BLRMS_100M_300M.rms,m-trend", ... ) {'ifo': 'H1', 'ndstype': 'm-trend', 'signal': 'ST1_SENSCOR_GND_STS_X_BLRMS_100M_300M', 'subsystem': 'BS', 'system': 'ISI', 'trend': 'rms'}
- find_frametype(gpstime: SupportsToGps | None = None, *, frametype_match: str | Pattern | None = None, return_all: Literal[False] = False, allow_tape: bool = True, **kwargs) str[source]
- find_frametype(gpstime: SupportsToGps | None = None, *, frametype_match: str | Pattern | None = None, return_all: Literal[True] = True, allow_tape: bool = True, **kwargs) list[str]
Find the containing frametype(s) for this Channel.
- Parameters:
gpstime (int, optional) β A reference GPS time at which to search for frame files. Default is to search in the latest available data for each discoverable dataset.
frametype_match (str) β A regular expression string to use to down-select from the list of all available datasets.
return_all (bool, optional) β If True return all matched datasets; if False (default) only the first match is returned
allow_tape (bool, default: True) β If True (default) include datasets whose files are stored on slow magnetic tape.
kwargs β Other keyword arguments are passed directly to
gwpy.io.datafind.find_frametype().
- Returns:
frametype β If
return_all=Falsea single str containing the βbestβ dataset name. Ifreturn_all=Truea list of dataset names.- Return type:
str or list[str]
- copy() Self[source]
Return a copy of this Channel.
- class gwexpy.detector.ChannelList(iterable=(), /)[source]
Bases:
listA list of channels <Channel>, with parsing utilities.
- read = <gwpy.detector.connect.ChannelListRead object>
- write = <gwpy.detector.connect.ChannelListWrite object>
- 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.
- find(name: str) int[source]
Find the Channel with a specific name in this ChannelList.
- Parameters:
name (str) β name of the Channel to find
- Returns:
index β the position of the first Channel in this ChannelList whose ~Channel.name matches the search key.
- Return type:
int
- Raises:
ValueError β if no matching Channel is found.
- 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:
name (str, or regular expression) β Any part of the channel name against which to match (or full name if exact_match=False is given).
sample_rate (float) β Rate (number of samples per second) to match exactly.
sample_range (2-tuple) β [low, high] closed interval or rates to match within.
exact_match (bool) β If True return channels matching
nameexactly. If False (default) allow partial matches.others β Other
(key, value)attribute pairs to match.
- Returns:
new β A new ChannelList containing the matching channels.
- Return type:
ChannelList
- classmethod query(name: str, *, kerberos: bool | None = None, **kwargs) Self[source]
Query the LIGO Channel Information System a ChannelList.
- Parameters:
name (str) β name of channel, or part of it.
kerberos (bool, 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:
channels β A new list containing all Channels <Channel> found.
- Return type:
ChannelList
- 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:
names (str) β Names of requested channels.
host (str, optional) β Name of NDS2 server.
port (int, optional) β Port number for NDS2 connection.
connection (nds2.connection, optional) β Open connection to use for query.
type (str, int, optional) β NDS2 channel type with which to restrict query
unique (bool, optional) β If True require a unique query result for each name given. Default is False.
- Returns:
channellist β list of Channels <Channel> with metadata retrieved from NDS2 server
- Return type:
ChannelList
- Raises:
ValueError β If multiple channels are found for a given name and unique=True is given.
Notes
Warning
One of
hostorconnectionis 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:
channels (list of str or Channel) β List of Channel or str for which to search.
start (~gwpy.time.LIGOTimeGPS, float, str) β GPS start time of search. Any input parseable by ~gwpy.time.to_gps is fine.
end (~gwpy.time.LIGOTimeGPS, float, str, optional) β GPS end time of search. Any input parseable by ~gwpy.time.to_gps is fine.
ctype (int, str) β The NDS2 channel type name or enum ID against which to restrict results. Default is
127which means βallβ.host (str, optional) β Name of NDS2 server to use.
port (int, optional) β Port number for NDS2 connection.
connection (nds2.connection, optional) β Open connection to use for query.
- Returns:
segdict β dict of
(name, SegmentList)pairs- Return type:
~gwpy.segments.SegmentListDict
- gwexpy.detector.get_timezone(ifo: str) str[source]
Return the timezone for the given interferometer prefix.
- Parameters:
ifo (str) β Prefix of interferometer, e.g.
'X1'- Returns:
timezone β The name of the timezone for
ifo.- Return type:
str
- Raises:
ValueError β If
ifois not recognised.
Examples
>>> get_timezone("G1") 'Europe/Berlin'
- gwexpy.detector.get_timezone_offset(ifo: str, dt: datetime | None = None) float[source]
Return the offset in seconds between UTC and the given interferometer.
- Parameters:
ifo (str) β Prefix of interferometer, e.g.
'X1'dt (datetime.datetime, optional) β The time at which to calculate the offset. Default is datetime.datetime.now.
- Returns:
offset β The offset in seconds between the timezone of the interferometer and UTC.
- Return type:
float