gstlal
1.13.0
Toggle main menu visibility
Loading...
Searching...
No Matches
bin
gstlal_plot_psd
1
#!/usr/bin/env python3
2
#
3
# Copyright (C) 2012 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
19
20
21
22
23
from
optparse
import
OptionParser
24
import
os
25
26
from
gstlal.plots
import
set_matplotlib_cache_directory
27
set_matplotlib_cache_directory()
28
from
gstlal.psd
import
read_psd
29
from
gstlal.plots.psd
import
plot_psds
30
31
import
matplotlib
32
33
34
matplotlib.rcParams.update({
35
"font.size"
: 10.0,
36
"axes.titlesize"
: 10.0,
37
"axes.labelsize"
: 10.0,
38
"xtick.labelsize"
: 8.0,
39
"ytick.labelsize"
: 8.0,
40
"legend.fontsize"
: 8.0,
41
"figure.dpi"
: 300,
42
"savefig.dpi"
: 300,
43
"text.usetex"
:
True
,
44
"path.simplify"
:
True
45
})
46
47
48
def
parse_command_line():
49
parser = OptionParser()
50
parser.add_option(
"-o"
,
"--output"
, help =
"Set plot filename (default = replace input file's extension with .png)."
)
51
parser.add_option(
"-v"
,
"--verbose"
, action =
"store_true"
, help =
"Be verbose."
)
52
options, filenames = parser.parse_args()
53
54
if
not
filenames:
55
raise
ValueError(
"must supply at least one input filename"
)
56
if
options.output
and
len(filenames) > 1:
57
raise
ValueError(
"must supply only one input file when setting --output"
)
58
59
return
options, filenames
60
61
62
options, filenames = parse_command_line()
63
64
65
for
fname
in
filenames:
66
if
options.output:
67
outname = options.output
68
else
:
69
outname = os.path.join(os.path.splitext(fname)[0],
".png"
)
70
71
fig = plot_psds(read_psd(fname, verbose=options.verbose), plot_width=2400)
72
fig.savefig(outname)
Generated by
1.17.0