moble / PostNewtonian.jl

Orbital dynamics and waveforms for binary black-hole systems, in the post-Newtonian approximation
MIT License
12 stars 1 forks source link

Dynamics data not being transferred when changing frames #55

Closed vijayvarma392 closed 3 months ago

vijayvarma392 commented 3 months ago

Here's a script to reproduce the issue

import numpy as np

# Start the Julia session
from sxs.julia import PNWaveform

q = 1.0
chiA0 = [0, 0, 0.5]
chiB0 = [0, 0, 0.5]
omega_ref = 1e-2

w = PNWaveform(q/(1+q), 1/(1+q), np.array(chiA0), np.array(chiB0),
                    omega_ref, inertial=True)

# This works fine
chiA = w.chi1
chiB = w.chi2
quat = w.frame
omega_orb = w.v**3 / (w.M1 + w.M2)
phi_orb = w.orbital_phase
print (chiA[0])

w = PNWaveform(q/(1+q), 1/(1+q), np.array(chiA0), np.array(chiB0),
                    omega_ref, inertial=False)
# So does this
chiA = w.chi1
chiB = w.chi2
quat = w.frame
omega_orb = w.v**3 / (w.M1 + w.M2)
phi_orb = w.orbital_phase
print (chiA[0])

# But this doesn't work (AttributeError: 'WaveformModes' object has no attribute 'chi1')
w = w.to_inertial_frame()
chiA = w.chi1
chiB = w.chi2
quat = w.frame
omega_orb = w.v**3 / (w.M1 + w.M2)
phi_orb = w.orbital_phase
print (chiA[0])
moble commented 3 months ago

That's correct. The object returned from PNWaveform is an sxs.WaveformModes, which does not track those things. If you want them, you have to copy them before throwing away the original w.