gstlal 1.13.0
Loading...
Searching...
No Matches
psd.py
1# Copyright (C) 2020 Patrick Godwin (patrick.godwin@ligo.org)
2#
3# This program is free software; you can redistribute it and/or modify it
4# under the terms of the GNU General Public License as published by the
5# Free Software Foundation; either version 2 of the License, or (at your
6# option) any later version.
7#
8# This program is distributed in the hope that it will be useful, but
9# WITHOUT ANY WARRANTY; without even the implied warranty of
10# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General
11# Public License for more details.
12#
13# You should have received a copy of the GNU General Public License along
14# with this program; if not, write to the Free Software Foundation, Inc.,
15# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
16
17
18from gstlal import plugins
19from gstlal.datafind import DataType, DataCache
20from gstlal.dags import Argument, Option
21from gstlal.dags import util as dagutil
22from gstlal.dags.layers import Layer, Node
23
24
25def reference_psd_layer(config, dag):
26 layer = Layer(
27 "gstlal_reference_psd",
28 requirements={
29 "request_cpus": 2,
30 "request_memory": 2000,
31 "request_disk": "2GB",
32 **config.condor.submit
33 },
34 transfer_files=config.condor.transfer_files,
35 )
36
37 psd_cache = DataCache.generate(DataType.REFERENCE_PSD, config.ifo_combos, config.time_bins)
38
39 frame_opts = [
40 Option("data-source", "frames"),
41 Option("psd-fft-length", config.psd.fft_length),
42 Option("frame-segments-name", config.source.frame_segments_name),
43 ]
44
45 for (ifo_combo, span), psds in psd_cache.groupby("ifo", "time").items():
46 ifos = config.to_ifo_list(ifo_combo)
47 start, end = span
48
49 arguments = [
50 Option("gps-start-time", int(start)),
51 Option("gps-end-time", int(end)),
52 Option("channel-name", dagutil.format_ifo_args(ifos, config.source.channel_name)),
53 *frame_opts,
54 ]
55 inputs = [Option("frame-segments-file", config.source.frame_segments_file, track=False)]
56
57 if config.source.frame_cache:
58 inputs.append(Option("frame-cache", config.source.frame_cache, track=False))
59 else:
60 arguments.extend([
61 Option("frame-type", dagutil.format_ifo_args(ifos, config.source.frame_type)),
62 Option("data-find-server", config.source.data_find_server),
63 ])
64
65 layer += Node(
66 arguments = arguments,
67 inputs = inputs,
68 outputs = Option("write-psd", psds.files)
69 )
70
71 dag.attach(layer)
72 return psd_cache
73
74
75def median_psd_layer(config, dag, psd_cache):
76 layer = Layer(
77 "gstlal_median_of_psds",
78 requirements={
79 "request_cpus": 2,
80 "request_memory": 2000,
81 "request_disk": "2GB",
82 **config.condor.submit
83 },
84 transfer_files=config.condor.transfer_files,
85 )
86
87 median_psd_cache = DataCache.generate(DataType.MEDIAN_PSD, config.all_ifos, config.span)
88
89 layer += Node(
90 inputs = Argument("psds", psd_cache.files),
91 outputs = Option("output-name", median_psd_cache.files)
92 )
93
94 dag.attach(layer)
95 return median_psd_cache
96
97
98def smoothen_psd_layer(config, dag, psd_cache):
99 layer = Layer(
100 "gstlal_psd_polyfit",
101 requirements={
102 "request_cpus": 2,
103 "request_memory": 2000,
104 "request_disk": "2GB",
105 **config.condor.submit
106 },
107 transfer_files=config.condor.transfer_files,
108 )
109
110 smooth_psd_cache = DataCache.generate(DataType.SMOOTH_PSD, config.ifo_combos, config.time_bins)
111
112 smooth_psds = smooth_psd_cache.groupby("ifo", "time")
113 for (ifo_combo, span), psds in psd_cache.groupby("ifo", "time").items():
114 layer += Node(
115 arguments = Option("low-fit-freq", 10),
116 inputs = Argument("psds", psd_cache.files),
117 outputs = Option("output-name", smooth_psds[span].files)
118 )
119
120 dag.attach(layer)
121 return smooth_psd_cache
122
123
124@plugins.register
125def layers():
126 return {
127 "reference_psd": reference_psd_layer,
128 "median_psd": median_psd_layer,
129 "smoothen_psd": smoothen_psd_layer,
130 }