lisaanalysistools 1.0.10__cp312-cp312-macosx_10_13_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 might be problematic. Click here for more details.

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