Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
Binary file modified docs/data/spherex.bsp
Binary file not shown.
4 changes: 2 additions & 2 deletions docs/tutorials/neatm_plots.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion src/examples/plot_light_curve.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
6 changes: 3 additions & 3 deletions src/examples/plot_thermal_model.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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
Expand Down
11 changes: 5 additions & 6 deletions src/kete/rust/flux/common.rs
Original file line number Diff line number Diff line change
Expand Up @@ -75,8 +75,8 @@ pub fn solar_flux_py(dist: f64, wavelength: f64) -> PyResult<f64> {
///
/// 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 :
Expand All @@ -86,16 +86,15 @@ pub fn solar_flux_py(dist: f64, wavelength: f64) -> PyResult<f64> {
/// 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.
Expand Down
4 changes: 2 additions & 2 deletions src/kete/rust/nongrav.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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<f64>,
diameter: Option<f64>,
Expand Down
4 changes: 2 additions & 2 deletions src/kete/rust/state.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
15 changes: 6 additions & 9 deletions src/kete_core/src/flux/common.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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::{
Expand Down Expand Up @@ -264,15 +264,15 @@ 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.
/// * `emissivity` - The emissivity of the surface.
#[inline(always)]
#[must_use]
pub fn sub_solar_temperature(
obj2sun: &Vector3<f64>,
sun_dist: f64,
geom_albedo: f64,
g_param: f64,
beaming: f64,
Expand All @@ -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;
Expand Down Expand Up @@ -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);
Expand Down
2 changes: 1 addition & 1 deletion src/kete_core/src/flux/frm.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
2 changes: 1 addition & 1 deletion src/kete_core/src/flux/neatm.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
4 changes: 2 additions & 2 deletions src/tests/flux/test_common.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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
Expand Down