gstlal 1.13.0
Loading...
Searching...
No Matches
segmentsrc_test_01.py
1#!/usr/bin/env python3
2# Copyright (C) 2015 Kipp Cannon
3#
4# This program is free software; you can redistribute it and/or modify it
5# under the terms of the GNU General Public License as published by the
6# Free Software Foundation; either version 2 of the License, or (at your
7# option) any later version.
8#
9# This program is distributed in the hope that it will be useful, but
10# WITHOUT ANY WARRANTY; without even the implied warranty of
11# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General
12# Public License for more details.
13#
14# You should have received a copy of the GNU General Public License along
15# with this program; if not, write to the Free Software Foundation, Inc.,
16# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
17
18#
19# =============================================================================
20#
21# Preamble
22#
23# =============================================================================
24#
25
26
27import numpy
28from ligo import segments
29from gstlal import pipeio
30from gstlal import pipeparts
31from lal import LIGOTimeGPS
32
33import test_common
34import cmp_nxydumps
35
36
37#
38# =============================================================================
39#
40# Pipelines
41#
42# =============================================================================
43#
44
45
46def segmentsrc_test_01(pipeline, name, seg):
47 segs = segments.segmentlist([segments.segment(LIGOTimeGPS(100), LIGOTimeGPS(200)), segments.segment(LIGOTimeGPS(250), LIGOTimeGPS(300))])
48
49 head = pipeparts.mksegmentsrc(pipeline, segs, blocksize = 1)
50 head = pipeparts.mkcapsfilter(pipeline, head, "audio/x-raw, format=(string)U8, rate=(int)4, channels=(int)1, layout=(string)interleaved, channel-mask=(bitmask)0")
51 head = pipeparts.mknxydumpsink(pipeline, head, "%s_out.dump" % name)
52
53 f = open("%s_in.dump" % name, "w")
54 for t in numpy.arange(float(seg[0]), float(seg[1]), 0.25):
55 print("%g\t%d" % (t, 128 if t in segs else 0), file=f)
56
57 return pipeline
58
59
60#
61# =============================================================================
62#
63# Main
64#
65# =============================================================================
66#
67
68
69seg = segments.segment(LIGOTimeGPS(0), LIGOTimeGPS(350))
70test_common.build_and_run(segmentsrc_test_01, segment = seg, seg = seg, name = "segmentsrc_test_01a")
71cmp_nxydumps.compare("segmentsrc_test_01a_in.dump", "segmentsrc_test_01a_out.dump")
compare(filename1, filename2, *args, **kwargs)
build_and_run(pipelinefunc, name, segment=None, **pipelinefunc_kwargs)