Skip to content
This repository was archived by the owner on Aug 28, 2024. It is now read-only.

Commit

Permalink
Now correctly transform spin poles from the celestial frame to the ec…
Browse files Browse the repository at this point in the history
…liptic frame
  • Loading branch information
daminton committed Feb 26, 2024
1 parent cba1f77 commit 8171caa
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
4 changes: 3 additions & 1 deletion swiftest/init_cond.py
Original file line number Diff line number Diff line change
Expand Up @@ -140,11 +140,13 @@ def get_rotrate(raw_response):
def get_rotpole(jpl):
RA = jpl.ephemerides()['NPole_RA'][0]
DEC = jpl.ephemerides()['NPole_DEC'][0]


if np.ma.is_masked(RA) or np.ma.is_masked(DEC):
return np.array([0.0,0.0,1.0])

rotpole = SkyCoord(ra=RA * u.degree, dec=DEC * u.degree).cartesian
rotpole = SkyCoord(ra=RA * u.degree, dec=DEC * u.degree,frame='icrs').transform_to('barycentricmeanecliptic').cartesian

return np.array([rotpole.x.value, rotpole.y.value, rotpole.z.value])

if type(altid) != list:
Expand Down
2 changes: 1 addition & 1 deletion swiftest/tool.py
Original file line number Diff line number Diff line change
Expand Up @@ -550,7 +550,7 @@ def rotate_to_vector(ds, new_pole, skip_vars=['space','Ip']):
original_vector = unit_pole.reshape(1, 3)

# Use align_vectors to get the rotation that aligns the z-axis with Mars_rot
rotation, _ = R.align_vectors(target_vector, original_vector.reshape(1, 3))
rotation, _ = R.align_vectors(target_vector, original_vector)

# Define a function to apply the rotation, which will be used with apply_ufunc
def apply_rotation(vector, rotation):
Expand Down

0 comments on commit 8171caa

Please sign in to comment.