gstlal
1.13.0
Toggle main menu visibility
Loading...
Searching...
No Matches
bin
gstlal_asd_txt_from_psd_xml
1
#!/usr/bin/env python3
2
#
3
# Copyright (C) 2018 Kipp Cannon
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
19
20
#
21
# =============================================================================
22
#
23
# Preamble
24
#
25
# =============================================================================
26
#
27
28
29
from
optparse
import
OptionParser
30
31
from
gstlal.psd
import
read_psd, write_asd_txt
32
33
34
#
35
# =============================================================================
36
#
37
# Command Line
38
#
39
# =============================================================================
40
#
41
42
43
def
parse_command_line():
44
parser = OptionParser(
45
description =
""
46
)
47
parser.add_option(
"--prefix"
, metavar =
"string"
, default =
"psd_"
, help =
"Prepend output files with this string (default = \"psd_\")."
)
48
parser.add_option(
"-v"
,
"--verbose"
, action =
"store_true"
, help =
"Be verbose (optional)."
)
49
50
options, filenames = parser.parse_args()
51
52
if
len(filenames) != 1:
53
raise
ValueError(
"only file PSD file may be given"
)
54
55
return
options, filenames
56
57
58
#
59
# =============================================================================
60
#
61
# Main
62
#
63
# =============================================================================
64
#
65
66
67
#
68
# parse command line
69
#
70
71
72
options, filenames = parse_command_line()
73
74
75
#
76
# load the PSD file iterate over instruments, writing ASD to ascii file
77
#
78
79
80
for
filename
in
filenames:
81
for
instrument, psd
in
read_psd(filename, verbose=options.verbose).items():
82
filename =
"%s%s.txt"
% (options.prefix, instrument)
83
write_asd_txt(filename, psd, verbose=options.verbose)
Generated by
1.17.0