Loading [MathJax]/extensions/TeX/AMSsymbols.js
LALPulsar 7.1.1.1-5e288d3
All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Modules Pages
class_definitions.py
Go to the documentation of this file.
1# Copyright (C) 2019--2023 Benjamin Grace
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## \file
18## \ingroup lalpulsar_python_piecewise_model
19"""
20Common classes for piecewise model module.
21"""
22
23from . import basis_functions as bf
24from . import estimating_knots as ek
25from . import gte_and_other_methods as gom
26
27HOUR = 3600
28DAY = 24 * HOUR
29
30
31class TBank:
32 name = None
33 s = None
34 fmin = None
35 fmax = None
36 nmin = None
37 nmax = None
38 Izz = None
39 ellip = None
40 radius = None
41 kmin = None
42 kmax = None
43 mismatch = None
44 dur = None
45 knotnum = None
46 knots = None
47
48 flags_bbox = []
49 flags_intbox = []
50
51 tstart = None
52
53 cosi = None
54 psi = None
55 phi0 = None
56 Alpha = None
57 Delta = None
58
59 detectors = []
60
61 noise_path = None
62 sft_path = None
63 psd_path = None
64
65 def SetTBankParams(self, args):
66
67 if args.s:
68 self.s = args.s
69 if args.fmin:
70 self.fmin = args.fmin
71 if args.fmax:
72 self.fmax = args.fmax
73 if args.nmin:
74 self.nmin = args.nmin
75 if args.nmax:
76 self.nmax = args.nmax
77 if args.Izz:
78 self.Izz = args.Izz
79 if args.ellip:
80 self.ellip = args.ellip
81 if args.radius:
82 self.radius = args.radius
83
84 self.kmin = (
85 args.kmin
86 if args.kmin is not None
87 else gom.kforGWsource(Izz=self.Izz, ellip=self.ellip, radius=self.radius)
88 * 0.1
89 )
90 self.kmax = (
91 args.kmax
92 if args.kmax is not None
93 else gom.kforGWsource(Izz=self.Izz, ellip=self.ellip, radius=self.radius)
94 )
95
96 if args.dur:
97 self.dur = args.dur
98 if args.maxmismatch:
99 self.maxmismatch = args.maxmismatch
100 if args.knotnum:
101 self.knotnum = args.knotnum
102
103 if args.flags_bbox is not []:
104 self.flags_bboxflags_bbox = args.flags_bbox
105 if args.flags_intbox is not []:
106 self.flags_intboxflags_intbox = args.flags_intbox
107
108 if args.tstart:
109 self.tstart = args.tstart
110
111 if args.cosi:
112 self.cosi = args.cosi
113 if args.psi:
114 self.psi = args.psi
115 if args.phi0:
116 self.phi0 = args.phi0
117 if args.Alpha:
118 self.Alpha = args.Alpha
119 if args.Delta:
120 self.Delta = args.Delta
121
122 if not (args.detectors == []):
123 self.detectorsdetectors = args.detectors
124
125 if args.noise_path:
126 self.noise_path = args.noise_path
127 if args.sft_path:
128 self.sft_path = args.sft_path
129 if args.psd_path:
130 self.psd_path = args.psd_path
131
133 self.name = "GW170817"
134
135 # Physical Parameters
136 self.s = 2
137 self.fmin = 999
138 self.fmax = 1000
139 self.nmin = 3
140 self.nmax = 5
141 self.Izz = 1e38 # The long transient paper uses a value of 4.34e38
142 self.ellip = 1e-4
143 self.radius = 1e4
144
145 self.kmin = (
146 gom.kforGWsource(Izz=self.Izz, ellip=self.ellip, radius=self.radius) * 0.1
147 )
148 self.kmax = gom.kforGWsource(Izz=self.Izz, ellip=self.ellip, radius=self.radius)
149
150 # Relevant to search data
151 self.maxmismatch = 0.2
152 self.Tsft = 10
153
154 # Timing
155 self.dur = 1800
156 self.knotnum = 0
157 self.knots = [0, 1800]
158 self.tstart = 1187008882
159
160 # Sky Positions and orientations
161 self.cosi = None # 0.882948 # iota = 28 Degrees
162 self.psi = None # 0
163 self.phi0 = None # 0
164 self.Alpha = 3.446
165 self.Delta = -0.408
166
167 self.detectorsdetectors = ["H1", "L1"]
168
170 self.name = "GW190425"
171
172 # Physical Parameters
173 self.s = 2
174 self.fmin = 999
175 self.fmax = 1000
176 self.nmin = 3
177 self.nmax = 5
178 self.Izz = 1e38 # The long transient paper uses a value of 4.34e38
179 self.ellip = 1e-4
180 self.radius = 1e4
181
182 self.kmin = (
183 gom.kforGWsource(Izz=self.Izz, ellip=self.ellip, radius=self.radius) * 0.1
184 )
185 self.kmax = gom.kforGWsource(Izz=self.Izz, ellip=self.ellip, radius=self.radius)
186
187 # Relevant to search data
188 self.maxmismatch = 0.2
189 self.Tsft = 10
190
191 # Timing
192 self.dur = 1800
193 self.knotnum = 0
194 self.knots = [0, 1800]
195 self.tstart = 1240215503
196
197 # Sky Positions and orientations
198 self.cosi = None # 0
199 self.psi = None # 0
200 self.phi0 = None # 0
201 self.Alpha = 4.218
202 self.Delta = 0.401
203
204 self.detectorsdetectors = ["L1", "V1"]
205
207 self.name = "1987A"
208
209 self.s = 2
210 self.fmin = 49.99
211 self.fmax = 50
212 self.nmin = 3
213 self.nmax = 5
214 self.kmin = gom.kforGWsource() * 0.1
215 self.kmax = gom.kforGWsource()
216
217 self.maxmismatch = 0.2
218 self.Tsft = 1800
219
220 self.dur = 20 * DAY
221 self.knotnum = 0
222 self.knots = [0, self.dur]
223
224 def SetDefaultCasA(self):
225 self.name = "CasA"
226
227 self.s = 2
228 self.fmin = 29.99
229 self.fmax = 30
230 self.nmin = 3
231 self.nmax = 5
232 self.kmin = gom.kforGWsource() * 0.1
233 self.kmax = gom.kforGWsource()
234
235 self.maxmismatch = 0.2
236 self.Tsft = 1800
237
238 self.dur = 20 * DAY
239 self.knotnum = 0
240 self.knots = [0, self.dur]
241
242 # Sets the knots of a TBank object to be those calculated by our knot algorithm. A duration or knot number must first be set
243 def SetKnotsByAlg(self):
244 s = self.s
245 steps = 40 # These are the number of steps used to find the maximum error in the bi-section method for calculating knots. A value of at least 30 usually gives good enough results
246 f0 = self.fmax
247 nmax = self.nmax
248 kmax = self.kmax
249 mismatch = self.maxmismatch
250 dur = self.dur
251 knotnum = self.knotnum
252
253 self.knots = ek.allidealisedknots(
254 s, dur, steps, f0, nmax, kmax, mismatch, knotnum=knotnum
255 )
256
257 if self.knotnum != 0:
258 self.knots = self.knots[0 : self.knotnum + 1]
259 self.dur = self.knots[-1] - self.knots[0]
260 self.knotnum = len(self.knots)
261
262 bf.knotslist = self.knots
263
264 # Returns a string containing all parameters for this particular TBank, excluding the knots
265 def toString(self):
266 string = self.name
267
268 tbank = TBank()
269
270 if string == "GW170817":
271 tbank.SetDefaultGW170817()
272 elif string == "GW190425":
273 tbank.SetDefaultGW190425()
274
275 tbank.fmin = -1
276 tbank.fmax = -1
277
278 original_dict = vars(self)
279 default_dict = vars(tbank)
280
281 different_variables = []
282
283 skip_variables = [
284 "name",
285 "knots",
286 "flags_bbox",
287 "flags_intbox",
288 "noise_path",
289 "sft_path",
290 "psd_path",
291 ]
292
293 for key, value in original_dict.items():
294
295 if key in skip_variables:
296 continue
297
298 if value is None:
299 continue
300
301 default_variable = default_dict[key]
302
303 if value != default_variable:
304
305 if key == "detectors":
306
307 value_string = ""
308
309 for det in value:
310 value_string += det
311 different_variables.append(value_string)
312 else:
313 value_string = key + "-" + str(value)
314 different_variables.append(value_string)
315
316 for diff_var in different_variables:
317 string += "_" + diff_var
318
319 return string
320
321
322class FInput:
323 pass