lisaanalysistools-cuda11x 1.1.0__cp313-cp313-manylinux_2_17_x86_64.manylinux2014_x86_64.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.

Potentially problematic release.


This version of lisaanalysistools-cuda11x might be problematic. Click here for more details.

Files changed (41) hide show
  1. lisaanalysistools_cuda11x-1.1.0.dist-info/METADATA +300 -0
  2. lisaanalysistools_cuda11x-1.1.0.dist-info/RECORD +41 -0
  3. lisaanalysistools_cuda11x-1.1.0.dist-info/WHEEL +6 -0
  4. lisaanalysistools_cuda11x-1.1.0.dist-info/licenses/LICENSE +201 -0
  5. lisaanalysistools_cuda11x.libs/libcudart-d0da41ae.so.11.8.89 +0 -0
  6. lisatools/__init__.py +58 -0
  7. lisatools/_version.py +34 -0
  8. lisatools/analysiscontainer.py +474 -0
  9. lisatools/cutils/__init__.py +139 -0
  10. lisatools/datacontainer.py +312 -0
  11. lisatools/detector.py +696 -0
  12. lisatools/diagnostic.py +990 -0
  13. lisatools/git_version.py.in +7 -0
  14. lisatools/orbit_files/equalarmlength-orbits-best-fit-to-esa.h5 +0 -0
  15. lisatools/orbit_files/equalarmlength-orbits.h5 +0 -0
  16. lisatools/orbit_files/esa-trailing-orbits.h5 +0 -0
  17. lisatools/sampling/__init__.py +0 -0
  18. lisatools/sampling/likelihood.py +882 -0
  19. lisatools/sampling/moves/__init__.py +0 -0
  20. lisatools/sampling/moves/skymodehop.py +110 -0
  21. lisatools/sampling/prior.py +646 -0
  22. lisatools/sampling/stopping.py +320 -0
  23. lisatools/sampling/utility.py +411 -0
  24. lisatools/sensitivity.py +972 -0
  25. lisatools/sources/__init__.py +6 -0
  26. lisatools/sources/bbh/__init__.py +1 -0
  27. lisatools/sources/bbh/waveform.py +106 -0
  28. lisatools/sources/defaultresponse.py +36 -0
  29. lisatools/sources/emri/__init__.py +1 -0
  30. lisatools/sources/emri/waveform.py +79 -0
  31. lisatools/sources/gb/__init__.py +1 -0
  32. lisatools/sources/gb/waveform.py +69 -0
  33. lisatools/sources/utils.py +459 -0
  34. lisatools/sources/waveformbase.py +41 -0
  35. lisatools/stochastic.py +327 -0
  36. lisatools/utils/__init__.py +0 -0
  37. lisatools/utils/constants.py +54 -0
  38. lisatools/utils/parallelbase.py +11 -0
  39. lisatools/utils/utility.py +245 -0
  40. lisatools_backend_cuda11x/git_version.py +7 -0
  41. lisatools_backend_cuda11x/pycppdetector.cpython-313-x86_64-linux-gnu.so +0 -0
lisatools/detector.py ADDED
@@ -0,0 +1,696 @@
1
+ from __future__ import annotations
2
+ import os
3
+ from abc import ABC, abstractmethod
4
+ from typing import Any, List, Tuple, Optional
5
+ from dataclasses import dataclass
6
+ import requests
7
+ from copy import deepcopy
8
+ import h5py
9
+ from scipy import interpolate
10
+
11
+ from .utils.constants import *
12
+ from .utils.utility import get_array_module
13
+
14
+ import numpy as np
15
+
16
+
17
+ SC = [1, 2, 3]
18
+ LINKS = [12, 23, 31, 13, 32, 21]
19
+
20
+ LINEAR_INTERP_TIMESTEP = 600.00 # sec (0.25 hr)
21
+
22
+
23
+ class Orbits(ABC):
24
+ """LISA Orbit Base Class
25
+
26
+ Args:
27
+ filename: File name. File should be in the style of LISAOrbits
28
+ use_gpu: If ``True``, use a gpu.
29
+ armlength: Armlength of detector.
30
+
31
+ """
32
+
33
+ def __init__(
34
+ self,
35
+ filename: str,
36
+ use_gpu: bool = False,
37
+ armlength: Optional[float] = 2.5e9,
38
+ ) -> None:
39
+ self.use_gpu = use_gpu
40
+ self.filename = filename
41
+ self.armlength = armlength
42
+ self._setup()
43
+ self.configured = False
44
+
45
+ @property
46
+ def xp(self):
47
+ """numpy or cupy based on self.use_gpu"""
48
+ xp = np if not self.use_gpu else cp
49
+ return xp
50
+
51
+ @property
52
+ def armlength(self) -> float:
53
+ """Armlength parameter."""
54
+ return self._armlength
55
+
56
+ @armlength.setter
57
+ def armlength(self, armlength: float) -> None:
58
+ """armlength setter."""
59
+
60
+ if isinstance(armlength, float):
61
+ # TODO: put error check that it is close
62
+ self._armlength = armlength
63
+
64
+ else:
65
+ raise ValueError("armlength must be float.")
66
+
67
+ @property
68
+ def LINKS(self) -> List[int]:
69
+ """Link order."""
70
+ return LINKS
71
+
72
+ @property
73
+ def SC(self) -> List[int]:
74
+ """Spacecraft order."""
75
+ return SC
76
+
77
+ @property
78
+ def link_space_craft_r(self) -> List[int]:
79
+ """Receiver (first) spacecraft"""
80
+ return [int(str(link_i)[0]) for link_i in self.LINKS]
81
+
82
+ @property
83
+ def link_space_craft_e(self) -> List[int]:
84
+ """Sender (second) spacecraft"""
85
+ return [int(str(link_i)[1]) for link_i in self.LINKS]
86
+
87
+ def _setup(self) -> None:
88
+ """Read in orbital data from file and store."""
89
+ with self.open() as f:
90
+ for key in f.attrs.keys():
91
+ setattr(self, key + "_base", f.attrs[key])
92
+
93
+ @property
94
+ def filename(self) -> str:
95
+ """Orbit file name."""
96
+ return self._filename
97
+
98
+ @filename.setter
99
+ def filename(self, filename: str) -> None:
100
+ """Set file name."""
101
+
102
+ assert isinstance(filename, str)
103
+
104
+ if os.path.exists(filename):
105
+ self._filename = filename
106
+
107
+ else:
108
+ # get path
109
+ path_to_this_file = __file__.split("detector.py")[0]
110
+
111
+ # make sure orbit_files directory exists in the right place
112
+ if not os.path.exists(path_to_this_file + "orbit_files/"):
113
+ os.mkdir(path_to_this_file + "orbit_files/")
114
+ path_to_this_file = path_to_this_file + "orbit_files/"
115
+
116
+ if not os.path.exists(path_to_this_file + filename):
117
+ # download files from github if they are not there
118
+ github_file = f"https://github.com/mikekatz04/LISAanalysistools/raw/main/lisatools/orbit_files/{filename}"
119
+ r = requests.get(github_file)
120
+
121
+ # if not success
122
+ if r.status_code != 200:
123
+ raise ValueError(
124
+ f"Cannot find {filename} within default files located at github.com/mikekatz04/LISAanalysistools/lisatools/orbit_files/."
125
+ )
126
+ # write the contents to a local file
127
+ with open(path_to_this_file + filename, "wb") as f:
128
+ f.write(r.content)
129
+
130
+ # store
131
+ self._filename = path_to_this_file + filename
132
+
133
+ def open(self) -> h5py.File:
134
+ """Opens the h5 file in the proper mode.
135
+
136
+ Returns:
137
+ H5 file object: Opened file.
138
+
139
+ Raises:
140
+ RuntimeError: If backend is opened for writing when it is read-only.
141
+
142
+ """
143
+ f = h5py.File(self.filename, "r")
144
+ return f
145
+
146
+ @property
147
+ def t_base(self) -> np.ndarray:
148
+ """Time array from file."""
149
+ with self.open() as f:
150
+ t_base = np.arange(self.size_base) * self.dt_base
151
+ return t_base
152
+
153
+ @property
154
+ def ltt_base(self) -> np.ndarray:
155
+ """Light travel times along links from file."""
156
+ with self.open() as f:
157
+ ltt = f["tcb"]["ltt"][:]
158
+ return ltt
159
+
160
+ @property
161
+ def n_base(self) -> np.ndarray:
162
+ """Normal unit vectors towards receiver along links from file."""
163
+ with self.open() as f:
164
+ n = f["tcb"]["n"][:]
165
+ return n
166
+
167
+ @property
168
+ def x_base(self) -> np.ndarray:
169
+ """Spacecraft position from file."""
170
+ with self.open() as f:
171
+ x = f["tcb"]["x"][:]
172
+ return x
173
+
174
+ @property
175
+ def v_base(self) -> np.ndarray:
176
+ """Spacecraft velocities from file."""
177
+ with self.open() as f:
178
+ v = f["tcb"]["v"][:]
179
+ return v
180
+
181
+ @property
182
+ def t(self) -> np.ndarray:
183
+ """Configured time array."""
184
+ self._check_configured()
185
+ return self._t
186
+
187
+ @t.setter
188
+ def t(self, t: np.ndarray):
189
+ """Set configured time array."""
190
+ assert isinstance(t, np.ndarray) and t.ndim == 1
191
+ self._t = t
192
+
193
+ @property
194
+ def ltt(self) -> np.ndarray:
195
+ """Light travel time."""
196
+ self._check_configured()
197
+ return self._ltt
198
+
199
+ @ltt.setter
200
+ def ltt(self, ltt: np.ndarray) -> np.ndarray:
201
+ """Set light travel time."""
202
+ assert ltt.shape[0] == len(self.t)
203
+
204
+ @property
205
+ def n(self) -> np.ndarray:
206
+ """Normal vectors along links."""
207
+ self._check_configured()
208
+ return self._n
209
+
210
+ @n.setter
211
+ def n(self, n: np.ndarray) -> np.ndarray:
212
+ """Set Normal vectors along links."""
213
+ return self._n
214
+
215
+ @property
216
+ def x(self) -> np.ndarray:
217
+ """Spacecraft positions."""
218
+ self._check_configured()
219
+ return self._x
220
+
221
+ @x.setter
222
+ def x(self, x: np.ndarray) -> np.ndarray:
223
+ """Set Spacecraft positions."""
224
+ return self._x
225
+
226
+ @property
227
+ def v(self) -> np.ndarray:
228
+ """Spacecraft velocities."""
229
+ self._check_configured()
230
+ return self._v
231
+
232
+ @v.setter
233
+ def v(self, v: np.ndarray) -> np.ndarray:
234
+ """Set Spacecraft velocities."""
235
+ return self._v
236
+
237
+ def configure(
238
+ self,
239
+ t_arr: Optional[np.ndarray] = None,
240
+ dt: Optional[float] = None,
241
+ linear_interp_setup: Optional[bool] = False,
242
+ ) -> None:
243
+ """Configure the orbits to match the signal response generator time basis.
244
+
245
+ The base orbits will be scaled up or down as needed using Cubic Spline interpolation.
246
+ The higherarchy of consideration to each keyword argument if multiple are given:
247
+ ``linear_interp_setup``, ``t_arr``, ``dt``.
248
+
249
+ If nothing is provided, the base points are used.
250
+
251
+ Args:
252
+ t_arr: New time array.
253
+ dt: New time step. Will take the time duration to be that of the input data.
254
+ linear_interp_setup: If ``True``, it will create a dense grid designed for linear interpolation with a constant time step.
255
+
256
+ """
257
+
258
+ x_orig = self.t_base
259
+
260
+ # everything up base on input
261
+ if linear_interp_setup:
262
+ # setup spline
263
+ make_cpp = True
264
+ dt = LINEAR_INTERP_TIMESTEP
265
+ Tobs = self.t_base[-1]
266
+ Nobs = int(Tobs / dt)
267
+ t_arr = np.arange(Nobs) * dt
268
+ if t_arr[-1] < self.t_base[-1]:
269
+ t_arr = np.concatenate([t_arr, self.t_base[-1:]])
270
+ elif t_arr is not None:
271
+ # check array inputs and fill dt
272
+ assert np.all(t_arr >= self.t_base[0]) and np.all(t_arr <= self.t_base[-1])
273
+ make_cpp = True
274
+ dt = abs(t_arr[1] - t_arr[0])
275
+
276
+ elif dt is not None:
277
+ # fill array based on dt and base t
278
+ make_cpp = True
279
+ Tobs = self.t_base[-1]
280
+ Nobs = int(Tobs / dt)
281
+ t_arr = np.arange(Nobs) * dt
282
+ if t_arr[-1] < self.t_base[-1]:
283
+ t_arr = np.concatenate([t_arr, self.t_base[-1:]])
284
+
285
+ else:
286
+ make_cpp = False
287
+ t_arr = self.t_base
288
+
289
+ x_new = t_arr.copy()
290
+ self.t = t_arr.copy()
291
+
292
+ # use base quantities, and interpolate to prepare new arrays accordingly
293
+ for which in ["ltt", "x", "n", "v"]:
294
+ arr = getattr(self, which + "_base")
295
+ arr_tmp = arr.reshape(self.size_base, -1)
296
+ arr_out_tmp = np.zeros((len(x_new), arr_tmp.shape[-1]))
297
+ for i in range(arr_tmp.shape[-1]):
298
+ arr_out_tmp[:, i] = interpolate.CubicSpline(x_orig, arr_tmp[:, i])(
299
+ x_new
300
+ )
301
+ arr_out = arr_out_tmp.reshape((len(x_new),) + arr.shape[1:])
302
+ setattr(self, "_" + which, arr_out)
303
+
304
+ # make sure base spacecraft and link inormation is ready
305
+ lsr = np.asarray(self.link_space_craft_r).copy().astype(np.int32)
306
+ lse = np.asarray(self.link_space_craft_e).copy().astype(np.int32)
307
+ ll = np.asarray(self.LINKS).copy().astype(np.int32)
308
+
309
+ # indicate this class instance has been configured
310
+ self.configured = True
311
+
312
+ # prepare cpp class args to load when needed
313
+ if make_cpp:
314
+ self.pycppdetector_args = [
315
+ dt,
316
+ len(self.t),
317
+ self.xp.asarray(self.n.flatten().copy()),
318
+ self.xp.asarray(self.ltt.flatten().copy()),
319
+ self.xp.asarray(self.x.flatten().copy()),
320
+ self.xp.asarray(ll),
321
+ self.xp.asarray(lsr),
322
+ self.xp.asarray(lse),
323
+ self.armlength,
324
+ ]
325
+ self.dt = dt
326
+ else:
327
+ self.pycppdetector_args = None
328
+ self.dt = dt
329
+
330
+ @property
331
+ def dt(self) -> float:
332
+ """new time step if it exists"""
333
+ if self._dt is None:
334
+ raise ValueError("dt not available for t_arr only.")
335
+ return self._dt
336
+
337
+ @dt.setter
338
+ def dt(self, dt: float) -> None:
339
+ self._dt = dt
340
+
341
+ @property
342
+ def pycppdetector(self) -> pycppDetector_cpu | pycppDetector_gpu:
343
+ """C++ class"""
344
+ if self._pycppdetector_args is None:
345
+ raise ValueError(
346
+ "Asking for c++ class. Need to set linear_interp_setup = True when configuring."
347
+ )
348
+ pycppDetector = pycppDetector_cpu if not self.use_gpu else pycppDetector_gpu
349
+ self._pycppdetector = pycppDetector(*self._pycppdetector_args)
350
+ return self._pycppdetector
351
+
352
+ @property
353
+ def pycppdetector_args(self) -> tuple:
354
+ """args for the c++ class."""
355
+ return self._pycppdetector_args
356
+
357
+ @pycppdetector_args.setter
358
+ def pycppdetector_args(self, pycppdetector_args: tuple) -> None:
359
+ self._pycppdetector_args = pycppdetector_args
360
+
361
+ @property
362
+ def size(self) -> int:
363
+ """Number of time points."""
364
+ self._check_configured()
365
+ return len(self.t)
366
+
367
+ def _check_configured(self) -> None:
368
+ if not self.configured:
369
+ raise ValueError(
370
+ "Cannot request property. Need to use configure() method first."
371
+ )
372
+
373
+ def get_light_travel_times(
374
+ self, t: float | np.ndarray, link: int | np.ndarray
375
+ ) -> float | np.ndarray:
376
+ """Compute light travel time as a function of time.
377
+
378
+ Computes with the c++ backend.
379
+
380
+ Args:
381
+ t: Time array in seconds.
382
+ link: which link. Must be ``in self.LINKS``.
383
+
384
+ Returns:
385
+ Light travel times.
386
+
387
+ """
388
+ # test and prepare inputs
389
+ if isinstance(t, float) and isinstance(link, int):
390
+ squeeze = True
391
+ t = self.xp.atleast_1d(t)
392
+ link = self.xp.atleast_1d(link).astype(np.int32)
393
+
394
+ elif isinstance(t, self.xp.ndarray) and isinstance(link, int):
395
+ squeeze = False
396
+ t = self.xp.atleast_1d(t)
397
+ link = self.xp.full_like(t, link, dtype=np.int32)
398
+
399
+ elif isinstance(t, self.xp.ndarray) and isinstance(link, self.xp.ndarray):
400
+ squeeze = False
401
+ t = self.xp.asarray(t)
402
+ link = self.xp.asarray(link).astype(np.int32)
403
+ else:
404
+ raise ValueError(
405
+ "(t, link) can be (float, int), (np.ndarray, int), (np.ndarray, np.ndarray)."
406
+ )
407
+
408
+ # buffer array and c computation
409
+ ltt_out = self.xp.zeros_like(t)
410
+ self.pycppdetector.get_light_travel_time_arr_wrap(
411
+ ltt_out, t, link, len(ltt_out)
412
+ )
413
+
414
+ # prepare output
415
+ if squeeze:
416
+ return ltt_out[0]
417
+ return ltt_out
418
+
419
+ def get_pos(self, t: float | np.ndarray, sc: int | np.ndarray) -> np.ndarray:
420
+ """Compute light travel time as a function of time.
421
+
422
+ Computes with the c++ backend.
423
+
424
+ Args:
425
+ t: Time array in seconds.
426
+ sc: which spacecraft. Must be ``in self.SC``.
427
+
428
+ Returns:
429
+ Position of spacecraft.
430
+
431
+ """
432
+ # test and setup inputs accordingly
433
+ if isinstance(t, float) and isinstance(sc, int):
434
+ squeeze = True
435
+ t = self.xp.atleast_1d(t)
436
+ sc = self.xp.atleast_1d(sc).astype(np.int32)
437
+
438
+ elif isinstance(t, self.xp.ndarray) and isinstance(sc, int):
439
+ squeeze = False
440
+ t = self.xp.atleast_1d(t)
441
+ sc = self.xp.full_like(t, sc, dtype=np.int32)
442
+
443
+ elif isinstance(t, self.xp.ndarray) and isinstance(sc, self.xp.ndarray):
444
+ squeeze = False
445
+ t = self.xp.asarray(t)
446
+ sc = self.xp.asarray(sc).astype(np.int32)
447
+
448
+ else:
449
+ raise ValueError(
450
+ "(t, sc) can be (float, int), (np.ndarray, int), (np.ndarray, np.ndarray). If the inputs follow this, make sure the orbits class GPU setting matches the arrays coming in (GPU or CPU)."
451
+ )
452
+
453
+ # buffer arrays for input into c code
454
+ pos_x = self.xp.zeros_like(t)
455
+ pos_y = self.xp.zeros_like(t)
456
+ pos_z = self.xp.zeros_like(t)
457
+
458
+ # c code computation
459
+ self.pycppdetector.get_pos_arr_wrap(pos_x, pos_y, pos_z, t, sc, len(pos_x))
460
+
461
+ # prepare output
462
+ output = self.xp.array([pos_x, pos_y, pos_z]).T
463
+ if squeeze:
464
+ return output.squeeze()
465
+ return output
466
+
467
+ def get_normal_unit_vec(
468
+ self, t: float | np.ndarray, link: int | np.ndarray
469
+ ) -> np.ndarray:
470
+ """Compute link normal vector as a function of time.
471
+
472
+ Computes with the c++ backend.
473
+
474
+ Args:
475
+ t: Time array in seconds.
476
+ link: which link. Must be ``in self.LINKS``.
477
+
478
+ Returns:
479
+ Link normal vectors.
480
+
481
+ """
482
+ # test and prepare inputs
483
+ if isinstance(t, float) and isinstance(link, int):
484
+ squeeze = True
485
+ t = self.xp.atleast_1d(t)
486
+ link = self.xp.atleast_1d(link).astype(np.int32)
487
+
488
+ elif isinstance(t, self.xp.ndarray) and isinstance(link, int):
489
+ squeeze = False
490
+ t = self.xp.atleast_1d(t)
491
+ link = self.xp.full_like(t, link, dtype=np.int32)
492
+
493
+ elif isinstance(t, self.xp.ndarray) and isinstance(link, self.xp.ndarray):
494
+ squeeze = False
495
+ t = self.xp.asarray(t)
496
+ link = self.xp.asarray(link).astype(np.int32)
497
+ else:
498
+ raise ValueError(
499
+ "(t, link) can be (float, int), (np.ndarray, int), (np.ndarray, np.ndarray)."
500
+ )
501
+
502
+ # c code with buffers
503
+ normal_unit_vec_x = self.xp.zeros_like(t)
504
+ normal_unit_vec_y = self.xp.zeros_like(t)
505
+ normal_unit_vec_z = self.xp.zeros_like(t)
506
+
507
+ # c code
508
+ self.pycppdetector.get_normal_unit_vec_arr_wrap(
509
+ normal_unit_vec_x,
510
+ normal_unit_vec_y,
511
+ normal_unit_vec_z,
512
+ t,
513
+ link,
514
+ len(normal_unit_vec_x),
515
+ )
516
+
517
+ # prep outputs
518
+ output = self.xp.array(
519
+ [normal_unit_vec_x, normal_unit_vec_y, normal_unit_vec_z]
520
+ ).T
521
+ if squeeze:
522
+ return output.squeeze()
523
+ return output
524
+
525
+ @property
526
+ def ptr(self) -> int:
527
+ """pointer to c++ class"""
528
+ return self.pycppdetector.ptr
529
+
530
+
531
+ class EqualArmlengthOrbits(Orbits):
532
+ """Equal Armlength Orbits
533
+
534
+ Orbit file: equalarmlength-orbits.h5
535
+
536
+ Args:
537
+ *args: Arguments for :class:`Orbits`.
538
+ **kwargs: Kwargs for :class:`Orbits`.
539
+
540
+ """
541
+
542
+ def __init__(self, *args: Any, **kwargs: Any):
543
+ super().__init__("equalarmlength-orbits.h5", *args, **kwargs)
544
+
545
+
546
+ class ESAOrbits(Orbits):
547
+ """ESA Orbits
548
+
549
+ Orbit file: esa-trailing-orbits.h5
550
+
551
+ Args:
552
+ *args: Arguments for :class:`Orbits`.
553
+ **kwargs: Kwargs for :class:`Orbits`.
554
+
555
+ """
556
+
557
+ def __init__(self, *args, **kwargs):
558
+ super().__init__("esa-trailing-orbits.h5", *args, **kwargs)
559
+
560
+
561
+ class DefaultOrbits(EqualArmlengthOrbits):
562
+ """Set default orbit class to Equal Armlength orbits for now."""
563
+
564
+ pass
565
+
566
+
567
+ @dataclass
568
+ class LISAModelSettings:
569
+ """Required LISA model settings:
570
+
571
+ Args:
572
+ Soms_d: OMS displacement noise.
573
+ Sa_a: Acceleration noise.
574
+ orbits: Orbital information.
575
+ name: Name of model.
576
+
577
+ """
578
+
579
+ Soms_d: float
580
+ Sa_a: float
581
+ orbits: Orbits
582
+ name: str
583
+
584
+
585
+ class LISAModel(LISAModelSettings, ABC):
586
+ """Model for the LISA Constellation
587
+
588
+ This includes sensitivity information computed in
589
+ :py:mod:`lisatools.sensitivity` and orbital information
590
+ contained in an :class:`Orbits` class object.
591
+
592
+ This class is used to house high-level methods useful
593
+ to various needed computations.
594
+
595
+ """
596
+
597
+ def __str__(self) -> str:
598
+ out = "LISA Constellation Configurations Settings:\n"
599
+ for key, item in self.__dict__.items():
600
+ out += f"{key}: {item}\n"
601
+ return out
602
+
603
+ def lisanoises(
604
+ self,
605
+ f: float | np.ndarray,
606
+ unit: Optional[str] = "relative_frequency",
607
+ ) -> Tuple[float, float]:
608
+ """Calculate both LISA noise terms based on input model.
609
+ Args:
610
+ f: Frequency array.
611
+ unit: Either ``"relative_frequency"`` or ``"displacement"``.
612
+ Returns:
613
+ Tuple with acceleration term as first value and oms term as second value.
614
+ """
615
+
616
+ # TODO: fix this up
617
+ Soms_d_in = self.Soms_d
618
+ Sa_a_in = self.Sa_a
619
+
620
+ frq = f
621
+ ### Acceleration noise
622
+ ## In acceleration
623
+ Sa_a = Sa_a_in * (1.0 + (0.4e-3 / frq) ** 2) * (1.0 + (frq / 8e-3) ** 4)
624
+ ## In displacement
625
+ Sa_d = Sa_a * (2.0 * np.pi * frq) ** (-4.0)
626
+ ## In relative frequency unit
627
+ Sa_nu = Sa_d * (2.0 * np.pi * frq / C_SI) ** 2
628
+ Spm = Sa_nu
629
+
630
+ ### Optical Metrology System
631
+ ## In displacement
632
+ Soms_d = Soms_d_in * (1.0 + (2.0e-3 / f) ** 4)
633
+ ## In relative frequency unit
634
+ Soms_nu = Soms_d * (2.0 * np.pi * frq / C_SI) ** 2
635
+ Sop = Soms_nu
636
+
637
+ if unit == "displacement":
638
+ return Sa_d, Soms_d
639
+ elif unit == "relative_frequency":
640
+ return Spm, Sop
641
+
642
+
643
+ # defaults
644
+ scirdv1 = LISAModel((15.0e-12) ** 2, (3.0e-15) ** 2, DefaultOrbits(), "scirdv1")
645
+ proposal = LISAModel((10.0e-12) ** 2, (3.0e-15) ** 2, DefaultOrbits(), "proposal")
646
+ mrdv1 = LISAModel((10.0e-12) ** 2, (2.4e-15) ** 2, DefaultOrbits(), "mrdv1")
647
+ sangria = LISAModel((7.9e-12) ** 2, (2.4e-15) ** 2, DefaultOrbits(), "sangria")
648
+
649
+ __stock_list_models__ = [scirdv1, proposal, mrdv1, sangria]
650
+ __stock_list_models_name__ = [tmp.name for tmp in __stock_list_models__]
651
+
652
+
653
+ def get_available_default_lisa_models() -> List[LISAModel]:
654
+ """Get list of default LISA models
655
+
656
+ Returns:
657
+ List of LISA models.
658
+
659
+ """
660
+ return __stock_list_models__
661
+
662
+
663
+ def get_default_lisa_model_from_str(model: str) -> LISAModel:
664
+ """Return a LISA model from a ``str`` input.
665
+
666
+ Args:
667
+ model: Model indicated with a ``str``.
668
+
669
+ Returns:
670
+ LISA model associated to that ``str``.
671
+
672
+ """
673
+ if model not in __stock_list_models_name__:
674
+ raise ValueError(
675
+ "Requested string model is not available. See lisatools.detector documentation."
676
+ )
677
+ return globals()[model]
678
+
679
+
680
+ def check_lisa_model(model: Any) -> LISAModel:
681
+ """Check input LISA model.
682
+
683
+ Args:
684
+ model: LISA model to check.
685
+
686
+ Returns:
687
+ LISA Model checked. Adjusted from ``str`` if ``str`` input.
688
+
689
+ """
690
+ if isinstance(model, str):
691
+ model = get_default_lisa_model_from_str(model)
692
+
693
+ if not isinstance(model, LISAModel):
694
+ raise ValueError("model argument not given correctly.")
695
+
696
+ return model