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
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

### Changed

- Rewrite of NEATM and FRM internal models, remove support for saving files related
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.

Expand Down
24 changes: 20 additions & 4 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -76,12 +76,22 @@ rust.trivial_casts = "deny"
rust.elided_lifetimes_in_paths = "deny"
rust.unexpected_cfgs = "deny"

clippy.too_many_arguments = "allow"
clippy.type_complexity = "allow"

clippy.perf = { level = "deny", priority = 1 }
# clippy.pedantic = { level = "warn", priority = 1 }
clippy.pedantic = { level = "deny", priority = 1 }

# Pedantic overrides
clippy.float_cmp = {level = "allow", priority = 2 }
clippy.inline_always = {level = "allow", priority = 2 }
clippy.unreadable-literal = {level = "allow", priority = 2}
clippy.similar_names = {level = "allow", priority = 2}
clippy.too_many_lines = {level = "allow", priority = 2}
clippy.cast_precision_loss = {level = "allow", priority = 2}
clippy.cast_possible_truncation = {level = "allow", priority = 2}

# General list
clippy.too_many_arguments = "allow"
clippy.type_complexity = "allow"
clippy.allow_attributes_without_reason = "warn"
clippy.collection_is_never_read = "warn"
clippy.dbg_macro = "warn"
Expand All @@ -102,4 +112,10 @@ clippy.use_self = "warn"
clippy.cargo_common_metadata = "warn"
clippy.negative_feature_names = "warn"
clippy.redundant_feature_names = "warn"
clippy.wildcard_dependencies = "warn"
clippy.wildcard_enum_match_arm = "warn"
clippy.wildcard_dependencies = "warn"
clippy.fallible_impl_from = "warn"
clippy.unneeded_field_pattern = "warn"
clippy.fn_params_excessive_bools = "warn"

clippy.must_use_candidate = "deny"
3 changes: 1 addition & 2 deletions src/kete/plot.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,7 @@ def plot_fits_image(fit, percentiles=(0.1, 99.95), power_stretch=1.0, cmap="gray
`ZScaleInterval`.
power_stretch :
The scaling of the intensity of the plot is a power law, this defines the power
of that power law. By default plots are sqrt scaled. If this is set to 1, then
this becomes a linear scaling.
of that power law. By default plots are linear scaled (`power_stretch=1.0`).
cmap :
Color map to use for the plot.
"""
Expand Down
2 changes: 1 addition & 1 deletion src/kete/rust/fitting.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,5 +14,5 @@ pub fn ks_test_py(sample_a: Vec<f64>, sample_b: Vec<f64>) -> f64 {
#[pyo3(name = "fit_chi2")]
pub fn fit_chi2_py(data: Vec<f64>, sigmas: Vec<f64>) -> f64 {
assert_eq!(data.len(), sigmas.len());
fitting::fit_reduced_chi2(&data, &sigmas)
fitting::fit_reduced_chi2(&data, &sigmas).unwrap()
}
31 changes: 12 additions & 19 deletions src/kete/rust/flux/common.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
use core::f64;

use crate::{frame::PyFrames, vector::VectorLike};
use itertools::Itertools;
use kete_core::constants::{
Expand Down Expand Up @@ -232,7 +234,7 @@ pub fn neatm_thermal_py(
diameter: f64,
wavelength: f64,
emissivity: f64,
) -> f64 {
) -> PyResult<f64> {
let sun2obj = sun2obj.into_vector(PyFrames::Ecliptic).into();
let sun2obs = sun2obs.into_vector(PyFrames::Ecliptic).into();

Expand All @@ -246,17 +248,13 @@ pub fn neatm_thermal_py(
)
.unwrap();
let params = NeatmParams {
obs_bands: ObserverBands::Generic {
bands: vec![wavelength; 1],
zero_mags: None,
solar_correction: vec![1.0],
},
band_albedos: vec![0.0; 1],
obs_bands: vec![BandInfo::new(wavelength, 1.0, f64::NAN, None)],
band_albedos: vec![0.0],
hg_params,
emissivity,
beaming,
};
params.apparent_thermal_flux(&sun2obj, &sun2obs).unwrap()[0]
Ok(params.apparent_thermal_flux(&sun2obj, &sun2obs).unwrap()[0])
}

/// Calculate the flux from an object using the FRM thermal model in Jansky.
Expand Down Expand Up @@ -300,7 +298,7 @@ pub fn frm_thermal_py(
diameter: f64,
wavelength: f64,
emissivity: f64,
) -> f64 {
) -> PyResult<f64> {
let sun2obj = sun2obj.into_vector(PyFrames::Ecliptic).into();
let sun2obs = sun2obs.into_vector(PyFrames::Ecliptic).into();
let hg_params = HGParams::try_new(
Expand All @@ -310,20 +308,15 @@ pub fn frm_thermal_py(
Some(C_V),
Some(v_albedo),
Some(diameter),
)
.unwrap();
)?;

let params = FrmParams {
obs_bands: ObserverBands::Generic {
bands: vec![wavelength; 1],
zero_mags: None,
solar_correction: vec![1.0],
},
band_albedos: vec![0.0; 1],
obs_bands: vec![BandInfo::new(wavelength, 1.0, f64::NAN, None)],
band_albedos: vec![0.0],
hg_params,
emissivity,
};
params.apparent_thermal_flux(&sun2obj, &sun2obs).unwrap()[0]
Ok(params.apparent_thermal_flux(&sun2obj, &sun2obs).unwrap()[0])
}

/// Given the M1/K1 and M2/K2 values, compute the apparent Comet visible magnitudes.
Expand Down Expand Up @@ -421,7 +414,7 @@ pub fn w4_color_correction_py(temp: f64) -> f64 {
/// The normal vectors of the fib lattice
#[pyfunction]
#[pyo3(name = "fib_lattice_vecs")]
pub fn fib_lattice_vecs_py(n_facets: usize) -> Vec<[f64; 3]> {
pub fn fib_lattice_vecs_py(n_facets: u32) -> Vec<[f64; 3]> {
let facets = ConvexShape::new_fibonacci_lattice(n_facets).facets;
facets
.iter()
Expand Down
Loading