gstlal 1.13.0
Loading...
Searching...
No Matches
gstlal_psd_xml_from_asd_txt
1#!/usr/bin/env python3
2#
3# Copyright (C) 2011 Chad Hanna
4#
5# This program is free software; you can redistribute it and/or modify it
6# under the terms of the GNU General Public License as published by the
7# Free Software Foundation; either version 2 of the License, or (at your
8# option) any later version.
9#
10# This program is distributed in the hope that it will be useful, but
11# WITHOUT ANY WARRANTY; without even the implied warranty of
12# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General
13# Public License for more details.
14#
15# You should have received a copy of the GNU General Public License along
16# with this program; if not, write to the Free Software Foundation, Inc.,
17# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
18
19from optparse import OptionParser
20
21from gstlal.psd import read_asd_txt, write_psd
22
23
56
57parser = OptionParser(description = __doc__)
58parser.add_option("--instrument", help="instrument, e.g. H1")
59parser.add_option("--output", metavar = "filename", help = "Set the name of the LIGO light-weight XML file to output")
60parser.add_option("--df", metavar = "float", type = "float", default = 0.25, help = "set the frequency resolution to interpolate to, default = 0.25")
61parser.add_option("--type", metavar = "type", default = "ASD", help = "input is ASD or PSD, default ASD")
62
63options, filenames = parser.parse_args()
64
65if options.type == "ASD":
66 read_as_psd = False
67elif options.type == "PSD":
68 read_as_psd = True
69else:
70 raise ValueError("--type must be ASD or PSD")
71
72#FIXME hack to pad the series since it doesn't start at 0
73psd = read_asd_txt(filenames[0], df=options.df, zero_pad=True, read_as_psd=read_as_psd)
74
75write_psd(options.output, {options.instrument: psd})