-
Notifications
You must be signed in to change notification settings - Fork 355
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
add coordinates_space.py #4289
Merged
Merged
add coordinates_space.py #4289
Changes from 1 commit
Commits
Show all changes
144 commits
Select commit
Hold shift + click to select a range
06522ce
add coordinates_space.py
WuShichao a967fbb
add LISA/SSB frame params
WuShichao d31f211
add LISA_to_GEO and GEO_to_LISA
WuShichao 3bbb0b1
add coordinates_space into FieldArray
WuShichao b1e3216
add doc and Astropy support
WuShichao 27c26a9
update comments on sympy
WuShichao bd83c64
use fsolve from scipy instead
WuShichao bf07a1e
fix cc issues
WuShichao f1c21fb
fix cc issues
WuShichao e856f4b
minor fix
WuShichao e85bc51
update
WuShichao 62fdd9f
Merge branch 'gwastro:master' into multiband_transform
WuShichao a1c8739
not use iteration
WuShichao 542523d
Merge branch 'gwastro:master' into multiband_transform
WuShichao 668ae7d
decouple LISA orbit and more accurate Earth
WuShichao cae4757
rename
WuShichao e3b5f84
remove jplephem
WuShichao 0cddb9c
add the angular displacement of the Earth
WuShichao ced106d
use radians
WuShichao d67375f
make func readable in .ini
WuShichao 5d9e72d
reverse back to master
WuShichao df18e9b
correct psi range
WuShichao c03d88c
reverse to master
WuShichao 352073e
Merge branch 'multiband_transform' of https://github.com/WuShichao/py…
WuShichao 52ec83b
fix unit issue in earth_position_SSB
WuShichao 79bc677
put LISA to the "right" position
WuShichao 6f1ebca
add LISA specific transform classes here
WuShichao ac4fc40
change names
WuShichao 0b89641
update
WuShichao 4f01ef2
make a package for coordinates
WuShichao cd10893
remove coordinates_space import
WuShichao b8e5625
move __all__ into __init__.py
WuShichao 2615d02
remove all coordinates_space
WuShichao b432f0e
change TIME_OFFSET to seconds
WuShichao b434c09
fix SOBHB issue
WuShichao 5f14830
rename
WuShichao 0f85dc3
add SSB or LISA params into fid_params
WuShichao e00d1b6
rename
WuShichao 7b2e5e4
fix cc issues
WuShichao ac74625
fix cc issue
WuShichao ad77581
fix cc issue
WuShichao b91ac58
update
WuShichao cf04a2e
update
WuShichao 54073e4
fix
WuShichao 9d859b5
add default names
WuShichao 7910a95
overwrite params with same names
WuShichao d516d30
remove pre-fixed names
WuShichao 9b57574
remove all pre-fixed names
WuShichao 6c8cef3
not pop
WuShichao 5669f07
fix inverse transform
WuShichao 53b20ce
update tc
WuShichao 3662303
not overwrite
WuShichao 38d95f9
add SNR support for multi-model
WuShichao 7166baa
Update waveform.py
WuShichao 6c806f3
Merge branch 'gwastro:master' into multiband_transform
WuShichao cc0c2d9
t0 issue
WuShichao 830b5c3
t0 issue
WuShichao bc24cd9
Update space.py
WuShichao 2529d52
add obstime
WuShichao 3a9322d
np.mod(psi_newframe, 2*np.pi)
WuShichao 156dfd6
fix obstime
WuShichao 1a38386
add support for array inputs
WuShichao e1b4ca4
Update hierarchical.py
WuShichao b38d47d
Merge branch 'gwastro:master' into multiband_transform
WuShichao 2bfd901
just use Alex's implementation
WuShichao 5372a32
CustomTransformMultiOutputs is in another PR, so remove it
WuShichao 29215db
add LDC and LAL convention correction
WuShichao e2d389c
use pycbc standard names
WuShichao ad2e0a3
more meaningful name
WuShichao 2b2e93a
use pycbc standard names
WuShichao 2ce81bc
Update relbin.py
WuShichao eec4c1c
Merge branch 'gwastro:master' into multiband_transform
WuShichao cee4738
Update parameters.py
WuShichao fc04312
remove unnecessary changes
WuShichao e6f2674
fix cc issue
WuShichao 9cda1f2
fix cc issue
WuShichao f4f8d32
fix cc issue
WuShichao 1279666
fix cc issue
WuShichao ff2af5d
Merge branch 'gwastro:master' into multiband_transform
WuShichao b547483
compactify
WuShichao 7ce1b9d
compactify
WuShichao c997389
add __all__ back
WuShichao f34b1d0
Update transforms.py
WuShichao db90980
Update transforms.py
WuShichao 78b8ec3
Update test_transforms.py
WuShichao 948e3ca
Update transforms.py
WuShichao 7998cd2
update doc
WuShichao d39bf09
fix time warning
WuShichao 199ce9d
Merge branch 'gwastro:master' into multiband_transform
WuShichao 5acd874
Update space.py
WuShichao b45fdce
Update test_transforms.py
WuShichao f513dcc
Create test_coordinates_space.py
WuShichao 9264796
fix cc issues
WuShichao 2c001b6
fix cc issues
WuShichao 6d3c503
fix cc issue
WuShichao 450eebf
Update tox.ini
WuShichao 0af7e89
Update tox.ini
WuShichao a6347b0
Update tox.ini
WuShichao 44e7e21
Update tox.ini
WuShichao 159b6c9
Update tox.ini
WuShichao 9ee8c86
Update tox.ini
WuShichao 5159f75
Update tox.ini
WuShichao 7ddad33
Update test_coordinates_space.py
WuShichao cb8cd25
add inline doc
WuShichao 4aaef29
Update tox.ini
WuShichao 5e3aa85
add check of bbhx
WuShichao 8ed9575
Update test_coordinates_space.py
WuShichao 61d61ed
Update tox.ini
WuShichao d81314e
Merge branch 'gwastro:master' into multiband_transform
WuShichao fbf8fbd
Update test_coordinates_space.py
WuShichao d1fe3c8
Merge branch 'gwastro:master' into multiband_transform
WuShichao 9629250
Merge branch 'gwastro:master' into multiband_transform
WuShichao 3de4b35
Merge branch 'gwastro:master' into multiband_transform
WuShichao 3d9dba7
add MultibandRelativeTimeDom into hierarchical.py
WuShichao b6c27f6
Update __init__.py
WuShichao 37029ca
Update hierarchical.py
WuShichao 6721aff
Merge branch 'gwastro:master' into multiband_transform
WuShichao 635c3ee
Update hierarchical.py
WuShichao 39f4a1d
Merge branch 'gwastro:master' into multiband_transform
WuShichao b24a047
Update relbin.py
WuShichao 395039d
Update hierarchical.py
WuShichao e176430
Update hierarchical.py
WuShichao e3c793e
Update relbin.py
WuShichao 7423058
Update hierarchical.py
WuShichao fef5a3f
Update hierarchical.py
WuShichao 2e78ba8
Update hierarchical.py
WuShichao 116e5bc
Update hierarchical.py
WuShichao cb5a9c4
Update hierarchical.py
WuShichao d13dca2
Update relbin.py
WuShichao b79d265
Update hierarchical.py
WuShichao 7de0de5
Update hierarchical.py
WuShichao 5418546
Update relbin.py
WuShichao 1f9cf7d
Update __init__.py
WuShichao b22eb7e
Merge branch 'gwastro:master' into multiband_transform
WuShichao c673186
Update space.py
WuShichao 2fa62c0
Update space.py
WuShichao c60008f
Update space.py
WuShichao 5eb784a
fix psi issue
WuShichao 7753d85
Merge branch 'gwastro:master' into multiband_transform
WuShichao a6718ca
Update test_coordinates_space.py
WuShichao df1619e
Update test_coordinates_space.py
WuShichao 670f9de
Merge branch 'gwastro:master' into multiband_transform
WuShichao e39902b
Merge branch 'gwastro:master' into multiband_transform
WuShichao f8cb244
Merge branch 'gwastro:master' into multiband_transform
WuShichao File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,196 @@ | ||
# Copyright (C) 2023 Shichao Wu, Alex Nitz | ||
# This program is free software; you can redistribute it and/or modify it | ||
# under the terms of the GNU General Public License as published by the | ||
# Free Software Foundation; either version 3 of the License, or (at your | ||
# option) any later version. | ||
# | ||
# This program is distributed in the hope that it will be useful, but | ||
# WITHOUT ANY WARRANTY; without even the implied warranty of | ||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General | ||
# Public License for more details. | ||
# | ||
# You should have received a copy of the GNU General Public License along | ||
# with this program; if not, write to the Free Software Foundation, Inc., | ||
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. | ||
|
||
|
||
# | ||
# ============================================================================= | ||
# | ||
# Preamble | ||
# | ||
# ============================================================================= | ||
# | ||
""" | ||
This module provides coordinate transform between space-borne detectors and | ||
ground-based detectors. | ||
""" | ||
|
||
import numpy as np | ||
from scipy.spatial.transform import Rotation | ||
from sympy import symbols, nsolve, sin, cos | ||
|
||
|
||
YRSID_SI = 31558149.763545603 | ||
OMEGA_0 = 1.99098659277e-7 | ||
|
||
def localization_to_propagation_vector(lamda, beta): | ||
x = -np.cos(beta) * np.cos(lamda) | ||
y = -np.cos(beta) * np.sin(lamda) | ||
z = -np.sin(beta) | ||
|
||
return np.array([[x], [y], [z]]) | ||
|
||
def rotation_matrix_SSBtoLISA(alpha): | ||
r = Rotation.from_rotvec([ | ||
[0, 0, alpha], | ||
[0, -np.pi/3, 0], | ||
[0, 0, -alpha] | ||
]).as_matrix() | ||
r_total = np.array(r[0]) @ np.array(r[1]) @ np.array(r[2]) | ||
|
||
return r_total | ||
|
||
def propagation_vector_to_localization(k): | ||
# beta already within [-pi/2, pi/2] | ||
beta = np.float64(np.arcsin(-k[2])) | ||
lamda = np.float64(np.arctan2(-k[1]/np.cos(beta), -k[0]/np.cos(beta))) | ||
print("lamda before mod: ", lamda) | ||
# lamda should within [0, 2*pi] | ||
lamda = np.mod(lamda, 2*np.pi) | ||
|
||
return np.array([lamda, beta]) | ||
|
||
def polarization_angle_newframe(psi, k, rotation_matrix): | ||
lamda, beta = propagation_vector_to_localization(k) | ||
u = np.array([[np.sin(lamda)], [-np.cos(lamda)], [0]]) | ||
rotation_vector = psi * k | ||
rotation_psi = Rotation.from_rotvec(rotation_vector.T[0]) | ||
p = rotation_psi.apply(u.T[0]).reshape(3, 1) | ||
p_newframe = rotation_matrix.T @ p | ||
k_newframe = rotation_matrix.T @ k | ||
lamda_newframe, beta_newframe = propagation_vector_to_localization(k_newframe) | ||
u_newframe = np.array([[np.sin(lamda_newframe)], [-np.cos(lamda_newframe)], [0]]) | ||
v_newframe = np.array([[-np.sin(beta_newframe) * np.cos(lamda_newframe)], | ||
[-np.sin(beta_newframe) * np.sin(lamda_newframe)], | ||
[np.cos(beta_newframe)]]) | ||
p_dot_u_newframe = np.vdot(p_newframe, u_newframe) | ||
p_dot_v_newframe = np.vdot(p_newframe, v_newframe) | ||
psi_newframe = np.arctan2(p_dot_v_newframe, p_dot_u_newframe) | ||
psi_newframe = np.mod(psi_newframe, np.pi) | ||
|
||
return psi_newframe | ||
|
||
def tL_from_SSB(tSSB, lamdaSSB, betaSSB, t0=0.0): | ||
R_ORBIT = au.value | ||
OMEGA_L = 2*np.pi / YRSID_SI | ||
t0 *= YRSID_SI | ||
alpha = (tSSB + t0) * OMEGA_L | ||
k = localization_to_propagation_vector(lamdaSSB, betaSSB) | ||
v_LISA = np.array([[R_ORBIT*np.cos(alpha)], | ||
[R_ORBIT*np.sin(alpha)], [0]]) | ||
tL = tSSB + np.vdot(k, v_LISA) / c.value | ||
|
||
return tL | ||
|
||
def tSSB_from_tL(tL, lamdaSSB, betaSSB, t0=0.0): | ||
tSSB = symbols('tSSB') | ||
t0 *= YRSID_SI | ||
R_ORBIT = au.value | ||
OMEGA_L = 2*np.pi / YRSID_SI | ||
|
||
equation = tL - tSSB + R_ORBIT * cos(betaSSB) * ( | ||
cos(lamdaSSB) * cos(OMEGA_L * (tSSB + t0)) + | ||
sin(lamdaSSB) * sin(OMEGA_L * (tSSB + t0)) | ||
) / c.value | ||
|
||
return np.float64(nsolve(equation, tL)) | ||
|
||
def SSB_to_LISA(tSSB, lamdaSSB, betaSSB, psiSSB, t0): | ||
tL = tL_from_SSB(tSSB, lamdaSSB, betaSSB, t0) | ||
kSSB = localization_to_propagation_vector(lamdaSSB, betaSSB) | ||
alpha = OMEGA_0 * (tSSB + t0*YRSID_SI) | ||
rotation_matrix_L = rotation_matrix_SSBtoLISA(alpha) | ||
kL = rotation_matrix_L.T @ kSSB | ||
lamdaL, betaL = propagation_vector_to_localization(kL) | ||
psiL = polarization_angle_newframe(psiSSB, kSSB, rotation_matrix_L) | ||
|
||
return (tL, lamdaL, betaL, psiL) | ||
|
||
def LISA_to_SSB(tL, lamdaL, betaL, psiL, t0): | ||
lamdaSSB_approx = 0.0 | ||
betaSSB_approx = 0.0 | ||
tSSB_approx = tL | ||
kL = localization_to_propagation_vector(lamdaL, betaL) | ||
for i in range(3): | ||
alpha = OMEGA_0 * (tSSB_approx + t0*YRSID_SI) | ||
rotation_matrix_L = rotation_matrix_SSBtoLISA(alpha) | ||
kSSB_approx = rotation_matrix_L @ kL | ||
lamdaSSB_approx, betaSSB_approx = propagation_vector_to_localization(kSSB_approx) | ||
tSSB_approx = tSSB_from_tL(tL, lamdaSSB_approx, betaSSB_approx, t0) | ||
psiSSB = polarization_angle_newframe(psiL, kL, rotation_matrix_L.T) | ||
|
||
return (tSSB_approx, lamdaSSB_approx, betaSSB_approx, psiSSB) | ||
|
||
def rotation_matrix_SSBtoGEO(epsilon=np.deg2rad(23.44)): | ||
r = Rotation.from_rotvec([ | ||
[-epsilon, 0, 0] | ||
]).as_matrix() | ||
|
||
return np.array(r[0]) | ||
|
||
def tG_from_SSB(tSSB, lamdaSSB, betaSSB, t0=0.0): | ||
R_ORBIT = au.value | ||
OMEGA_G = 2*np.pi / YRSID_SI | ||
t0 *= YRSID_SI | ||
alpha = (tSSB + t0) * OMEGA_G | ||
k = localization_to_propagation_vector(lamdaSSB, betaSSB) | ||
v_GEO = np.array([[R_ORBIT*np.cos(alpha)], | ||
[R_ORBIT*np.sin(alpha)], [0]]) | ||
tG = tSSB + np.vdot(k, v_GEO) / c.value | ||
|
||
return tG | ||
|
||
def tSSB_from_tG(tG, lamdaSSB, betaSSB, t0=0.0): | ||
tSSB = symbols('tSSB') | ||
t0 *= YRSID_SI | ||
R_ORBIT = au.value | ||
OMEGA_G = 2*np.pi / YRSID_SI | ||
|
||
equation = tG - tSSB + R_ORBIT * cos(betaSSB) * ( | ||
cos(lamdaSSB) * cos(OMEGA_G * (tSSB + t0)) + | ||
sin(lamdaSSB) * sin(OMEGA_G * (tSSB + t0)) | ||
) / c.value | ||
|
||
return np.float64(nsolve(equation, tG)) | ||
|
||
def SSB_to_GEO(tSSB, lamdaSSB, betaSSB, psiSSB, t0): | ||
tG = tG_from_SSB(tSSB, lamdaSSB, betaSSB, t0) | ||
kSSB = localization_to_propagation_vector(lamdaSSB, betaSSB) | ||
rotation_matrix_G = rotation_matrix_SSBtoGEO() | ||
kG = rotation_matrix_G.T @ kSSB | ||
lamdaG, betaG = propagation_vector_to_localization(kG) | ||
psiG = polarization_angle_newframe(psiSSB, kSSB, rotation_matrix_G) | ||
|
||
return (tG, lamdaG, betaG, psiG) | ||
|
||
def GEO_to_SSB(tG, lamdaG, betaG, psiG, t0): | ||
lamdaSSB_approx = 0.0 | ||
betaSSB_approx = 0.0 | ||
tSSB_approx = tG | ||
kG = localization_to_propagation_vector(lamdaG, betaG) | ||
for i in range(3): | ||
rotation_matrix_G = rotation_matrix_SSBtoGEO() | ||
kSSB_approx = rotation_matrix_G @ kG | ||
lamdaSSB_approx, betaSSB_approx = propagation_vector_to_localization(kSSB_approx) | ||
tSSB_approx = tSSB_from_tG(tG, lamdaSSB_approx, betaSSB_approx, t0) | ||
psiSSB = polarization_angle_newframe(psiG, kG, rotation_matrix_G.T) | ||
|
||
return (tSSB_approx, lamdaSSB_approx, betaSSB_approx, psiSSB) | ||
|
||
__all__ = ['localization_to_propagation_vector', 'rotation_matrix_SSBtoLISA', | ||
'propagation_vector_to_localization', 'polarization_angle_newframe', | ||
'tL_from_SSB', 'tSSB_from_tL', 'SSB_to_LISA', 'LISA_to_SSB', | ||
'rotation_matrix_SSBtoGEO', 'tG_from_SSB', 'tSSB_from_tG', | ||
'SSB_to_GEO', 'GEO_to_SSB', | ||
] |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In addition to the actions items you've already posted, I think we should avoid the sympy dependence here. This may be somewhat covered by switching to astropy for some parts here.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actually, this function is fast, but I will check if this can be done with Astropy.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The latest doc for this module https://www.atlas.aei.uni-hannover.de/work/shichao.wu/doc/pycbc.html#module-pycbc.coordinates_space