diff --git a/CHANGELOG.md b/CHANGELOG.md index c179d66..2947715 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -20,6 +20,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 to thermal and optical models. - Throughout the rust code, `Time` is being enforced as inputs for functions instead of accepting `f64` in a large number of places. +- Updated SPHEREx SPICE kernel to include orbit through Dec 10, 2025. ### Fixed diff --git a/docs/data/spherex.bsp b/docs/data/spherex.bsp index 50ae399..757b467 100644 Binary files a/docs/data/spherex.bsp and b/docs/data/spherex.bsp differ diff --git a/docs/tutorials/neatm_plots.py b/docs/tutorials/neatm_plots.py index fd36388..0402786 100644 --- a/docs/tutorials/neatm_plots.py +++ b/docs/tutorials/neatm_plots.py @@ -21,11 +21,11 @@ # Define the geometry geom = kete.shape.TriangleEllipsoid(40) -obj2sun = np.array([1, 0, 0]) +obj2sun = kete.Vector([1, 0, 0]) # Compute the temperature at the subsolar point on the object. subsolar_temp = kete.flux.sub_solar_temperature( - -obj2sun, vis_albedo, g_phase, emissivity, beaming + obj2sun.r, vis_albedo, g_phase, emissivity, beaming ) # Compute the NEATM facet temperatures for the object diff --git a/src/examples/plot_light_curve.py b/src/examples/plot_light_curve.py index c78d733..19361f8 100644 --- a/src/examples/plot_light_curve.py +++ b/src/examples/plot_light_curve.py @@ -52,7 +52,7 @@ ] ) - ss_temp = kete.flux.sub_solar_temperature(-obj2obs, albedo, G, emissivity, beaming) + ss_temp = kete.flux.sub_solar_temperature(obj2obs.r, albedo, G, emissivity, beaming) temps = kete.flux.neatm_facet_temps(new_normals, ss_temp, obj2obs) facet_fluxes = [kete.flux.black_body_flux(t, wavelength) for t in temps] facet_fluxes = np.array(facet_fluxes) * geom.areas diff --git a/src/examples/plot_thermal_model.py b/src/examples/plot_thermal_model.py index 1fb2b0a..80255f6 100644 --- a/src/examples/plot_thermal_model.py +++ b/src/examples/plot_thermal_model.py @@ -26,7 +26,7 @@ # Define the geometry geom = kete.shape.TriangleEllipsoid(12) -obj2sun = np.array([1, 0, 0]) +obj2sun = kete.Vector([1, 0, 0]) # Note: The TriangleEllipsoid geometry is not used by default in the kete code. # This is because its facet normals tend to be slightly correlated with one another. # These correlations can be eliminated by setting the number of facets high enough, @@ -37,11 +37,11 @@ # Compute the temperature at the subsolar point on the object. neatm_subsolar_temp = kete.flux.sub_solar_temperature( - -obj2sun, vis_albedo, g_phase, beaming, emissivity + obj2sun.r, vis_albedo, g_phase, beaming, emissivity ) # Note that FRM uses a beaming = pi frm_subsolar_temp = kete.flux.sub_solar_temperature( - -obj2sun, vis_albedo, g_phase, np.pi, emissivity + obj2sun.r, vis_albedo, g_phase, np.pi, emissivity ) # Compute the FRM and NEATM facet temperatures for the object diff --git a/src/kete/rust/flux/common.rs b/src/kete/rust/flux/common.rs index 5aa8fbc..02a0044 100644 --- a/src/kete/rust/flux/common.rs +++ b/src/kete/rust/flux/common.rs @@ -75,8 +75,8 @@ pub fn solar_flux_py(dist: f64, wavelength: f64) -> PyResult { /// /// Parameters /// ---------- -/// obj2sun : -/// Vector from the object to the sun in AU. +/// sun_dist : +/// Distance from the object to the sun in AU. /// geom_albedo : /// Geometric albedo. /// g_param : @@ -86,16 +86,15 @@ pub fn solar_flux_py(dist: f64, wavelength: f64) -> PyResult { /// emissivity : /// Emissivity of the object, 0.9 by default. #[pyfunction] -#[pyo3(name = "sub_solar_temperature", signature = (obj2sun, geom_albedo, g_param, beaming, emissivity=0.9))] +#[pyo3(name = "sub_solar_temperature", signature = (sun_dist, geom_albedo, g_param, beaming, emissivity=0.9))] pub fn sub_solar_temperature_py( - obj2sun: VectorLike, + sun_dist: f64, geom_albedo: f64, g_param: f64, beaming: f64, emissivity: f64, ) -> f64 { - let obj2sun = obj2sun.into_vector(PyFrames::Ecliptic).into(); - sub_solar_temperature(&obj2sun, geom_albedo, g_param, beaming, emissivity) + sub_solar_temperature(sun_dist, geom_albedo, g_param, beaming, emissivity) } /// Compute the black body flux at the specified temperatures and wavelength. diff --git a/src/kete/rust/nongrav.rs b/src/kete/rust/nongrav.rs index a8bd7df..b5f1dcf 100644 --- a/src/kete/rust/nongrav.rs +++ b/src/kete/rust/nongrav.rs @@ -82,12 +82,12 @@ impl PyNonGravModel { /// density: /// Density in kg/m^3, defaults to 1000 kg/m^3 /// c_pr: - /// Radiation pressure coefficient, defaults to 1.19 kg/m^2 + /// Radiation pressure coefficient, defaults to 1.19e-3 kg/m^2 /// q_pr: /// Scattering efficiency for radiation pressure, defaults to 1.0 /// 1.0 is a good estimate for particles larger than 1um (Burns, Lamy & Soter 1979) #[staticmethod] - #[pyo3(signature=(beta=None, diameter=None, density=1000.0, c_pr=1.19, q_pr=1.0))] + #[pyo3(signature=(beta=None, diameter=None, density=1000.0, c_pr=1.19e-3, q_pr=1.0))] pub fn new_dust( beta: Option, diameter: Option, diff --git a/src/kete/rust/state.rs b/src/kete/rust/state.rs index 37dbcaf..6e2bded 100644 --- a/src/kete/rust/state.rs +++ b/src/kete/rust/state.rs @@ -144,8 +144,8 @@ impl PyState { /// JD of the object's state in TDB scaled time. #[getter] - pub fn jd(&self) -> PyTime { - self.raw.epoch.into() + pub fn jd(&self) -> f64 { + self.raw.epoch.jd } /// Position of the object in AU with respect to the central object. diff --git a/src/kete_core/src/flux/common.rs b/src/kete_core/src/flux/common.rs index 292978f..eae9ab8 100644 --- a/src/kete_core/src/flux/common.rs +++ b/src/kete_core/src/flux/common.rs @@ -27,7 +27,7 @@ // OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -use nalgebra::{UnitVector3, Vector3}; +use nalgebra::UnitVector3; use std::f64::consts::PI; use crate::constants::{ @@ -264,7 +264,7 @@ pub fn lambertian_vis_scale_factor( /// /// # Arguments /// -/// * `obj2sun` - Vector from the object to the sun in AU. +/// * `sun_dist` - Object distance to the Sun in AU. /// * `geom_albedo` - Geometric Albedo. /// * `g_param` - The G phase parameter. /// * `beaming` - Beaming of the object, this is geometry dependent. @@ -272,7 +272,7 @@ pub fn lambertian_vis_scale_factor( #[inline(always)] #[must_use] pub fn sub_solar_temperature( - obj2sun: &Vector3, + sun_dist: f64, geom_albedo: f64, g_param: f64, beaming: f64, @@ -281,7 +281,7 @@ pub fn sub_solar_temperature( let phase_integral = 0.29 + 0.684 * g_param; let bond_albedo = geom_albedo * phase_integral; - let reflected = (1.0 - bond_albedo) * SOLAR_FLUX / obj2sun.norm_squared(); + let reflected = (1.0 - bond_albedo) * SOLAR_FLUX / sun_dist.powi(2); let temp = reflected / (beaming * emissivity * STEFAN_BOLTZMANN); if temp <= 0.0 { return 0.0; @@ -347,15 +347,12 @@ mod tests { #[test] fn test_sub_solar_temperature() { - let obj2sun = [1.0, 0.0, 0.0].into(); - // albedo, G set to make bond_albedo == 1 - let temp = sub_solar_temperature(&obj2sun, 1.0 / 0.29, 1.0, 1.0, 1.0); + let temp = sub_solar_temperature(1.0, 1.0 / 0.29, 1.0, 1.0, 1.0); assert_eq!(temp, 0.0); for range in 1..10 { - let obj2sun = [f64::from(range), 0.0, 0.0].into(); - let mut temp = sub_solar_temperature(&obj2sun, 0.0, 0.0, 1.0, 1.0); + let mut temp = sub_solar_temperature(f64::from(range), 0.0, 0.0, 1.0, 1.0); temp = temp.powi(4); let expected = SOLAR_FLUX / f64::from(range).powi(2) / STEFAN_BOLTZMANN; assert!((temp - expected).abs() < 1e-5); diff --git a/src/kete_core/src/flux/frm.rs b/src/kete_core/src/flux/frm.rs index e6fe81b..2cdafff 100644 --- a/src/kete_core/src/flux/frm.rs +++ b/src/kete_core/src/flux/frm.rs @@ -121,7 +121,7 @@ impl FrmParams { let diameter = self.hg_params.diam()?; let ss_temp = sub_solar_temperature( - &obj2sun, + obj2sun.norm(), self.hg_params.vis_albedo()?, self.hg_params.g_param, PI, diff --git a/src/kete_core/src/flux/neatm.rs b/src/kete_core/src/flux/neatm.rs index 9103c96..1b5e780 100644 --- a/src/kete_core/src/flux/neatm.rs +++ b/src/kete_core/src/flux/neatm.rs @@ -126,7 +126,7 @@ impl NeatmParams { let diameter = hg_params.diam()?; let ss_temp = sub_solar_temperature( - &obj2sun, + obj2sun.norm(), self.hg_params.vis_albedo()?, self.hg_params.g_param, self.beaming, diff --git a/src/tests/flux/test_common.py b/src/tests/flux/test_common.py index 89ae822..c61e7d4 100644 --- a/src/tests/flux/test_common.py +++ b/src/tests/flux/test_common.py @@ -38,7 +38,7 @@ def test_subsolarpoint_temp(): # albedo, G set to make bond_albedo == 1 assert ( sub_solar_temperature( - vec, + vec.r, geom_albedo=1 / 0.29, g_param=0, emissivity=1, @@ -50,7 +50,7 @@ def test_subsolarpoint_temp(): for r in range(1, 10): vec = Vector([r, 0, 0]) temp = sub_solar_temperature( - vec, geom_albedo=0, g_param=0, emissivity=1, beaming=1 + r, geom_albedo=0, g_param=0, emissivity=1, beaming=1 ) temp = temp**4 expected = constants.SOLAR_FLUX / r**2 / constants.STEFAN_BOLTZMANN