Skip to content

Commit

Permalink
Remove transforms from barycentric equatorial to heliocentric eclipti…
Browse files Browse the repository at this point in the history
…c in detect_impacts
  • Loading branch information
moeyensj committed Jan 27, 2025
1 parent 0c24950 commit 51fd94b
Showing 1 changed file with 10 additions and 19 deletions.
29 changes: 10 additions & 19 deletions src/adam_assist/propagator.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import hashlib
from ctypes import c_uint32
from typing import Dict, List, Tuple, Union
from typing import Any, Dict, List, Tuple, Union

import assist
import numpy as np
Expand Down Expand Up @@ -81,12 +81,12 @@ def __init__(
self.adaptive_mode = adaptive_mode
self.epsilon = epsilon

def __getstate__(self):
def __getstate__(self) -> Dict[str, Any]:
state = self.__dict__.copy()
state.pop("_last_simulation", None)
return state

def __setstate__(self, state):
def __setstate__(self, state: Dict[str, Any]) -> None:
self.__dict__.update(state)

def _propagate_orbits(self, orbits: OrbitType, times: TimestampType) -> OrbitType:
Expand Down Expand Up @@ -433,18 +433,8 @@ def _detect_impacts(
)

assert isinstance(time_step_results, OrbitType)
time_step_results = time_step_results.set_column(
"coordinates",
transform_coordinates(
time_step_results.coordinates,
origin_out=OriginCodes.SUN,
frame_out="ecliptic",
),
)

# Get the Earth's position at the current time
# earth_geo = get_perturber_state(OriginCodes.EARTH, results.coordinates.time[0], origin=OriginCodes.SUN)
# diff = time_step_results.coordinates.values - earth_geo.coordinates.values
earth_geo = ephem.get_particle("Earth", sim.t)
earth_geo = CartesianCoordinates.from_kwargs(
x=[earth_geo.x],
Expand All @@ -459,11 +449,12 @@ def _detect_impacts(
),
frame="equatorial",
)
earth_geo = transform_coordinates(
earth_geo,
origin_out=OriginCodes.SUN,
frame_out="ecliptic",
)

# Compute the geocentric state vector using the Earth's state vector
# and the results from the simulation.
# Note: ASSIST already computes the geocentric state vector, and so
# we can just subtract the Earth's state vector from the simulation rather than
# using our adam_core's transform_coordinates.
diff = time_step_results.coordinates.values - earth_geo.values

# Calculate the distance in KM
Expand Down Expand Up @@ -543,7 +534,7 @@ def _detect_impacts(
origin=Origin.from_kwargs(
code=[],
),
frame="ecliptic",
frame="equatorial",
),
variant_id=[],
)
Expand Down

0 comments on commit 51fd94b

Please sign in to comment.