Skip to content

Commit

Permalink
Fix Time for all time (#83)
Browse files Browse the repository at this point in the history
  • Loading branch information
dahlend authored Jul 19, 2024
1 parent 1b49eba commit f854b34
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 3 deletions.
4 changes: 3 additions & 1 deletion src/neospy/horizons.py
Original file line number Diff line number Diff line change
Expand Up @@ -253,14 +253,16 @@ def _nongrav(self) -> NonGravModel:
"NM": "m",
"R0": "r_0",
"NK": "k",
"N": "n",
"NN": "n",
}

orbit = self.json["orbit"]
if "model_pars" not in orbit:
return None

for vals in orbit["model_pars"]:
if vals["name"] not in lookup:
raise ValueError("Unknown non-grav values: ", vals)
params[lookup[vals["name"]]] = float(vals["value"])

return NonGravModel.new_comet(**params)
Expand Down
2 changes: 1 addition & 1 deletion src/neospy/rust/time.rs
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ impl<'py> FromPyObject<'py> for PyTime {
if let Ok(jd) = ob.extract::<f64>() {
return Ok(PyTime(Time::new(jd)));
}
ob.extract::<PyTime>()
Ok(PyTime(ob.downcast_exact::<PyTime>()?.get().0))
}
}

Expand Down
3 changes: 2 additions & 1 deletion src/tests/test_propagation.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
moid,
Vector,
State,
Time,
)
from neospy.propagation import NonGravModel

Expand Down Expand Up @@ -46,7 +47,7 @@ class TestNBodyPropagation:
def test_propagation_short(self, ceres_traj):
initial_state = ceres_traj[0]
final_state = ceres_traj[1]
calc = propagate_n_body([initial_state], final_state.jd)[0]
calc = propagate_n_body([initial_state], Time(final_state.jd))[0]
assert np.allclose(calc.pos, final_state.pos)
assert np.allclose(calc.vel, final_state.vel)

Expand Down

0 comments on commit f854b34

Please sign in to comment.