lisaanalysistools 1.0.5__cp312-cp312-macosx_10_9_x86_64.whl → 1.0.7__cp312-cp312-macosx_10_9_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.
- {lisaanalysistools-1.0.5.dist-info → lisaanalysistools-1.0.7.dist-info}/METADATA +12 -6
- lisaanalysistools-1.0.7.dist-info/RECORD +36 -0
- {lisaanalysistools-1.0.5.dist-info → lisaanalysistools-1.0.7.dist-info}/WHEEL +1 -1
- {lisaanalysistools-1.0.5.dist-info → lisaanalysistools-1.0.7.dist-info}/top_level.txt +0 -1
- lisatools/_version.py +1 -1
- lisatools/cutils/__init__.py +0 -0
- lisatools/cutils/detector_cpu.cpython-312-darwin.so +0 -0
- lisatools/cutils/include/Detector.hpp +78 -0
- lisatools/cutils/include/__init__.py +0 -0
- lisatools/cutils/include/global.hpp +28 -0
- lisatools/cutils/src/Detector.cpp +210 -0
- lisatools/cutils/src/Detector.cu +210 -0
- lisatools/cutils/src/__init__.py +0 -0
- lisatools/cutils/src/pycppdetector.pyx +199 -0
- lisatools/datacontainer.py +24 -6
- lisatools/detector.py +59 -14
- lisatools/diagnostic.py +4 -4
- lisatools/sensitivity.py +1 -0
- lisatools/sources/emri/tdiwaveform.py +3 -2
- lisatools/stochastic.py +2 -1
- lisatools/utils/utility.py +2 -3
- lisaanalysistools-1.0.5.dist-info/RECORD +0 -28
- lisatools/cutils/detector.cpython-312-darwin.so +0 -0
- {lisaanalysistools-1.0.5.dist-info → lisaanalysistools-1.0.7.dist-info}/LICENSE +0 -0
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
Metadata-Version: 2.1
|
|
2
2
|
Name: lisaanalysistools
|
|
3
|
-
Version: 1.0.
|
|
4
|
-
Home-page: https://github.com/mikekatz04/
|
|
3
|
+
Version: 1.0.7
|
|
4
|
+
Home-page: https://github.com/mikekatz04/LISAanalysistools
|
|
5
5
|
Author: Michael Katz
|
|
6
6
|
Author-email: mikekatz04@gmail.com
|
|
7
7
|
Classifier: Programming Language :: Python :: 3
|
|
@@ -36,7 +36,9 @@ pip install lisaanalysistools
|
|
|
36
36
|
|
|
37
37
|
If you want to install all of the tools associated with LISA Analysis Tools (Fast EMRI Waveforms, BBHx, GBGPU, fastlisaresponse, eryn), see the following instructions.
|
|
38
38
|
|
|
39
|
-
LISA Analysis Tools leverages conda environments to install and use necessary packages. If you do not have [Anaconda](https://www.anaconda.com/download) or [miniconda](https://docs.anaconda.com/free/miniconda/index.html) installed, you must do this first and load your `base` conda environment.
|
|
39
|
+
LISA Analysis Tools leverages conda environments to install and use necessary packages. If you do not have [Anaconda](https://www.anaconda.com/download) or [miniconda](https://docs.anaconda.com/free/miniconda/index.html) installed, you must do this first and load your `base` conda environment. Recommended components for install in your conda environment are `lapack`, `gsl`, `hdf5`, which are needed for various waveform packages.
|
|
40
|
+
|
|
41
|
+
For an easy full install, follow these instructions.
|
|
40
42
|
|
|
41
43
|
First, clone the repo and `cd` to the `LATW` directory.:
|
|
42
44
|
```
|
|
@@ -50,7 +52,11 @@ bash install.sh
|
|
|
50
52
|
```
|
|
51
53
|
Running `bash install.sh -h` will also give you some basic install options.
|
|
52
54
|
|
|
53
|
-
If you want more flexibility, you can install each package given above separately.
|
|
55
|
+
If you want more flexibility, you can install each package given above separately.
|
|
56
|
+
|
|
57
|
+
To install this software for use with NVIDIA GPUs (compute capability >5.0), you need the [CUDA toolkit](https://docs.nvidia.com/cuda/cuda-installation-guide-linux/index.html) and [CuPy](https://cupy.chainer.org/). The CUDA toolkit must have cuda version >8.0. Be sure to properly install CuPy within the correct CUDA toolkit version. Make sure the nvcc binary is on `$PATH` or set it as the `CUDA_HOME` environment variable.
|
|
58
|
+
|
|
59
|
+
We are currently working on building wheels and making the GPU version pip installable. For now, to work with GPUs, git clone the repository and install it from source.
|
|
54
60
|
|
|
55
61
|
## Contributing
|
|
56
62
|
|
|
@@ -58,9 +64,9 @@ Please read [CONTRIBUTING.md](CONTRIBUTING.md) for details on our code of conduc
|
|
|
58
64
|
|
|
59
65
|
## Versioning
|
|
60
66
|
|
|
61
|
-
We use [SemVer](http://semver.org/) for versioning. For the versions available, see the [tags on this repository](https://github.com/
|
|
67
|
+
We use [SemVer](http://semver.org/) for versioning. For the versions available, see the [tags on this repository](https://github.com/mikekatz04/LISAanalysistools/tags).
|
|
62
68
|
|
|
63
|
-
Current Version: 1.0.
|
|
69
|
+
Current Version: 1.0.7
|
|
64
70
|
|
|
65
71
|
## Authors/Developers
|
|
66
72
|
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
lisatools/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
2
|
+
lisatools/_version.py,sha256=-zmsQRMbGGNv3OHlChLFgB4Mm3Z4ucN7sI_XyxEnGhw,123
|
|
3
|
+
lisatools/analysiscontainer.py,sha256=ePwTBUTEBJn2TK93_afARate9SAqUKK8c8T6DcGUx1Y,15321
|
|
4
|
+
lisatools/datacontainer.py,sha256=hzdTsAsYGhVCjTUG4BFJ0mjO4kCJuQI3oLT5YaSz4ZM,9844
|
|
5
|
+
lisatools/detector.py,sha256=KSyE-9fRhf1aXZDiYJV5qC5jIOtnZ6oaRM9Jg5IRIpQ,15344
|
|
6
|
+
lisatools/diagnostic.py,sha256=fLaQi_xtugnlAWifgYKHWF1wx0pk1yJXW2achO_UedM,34158
|
|
7
|
+
lisatools/sensitivity.py,sha256=HkXAWIbJ-X52av1sz4dnmurUcUU4HUC3G3718G7QktM,27332
|
|
8
|
+
lisatools/stochastic.py,sha256=CysAQ5BIVD349fLjAMpZAXaT0X0dFjrd4QFi0vfqops,9458
|
|
9
|
+
lisatools/cutils/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
10
|
+
lisatools/cutils/detector_cpu.cpython-312-darwin.so,sha256=QQFxyuqx9L7HciApuIiw2tLkh-7Qqs4PRkiOWkqcClM,126912
|
|
11
|
+
lisatools/cutils/include/Detector.hpp,sha256=dzdo8QUrrcAnfrTyytlZkQrYmVk_QWXXTL68p4COpZ8,1926
|
|
12
|
+
lisatools/cutils/include/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
13
|
+
lisatools/cutils/include/global.hpp,sha256=3VPiqglTMRrIBXlEvDUJO2-CjKy_SLUXZt-9A1fH6lQ,572
|
|
14
|
+
lisatools/cutils/src/Detector.cpp,sha256=RbPYrK70m0heUZyFha-2_FJOW8Fg9vKfZQzNIXvOqUQ,5188
|
|
15
|
+
lisatools/cutils/src/Detector.cu,sha256=RbPYrK70m0heUZyFha-2_FJOW8Fg9vKfZQzNIXvOqUQ,5188
|
|
16
|
+
lisatools/cutils/src/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
17
|
+
lisatools/cutils/src/pycppdetector.pyx,sha256=N0AyF5YPPqmHaBKuj4gZVXOt67z9qKwzpB6jlh9zWRY,5581
|
|
18
|
+
lisatools/sampling/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
19
|
+
lisatools/sampling/likelihood.py,sha256=G2kAQ43qlhAzIFWvYsrSmHXd7WKJAzcCN2o07vRE8vc,29585
|
|
20
|
+
lisatools/sampling/prior.py,sha256=1K1PMStpwO9WT0qG0aotKSyoNjuehXNbzTDtlk8Q15M,21407
|
|
21
|
+
lisatools/sampling/stopping.py,sha256=Q8q7nM0wnJervhRduf2tBXZZHUVza5kJiAUAMUQXP5o,9682
|
|
22
|
+
lisatools/sampling/utility.py,sha256=rOGotS0Aj8-DAWqsTVy2xWNsxsoz74BVrHEnG2mOkwU,14340
|
|
23
|
+
lisatools/sampling/moves/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
24
|
+
lisatools/sampling/moves/skymodehop.py,sha256=0nf72eFhFMGwi0dLJci6XZz-bIMGqco2B2_J72hQvf8,3348
|
|
25
|
+
lisatools/sources/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
26
|
+
lisatools/sources/emri/__init__.py,sha256=HjsWS4mjog_gRE4N90My6ahLKQGjNwrHIeA40R7qzw0,41
|
|
27
|
+
lisatools/sources/emri/tdiwaveform.py,sha256=tPbPAARKD-gscy8C5C5uqVor5YoWdP1ZApErhfg2KYc,2334
|
|
28
|
+
lisatools/utils/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
29
|
+
lisatools/utils/constants.py,sha256=r1kVwkpbZS13JTOxj2iRxT5sMgTYX30y-S0JdVmD5Oo,1354
|
|
30
|
+
lisatools/utils/pointeradjust.py,sha256=2sT-7qeYWr1pd_sHk9leVHUTSJ7jJgYIRoWQOtYqguE,2995
|
|
31
|
+
lisatools/utils/utility.py,sha256=MKqRsG8qRI1xCsj51mt6QRa80-deUUgedxibyMV3KD4,6776
|
|
32
|
+
lisaanalysistools-1.0.7.dist-info/LICENSE,sha256=xx0jnfkXJvxRnG63LTGOxlggYnIysveWIZ6H3PNdCrQ,11357
|
|
33
|
+
lisaanalysistools-1.0.7.dist-info/METADATA,sha256=Y9xZqm2Wkx-6thoi1pW4QYMh7ilsgwzN91MlP28h7W0,4109
|
|
34
|
+
lisaanalysistools-1.0.7.dist-info/WHEEL,sha256=wTFHiv6xiwExbw_CBGcw1b3hAKzFq_QaWIv4Plh5P0w,110
|
|
35
|
+
lisaanalysistools-1.0.7.dist-info/top_level.txt,sha256=qXUn8Xi8yvK0vr3QH0vvT5cmoccjSj-UPeKGLAxdYGo,10
|
|
36
|
+
lisaanalysistools-1.0.7.dist-info/RECORD,,
|
lisatools/_version.py
CHANGED
|
File without changes
|
|
Binary file
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
#ifndef __DETECTOR_HPP__
|
|
2
|
+
#define __DETECTOR_HPP__
|
|
3
|
+
|
|
4
|
+
#include "global.hpp"
|
|
5
|
+
#include <iostream>
|
|
6
|
+
|
|
7
|
+
class Vec
|
|
8
|
+
{
|
|
9
|
+
public:
|
|
10
|
+
double x;
|
|
11
|
+
double y;
|
|
12
|
+
double z;
|
|
13
|
+
|
|
14
|
+
CUDA_DEVICE
|
|
15
|
+
Vec(double x_, double y_, double z_)
|
|
16
|
+
{
|
|
17
|
+
x = x_;
|
|
18
|
+
y = y_;
|
|
19
|
+
z = z_;
|
|
20
|
+
}
|
|
21
|
+
};
|
|
22
|
+
|
|
23
|
+
class Orbits
|
|
24
|
+
{
|
|
25
|
+
public:
|
|
26
|
+
double dt;
|
|
27
|
+
int N;
|
|
28
|
+
double *n_arr;
|
|
29
|
+
double *ltt_arr;
|
|
30
|
+
double *x_arr;
|
|
31
|
+
int nlinks;
|
|
32
|
+
int nspacecraft;
|
|
33
|
+
int *links;
|
|
34
|
+
int *sc_r;
|
|
35
|
+
int *sc_e;
|
|
36
|
+
|
|
37
|
+
Orbits(double dt_, int N_, double *n_arr_, double *ltt_arr_, double *x_arr_, int *links_, int *sc_r_, int *sc_e_)
|
|
38
|
+
{
|
|
39
|
+
dt = dt_;
|
|
40
|
+
N = N_;
|
|
41
|
+
n_arr = n_arr_;
|
|
42
|
+
ltt_arr = ltt_arr_;
|
|
43
|
+
x_arr = x_arr_;
|
|
44
|
+
nlinks = 6;
|
|
45
|
+
nspacecraft = 3;
|
|
46
|
+
|
|
47
|
+
sc_r = sc_r_;
|
|
48
|
+
sc_e = sc_e_;
|
|
49
|
+
links = links_;
|
|
50
|
+
|
|
51
|
+
// std::cout << " START " << std::endl;
|
|
52
|
+
// for (int i = 0; i < nlinks; i += 1)
|
|
53
|
+
// {
|
|
54
|
+
// sc_r[i] = sc_r_[i];
|
|
55
|
+
// sc_e[i] = sc_e_[i];
|
|
56
|
+
// links[i] = links_[i];
|
|
57
|
+
// // std::cout << i << " HAHAHAH " << sc_r_[i] << " " << sc_e_[i] << std::endl;
|
|
58
|
+
// }
|
|
59
|
+
};
|
|
60
|
+
|
|
61
|
+
CUDA_DEVICE int get_window(double t);
|
|
62
|
+
CUDA_DEVICE Vec get_normal_unit_vec(double t, int link);
|
|
63
|
+
CUDA_DEVICE double interpolate(double t, double *in_arr, int window, int major_ndim, int major_ind, int ndim, int pos);
|
|
64
|
+
CUDA_DEVICE int get_link_ind(int link);
|
|
65
|
+
CUDA_DEVICE int get_sc_ind(int sc);
|
|
66
|
+
CUDA_DEVICE double get_light_travel_time(double t, int link);
|
|
67
|
+
CUDA_DEVICE Vec get_pos(double t, int sc);
|
|
68
|
+
CUDA_DEVICE void get_normal_unit_vec_ptr(Vec *vec, double t, int link);
|
|
69
|
+
CUDA_DEVICE void get_pos_ptr(Vec *vec, double t, int sc);
|
|
70
|
+
void get_light_travel_time_arr(double *ltt, double *t, int *link, int num);
|
|
71
|
+
void dealloc(){
|
|
72
|
+
// delete[] links;
|
|
73
|
+
// delete[] sc_r;
|
|
74
|
+
// delete[] sc_e;
|
|
75
|
+
};
|
|
76
|
+
};
|
|
77
|
+
|
|
78
|
+
#endif // __DETECTOR_HPP__
|
|
File without changes
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
#ifndef __GLOBAL_HPP__
|
|
2
|
+
#define __GLOBAL_HPP__
|
|
3
|
+
|
|
4
|
+
#ifdef __CUDACC__
|
|
5
|
+
#define CUDA_KERNEL __global__
|
|
6
|
+
#define CUDA_DEVICE __device__
|
|
7
|
+
|
|
8
|
+
#else // __CUDACC__
|
|
9
|
+
#define CUDA_KERNEL
|
|
10
|
+
#define CUDA_DEVICE
|
|
11
|
+
|
|
12
|
+
#endif // __CUDACC__
|
|
13
|
+
|
|
14
|
+
#ifdef __CUDACC__
|
|
15
|
+
#define gpuErrchk(ans) { gpuAssert((ans), __FILE__, __LINE__); }
|
|
16
|
+
inline void gpuAssert(cudaError_t code, const char *file, int line, bool abort=true)
|
|
17
|
+
{
|
|
18
|
+
if (code != cudaSuccess)
|
|
19
|
+
{
|
|
20
|
+
fprintf(stderr,"GPUassert: %s %s %d\n", cudaGetErrorString(code), file, line);
|
|
21
|
+
if (abort) exit(code);
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
#endif
|
|
26
|
+
|
|
27
|
+
|
|
28
|
+
#endif // __GLOBAL_HPP__
|
|
@@ -0,0 +1,210 @@
|
|
|
1
|
+
#include "stdio.h"
|
|
2
|
+
#include "global.hpp"
|
|
3
|
+
#include "Detector.hpp"
|
|
4
|
+
#include <iostream>
|
|
5
|
+
#include <stdexcept>
|
|
6
|
+
#include <string>
|
|
7
|
+
#include <sstream>
|
|
8
|
+
|
|
9
|
+
CUDA_DEVICE
|
|
10
|
+
int Orbits::get_window(double t)
|
|
11
|
+
{
|
|
12
|
+
int out = int(t / dt);
|
|
13
|
+
if ((out < 0) || (out >= N))
|
|
14
|
+
return -1;
|
|
15
|
+
else
|
|
16
|
+
return out;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
CUDA_DEVICE
|
|
20
|
+
int Orbits::get_link_ind(int link)
|
|
21
|
+
{
|
|
22
|
+
if (link == 12)
|
|
23
|
+
return 0;
|
|
24
|
+
else if (link == 23)
|
|
25
|
+
return 1;
|
|
26
|
+
else if (link == 31)
|
|
27
|
+
return 2;
|
|
28
|
+
else if (link == 13)
|
|
29
|
+
return 3;
|
|
30
|
+
else if (link == 32)
|
|
31
|
+
return 4;
|
|
32
|
+
else if (link == 21)
|
|
33
|
+
return 5;
|
|
34
|
+
else
|
|
35
|
+
#ifdef __CUDACC__
|
|
36
|
+
printf("BAD link ind. Must be 12, 23, 31, 13, 32, 21.");
|
|
37
|
+
#else
|
|
38
|
+
throw std::invalid_argument("Bad link ind. Must be 12, 23, 31, 13, 32, 21.");
|
|
39
|
+
#endif // __CUDACC__
|
|
40
|
+
return -1;
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
CUDA_DEVICE
|
|
44
|
+
int Orbits::get_sc_ind(int sc)
|
|
45
|
+
{
|
|
46
|
+
if (sc == 1)
|
|
47
|
+
return 0;
|
|
48
|
+
else if (sc == 2)
|
|
49
|
+
return 1;
|
|
50
|
+
else if (sc == 3)
|
|
51
|
+
return 2;
|
|
52
|
+
else
|
|
53
|
+
{
|
|
54
|
+
#ifdef __CUDACC__
|
|
55
|
+
printf("BAD sc ind. Must be 1,2,3. %d\n", sc);
|
|
56
|
+
#else
|
|
57
|
+
std::ostringstream oss;
|
|
58
|
+
int xxxx = 1;
|
|
59
|
+
oss << "Bad sc ind. Must be 1,2,3. Input sc is " << sc << " " << xxxx;
|
|
60
|
+
std::string var = oss.str();
|
|
61
|
+
throw std::invalid_argument(var);
|
|
62
|
+
#endif // __CUDACC__
|
|
63
|
+
}
|
|
64
|
+
return 0;
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
CUDA_DEVICE
|
|
68
|
+
double Orbits::interpolate(double t, double *in_arr, int window, int major_ndim, int major_ind, int ndim, int pos)
|
|
69
|
+
{
|
|
70
|
+
double up = in_arr[((window + 1) * major_ndim + major_ind) * ndim + pos]; // down_ind * ndim + pos];
|
|
71
|
+
double down = in_arr[(window * major_ndim + major_ind) * ndim + pos];
|
|
72
|
+
|
|
73
|
+
// m *(x - x0) + y0
|
|
74
|
+
double fin = ((up - down) / dt) * (t - (dt * window)) + down;
|
|
75
|
+
// if ((ndim == 1))
|
|
76
|
+
// printf("%d %e %e %e %e \n", window, fin, down, up, (t - (dt * window)));
|
|
77
|
+
|
|
78
|
+
return fin;
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
CUDA_DEVICE
|
|
82
|
+
void Orbits::get_normal_unit_vec_ptr(Vec *vec, double t, int link)
|
|
83
|
+
{
|
|
84
|
+
Vec _tmp = get_normal_unit_vec(t, link);
|
|
85
|
+
vec->x = _tmp.x;
|
|
86
|
+
vec->y = _tmp.y;
|
|
87
|
+
vec->z = _tmp.z;
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
CUDA_DEVICE
|
|
91
|
+
Vec Orbits::get_normal_unit_vec(double t, int link)
|
|
92
|
+
{
|
|
93
|
+
int window = get_window(t);
|
|
94
|
+
if (window == -1)
|
|
95
|
+
{
|
|
96
|
+
// out of bounds
|
|
97
|
+
return Vec(0.0, 0.0, 0.0);
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
int link_ind = get_link_ind(link);
|
|
101
|
+
|
|
102
|
+
int up_ind = (window + 1) * nlinks + link_ind;
|
|
103
|
+
int down_ind = window * nlinks + link_ind;
|
|
104
|
+
|
|
105
|
+
// x (pos = 0) ndim = 3
|
|
106
|
+
double x_out = interpolate(t, n_arr, window, nlinks, link_ind, 3, 0);
|
|
107
|
+
// y (pos = 1)
|
|
108
|
+
double y_out = interpolate(t, n_arr, window, nlinks, link_ind, 3, 1);
|
|
109
|
+
// z (pos = 2)
|
|
110
|
+
double z_out = interpolate(t, n_arr, window, nlinks, link_ind, 3, 2);
|
|
111
|
+
|
|
112
|
+
return Vec(x_out, y_out, z_out);
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
CUDA_DEVICE
|
|
116
|
+
double Orbits::get_light_travel_time(double t, int link)
|
|
117
|
+
{
|
|
118
|
+
int window = get_window(t);
|
|
119
|
+
if (window == -1)
|
|
120
|
+
{
|
|
121
|
+
// out of bounds
|
|
122
|
+
return 0.0;
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
int link_ind = get_link_ind(link);
|
|
126
|
+
if ((link_ind < 0) || (link_ind >= 6))
|
|
127
|
+
printf("BAD %d\n", link_ind);
|
|
128
|
+
int up_ind = (window + 1) * (nlinks + link_ind);
|
|
129
|
+
int down_ind = window * (nlinks + link_ind);
|
|
130
|
+
|
|
131
|
+
// x (pos = 0), ndim = 1
|
|
132
|
+
double ltt_out = interpolate(t, ltt_arr, window, nlinks, link_ind, 1, 0);
|
|
133
|
+
|
|
134
|
+
return ltt_out;
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
CUDA_DEVICE
|
|
138
|
+
Vec Orbits::get_pos(double t, int sc)
|
|
139
|
+
{
|
|
140
|
+
int window = get_window(t);
|
|
141
|
+
if (window == -1)
|
|
142
|
+
{
|
|
143
|
+
// out of bounds
|
|
144
|
+
return Vec(0.0, 0.0, 0.0);
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
int sc_ind = get_sc_ind(sc);
|
|
148
|
+
|
|
149
|
+
// x (pos = 0), ndim = 3
|
|
150
|
+
double x_out = interpolate(t, x_arr, window, nspacecraft, sc_ind, 3, 0);
|
|
151
|
+
// y (pos = 1), ndim = 3
|
|
152
|
+
double y_out = interpolate(t, x_arr, window, nspacecraft, sc_ind, 3, 1);
|
|
153
|
+
// z (pos = 2), ndim = 3
|
|
154
|
+
double z_out = interpolate(t, x_arr, window, nspacecraft, sc_ind, 3, 2);
|
|
155
|
+
return Vec(x_out, y_out, z_out);
|
|
156
|
+
}
|
|
157
|
+
|
|
158
|
+
CUDA_DEVICE
|
|
159
|
+
void Orbits::get_pos_ptr(Vec *vec, double t, int sc)
|
|
160
|
+
{
|
|
161
|
+
Vec _tmp = get_pos(t, sc);
|
|
162
|
+
vec->x = _tmp.x;
|
|
163
|
+
vec->y = _tmp.y;
|
|
164
|
+
vec->z = _tmp.z;
|
|
165
|
+
}
|
|
166
|
+
|
|
167
|
+
#define NUM_THREADS 64
|
|
168
|
+
|
|
169
|
+
CUDA_KERNEL
|
|
170
|
+
void get_light_travel_time_kernel(double *ltt, double *t, int *link, int num, Orbits& orbits)
|
|
171
|
+
{
|
|
172
|
+
int start, end, increment;
|
|
173
|
+
#ifdef __CUDACC__
|
|
174
|
+
start = blockIdx.x * blockDim.x + threadIdx.x;
|
|
175
|
+
end = num;
|
|
176
|
+
increment = gridDim.x * blockDim.x;
|
|
177
|
+
#else // __CUDACC__
|
|
178
|
+
start = 0;
|
|
179
|
+
end = num;
|
|
180
|
+
increment = 1;
|
|
181
|
+
#endif // __CUDACC__
|
|
182
|
+
|
|
183
|
+
for (int i = start; i < end; i += increment)
|
|
184
|
+
{
|
|
185
|
+
ltt[i] = orbits.get_light_travel_time(t[i], link[i]);
|
|
186
|
+
}
|
|
187
|
+
}
|
|
188
|
+
|
|
189
|
+
void Orbits::get_light_travel_time_arr(double *ltt, double *t, int *link, int num)
|
|
190
|
+
{
|
|
191
|
+
#ifdef __CUDACC__
|
|
192
|
+
int num_blocks = std::ceil((num + NUM_THREADS - 1) / NUM_THREADS);
|
|
193
|
+
|
|
194
|
+
// copy self to GPU
|
|
195
|
+
Orbits *orbits_gpu;
|
|
196
|
+
gpuErrchk(cudaMalloc(&orbits_gpu, sizeof(Orbits)));
|
|
197
|
+
gpuErrchk(cudaMemcpy(orbits_gpu, this, sizeof(Orbits), cudaMemcpyHostToDevice));
|
|
198
|
+
|
|
199
|
+
get_light_travel_time_kernel<<<num_blocks, NUM_THREADS>>>(ltt, t, link, num, *orbits_gpu);
|
|
200
|
+
cudaDeviceSynchronize();
|
|
201
|
+
gpuErrchk(cudaGetLastError());
|
|
202
|
+
|
|
203
|
+
gpuErrchk(cudaFree(orbits_gpu));
|
|
204
|
+
|
|
205
|
+
#else // __CUDACC__
|
|
206
|
+
|
|
207
|
+
get_light_travel_time_kernel(ltt, t, link, num, *this);
|
|
208
|
+
|
|
209
|
+
#endif // __CUDACC__
|
|
210
|
+
}
|
|
@@ -0,0 +1,210 @@
|
|
|
1
|
+
#include "stdio.h"
|
|
2
|
+
#include "global.hpp"
|
|
3
|
+
#include "Detector.hpp"
|
|
4
|
+
#include <iostream>
|
|
5
|
+
#include <stdexcept>
|
|
6
|
+
#include <string>
|
|
7
|
+
#include <sstream>
|
|
8
|
+
|
|
9
|
+
CUDA_DEVICE
|
|
10
|
+
int Orbits::get_window(double t)
|
|
11
|
+
{
|
|
12
|
+
int out = int(t / dt);
|
|
13
|
+
if ((out < 0) || (out >= N))
|
|
14
|
+
return -1;
|
|
15
|
+
else
|
|
16
|
+
return out;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
CUDA_DEVICE
|
|
20
|
+
int Orbits::get_link_ind(int link)
|
|
21
|
+
{
|
|
22
|
+
if (link == 12)
|
|
23
|
+
return 0;
|
|
24
|
+
else if (link == 23)
|
|
25
|
+
return 1;
|
|
26
|
+
else if (link == 31)
|
|
27
|
+
return 2;
|
|
28
|
+
else if (link == 13)
|
|
29
|
+
return 3;
|
|
30
|
+
else if (link == 32)
|
|
31
|
+
return 4;
|
|
32
|
+
else if (link == 21)
|
|
33
|
+
return 5;
|
|
34
|
+
else
|
|
35
|
+
#ifdef __CUDACC__
|
|
36
|
+
printf("BAD link ind. Must be 12, 23, 31, 13, 32, 21.");
|
|
37
|
+
#else
|
|
38
|
+
throw std::invalid_argument("Bad link ind. Must be 12, 23, 31, 13, 32, 21.");
|
|
39
|
+
#endif // __CUDACC__
|
|
40
|
+
return -1;
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
CUDA_DEVICE
|
|
44
|
+
int Orbits::get_sc_ind(int sc)
|
|
45
|
+
{
|
|
46
|
+
if (sc == 1)
|
|
47
|
+
return 0;
|
|
48
|
+
else if (sc == 2)
|
|
49
|
+
return 1;
|
|
50
|
+
else if (sc == 3)
|
|
51
|
+
return 2;
|
|
52
|
+
else
|
|
53
|
+
{
|
|
54
|
+
#ifdef __CUDACC__
|
|
55
|
+
printf("BAD sc ind. Must be 1,2,3. %d\n", sc);
|
|
56
|
+
#else
|
|
57
|
+
std::ostringstream oss;
|
|
58
|
+
int xxxx = 1;
|
|
59
|
+
oss << "Bad sc ind. Must be 1,2,3. Input sc is " << sc << " " << xxxx;
|
|
60
|
+
std::string var = oss.str();
|
|
61
|
+
throw std::invalid_argument(var);
|
|
62
|
+
#endif // __CUDACC__
|
|
63
|
+
}
|
|
64
|
+
return 0;
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
CUDA_DEVICE
|
|
68
|
+
double Orbits::interpolate(double t, double *in_arr, int window, int major_ndim, int major_ind, int ndim, int pos)
|
|
69
|
+
{
|
|
70
|
+
double up = in_arr[((window + 1) * major_ndim + major_ind) * ndim + pos]; // down_ind * ndim + pos];
|
|
71
|
+
double down = in_arr[(window * major_ndim + major_ind) * ndim + pos];
|
|
72
|
+
|
|
73
|
+
// m *(x - x0) + y0
|
|
74
|
+
double fin = ((up - down) / dt) * (t - (dt * window)) + down;
|
|
75
|
+
// if ((ndim == 1))
|
|
76
|
+
// printf("%d %e %e %e %e \n", window, fin, down, up, (t - (dt * window)));
|
|
77
|
+
|
|
78
|
+
return fin;
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
CUDA_DEVICE
|
|
82
|
+
void Orbits::get_normal_unit_vec_ptr(Vec *vec, double t, int link)
|
|
83
|
+
{
|
|
84
|
+
Vec _tmp = get_normal_unit_vec(t, link);
|
|
85
|
+
vec->x = _tmp.x;
|
|
86
|
+
vec->y = _tmp.y;
|
|
87
|
+
vec->z = _tmp.z;
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
CUDA_DEVICE
|
|
91
|
+
Vec Orbits::get_normal_unit_vec(double t, int link)
|
|
92
|
+
{
|
|
93
|
+
int window = get_window(t);
|
|
94
|
+
if (window == -1)
|
|
95
|
+
{
|
|
96
|
+
// out of bounds
|
|
97
|
+
return Vec(0.0, 0.0, 0.0);
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
int link_ind = get_link_ind(link);
|
|
101
|
+
|
|
102
|
+
int up_ind = (window + 1) * nlinks + link_ind;
|
|
103
|
+
int down_ind = window * nlinks + link_ind;
|
|
104
|
+
|
|
105
|
+
// x (pos = 0) ndim = 3
|
|
106
|
+
double x_out = interpolate(t, n_arr, window, nlinks, link_ind, 3, 0);
|
|
107
|
+
// y (pos = 1)
|
|
108
|
+
double y_out = interpolate(t, n_arr, window, nlinks, link_ind, 3, 1);
|
|
109
|
+
// z (pos = 2)
|
|
110
|
+
double z_out = interpolate(t, n_arr, window, nlinks, link_ind, 3, 2);
|
|
111
|
+
|
|
112
|
+
return Vec(x_out, y_out, z_out);
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
CUDA_DEVICE
|
|
116
|
+
double Orbits::get_light_travel_time(double t, int link)
|
|
117
|
+
{
|
|
118
|
+
int window = get_window(t);
|
|
119
|
+
if (window == -1)
|
|
120
|
+
{
|
|
121
|
+
// out of bounds
|
|
122
|
+
return 0.0;
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
int link_ind = get_link_ind(link);
|
|
126
|
+
if ((link_ind < 0) || (link_ind >= 6))
|
|
127
|
+
printf("BAD %d\n", link_ind);
|
|
128
|
+
int up_ind = (window + 1) * (nlinks + link_ind);
|
|
129
|
+
int down_ind = window * (nlinks + link_ind);
|
|
130
|
+
|
|
131
|
+
// x (pos = 0), ndim = 1
|
|
132
|
+
double ltt_out = interpolate(t, ltt_arr, window, nlinks, link_ind, 1, 0);
|
|
133
|
+
|
|
134
|
+
return ltt_out;
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
CUDA_DEVICE
|
|
138
|
+
Vec Orbits::get_pos(double t, int sc)
|
|
139
|
+
{
|
|
140
|
+
int window = get_window(t);
|
|
141
|
+
if (window == -1)
|
|
142
|
+
{
|
|
143
|
+
// out of bounds
|
|
144
|
+
return Vec(0.0, 0.0, 0.0);
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
int sc_ind = get_sc_ind(sc);
|
|
148
|
+
|
|
149
|
+
// x (pos = 0), ndim = 3
|
|
150
|
+
double x_out = interpolate(t, x_arr, window, nspacecraft, sc_ind, 3, 0);
|
|
151
|
+
// y (pos = 1), ndim = 3
|
|
152
|
+
double y_out = interpolate(t, x_arr, window, nspacecraft, sc_ind, 3, 1);
|
|
153
|
+
// z (pos = 2), ndim = 3
|
|
154
|
+
double z_out = interpolate(t, x_arr, window, nspacecraft, sc_ind, 3, 2);
|
|
155
|
+
return Vec(x_out, y_out, z_out);
|
|
156
|
+
}
|
|
157
|
+
|
|
158
|
+
CUDA_DEVICE
|
|
159
|
+
void Orbits::get_pos_ptr(Vec *vec, double t, int sc)
|
|
160
|
+
{
|
|
161
|
+
Vec _tmp = get_pos(t, sc);
|
|
162
|
+
vec->x = _tmp.x;
|
|
163
|
+
vec->y = _tmp.y;
|
|
164
|
+
vec->z = _tmp.z;
|
|
165
|
+
}
|
|
166
|
+
|
|
167
|
+
#define NUM_THREADS 64
|
|
168
|
+
|
|
169
|
+
CUDA_KERNEL
|
|
170
|
+
void get_light_travel_time_kernel(double *ltt, double *t, int *link, int num, Orbits& orbits)
|
|
171
|
+
{
|
|
172
|
+
int start, end, increment;
|
|
173
|
+
#ifdef __CUDACC__
|
|
174
|
+
start = blockIdx.x * blockDim.x + threadIdx.x;
|
|
175
|
+
end = num;
|
|
176
|
+
increment = gridDim.x * blockDim.x;
|
|
177
|
+
#else // __CUDACC__
|
|
178
|
+
start = 0;
|
|
179
|
+
end = num;
|
|
180
|
+
increment = 1;
|
|
181
|
+
#endif // __CUDACC__
|
|
182
|
+
|
|
183
|
+
for (int i = start; i < end; i += increment)
|
|
184
|
+
{
|
|
185
|
+
ltt[i] = orbits.get_light_travel_time(t[i], link[i]);
|
|
186
|
+
}
|
|
187
|
+
}
|
|
188
|
+
|
|
189
|
+
void Orbits::get_light_travel_time_arr(double *ltt, double *t, int *link, int num)
|
|
190
|
+
{
|
|
191
|
+
#ifdef __CUDACC__
|
|
192
|
+
int num_blocks = std::ceil((num + NUM_THREADS - 1) / NUM_THREADS);
|
|
193
|
+
|
|
194
|
+
// copy self to GPU
|
|
195
|
+
Orbits *orbits_gpu;
|
|
196
|
+
gpuErrchk(cudaMalloc(&orbits_gpu, sizeof(Orbits)));
|
|
197
|
+
gpuErrchk(cudaMemcpy(orbits_gpu, this, sizeof(Orbits), cudaMemcpyHostToDevice));
|
|
198
|
+
|
|
199
|
+
get_light_travel_time_kernel<<<num_blocks, NUM_THREADS>>>(ltt, t, link, num, *orbits_gpu);
|
|
200
|
+
cudaDeviceSynchronize();
|
|
201
|
+
gpuErrchk(cudaGetLastError());
|
|
202
|
+
|
|
203
|
+
gpuErrchk(cudaFree(orbits_gpu));
|
|
204
|
+
|
|
205
|
+
#else // __CUDACC__
|
|
206
|
+
|
|
207
|
+
get_light_travel_time_kernel(ltt, t, link, num, *this);
|
|
208
|
+
|
|
209
|
+
#endif // __CUDACC__
|
|
210
|
+
}
|
|
File without changes
|
|
@@ -0,0 +1,199 @@
|
|
|
1
|
+
import numpy as np
|
|
2
|
+
cimport numpy as np
|
|
3
|
+
from libcpp.string cimport string
|
|
4
|
+
from libcpp cimport bool
|
|
5
|
+
from lisatools.utils.pointeradjust import wrapper
|
|
6
|
+
from libc.stdint cimport uintptr_t
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
cdef extern from "../include/Detector.hpp":
|
|
10
|
+
cdef cppclass VecWrap "Vec":
|
|
11
|
+
double x
|
|
12
|
+
double y
|
|
13
|
+
double z
|
|
14
|
+
VecWrap(double x_, double y_, double z_) except+
|
|
15
|
+
|
|
16
|
+
cdef cppclass OrbitsWrap "Orbits":
|
|
17
|
+
OrbitsWrap(double dt_, int N_, double *n_arr_, double *L_arr_, double *x_arr_, int *links_, int *sc_r_, int *sc_e_) except+
|
|
18
|
+
int get_window(double t) except+
|
|
19
|
+
void get_normal_unit_vec_ptr(VecWrap *vec, double t, int link)
|
|
20
|
+
int get_link_ind(int link) except+
|
|
21
|
+
int get_sc_ind(int sc) except+
|
|
22
|
+
double get_light_travel_time(double t, int link) except+
|
|
23
|
+
VecWrap get_pos_ptr(VecWrap* out, double t, int sc) except+
|
|
24
|
+
void get_light_travel_time_arr(double *ltt, double *t, int *link, int num) except+
|
|
25
|
+
void dealloc();
|
|
26
|
+
|
|
27
|
+
|
|
28
|
+
cdef class pycppDetector:
|
|
29
|
+
cdef OrbitsWrap *g
|
|
30
|
+
cdef double dt
|
|
31
|
+
cdef int N
|
|
32
|
+
cdef size_t n_arr
|
|
33
|
+
cdef size_t L_arr
|
|
34
|
+
cdef size_t x_arr
|
|
35
|
+
cdef size_t links
|
|
36
|
+
cdef size_t sc_r
|
|
37
|
+
cdef size_t sc_e
|
|
38
|
+
|
|
39
|
+
def __cinit__(self,
|
|
40
|
+
*args,
|
|
41
|
+
**kwargs
|
|
42
|
+
):
|
|
43
|
+
(
|
|
44
|
+
dt,
|
|
45
|
+
N,
|
|
46
|
+
n_arr,
|
|
47
|
+
L_arr,
|
|
48
|
+
x_arr,
|
|
49
|
+
links,
|
|
50
|
+
sc_r,
|
|
51
|
+
sc_e
|
|
52
|
+
), tkwargs = wrapper(*args, **kwargs)
|
|
53
|
+
|
|
54
|
+
self.dt = dt
|
|
55
|
+
self.N = N
|
|
56
|
+
self.n_arr = n_arr
|
|
57
|
+
self.L_arr = L_arr
|
|
58
|
+
self.x_arr = x_arr
|
|
59
|
+
self.links = links
|
|
60
|
+
self.sc_r = sc_r
|
|
61
|
+
self.sc_e = sc_e
|
|
62
|
+
|
|
63
|
+
cdef size_t n_arr_in = n_arr
|
|
64
|
+
cdef size_t L_arr_in = L_arr
|
|
65
|
+
cdef size_t x_arr_in = x_arr
|
|
66
|
+
cdef size_t links_in = links
|
|
67
|
+
cdef size_t sc_r_in = sc_r
|
|
68
|
+
cdef size_t sc_e_in = sc_e
|
|
69
|
+
|
|
70
|
+
self.g = new OrbitsWrap(
|
|
71
|
+
dt,
|
|
72
|
+
N,
|
|
73
|
+
<double*> n_arr_in,
|
|
74
|
+
<double*> L_arr_in,
|
|
75
|
+
<double*> x_arr_in,
|
|
76
|
+
<int*> links_in,
|
|
77
|
+
<int*> sc_r_in,
|
|
78
|
+
<int*> sc_e_in
|
|
79
|
+
)
|
|
80
|
+
|
|
81
|
+
def __dealloc__(self):
|
|
82
|
+
self.g.dealloc()
|
|
83
|
+
if self.g:
|
|
84
|
+
del self.g
|
|
85
|
+
|
|
86
|
+
def __reduce__(self):
|
|
87
|
+
return (rebuild, (self.dt, self.N, self.n_arr, self.L_arr, self.x_arr, self.links, self.sc_r, self.sc_e,))
|
|
88
|
+
|
|
89
|
+
def get_window(self, t: float) -> int:
|
|
90
|
+
return self.g.get_window(t)
|
|
91
|
+
|
|
92
|
+
def get_normal_unit_vec_single(self, t: float, link: int) -> np.ndarray:
|
|
93
|
+
cdef VecWrap *out = new VecWrap(0.0, 0.0, 0.0)
|
|
94
|
+
self.g.get_normal_unit_vec_ptr(out, t, link)
|
|
95
|
+
|
|
96
|
+
return np.array([out.x, out.y, out.z])
|
|
97
|
+
|
|
98
|
+
def get_normal_unit_vec_arr(self, t: np.ndarray, link: int) -> np.ndarray:
|
|
99
|
+
output = np.zeros((len(t), 3), dtype=float)
|
|
100
|
+
assert t.ndim == 1
|
|
101
|
+
for i in range(len(t)):
|
|
102
|
+
output[i] = self.get_normal_unit_vec_single(t[i], link)
|
|
103
|
+
|
|
104
|
+
return output
|
|
105
|
+
|
|
106
|
+
def get_normal_unit_vec(self, t: np.ndarray | float, link: int) -> np.ndarray:
|
|
107
|
+
|
|
108
|
+
if isinstance(t, float):
|
|
109
|
+
return self.get_normal_unit_vec_single(t, link)
|
|
110
|
+
elif isinstance(t, np.ndarray):
|
|
111
|
+
return self.get_normal_unit_vec_arr(t, link)
|
|
112
|
+
|
|
113
|
+
def get_link_ind(self, link: int) -> int:
|
|
114
|
+
return self.g.get_link_ind(link)
|
|
115
|
+
|
|
116
|
+
def get_sc_ind(self, sc: int) -> int:
|
|
117
|
+
return self.g.get_sc_ind(sc)
|
|
118
|
+
|
|
119
|
+
def get_light_travel_time_single(self, t: float, link: int) -> float:
|
|
120
|
+
return self.g.get_light_travel_time(t, link)
|
|
121
|
+
|
|
122
|
+
def get_light_travel_time_arr(self, t: np.ndarray, link: int) -> np.ndarray:
|
|
123
|
+
output = np.zeros((len(t),), dtype=float)
|
|
124
|
+
assert t.ndim == 1
|
|
125
|
+
for i in range(len(t)):
|
|
126
|
+
output[i] = self.get_light_travel_time_single(t[i], link)
|
|
127
|
+
|
|
128
|
+
return output
|
|
129
|
+
|
|
130
|
+
def get_light_travel_time(self, t: np.ndarray | float, link: int) -> np.ndarray:
|
|
131
|
+
|
|
132
|
+
if isinstance(t, float):
|
|
133
|
+
print("t", t)
|
|
134
|
+
return self.get_light_travel_time_single(t, link)
|
|
135
|
+
elif isinstance(t, np.ndarray):
|
|
136
|
+
return self.get_light_travel_time_arr(t, link)
|
|
137
|
+
|
|
138
|
+
def get_pos_single(self, t: float, sc: int) -> np.ndarray:
|
|
139
|
+
|
|
140
|
+
cdef VecWrap *out = new VecWrap(0.0, 0.0, 0.0)
|
|
141
|
+
self.g.get_pos_ptr(out, t, sc)
|
|
142
|
+
|
|
143
|
+
return np.array([out.x, out.y, out.z])
|
|
144
|
+
|
|
145
|
+
def get_pos_arr(self, t: np.ndarray, sc: int) -> np.ndarray:
|
|
146
|
+
output = np.zeros((len(t), 3), dtype=float)
|
|
147
|
+
assert t.ndim == 1
|
|
148
|
+
for i in range(len(t)):
|
|
149
|
+
output[i] = self.get_pos_single(t[i], sc)
|
|
150
|
+
|
|
151
|
+
return output
|
|
152
|
+
|
|
153
|
+
def get_pos(self, t: np.ndarray | float, sc: int) -> np.ndarray:
|
|
154
|
+
|
|
155
|
+
if isinstance(t, float):
|
|
156
|
+
return self.get_pos_single(t, sc)
|
|
157
|
+
elif isinstance(t, np.ndarray):
|
|
158
|
+
return self.get_pos_arr(t, sc)
|
|
159
|
+
|
|
160
|
+
def get_light_travel_time_arr_wrap(self, *args, **kwargs):
|
|
161
|
+
(ltt, t, link, num), tkwargs = wrapper(*args, **kwargs)
|
|
162
|
+
|
|
163
|
+
cdef size_t ltt_in = ltt
|
|
164
|
+
cdef size_t t_in = t
|
|
165
|
+
cdef size_t link_in = link
|
|
166
|
+
|
|
167
|
+
self.g.get_light_travel_time_arr(
|
|
168
|
+
<double *>ltt_in,
|
|
169
|
+
<double *>t_in,
|
|
170
|
+
<int *>link_in,
|
|
171
|
+
num
|
|
172
|
+
)
|
|
173
|
+
|
|
174
|
+
|
|
175
|
+
@property
|
|
176
|
+
def ptr(self) -> long:
|
|
177
|
+
return <uintptr_t>self.g
|
|
178
|
+
|
|
179
|
+
|
|
180
|
+
def rebuild(dt,
|
|
181
|
+
N,
|
|
182
|
+
n_arr,
|
|
183
|
+
L_arr,
|
|
184
|
+
x_arr,
|
|
185
|
+
links,
|
|
186
|
+
sc_r,
|
|
187
|
+
sc_e
|
|
188
|
+
):
|
|
189
|
+
c = pycppDetector(
|
|
190
|
+
dt,
|
|
191
|
+
N,
|
|
192
|
+
n_arr,
|
|
193
|
+
L_arr,
|
|
194
|
+
x_arr,
|
|
195
|
+
links,
|
|
196
|
+
sc_r,
|
|
197
|
+
sc_e
|
|
198
|
+
)
|
|
199
|
+
return c
|
lisatools/datacontainer.py
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
from __future__ import annotations
|
|
1
2
|
import warnings
|
|
2
3
|
from abc import ABC
|
|
3
4
|
from typing import Any, Tuple, Optional, List
|
|
@@ -28,14 +29,19 @@ class DataResidualArray:
|
|
|
28
29
|
|
|
29
30
|
|
|
30
31
|
class DataResidualArray:
|
|
31
|
-
"""Container to hold
|
|
32
|
+
"""Container to hold Data, residual, or template information.
|
|
33
|
+
|
|
34
|
+
This class abstracts the connection with the sensitivity matrices to make this analysis
|
|
35
|
+
as generic as possible for the user frontend, while handling
|
|
36
|
+
special computations in the backend.
|
|
32
37
|
|
|
33
38
|
Args:
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
+
data_res_in: Data, residual, or template input information. Can be a list, numpy array
|
|
40
|
+
or another :class:`DataResidualArray`.
|
|
41
|
+
dt: Timestep in seconds.
|
|
42
|
+
f_arr: Frequency array.
|
|
43
|
+
df: Delta f in frequency domain.
|
|
44
|
+
**kwargs: For future compatibility.
|
|
39
45
|
|
|
40
46
|
"""
|
|
41
47
|
|
|
@@ -145,14 +151,17 @@ class DataResidualArray:
|
|
|
145
151
|
|
|
146
152
|
@property
|
|
147
153
|
def fmax(self):
|
|
154
|
+
"""Maximum frequency."""
|
|
148
155
|
return self._fmax
|
|
149
156
|
|
|
150
157
|
@property
|
|
151
158
|
def f_arr(self):
|
|
159
|
+
"""Frequency array."""
|
|
152
160
|
return self._f_arr
|
|
153
161
|
|
|
154
162
|
@property
|
|
155
163
|
def dt(self):
|
|
164
|
+
"""Time step in seconds."""
|
|
156
165
|
if self._dt is None:
|
|
157
166
|
raise ValueError("dt cannot be determined from this f_arr input.")
|
|
158
167
|
|
|
@@ -160,6 +169,7 @@ class DataResidualArray:
|
|
|
160
169
|
|
|
161
170
|
@property
|
|
162
171
|
def Tobs(self):
|
|
172
|
+
"""Observation time in seconds"""
|
|
163
173
|
if self._Tobs is None:
|
|
164
174
|
raise ValueError("Tobs cannot be determined from this f_arr input.")
|
|
165
175
|
|
|
@@ -167,6 +177,7 @@ class DataResidualArray:
|
|
|
167
177
|
|
|
168
178
|
@property
|
|
169
179
|
def df(self):
|
|
180
|
+
"""Delta f in the frequency domain."""
|
|
170
181
|
if self._df is None:
|
|
171
182
|
raise ValueError("df cannot be determined from this f_arr input.")
|
|
172
183
|
|
|
@@ -174,14 +185,17 @@ class DataResidualArray:
|
|
|
174
185
|
|
|
175
186
|
@property
|
|
176
187
|
def frequency_arr(self) -> np.ndarray:
|
|
188
|
+
"""Frequency array"""
|
|
177
189
|
return self._f_arr
|
|
178
190
|
|
|
179
191
|
@property
|
|
180
192
|
def data_res_arr(self) -> np.ndarray:
|
|
193
|
+
"""Actual data residual array"""
|
|
181
194
|
return self._data_res_arr
|
|
182
195
|
|
|
183
196
|
@data_res_arr.setter
|
|
184
197
|
def data_res_arr(self, data_res_arr: List[np.ndarray] | np.ndarray) -> None:
|
|
198
|
+
"""Set ``data_res_arr``."""
|
|
185
199
|
self._data_res_arr_input = data_res_arr
|
|
186
200
|
|
|
187
201
|
if (
|
|
@@ -214,17 +228,21 @@ class DataResidualArray:
|
|
|
214
228
|
self._data_res_arr = np.asarray(list(new_out), dtype=complex)
|
|
215
229
|
|
|
216
230
|
def __getitem__(self, index: tuple) -> np.ndarray:
|
|
231
|
+
"""Index this class directly in ``self.data_res_arr``."""
|
|
217
232
|
return self.data_res_arr[index]
|
|
218
233
|
|
|
219
234
|
@property
|
|
220
235
|
def ndim(self) -> int:
|
|
236
|
+
"""Number of dimensions in the `data_res_arr`."""
|
|
221
237
|
return self.data_res_arr.ndim
|
|
222
238
|
|
|
223
239
|
def flatten(self) -> np.ndarray:
|
|
240
|
+
"""Flatten the ``data_res_arr``."""
|
|
224
241
|
return self.data_res_arr.flatten()
|
|
225
242
|
|
|
226
243
|
@property
|
|
227
244
|
def shape(self) -> tuple:
|
|
245
|
+
"""Shape of ``data_res_arr``."""
|
|
228
246
|
return self.data_res_arr.shape
|
|
229
247
|
|
|
230
248
|
def loglog(
|
lisatools/detector.py
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
from __future__ import annotations
|
|
1
2
|
import os
|
|
2
3
|
from abc import ABC, abstractmethod
|
|
3
4
|
from typing import Any, List, Tuple, Optional
|
|
@@ -5,10 +6,20 @@ from dataclasses import dataclass
|
|
|
5
6
|
import requests
|
|
6
7
|
|
|
7
8
|
import numpy as np
|
|
9
|
+
|
|
10
|
+
# import for cpu/gpu
|
|
11
|
+
from lisatools.cutils.detector_cpu import pycppDetector as pycppDetector_cpu
|
|
12
|
+
|
|
13
|
+
try:
|
|
14
|
+
import cupy as cp
|
|
15
|
+
from lisatools.cutils.detector_gpu import pycppDetector as pycppDetector_gpu
|
|
16
|
+
|
|
17
|
+
except (ImportError, ModuleNotFoundError) as e:
|
|
18
|
+
pycppDetector_gpu = None # for doc string purposes
|
|
19
|
+
|
|
8
20
|
import h5py
|
|
9
21
|
from scipy import interpolate
|
|
10
22
|
|
|
11
|
-
from lisatools.cutils.detector import pycppDetector
|
|
12
23
|
|
|
13
24
|
SC = [1, 2, 3]
|
|
14
25
|
LINKS = [12, 23, 31, 13, 32, 21]
|
|
@@ -21,14 +32,22 @@ class Orbits(ABC):
|
|
|
21
32
|
|
|
22
33
|
Args:
|
|
23
34
|
filename: File name. File should be in the style of LISAOrbits
|
|
35
|
+
use_gpu: If ``True``, use a gpu.
|
|
24
36
|
|
|
25
37
|
"""
|
|
26
38
|
|
|
27
|
-
def __init__(self, filename: str) -> None:
|
|
39
|
+
def __init__(self, filename: str, use_gpu: bool = False) -> None:
|
|
40
|
+
self.use_gpu = use_gpu
|
|
28
41
|
self.filename = filename
|
|
29
42
|
self._setup()
|
|
30
43
|
self.configured = False
|
|
31
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
|
+
|
|
32
51
|
@property
|
|
33
52
|
def LINKS(self) -> List[int]:
|
|
34
53
|
"""Link order."""
|
|
@@ -229,6 +248,8 @@ class Orbits(ABC):
|
|
|
229
248
|
t_arr = np.concatenate([t_arr, self.t_base[-1:]])
|
|
230
249
|
elif t_arr is not None:
|
|
231
250
|
assert np.all(t_arr >= self.t_base[0]) and np.all(t_arr <= self.t_base[-1])
|
|
251
|
+
make_cpp = True
|
|
252
|
+
dt = abs(t_arr[1] - t_arr[0])
|
|
232
253
|
|
|
233
254
|
elif dt is not None:
|
|
234
255
|
make_cpp = True
|
|
@@ -266,12 +287,12 @@ class Orbits(ABC):
|
|
|
266
287
|
self.pycppdetector_args = (
|
|
267
288
|
dt,
|
|
268
289
|
len(self.t),
|
|
269
|
-
self.n.flatten().copy(),
|
|
270
|
-
self.ltt.flatten().copy(),
|
|
271
|
-
self.x.flatten().copy(),
|
|
272
|
-
ll,
|
|
273
|
-
lsr,
|
|
274
|
-
lse,
|
|
290
|
+
self.xp.asarray(self.n.flatten().copy()),
|
|
291
|
+
self.xp.asarray(self.ltt.flatten().copy()),
|
|
292
|
+
self.xp.asarray(self.x.flatten().copy()),
|
|
293
|
+
self.xp.asarray(ll),
|
|
294
|
+
self.xp.asarray(lsr),
|
|
295
|
+
self.xp.asarray(lse),
|
|
275
296
|
)
|
|
276
297
|
self.dt = dt
|
|
277
298
|
else:
|
|
@@ -290,12 +311,13 @@ class Orbits(ABC):
|
|
|
290
311
|
self._dt = dt
|
|
291
312
|
|
|
292
313
|
@property
|
|
293
|
-
def pycppdetector(self) ->
|
|
314
|
+
def pycppdetector(self) -> pycppDetector_cpu | pycppDetector_gpu:
|
|
294
315
|
"""C++ class"""
|
|
295
316
|
if self._pycppdetector_args is None:
|
|
296
317
|
raise ValueError(
|
|
297
318
|
"Asking for c++ class. Need to set linear_interp_setup = True when configuring."
|
|
298
319
|
)
|
|
320
|
+
pycppDetector = pycppDetector_cpu if not self.use_gpu else pycppDetector_gpu
|
|
299
321
|
self._pycppdetector = pycppDetector(*self._pycppdetector_args)
|
|
300
322
|
return self._pycppdetector
|
|
301
323
|
|
|
@@ -335,7 +357,24 @@ class Orbits(ABC):
|
|
|
335
357
|
Light travel times.
|
|
336
358
|
|
|
337
359
|
"""
|
|
338
|
-
|
|
360
|
+
if isinstance(t, float) and isinstance(link, int):
|
|
361
|
+
squeeze = True
|
|
362
|
+
t = self.xp.atleast_1d(t)
|
|
363
|
+
link = self.xp.atleast_1d(link).astype(np.int32)
|
|
364
|
+
|
|
365
|
+
else:
|
|
366
|
+
squeeze = False
|
|
367
|
+
t = self.xp.asarray(t)
|
|
368
|
+
link = self.xp.asarray(link).astype(np.int32)
|
|
369
|
+
|
|
370
|
+
ltt_out = self.xp.zeros_like(t)
|
|
371
|
+
self.pycppdetector.get_light_travel_time_arr_wrap(
|
|
372
|
+
ltt_out, t, link, len(ltt_out)
|
|
373
|
+
)
|
|
374
|
+
|
|
375
|
+
if squeeze:
|
|
376
|
+
return ltt_out[0]
|
|
377
|
+
return ltt_out
|
|
339
378
|
|
|
340
379
|
def get_normal_unit_vec(self, t: float | np.ndarray, link: int) -> np.ndarray:
|
|
341
380
|
"""Compute link normal vector as a function of time.
|
|
@@ -378,10 +417,13 @@ class EqualArmlengthOrbits(Orbits):
|
|
|
378
417
|
|
|
379
418
|
Orbit file: equalarmlength-orbits.h5
|
|
380
419
|
|
|
420
|
+
Args:
|
|
421
|
+
*args, **kwargs: for :class:`Orbits`.
|
|
422
|
+
|
|
381
423
|
"""
|
|
382
424
|
|
|
383
|
-
def __init__(self):
|
|
384
|
-
super().__init__("equalarmlength-orbits.h5")
|
|
425
|
+
def __init__(self, *args: Any, **kwargs: Any):
|
|
426
|
+
super().__init__("equalarmlength-orbits.h5", *args, **kwargs)
|
|
385
427
|
|
|
386
428
|
|
|
387
429
|
class ESAOrbits(Orbits):
|
|
@@ -389,11 +431,14 @@ class ESAOrbits(Orbits):
|
|
|
389
431
|
|
|
390
432
|
Orbit file: esa-trailing-orbits.h5
|
|
391
433
|
|
|
434
|
+
Args:
|
|
435
|
+
*args, **kwargs: for :class:`Orbits`.
|
|
436
|
+
|
|
392
437
|
"""
|
|
393
438
|
|
|
394
|
-
def __init__(self):
|
|
439
|
+
def __init__(self, *args, **kwargs):
|
|
395
440
|
# TODO: fix this up
|
|
396
|
-
super().__init__("esa-trailing-orbits.h5")
|
|
441
|
+
super().__init__("esa-trailing-orbits.h5", *args, **kwargs)
|
|
397
442
|
|
|
398
443
|
|
|
399
444
|
class DefaultOrbits(EqualArmlengthOrbits):
|
lisatools/diagnostic.py
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
+
from __future__ import annotations
|
|
1
2
|
import warnings
|
|
2
|
-
from types import ModuleType, NoneType
|
|
3
3
|
from typing import Optional, Any, Tuple, List
|
|
4
4
|
|
|
5
5
|
import matplotlib.pyplot as plt
|
|
@@ -27,7 +27,7 @@ def inner_product(
|
|
|
27
27
|
dt: Optional[float] = None,
|
|
28
28
|
df: Optional[float] = None,
|
|
29
29
|
f_arr: Optional[float] = None,
|
|
30
|
-
psd: Optional[str |
|
|
30
|
+
psd: Optional[str | None | np.ndarray | SensitivityMatrix] = "LISASens",
|
|
31
31
|
psd_args: Optional[tuple] = (),
|
|
32
32
|
psd_kwargs: Optional[dict] = {},
|
|
33
33
|
normalize: Optional[bool | str] = False,
|
|
@@ -243,7 +243,7 @@ def noise_likelihood_term(psd: SensitivityMatrix) -> float:
|
|
|
243
243
|
|
|
244
244
|
def residual_full_source_and_noise_likelihood(
|
|
245
245
|
data_res_arr: DataResidualArray,
|
|
246
|
-
psd: str |
|
|
246
|
+
psd: str | None | np.ndarray | SensitivityMatrix,
|
|
247
247
|
**kwargs: dict,
|
|
248
248
|
) -> float | complex:
|
|
249
249
|
"""Calculate the full Likelihood including noise and source terms.
|
|
@@ -306,7 +306,7 @@ def data_signal_source_likelihood_term(
|
|
|
306
306
|
def data_signal_full_source_and_noise_likelihood(
|
|
307
307
|
data_arr: DataResidualArray,
|
|
308
308
|
sig_arr: DataResidualArray,
|
|
309
|
-
psd: str |
|
|
309
|
+
psd: str | None | np.ndarray | SensitivityMatrix,
|
|
310
310
|
**kwargs: dict,
|
|
311
311
|
) -> float | complex:
|
|
312
312
|
"""Calculate the full Likelihood including noise and source terms.
|
lisatools/sensitivity.py
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
from __future__ import annotations
|
|
1
2
|
from lisatools.detector import EqualArmlengthOrbits
|
|
2
3
|
import numpy as np
|
|
3
4
|
from typing import Optional, Any
|
|
@@ -49,7 +50,7 @@ class EMRITDIWaveform(ResponseWrapper):
|
|
|
49
50
|
gen_wave = GenerateEMRIWaveform(
|
|
50
51
|
*emri_waveform_args,
|
|
51
52
|
sum_kwargs=dict(pad_output=True),
|
|
52
|
-
**emri_waveform_kwargs
|
|
53
|
+
**emri_waveform_kwargs,
|
|
53
54
|
)
|
|
54
55
|
|
|
55
56
|
response_kwargs_in = deepcopy(response_kwargs)
|
|
@@ -64,7 +65,7 @@ class EMRITDIWaveform(ResponseWrapper):
|
|
|
64
65
|
remove_sky_coords=False,
|
|
65
66
|
is_ecliptic_latitude=False,
|
|
66
67
|
remove_garbage=True, # removes the beginning of the signal that has bad information
|
|
67
|
-
**response_kwargs_in
|
|
68
|
+
**response_kwargs_in,
|
|
68
69
|
)
|
|
69
70
|
|
|
70
71
|
def __call__(self, *args: Any, **kwargs: Any) -> Any:
|
lisatools/stochastic.py
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
from __future__ import annotations
|
|
1
2
|
import warnings
|
|
2
3
|
from abc import ABC
|
|
3
4
|
from typing import Any, Tuple, Optional, List, Dict
|
|
@@ -249,7 +250,7 @@ class FittedHyperbolicTangentGalacticForeground(HyperbolicTangentGalacticForegro
|
|
|
249
250
|
|
|
250
251
|
Args:
|
|
251
252
|
f: Frequency array.
|
|
252
|
-
Tobs: Observation time in
|
|
253
|
+
Tobs: Observation time in seconds.
|
|
253
254
|
|
|
254
255
|
Returns:
|
|
255
256
|
PSD of the Galaxy foreground noise
|
lisatools/utils/utility.py
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
from
|
|
2
|
-
from types import ModuleType, NoneType
|
|
1
|
+
from __future__ import annotations
|
|
3
2
|
from typing import Tuple
|
|
4
3
|
import numpy as np
|
|
5
4
|
|
|
@@ -14,7 +13,7 @@ except (ModuleNotFoundError, ImportError):
|
|
|
14
13
|
pass
|
|
15
14
|
|
|
16
15
|
|
|
17
|
-
def get_array_module(arr: np.ndarray | cp.ndarray) ->
|
|
16
|
+
def get_array_module(arr: np.ndarray | cp.ndarray) -> object:
|
|
18
17
|
"""Return array library of an array (np/cp).
|
|
19
18
|
|
|
20
19
|
Args:
|
|
@@ -1,28 +0,0 @@
|
|
|
1
|
-
lisatools/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
2
|
-
lisatools/_version.py,sha256=QnhTB8xNwmBZijHj3vbB3rZZAVZJsQdBQ0N3zLG2pMY,123
|
|
3
|
-
lisatools/analysiscontainer.py,sha256=ePwTBUTEBJn2TK93_afARate9SAqUKK8c8T6DcGUx1Y,15321
|
|
4
|
-
lisatools/datacontainer.py,sha256=W89ErPJynfeioZwYqcpehHVorhKsb8FLKrj69zIsKKU,9187
|
|
5
|
-
lisatools/detector.py,sha256=_S7fmtOaFLIzTfVnVTXjD58rvl7-DVy2WR4aG1V-CsE,13851
|
|
6
|
-
lisatools/diagnostic.py,sha256=CfPpfvDys1XyZRWmmTqTSWb0SY2eH0G_8TRnt1OxBFo,34174
|
|
7
|
-
lisatools/sensitivity.py,sha256=rckXeJ_5U3cRRgbYDmt0kaTyJRjkrYfgBwos12QJJfw,27297
|
|
8
|
-
lisatools/stochastic.py,sha256=wdiToEj4nUpCDIb0j7vQ7netTPDDtPGPbUg8-RiFA9U,9421
|
|
9
|
-
lisatools/cutils/detector.cpython-312-darwin.so,sha256=FguczB3QPZfL3CCSMEuIx3VP0jj240_Dh30anER84m8,121664
|
|
10
|
-
lisatools/sampling/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
11
|
-
lisatools/sampling/likelihood.py,sha256=G2kAQ43qlhAzIFWvYsrSmHXd7WKJAzcCN2o07vRE8vc,29585
|
|
12
|
-
lisatools/sampling/prior.py,sha256=1K1PMStpwO9WT0qG0aotKSyoNjuehXNbzTDtlk8Q15M,21407
|
|
13
|
-
lisatools/sampling/stopping.py,sha256=Q8q7nM0wnJervhRduf2tBXZZHUVza5kJiAUAMUQXP5o,9682
|
|
14
|
-
lisatools/sampling/utility.py,sha256=rOGotS0Aj8-DAWqsTVy2xWNsxsoz74BVrHEnG2mOkwU,14340
|
|
15
|
-
lisatools/sampling/moves/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
16
|
-
lisatools/sampling/moves/skymodehop.py,sha256=0nf72eFhFMGwi0dLJci6XZz-bIMGqco2B2_J72hQvf8,3348
|
|
17
|
-
lisatools/sources/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
18
|
-
lisatools/sources/emri/__init__.py,sha256=HjsWS4mjog_gRE4N90My6ahLKQGjNwrHIeA40R7qzw0,41
|
|
19
|
-
lisatools/sources/emri/tdiwaveform.py,sha256=jaKL2PO8RlJrHP45zCa4BpRniLfdnMIP1QsIB-6jVq4,2297
|
|
20
|
-
lisatools/utils/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
21
|
-
lisatools/utils/constants.py,sha256=r1kVwkpbZS13JTOxj2iRxT5sMgTYX30y-S0JdVmD5Oo,1354
|
|
22
|
-
lisatools/utils/pointeradjust.py,sha256=2sT-7qeYWr1pd_sHk9leVHUTSJ7jJgYIRoWQOtYqguE,2995
|
|
23
|
-
lisatools/utils/utility.py,sha256=3mJoJKNGrm3KuNXIa2RUKi9WKd593V4q9XjjQZCQD0M,6831
|
|
24
|
-
lisaanalysistools-1.0.5.dist-info/LICENSE,sha256=xx0jnfkXJvxRnG63LTGOxlggYnIysveWIZ6H3PNdCrQ,11357
|
|
25
|
-
lisaanalysistools-1.0.5.dist-info/METADATA,sha256=zfuyj8R4brFWnqruMjtzkbTxmVQ5L9Lelh9zNrslfPs,3380
|
|
26
|
-
lisaanalysistools-1.0.5.dist-info/WHEEL,sha256=KYtn_mzb_QwZSHwPlosUO3fDl70znfUFngLlrLVHeBY,111
|
|
27
|
-
lisaanalysistools-1.0.5.dist-info/top_level.txt,sha256=oCQGY7qy66i_b9MCsK2fTRdbV1pcC9GsGgIDjN47Tyc,14
|
|
28
|
-
lisaanalysistools-1.0.5.dist-info/RECORD,,
|
|
Binary file
|
|
File without changes
|