Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Horizons Queries returning case-sensitive values #161

Merged
merged 3 commits into from
Dec 4, 2024
Merged
Show file tree
Hide file tree
Changes from 2 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
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,11 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

- Comet Magnitude estimates now accepts two phase correction values instead of 1.

### Fixed

- Fixed a text case-sensitivity but on Horizons parameter parsing.
- Thermal model example had function arguments out of order.


## [v1.0.4]

Expand Down
8 changes: 4 additions & 4 deletions src/examples/plot_thermal_model.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,12 +35,12 @@
# result is not used in this example.

# Compute the temperature at the subsolar point on the object.
# Note that FRM uses a beaming = pi
neatm_subsolar_temp = kete.flux.sub_solar_temperature(
-obj2sun, vis_albedo, g_phase, emissivity, beaming
-obj2sun, vis_albedo, g_phase, beaming, emissivity
dahlend marked this conversation as resolved.
Show resolved Hide resolved
)
# Note that FRM uses a beaming = pi
frm_subsolar_temp = kete.flux.sub_solar_temperature(
-obj2sun, vis_albedo, g_phase, emissivity
-obj2sun, vis_albedo, g_phase, np.pi, emissivity
)

# Compute the FRM and NEATM facet temperatures for the object
Expand All @@ -60,7 +60,7 @@
plt.subplot(121, projection="3d")

norm = mpl.colors.Normalize(vmin=0, vmax=max(neatm_facet_temps))
m = cm.ScalarMappable(norm=norm, cmap=mpl.colormaps["RdBu_r"])
m = cm.ScalarMappable(norm=norm, cmap=mpl.colormaps["inferno"])
colors = m.to_rgba(neatm_facet_temps, alpha=1)
polygons = Poly3DCollection(geom.facets, edgecolor="black", lw=0.2, color=colors)
plt.gca().add_collection3d(polygons)
Expand Down
7 changes: 5 additions & 2 deletions src/kete/horizons.py
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,9 @@ def fetch(name, update_name=True, cache=True, update_cache=False, exact_name=Fal
if "model_pars" in props["orbit"]:
for param in props["orbit"]["model_pars"]:
elements[param["name"]] = float(param["value"])
params = [(lookup_rev.get(x, x), elements.get(x, np.nan)) for x in labels]
params = [
(lookup_rev.get(x, x.lower()), elements.get(x, np.nan)) for x in labels
]
phys["covariance"] = Covariance(name, cov_epoch, params, mat)
else:
raise ValueError(
Expand Down Expand Up @@ -466,7 +468,8 @@ def fetch_known_orbit_data(update_cache=False):
res = requests.get(
(
"https://ssd-api.jpl.nasa.gov/sbdb_query.api?fields="
"pdes,spkid,orbit_id,rms,H,diameter,epoch,e,i,q,w,tp,om,A1,A2,A3,DT,M1,M2,K1,K2,PC,rot_per"
"pdes,spkid,orbit_id,rms,H,diameter,epoch,e,i,q,w,tp,om,"
"A1,A2,A3,DT,M1,M2,K1,K2,PC,rot_per"
"&full-prec=1&sb-xfrag=1"
),
timeout=120,
Expand Down
3 changes: 1 addition & 2 deletions src/kete/neos.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
import numpy as np
from .fov import NeosCmos, NeosVisit


__all__ = ["sunshield_rotation", "NeosCmos", "NeosVisit", "FOV_WIDTH", "FOV_HEIGHT"]
__all__ = ["sunshield_rotation", "FOV_WIDTH", "FOV_HEIGHT"]


BANDS: list[float] = [4700.0, 8000.0]
Expand Down
15 changes: 6 additions & 9 deletions src/kete/rust/flux/common.rs
Original file line number Diff line number Diff line change
Expand Up @@ -84,15 +84,14 @@ 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=None))]
#[pyo3(name = "sub_solar_temperature", signature = (obj2sun, geom_albedo, g_param, beaming, emissivity=0.9))]
dahlend marked this conversation as resolved.
Show resolved Hide resolved
pub fn sub_solar_temperature_py(
obj2sun: VectorLike,
geom_albedo: f64,
g_param: f64,
beaming: f64,
emissivity: Option<f64>,
emissivity: f64,
) -> f64 {
let emissivity = emissivity.unwrap_or(0.9);
let obj2sun = obj2sun.into_vec(PyFrames::Ecliptic);
sub_solar_temperature(&obj2sun, geom_albedo, g_param, beaming, emissivity)
}
Expand Down Expand Up @@ -222,7 +221,7 @@ pub fn frm_facet_temperature_py(
/// float
/// Flux in units of Jy.
#[pyfunction]
#[pyo3(name = "neatm_flux", signature = (sun2obj, sun2obs, v_albedo, g_param, beaming, diameter, wavelength, emissivity=None))]
#[pyo3(name = "neatm_flux", signature = (sun2obj, sun2obs, v_albedo, g_param, beaming, diameter, wavelength, emissivity=0.9))]
#[allow(clippy::too_many_arguments)]
pub fn neatm_thermal_py(
sun2obj: VectorLike,
Expand All @@ -232,9 +231,8 @@ pub fn neatm_thermal_py(
beaming: f64,
diameter: f64,
wavelength: f64,
emissivity: Option<f64>,
emissivity: f64,
) -> f64 {
let emissivity = emissivity.unwrap_or(0.9);
let sun2obj = sun2obj.into_vec(PyFrames::Ecliptic);
let sun2obs = sun2obs.into_vec(PyFrames::Ecliptic);

Expand Down Expand Up @@ -292,7 +290,7 @@ pub fn neatm_thermal_py(
/// float
/// Flux in units of Jy.
#[pyfunction]
#[pyo3(name = "frm_flux", signature = (sun2obj, sun2obs, v_albedo, g_param, diameter, wavelength, emissivity=None))]
#[pyo3(name = "frm_flux", signature = (sun2obj, sun2obs, v_albedo, g_param, diameter, wavelength, emissivity=0.9))]
#[allow(clippy::too_many_arguments)]
pub fn frm_thermal_py(
sun2obj: VectorLike,
Expand All @@ -301,9 +299,8 @@ pub fn frm_thermal_py(
g_param: f64,
diameter: f64,
wavelength: f64,
emissivity: Option<f64>,
emissivity: f64,
) -> f64 {
let emissivity = emissivity.unwrap_or(0.9);
let sun2obj = sun2obj.into_vec(PyFrames::Ecliptic);
let sun2obs = sun2obs.into_vec(PyFrames::Ecliptic);
let hg_params = HGParams::try_fill(
Expand Down
63 changes: 24 additions & 39 deletions src/kete/rust/flux/models.rs
Original file line number Diff line number Diff line change
Expand Up @@ -194,23 +194,20 @@ impl PyNeatmParams {
#[new]
#[allow(clippy::too_many_arguments, missing_docs)]
#[pyo3(signature = (desig, band_wavelength, band_albedos, h_mag=None, diam=None,
vis_albedo=None, beaming=None, g_param=None, c_hg=None, emissivity=None, zero_mags=None))]
vis_albedo=None, beaming=1.0, g_param=0.15, c_hg=None, emissivity=0.9, zero_mags=None))]
pub fn new(
desig: String,
band_wavelength: Vec<f64>,
band_albedos: Vec<f64>,
h_mag: Option<f64>,
diam: Option<f64>,
vis_albedo: Option<f64>,
beaming: Option<f64>,
g_param: Option<f64>,
beaming: f64,
g_param: f64,
c_hg: Option<f64>,
emissivity: Option<f64>,
emissivity: f64,
zero_mags: Option<Vec<f64>>,
) -> PyResult<Self> {
let emissivity = emissivity.unwrap_or(0.9);
let beaming = beaming.unwrap_or(1.0);
let g_param = g_param.unwrap_or(0.15);
let hg_params = HGParams::try_fill(desig, g_param, h_mag, c_hg, vis_albedo, diam)?;

let obs_bands = ObserverBands::Generic {
Expand Down Expand Up @@ -256,21 +253,18 @@ impl PyNeatmParams {
#[staticmethod]
#[allow(clippy::too_many_arguments)]
#[pyo3(signature = (desig, band_albedos, h_mag=None, diam=None, vis_albedo=None,
beaming=None, g_param=None, c_hg=None, emissivity=None))]
beaming=1.0, g_param=0.15, c_hg=None, emissivity=0.9))]
pub fn new_wise(
desig: String,
band_albedos: Vec<f64>,
h_mag: Option<f64>,
diam: Option<f64>,
vis_albedo: Option<f64>,
beaming: Option<f64>,
g_param: Option<f64>,
beaming: f64,
g_param: f64,
c_hg: Option<f64>,
emissivity: Option<f64>,
emissivity: f64,
) -> PyResult<Self> {
let emissivity = emissivity.unwrap_or(0.9);
let beaming = beaming.unwrap_or(1.0);
let g_param = g_param.unwrap_or(0.15);
let hg_params = HGParams::try_fill(desig, g_param, h_mag, c_hg, vis_albedo, diam)?;

let band_albedos = match band_albedos.try_into() {
Expand Down Expand Up @@ -311,23 +305,20 @@ impl PyNeatmParams {
/// emissivity:
/// Emissivity of the object, defaults to `0.9`.
#[staticmethod]
#[pyo3(signature = (desig, band_albedos, h_mag=None, diam=None, vis_albedo=None, beaming=None,
g_param=None, c_hg=None, emissivity=None))]
#[pyo3(signature = (desig, band_albedos, h_mag=None, diam=None, vis_albedo=None, beaming=1.0,
g_param=0.15, c_hg=None, emissivity=0.9))]
#[allow(clippy::too_many_arguments)]
pub fn new_neos(
desig: String,
band_albedos: Vec<f64>,
h_mag: Option<f64>,
diam: Option<f64>,
vis_albedo: Option<f64>,
beaming: Option<f64>,
g_param: Option<f64>,
beaming: f64,
g_param: f64,
c_hg: Option<f64>,
emissivity: Option<f64>,
emissivity: f64,
) -> PyResult<Self> {
let emissivity = emissivity.unwrap_or(0.9);
let beaming = beaming.unwrap_or(1.0);
let g_param = g_param.unwrap_or(0.15);
let hg_params = HGParams::try_fill(desig, g_param, h_mag, c_hg, vis_albedo, diam)?;

let band_albedos = match band_albedos.try_into() {
Expand Down Expand Up @@ -533,21 +524,19 @@ impl PyFrmParams {
#[new]
#[allow(clippy::too_many_arguments, missing_docs)]
#[pyo3(signature = (desig, band_wavelength, band_albedos, h_mag=None, diam=None,
vis_albedo=None, g_param=None, c_hg=None, emissivity=None, zero_mags=None))]
vis_albedo=None, g_param=0.15, c_hg=None, emissivity=0.9, zero_mags=None))]
pub fn new(
desig: String,
band_wavelength: Vec<f64>,
band_albedos: Vec<f64>,
h_mag: Option<f64>,
diam: Option<f64>,
vis_albedo: Option<f64>,
g_param: Option<f64>,
g_param: f64,
c_hg: Option<f64>,
emissivity: Option<f64>,
emissivity: f64,
zero_mags: Option<Vec<f64>>,
) -> PyResult<Self> {
let emissivity = emissivity.unwrap_or(0.9);
let g_param = g_param.unwrap_or(0.15);
let hg_params = HGParams::try_fill(desig, g_param, h_mag, c_hg, vis_albedo, diam)?;
let obs_bands = ObserverBands::Generic {
solar_correction: vec![1.0; band_wavelength.len()],
Expand Down Expand Up @@ -589,20 +578,18 @@ impl PyFrmParams {
/// Emissivity of the object, defaults to `0.9`.
#[staticmethod]
#[allow(clippy::too_many_arguments)]
#[pyo3(signature = (desig, band_albedos, h_mag=None, diam=None, vis_albedo=None, g_param=None,
c_hg=None, emissivity=None))]
#[pyo3(signature = (desig, band_albedos, h_mag=None, diam=None, vis_albedo=None, g_param=0.15,
c_hg=None, emissivity=0.9))]
pub fn new_wise(
desig: String,
band_albedos: Vec<f64>,
h_mag: Option<f64>,
diam: Option<f64>,
vis_albedo: Option<f64>,
g_param: Option<f64>,
g_param: f64,
c_hg: Option<f64>,
emissivity: Option<f64>,
emissivity: f64,
) -> PyResult<Self> {
let emissivity = emissivity.unwrap_or(0.9);
let g_param = g_param.unwrap_or(0.15);
let hg_params = HGParams::try_fill(desig, g_param, h_mag, c_hg, vis_albedo, diam)?;

let band_albedos = match band_albedos.try_into() {
Expand Down Expand Up @@ -639,20 +626,18 @@ impl PyFrmParams {
/// Emissivity of the object, defaults to `0.9`.
#[staticmethod]
#[allow(clippy::too_many_arguments)]
#[pyo3(signature = (desig, band_albedos, h_mag=None, diam=None, vis_albedo=None, g_param=None,
c_hg=None, emissivity=None))]
#[pyo3(signature = (desig, band_albedos, h_mag=None, diam=None, vis_albedo=None, g_param=0.15,
c_hg=None, emissivity=0.9))]
pub fn new_neos(
desig: String,
band_albedos: Vec<f64>,
h_mag: Option<f64>,
diam: Option<f64>,
vis_albedo: Option<f64>,
g_param: Option<f64>,
g_param: f64,
c_hg: Option<f64>,
emissivity: Option<f64>,
emissivity: f64,
) -> PyResult<Self> {
let emissivity = emissivity.unwrap_or(0.9);
let g_param = g_param.unwrap_or(0.15);
let hg_params = HGParams::try_fill(desig, g_param, h_mag, c_hg, vis_albedo, diam)?;

let band_albedos = match band_albedos.try_into() {
Expand Down
3 changes: 1 addition & 2 deletions src/kete/wise.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,9 @@
from .time import Time
from .vector import Vector, Frames
from .irsa import IRSA_URL, query_irsa_tap, plot_fits_image, zoom_plot, annotate_plot
from .fov import WiseCmos, FOVList

from ._core import (
WiseCmos,
FOVList,
w1_color_correction,
w2_color_correction,
w3_color_correction,
Expand Down
Loading