diff --git a/CHANGELOG.md b/CHANGELOG.md index 51a9a36..c56bf81 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -8,6 +8,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ## [Unreleased] +## [0.2.4] - 2024 - 7 - 15 + ### Added - Add `J2` non-spherical terms for the gravitational models of Earth and Jupiter. @@ -155,6 +157,7 @@ Initial Release [Unreleased]: https://github.com/IPAC-SW/neospy/tree/main +[0.2.4]: https://github.com/IPAC-SW/neospy/releases/tag/v0.2.4 [0.2.3]: https://github.com/IPAC-SW/neospy/releases/tag/v0.2.3 [0.2.2]: https://github.com/IPAC-SW/neospy/releases/tag/v0.2.2 [0.2.1]: https://github.com/IPAC-SW/neospy/releases/tag/v0.2.1 diff --git a/Cargo.toml b/Cargo.toml index ddcb132..78b13ff 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,7 +1,7 @@ [package] name = "_core" -version = "0.2.3" +version = "0.2.4" edition = "2021" diff --git a/docs/tutorials/propagation_plots.py b/docs/tutorials/propagation_plots.py index 19085c1..f5b1737 100644 --- a/docs/tutorials/propagation_plots.py +++ b/docs/tutorials/propagation_plots.py @@ -7,7 +7,7 @@ jd_start = neospy.Time.from_ymd(1920, 1, 1).jd jd_end = neospy.Time.from_ymd(2020, 1, 1).jd -state = neospy.spice.state("42", jd_end) +state = neospy.spice.get_state("42", jd_end) jds = np.logspace(np.log10(jd_end), np.log10(jd_end - 10), 1000) jds = np.concatenate( @@ -21,9 +21,9 @@ error_2body = [] n_body_no_asteroids = [] n_body_ast = [] -state = neospy.spice.state("42", jd_end) +state = neospy.spice.get_state("42", jd_end) for jd in jds: - jpl_pos = neospy.spice.state("42", jd).pos + jpl_pos = neospy.spice.get_state("42", jd).pos line = state.pos + state.vel * (jd - state.jd) error_line.append((jpl_pos - line).r * neospy.constants.AU_KM) diff --git a/pyproject.toml b/pyproject.toml index f5991a6..730a61f 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,6 +1,6 @@ [project] name = "neospy" -version = "0.2.3" +version = "0.2.4" description = "NEO Surveyor Simulation Tools" readme = "README.md" authors = [{name = "Dar Dahlen", email = "ddahlen@ipac.caltech.edu"}, diff --git a/src/examples/galactic_center.py b/src/examples/galactic_center.py index dbfa929..5e07833 100644 --- a/src/examples/galactic_center.py +++ b/src/examples/galactic_center.py @@ -36,7 +36,7 @@ while states[0].jd < jd_end: states = neospy.propagate_two_body(states, states[0].jd + 1) - earth = neospy.spice.state("Earth", states[0].jd) + earth = neospy.spice.get_state("Earth", states[0].jd) earth_to_obj = [(s.pos - earth.pos) for s in states] dist_to_galactic_center.append( diff --git a/src/examples/plot_close_approach.py b/src/examples/plot_close_approach.py index bdfbfd4..4a7f85d 100644 --- a/src/examples/plot_close_approach.py +++ b/src/examples/plot_close_approach.py @@ -40,7 +40,7 @@ rel_earth_state = cur_state.change_center(399) pos.append([rel_earth_state.pos.x, rel_earth_state.pos.y]) # gets earths position and record the distances. - moon = neospy.spice.state("Moon", cur_state.jd, center=399).pos + moon = neospy.spice.get_state("Moon", cur_state.jd, center=399).pos dist_to_moon.append((moon - rel_earth_state.pos).r * neospy.constants.AU_KM) dist_to_earth.append(rel_earth_state.pos.r * neospy.constants.AU_KM) moon_pos.append([moon.x, moon.y]) diff --git a/src/examples/plot_close_encounter.py b/src/examples/plot_close_encounter.py index 43fca11..95d559e 100644 --- a/src/examples/plot_close_encounter.py +++ b/src/examples/plot_close_encounter.py @@ -38,7 +38,7 @@ for jd in jds: last_state = neospy.propagate_two_body([last_state], jd)[0] obj_pos.append(last_state.pos) - earth_pos.append(neospy.spice.state("Earth", jd).pos) + earth_pos.append(neospy.spice.get_state("Earth", jd).pos) earth_r.append(neospy.Vector(obj_pos[-1] - earth_pos[-1]).r) # Find the time where the closest encounter with the earth @@ -55,10 +55,10 @@ ax.plot(pos[0], pos[1], pos[2], alpha=0.5, color="black") ax.scatter(pos_center.x, pos_center.y, pos_center.z, s=5, color="black") for i, planet in enumerate(["Mercury", "Venus", "Earth", "Mars", "Jupiter"]): - states = [neospy.spice.state(planet, jd).pos for jd in jds] + states = [neospy.spice.get_state(planet, jd).pos for jd in jds] pos = np.array(states).T ax.plot(pos[0], pos[1], pos[2], color=f"C{i}", alpha=0.5) - pos = neospy.spice.state(planet, jd_center).pos + pos = neospy.spice.get_state(planet, jd_center).pos ax.scatter(pos.x, pos.y, pos.z, color=f"C{i}", s=5) ax.scatter(0, 0, 0, color="red") ax.set_xticks([-zoom, 0, zoom]) diff --git a/src/examples/plot_light_curve.py b/src/examples/plot_light_curve.py index ce9436e..8e94a5b 100644 --- a/src/examples/plot_light_curve.py +++ b/src/examples/plot_light_curve.py @@ -11,7 +11,7 @@ # Using ceres as a source for a state vector -state = neospy.spice.state("ceres", 2460000.5) +state = neospy.spice.get_state("ceres", 2460000.5) # Various input values albedo = 0.1 @@ -39,7 +39,7 @@ for dt in dts: # Find the observer and object positions some time in the future. - earth_pos = neospy.spice.state("Earth", jd + dt).pos + earth_pos = neospy.spice.get_state("Earth", jd + dt).pos final_pos = neospy.propagate_two_body([state], jd + dt, earth_pos)[0].pos obj2obs = final_pos - earth_pos diff --git a/src/examples/plot_mpc_state.py b/src/examples/plot_mpc_state.py index 4396713..2e2a45a 100644 --- a/src/examples/plot_mpc_state.py +++ b/src/examples/plot_mpc_state.py @@ -39,10 +39,10 @@ # Plot the planets for 1 orbit each for i, planet in enumerate(["Mercury", "Venus", "Earth", "Mars", "Jupiter"]): jd = states[0].jd - plan = neospy.spice.state(planet, jd) + plan = neospy.spice.get_state(planet, jd) ax.scatter(plan.pos.x, plan.pos.y, color=f"C{i}", s=10) jds = np.linspace(jd - plan.elements.orbital_period, jd, 100) - pos = np.array([neospy.spice.state(planet, jd).pos for jd in jds]).T + pos = np.array([neospy.spice.get_state(planet, jd).pos for jd in jds]).T ax.plot(pos[0], pos[1], pos[2], color="black", alpha=0.2) for state in states: diff --git a/src/examples/plot_phases.py b/src/examples/plot_phases.py index c52b856..e954422 100644 --- a/src/examples/plot_phases.py +++ b/src/examples/plot_phases.py @@ -27,7 +27,7 @@ # Move the entire population of asteroids to that time using 2-body # mechanics, this can be directly substituted with propagate_n_body if you # want more precision. -sun2earth = neospy.spice.state("Earth", jd).pos +sun2earth = neospy.spice.get_state("Earth", jd).pos states = neospy.propagate_two_body(neos, jd) # Compute the expected V-mags for these objects at this time diff --git a/src/examples/plot_trojans.py b/src/examples/plot_trojans.py index f4336ad..aa0130b 100644 --- a/src/examples/plot_trojans.py +++ b/src/examples/plot_trojans.py @@ -16,7 +16,7 @@ states = neospy.propagate_n_body(states, states[0].jd) # Where is jupiter? -jupiter = neospy.spice.state("Jupiter", states[0].jd) +jupiter = neospy.spice.get_state("Jupiter", states[0].jd) # found it! # Compute the positions, and relative longitudinal distance from jupiter diff --git a/src/examples/plot_uncertainty.py b/src/examples/plot_uncertainty.py index 0c3f3d4..886d20d 100644 --- a/src/examples/plot_uncertainty.py +++ b/src/examples/plot_uncertainty.py @@ -50,7 +50,7 @@ mags = [] for jd in jds: states = neospy.propagate_n_body(states, jd) - earth = neospy.spice.state("earth", jd) + earth = neospy.spice.get_state("earth", jd) m = [ neospy.flux.hg_apparent_mag( sun2obj=x.pos, sun2obs=earth.pos, h_mag=obj.h_mag, g_param=g @@ -65,7 +65,7 @@ # position at lowest mag states = neospy.propagate_n_body(states, brightest_jd) -earth = neospy.spice.state("earth", brightest_jd) +earth = neospy.spice.get_state("earth", brightest_jd) vecs = [(s.pos - earth.pos).as_equatorial for s in states] ras = np.array([v.ra for v in vecs]) decs = np.array([v.dec for v in vecs]) diff --git a/src/neospy/mpc.py b/src/neospy/mpc.py index 9e0820b..8582f42 100644 --- a/src/neospy/mpc.py +++ b/src/neospy/mpc.py @@ -929,7 +929,7 @@ def _read_second_line(line, jd): y = float(line[46:57].replace(" ", "")) / constants.AU_KM z = float(line[58:69].replace(" ", "")) / constants.AU_KM earth2sc = Vector([x, y, z], Frames.Equatorial).as_ecliptic - sun2earth = spice.state("Earth", jd).pos + sun2earth = spice.get_state("Earth", jd).pos sun2sc = sun2earth + earth2sc return list(sun2sc) diff --git a/src/neospy/propagation.py b/src/neospy/propagation.py index 574b003..5d6687a 100644 --- a/src/neospy/propagation.py +++ b/src/neospy/propagation.py @@ -137,5 +137,5 @@ def moid(state: State, other: Optional[State] = None): calculation. """ if other is None: - other = spice.state("Earth", state.jd) + other = spice.get_state("Earth", state.jd) return _moid_single(state, other) diff --git a/src/neospy/spice.py b/src/neospy/spice.py index 8322459..7f6a9e6 100644 --- a/src/neospy/spice.py +++ b/src/neospy/spice.py @@ -13,7 +13,7 @@ __all__ = [ "SpkInfo", - "state", + "get_state", "name_lookup", "loaded_objects", "loaded_object_info", @@ -71,7 +71,7 @@ def _validate_time(time: Union[float, Time]) -> float: _NAME_CACHE: dict = {} -def state( +def get_state( target: Union[str, int], jd: Union[float, Time], center: str = "Sun", @@ -372,7 +372,7 @@ def moon_illumination_frac(jd: Union[float, Time], observer: str = "399"): """ jd = _validate_time(jd) - moon2sun = -state("moon", jd).pos - moon2earth = -state("moon", jd, center=observer).pos + moon2sun = -get_state("moon", jd).pos + moon2earth = -get_state("moon", jd, center=observer).pos perc = 1.0 - moon2sun.angle_between(moon2earth) / 180 return 0.5 - np.cos(np.pi * perc) / 2 diff --git a/src/neospy/wise.py b/src/neospy/wise.py index 9393828..ad412d2 100644 --- a/src/neospy/wise.py +++ b/src/neospy/wise.py @@ -579,7 +579,7 @@ def fetch_WISE_fovs(phase): fovs = [] for row in res.itertuples(): - state = spice.state("WISE", row.jd) + state = spice.get_state("WISE", row.jd) pointing = Vector.from_ra_dec(row.ra, row.dec).as_ecliptic fov = WiseCmos( diff --git a/src/neospy_core/Cargo.toml b/src/neospy_core/Cargo.toml index d13f192..166c471 100644 --- a/src/neospy_core/Cargo.toml +++ b/src/neospy_core/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "neospy_core" -version = "0.2.3" +version = "0.2.4" edition = "2021" [lib] diff --git a/src/tests/test_propagation.py b/src/tests/test_propagation.py index e6eb9df..87ff75b 100644 --- a/src/tests/test_propagation.py +++ b/src/tests/test_propagation.py @@ -75,12 +75,12 @@ def test_propagation_single(self): Propagate Venus using StateVector and compare the result to using spice. This is only over 5 days the 2 body approximation is accurate over that time. """ - state = spice.state("Venus", 2461161.5) + state = spice.get_state("Venus", 2461161.5) for jd in range(-5, 5): jd = state.jd + jd vec_state = propagate_two_body([state], jd)[0] - jpl_state = spice.state("Venus", jd) + jpl_state = spice.get_state("Venus", jd) assert vec_state.jd == jpl_state.jd assert np.allclose(vec_state.vel, jpl_state.vel) assert np.allclose(vec_state.pos, jpl_state.pos) @@ -92,7 +92,7 @@ def test_propagation_light_delay(self): Place an observer X AU away from Venus and ensure that the delay is correct. """ - state = spice.state("Venus", 2461161.5) + state = spice.get_state("Venus", 2461161.5) for au in range(0, 5): sun2obs = Vector(state.pos + [au, 0.0, 0.0]) @@ -108,9 +108,9 @@ def test_propagation_light_delay(self): def test_moid(planet): if planet is None: state = None - vs = spice.state("Earth", 2461161.5) + vs = spice.get_state("Earth", 2461161.5) else: - state = spice.state(planet, 2461161.5) + state = spice.get_state(planet, 2461161.5) vs = state assert np.isclose(moid(vs, state), 0) diff --git a/src/tests/test_spice.py b/src/tests/test_spice.py index 8e40e20..0549986 100644 --- a/src/tests/test_spice.py +++ b/src/tests/test_spice.py @@ -30,14 +30,14 @@ class TestSpice: def test_ecliptic_state(self, expected): e_pos = expected[2:5] e_vel = expected[5:8] - state = spice.state(expected[0], expected[1]) + state = spice.get_state(expected[0], expected[1]) assert isinstance(state, State) assert np.allclose(state.pos.as_equatorial, e_pos) assert np.allclose(state.vel.as_equatorial, e_vel) # Ensure that the same values are calculated if using an astropy time jd = Time(expected[1]) - state = spice.state(expected[0], jd) + state = spice.get_state(expected[0], jd) assert isinstance(state, State) assert np.allclose(state.pos.as_equatorial, e_pos) assert np.allclose(state.vel.as_equatorial, e_vel)