Loading [MathJax]/extensions/TeX/AMSsymbols.js
LALFrame 3.0.7.1-b246709
All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Modules Pages
frtools.py
Go to the documentation of this file.
1# -*- coding: utf-8 -*-
2# Copyright (C) 2013,2019 Duncan Macleod
3#
4# This program is free software; you can redistribute it and/or modify
5# it under the terms of the GNU General Public License as published by
6# the Free Software Foundation; either version 2 of the License, or
7# (at your option) any later version.
8#
9# This program is distributed in the hope that it will be useful,
10# but WITHOUT ANY WARRANTY; without even the implied warranty of
11# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12# GNU General Public License for more details.
13#
14# You should have received a copy of the GNU General Public License
15# along with with program; see the file COPYING. If not, write to the
16# Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
17# MA 02110-1301 USA
18
19"""Native python versions of LIGOTools and FrXXX frame utilities
20"""
21
22import lalframe
23
24__author__ = "Duncan Macleod <duncan.macleod@ligo.org>"
25
26
27def get_channels(framefile):
28 r"""Return a list of all channels written into the given GWF-format
29 framefile
30
31 @param framefile
32 `string` path to input frame file
33
34 @return A list of channel names
35
36 Example:
37
38 \code
39 >>> get_channels('H-H1_LDAS_C02_L2-9668/H-H1_LDAS_C02_L2-966802176-128.gwf')
40 ['H1:LSC-DATA_QUALITY_VECTOR', 'H1:IFO-SV_STATE_VECTOR', 'H1:LDAS-STRAIN']
41 \endcode
42 """
43 return sorted(iter_channels(framefile))
44
45
46def iter_channels(framefile):
47 """Yield channels from the table-of-contents of the given GWF file
48
49 @param framefile
50 `str` path to input frame file
51 @return An iterator of channel names
52 """
53 frfile = lalframe.FrameUFrFileOpen(str(framefile), "r")
54 frtoc = lalframe.FrameUFrTOCRead(frfile)
55 nsim = lalframe.FrameUFrTOCQuerySimN(frtoc)
56 for i in range(lalframe.FrameUFrTOCQueryAdcN(frtoc)):
57 yield lalframe.FrameUFrTOCQueryAdcName(frtoc, i)
58 for i in range(lalframe.FrameUFrTOCQueryProcN(frtoc)):
59 yield lalframe.FrameUFrTOCQueryProcName(frtoc, i)
60 for i in range(lalframe.FrameUFrTOCQuerySimN(frtoc)):
61 yield lalframe.FrameUFrTOCQuerySimName(frtoc, i)
def get_channels(framefile)
Return a list of all channels written into the given GWF-format framefile.
Definition: frtools.py:42
def iter_channels(framefile)
Yield channels from the table-of-contents of the given GWF file.
Definition: frtools.py:52