Flux

Thermal and Reflected light modeling tools.

This includes computations such as NEATM, FRM, HG, and reflection models.

Modeling is broken into categories of complexity, ranging from pure black body calculations, through to telescope specific models. Picking the appropriate model can save significant development time, but removes some of the control for the user.

For multi-band thermal + reflected light modeling, use neatm_model_flux() or frm_model_flux(). These return ModelResults objects containing total, thermal, and reflected fluxes.

Use resolve_hg_params() to compute any missing value from the (H-mag, diameter, visible albedo) triad before calling the model functions.

If optical wavelengths are the goal, hg_apparent_mag() or hg_apparent_flux() is probably appropriate.

There are a number of lower-level functions provided more for pedagogical reasons:

class kete.flux.FitResult

Full MCMC fitting result.

beaming

Posterior statistics for beaming (NEATM only). None for FRM/HG. Only non-divergent draws are included.

best_fit_fluxes

Model fluxes at the MAP point for each observation (Jy).

best_fit_reflected_frac

Reflected-light fraction at the MAP point, one per observation.

best_fit_residuals

Standardized residuals (obs - model) / (f_sigma * sigma) at the MAP, using the residual side’s sigma. 0.0 where undefined: bounds-only constraints, and one-sided limits whose model flux sits on the unconstrained side (e.g. below an upper-limit threshold).

chi2_best

Reduced chi-squared at the MAP point using inflated uncertainties.

columns

Column names for each element of a draw vector.

diameter

Posterior statistics for diameter (km). None for HG model. Only non-divergent draws are included.

divergent

Per-draw divergence flags from the NUTS sampler.

draws

Non-divergent MCMC posterior draws. Each row is one sample; column layout depends on the model (see columns).

draws_all

All MCMC posterior draws including divergent transitions. Use divergent to identify which rows diverged.

f_sigma

Posterior statistics for uncertainty inflation factor. Only non-divergent draws are included.

g_param

Posterior statistics for G parameter. Only non-divergent draws are included.

h_mag

Posterior statistics for H magnitude. Only non-divergent draws are included.

ir_albedo_ratio

Posterior statistics for IR-to-visible albedo ratio. None for HG model. Only non-divergent draws are included.

model

Model name ("Neatm", "Frm", or "Hg").

n_divergent

Total number of divergent transitions.

nobs

Number of non-upper-limit observations.

vis_albedo

Posterior statistics for visual geometric albedo. None for HG model. Only non-divergent draws are included.

class kete.flux.FluxObs(flux, sigma, band, sun2obj, sun2obs, is_upper_limit=False, sigma_hi=None, bounds=None)

A single flux constraint at a known geometry.

A constraint on the model flux is expressed the same way a ParamPrior constrains a parameter: an optional hard bounds interval plus an optional (possibly asymmetric) Gaussian point estimate. Provide flux/sigma for a point estimate, bounds for a hard interval, or both. The detection(), upper_limit(), and bounded() static constructors cover the common cases.

flux and sigma are always the first two arguments; pass None for both to give a bounds-only constraint.

Parameters:
  • flux – Gaussian point estimate (Jy), or the upper-limit threshold when is_upper_limit. None for a bounds-only constraint.

  • sigma – 1-sigma uncertainty in Jy (lower side if asymmetric). Required when flux is given, except for an upper limit, whose single noise scale may be passed as either sigma or sigma_hi (not both).

  • band – Band identifier: a WISE name ("W1"-"W4") or a wavelength in nm.

  • sun2obj – Sun-to-object vector in AU (Ecliptic frame).

  • sun2obs – Sun-to-observer vector in AU (Ecliptic frame).

  • is_upper_limit – If True, flux is a non-detection upper-limit threshold.

  • sigma_hi – Optional upper-side 1-sigma uncertainty (sigma_plus) in Jy. None means the error is symmetric and equal to sigma.

  • bounds – Optional hard (lo, hi) interval on the model flux (Jy): a wall, flat inside, not scaled by the fitted error inflation.

static bounded(lo, hi, band, sun2obj, sun2obs)

A hard flux interval [lo, hi] with no point estimate.

bounds

Hard (lo, hi) flux interval in Jy, or None if unbounded.

static detection(flux, sigma, band, sun2obj, sun2obs, sigma_hi=None)

A two-sided flux detection flux +/- sigma (asymmetric if sigma_hi).

flux

Point-estimate flux in Jy, or None for a bounds-only constraint.

is_upper_limit

Whether this is a non-detection upper limit.

sigma

The 1-sigma uncertainty in Jy. This is the lower-side width of a detection, the noise scale of an upper limit, or None if there is no point estimate.

sigma_hi

Upper-side 1-sigma uncertainty in Jy, or None if no point estimate.

sun2obj

Sun-to-object vector in AU (Ecliptic frame), as [x, y, z].

sun2obs

Sun-to-observer vector in AU (Ecliptic frame), as [x, y, z].

static upper_limit(threshold, sigma, band, sun2obj, sun2obs)

A soft photometric upper limit: a non-detection at threshold with noise scale sigma.

wavelength

Band wavelength in nm.

class kete.flux.FluxPriors(diameter=None, beaming=None, r_ir=None, h_mag=None, g_param=None, vis_albedo=None, f_sigma=None)

Priors used in thermal model fitting, below is the list of default priors.

Priors can be specified either using the FluxPriors constructor or by directly passing a tuple of the form (low, high) for bounds-only or (low, high, mean, sigma) for bounds + Gaussian. Below we see the defaults being specified using the tuple form.

Not all of these priors are used in every model, this is a comprehensive list for all models.

If not provided, defaults are used, specifying a prior will overwrite the specified priors while leaving the others at their defaults:

kete.flux.FluxPriors(
    diameter   = (0.001, 1000),
    beaming    = (0.5, 3.0, 1.0, 0.3),
    r_ir       = (0.5, 2.0, 1.6, 0.3),
    h_mag      = (-5.0, 35.0),
    g_param    = (-0.3, 0.7, 0.2, 0.05),
    vis_albedo = (0.01, 1.0),
    f_sigma    = (0.5, 5.0),
)

Each prior is a ParamPrior specifying bounds (logistic barrier) and an optional gaussian centering prior (mean, sigma). To effectively fix a parameter, set tight bounds around the desired value (e.g., bounds=(val - 1e-3, val + 1e-3)).

Parameters:
  • diameter – ParamPrior for diameter D in km.

  • beaming – ParamPrior for beaming parameter.

  • r_ir – ParamPrior for IR-to-visible albedo ratio R_IR.

  • h_mag – ParamPrior for H magnitude.

  • g_param – ParamPrior for G parameter.

  • vis_albedo – ParamPrior for visible geometric albedo.

  • f_sigma – ParamPrior for the factor that scales every flux uncertainty.

beaming
diameter
f_sigma
g_param
h_mag
r_ir
vis_albedo
class kete.flux.ModelResults(fluxes, thermal_fluxes, hg_fluxes, v_band_magnitude, v_band_flux, magnitudes=None)

Reflected/Thermal model results.

Parameters:
  • fluxes – Total fluxes per band in units of Jy.

  • thermal_fluxes – Black body specific fluxes per band in units of Jy.

  • hg_fluxes – Reflected light specific fluxes per band in units of Jy.

  • v_band_magnitude – Expected magnitude in the V-band using the HG model.

  • v_band_flux – Expected flux in the V-band using the HG model.

  • magnitudes – Magnitudes in the different bands if zero mags were available.

fluxes

Total fluxes per band in units of Jy.

hg_fluxes

Reflected light specific fluxes per band in units of Jy.

magnitudes

Magnitudes in the different bands if zero mags were available.

thermal_fluxes

Black body specific fluxes per band in units of Jy.

v_band_flux

Expected flux in the V-band using the HG model.

v_band_magnitude

Expected magnitude in the V-band using the HG model.

class kete.flux.ParamPrior(bounds, gaussian=None)

Prior configuration for model fitting. Configuration for a single parameter’s prior.

Parameters:
  • bounds – (low, high) hard bounds. Each bound is a smooth wall, so the sampler can use gradients. The soft part of a wall is about 2% of the smallest of the bound’s magnitude, high - low, and 1. Inside the bounds, away from the walls, the prior is flat.

  • gaussian – Optional Gaussian centering prior. Either (mean, sigma) for a symmetric prior, or (mean, sigma_lo, sigma_hi) for an asymmetric one (sigma_lo is the 1-sigma width below mean, sigma_hi above). None means flat (uniform) within the bounds.

bounds
gaussian

Gaussian center as (mean, sigma), (mean, sigma_lo, sigma_hi) when the two widths differ, or None.

kete.flux.black_body_flux(temp, wavelength)

Compute the black body flux at the specified temperatures and wavelength.

Flux is in units Janskys / steradian per unit freq. This can be converted to being per unit wavelength by multiplying the result of this by c / wavelength**2.

This is limited by the size of float 32s, numbers exceeding 1e-300 will be rounded to 0. This should not raise any warnings, and should be relatively numerically stable and correct over most domains of interest.

Parameters:
  • temp – List of temperatures, in units of Kelvin.

  • wavelength – In units of nanometers.

Returns:

Janskys per steradian

Return type:

List

kete.flux.bond_albedo(vis_albedo, g_param=0.15)

Approximate the Bond albedo from the visible geometric albedo and the HG slope parameter using Bowell et al. (1989): A_B = vis_albedo * (0.290 + 0.684 * g_param).

For the radiation force model the relevant quantity is the absorptivity alpha = 1 - A_B.

Parameters:
  • vis_albedo – Visible geometric albedo.

  • g_param – G phase parameter in the HG system. 0.15 is the typical asteroid default.

kete.flux.comet_apparent_mags(sun2obj, sun2obs, mk_1=None, mk_2=None, phase_corr=Ellipsis)

Given the M1/K1 and M2/K2 values, compute the apparent Comet visible magnitudes.

The model for apparent magnitudes are:

m1 + k1 * log10(sun2obj.r) + 5.0 * log10(obj2obs.r) + phase_mag_slope_1 * phase m2 + k2 * log10(sun2obj.r) + 5.0 * log10(obj2obs.r) + phase_mag_slope_2 * phase

Where m1/k1 are related to total magnitudes and m2/k2 are nucleus magnitudes.

This model is based off of these: https://ssd.jpl.nasa.gov/horizons/manual.html#obsquan (see section 9) https://en.wikipedia.org/wiki/Absolute_magnitude#Cometary_magnitudes

Note that the above model does not include a 2.5x term attached to the K1/2 terms which are present in the wikipedia definition, this matches the definitions used by JPL Horizons.

Note that this includes seperate phase magnitude slope for both the nucleus and total fluxes.

This does a best effort to compute both magnitudes, if any values are missing this will return None in the respective calculation.

Parameters:
  • sun2obj – A vector-like object containing the X/Y/Z coordinates pointing to the object from the sun in units of AU.

  • sun2obs – A vector-like object containing the X/Y/Z coordinates pointing from the sun to the observer in units of AU.

  • mk_1 – Tuple of (M_1, K_1), where M_1 is the total Absolute magnitude of the comet, and K_1 magnitude slope as a function of heliocentric distance.

  • mk_2 – Tuple of (M_2, K_2), where M_2 is the total Absolute magnitude of the nucleus, and K_2 nucleus magnitude slope as a function of heliocentric distance.

  • phase_corr – Magnitude variation of the comet as a function of observing phase, units are Mag/Deg of phase, this defaults to 0.0 for the total magnitude, and 0.035 Mag/Deg for the nucleus.

Returns:

(Total apparent magnitude, Magnitude of the nucleus)

Return type:

float

kete.flux.comet_dust_phase_curve_correction(phase_angle)

Phase correction curve for cometary dust from the following paper:

A composite phase function for cometary dust comae Bertini, Ivano, et al. Planetary and Space Science (2025): 106164.

This uses the fitted values from the paper for k=0.80, g_f=0.944, g_b=-0.542.

An additional normalization has been applied so that the value of this is 1.0 at 0.0 phase angle.

Parameters:

phase_angle – The angular separation between the sun and observer as viewed from the dust, units of degrees.

Returns:

The phase curve correction.

Return type:

float

kete.flux.fit_model(model, obs, h_mag=None, g_param=None, emissivity=0.9, priors=None, num_chains=10, num_tune=200, num_draws=500, c_hg=None)

Fit a model to observations using NUTS MCMC.

H magnitude and G parameter are fitted as free parameters. If h_mag or g_param are supplied, they set the center of the corresponding Gaussian prior (keeping its width from priors). emissivity is a fixed thermal property (not fitted).

Parameters:
  • model – Model name: "neatm", "frm", or "hg".

  • obs – List of FluxObs observations.

  • h_mag – Optional H magnitude – sets the center of the H prior.

  • g_param – Optional G parameter – sets the center of the G prior.

  • emissivity – Fixed thermal emissivity (default 0.9, not fitted).

  • priors – Prior configuration (FluxPriors, default if None).

  • num_chains – Number of MCMC chains (default 10).

  • num_tune – Warmup draws per chain (default 200).

  • num_draws – Posterior draws per chain (default 500).

  • c_hg – HG relationship constant (default 1329.0).

Returns:

MCMC posterior results.

Return type:

FitResult

Raises:

ValueError – If the fit fails to converge.

kete.flux.frm_facet_temps(facet_normals, subsolar_temp, obj2sun)

Calculate the temperatures of each facet assuming the FRM model.

This is a multi-core operation.

Parameters:
  • facet_normals – List of surface normal vectors.

  • subsolar_temp – Temperature at the sub-solar point in kelvin.

  • obj2sun – Vector from the object to the sun in AU.

kete.flux.frm_model_flux(sun2obj, sun2obs, band_albedos, h_mag=None, diameter=None, vis_albedo=None, g_param=0.15, emissivity=0.9, band_wavelengths=None, bands=None, zero_mags=None)

Compute FRM thermal + reflected fluxes for a single geometry.

Evaluates the FRM model for the given Sun-object-observer geometry, computing both thermal emission and reflected solar light (HG model) across multiple wavelength bands simultaneously.

Parameters:
  • sun2obj – Vector pointing from the Sun to the object (AU).

  • sun2obs – Vector pointing from the Sun to the observer (AU).

  • band_albedos – Albedo of the object in each band (0-1).

  • h_mag – H magnitude of the object in the HG system. At least two of h_mag, diameter, and vis_albedo must be provided.

  • diameter – Diameter of the object in km.

  • vis_albedo – Visible geometric albedo.

  • g_param – G phase coefficient, defaults to 0.15.

  • emissivity – Emissivity of the object, defaults to 0.9.

  • band_wavelengths – List of effective wavelengths in nm. Required unless bands is given.

  • bands – Band preset name: "wise", "neos", "irac", "mips", or "irs_pu". If given, band_wavelengths is ignored and the standard band definitions (including color corrections and zero magnitudes) are used.

  • zero_mags – Optional list of zero-point magnitudes for each band. Only used when band_wavelengths is provided.

Returns:

Fluxes and magnitudes for the given geometry.

Return type:

ModelResults

kete.flux.hg_apparent_flux(sun2obj, sun2obs, g_param, wavelength, vis_albedo, h_mag=None, diameter=None, c_hg=None)

Calculate the reflected flux from an object using the HG asteroid model.

This assumes that the object is an ideal disk facing the sun and applies the IAU correction curve to the reflected light, returning units of Jy per unit frequency.

This treats the sun as a flat black body disk, which is a good approximation as long as the object is several solar radii away.

Either h_mag or diameter must be provided, but only 1 is strictly required. The other will be computed if not provided.

Parameters:
  • sun2obj – A vector-like object containing the X/Y/Z coordinates pointing from the sun to the object in units of AU.

  • sun2obs – A vector-like object containing the X/Y/Z coordinates pointing from the sun to the observer in units of AU.

  • g_param – The G parameter of the object.

  • wavelength – The wavelength of the object in nanometers.

  • vis_albedo – The geometric albedo of the object at the specified wavelength.

  • h_mag – H magnitude of the object in V band.

  • diameter – The diameter of the object in km.

  • c_hg – The relationship constant between H, D, and pV for the bandpass. Defaults to 1329.0.

Returns:

Flux in Jy per unit frequency.

Return type:

float

kete.flux.hg_apparent_mag(sun2obj, sun2obs, h_mag, g_param)

Compute the apparent magnitude of an object using the absolute magnitude H, G, and positional information.

The HG IAU model is not technically defined above 120 degrees phase, however this will continue to return values fit to the model until 160 degrees. Phases larger than 160 degrees will return nan.

Parameters:
  • sun2obj – A vector-like object containing the X/Y/Z coordinates pointing from the sun to the object in units of AU.

  • sun2obs – A vector-like object containing the X/Y/Z coordinates pointing from the sun to the observer in units of AU.

  • G – The G parameter of the object.

  • H – The absolute magnitude of the object.

Returns:

The apparent magnitude of the object.

Return type:

float

kete.flux.hg_phase_curve_correction(g_param, phase_angle)

This computes the phase curve correction in the IAU format.

Parameters:
  • g_param – The G parameter of the object.

  • phase_angle – The angular separation between the sun and observer as viewed from the object, units of degrees.

Returns:

The phase curve correction.

Return type:

float

kete.flux.lambertian_flux(facet_flux, facet_normals, obs2obj, diameter, emissivity)

Calculate the visible flux at the observer assuming a convex faceted object made up of a collection of lambertian surfaces.

Parameters:
  • facet_flux – Flux from each of the facets in Jy / Steradian per unit freq.

  • facet_normals – List of surface normal vectors.

  • obs2obj – Vector from the observer to the object in AU.

  • diameter – Diameter of the object in km.

  • emissivity – Emissivity of the lambertian surfaces (between 0 and 1, 0.9 is a good default).

kete.flux.neatm_facet_temps(facet_normals, subsolar_temp, obj2sun)

Calculate the temperatures of each facet assuming the NEATM model.

This is a multi-core operation.

Parameters:
  • facet_normals – List of surface normal vectors.

  • subsolar_temp – Temperature at the sub-solar point in kelvin.

  • obj2sun – Vector from the object to the sun in AU.

kete.flux.neatm_model_flux(sun2obj, sun2obs, band_albedos, h_mag=None, diameter=None, vis_albedo=None, g_param=0.15, beaming=1.0, emissivity=0.9, band_wavelengths=None, bands=None, zero_mags=None)

Compute NEATM thermal + reflected fluxes for a single geometry.

Evaluates the NEATM model for the given Sun-object-observer geometry, computing both thermal emission and reflected solar light (HG model) across multiple wavelength bands simultaneously.

Parameters:
  • sun2obj – Vector pointing from the Sun to the object (AU).

  • sun2obs – Vector pointing from the Sun to the observer (AU).

  • band_albedos – Albedo of the object in each band (0-1).

  • h_mag – H magnitude of the object in the HG system. At least two of h_mag, diameter, and vis_albedo must be provided.

  • diameter – Diameter of the object in km.

  • vis_albedo – Visible geometric albedo.

  • g_param – G phase coefficient, defaults to 0.15.

  • beaming – Beaming parameter, defaults to 1.0.

  • emissivity – Emissivity of the object, defaults to 0.9.

  • band_wavelengths – List of effective wavelengths in nm. Required unless bands is given.

  • bands – Band preset name: "wise", "neos", "irac", "mips", or "irs_pu". If given, band_wavelengths is ignored and the standard band definitions (including color corrections and zero magnitudes) are used.

  • zero_mags – Optional list of zero-point magnitudes for each band. Only used when band_wavelengths is provided.

Returns:

Fluxes and magnitudes for the given geometry.

Return type:

ModelResults

kete.flux.resolve_hg_params(h_mag=None, vis_albedo=None, diameter=None, c_hg=None)

Resolve any two of (h_mag, vis_albedo, diameter) to compute the third.

Given any two of H-magnitude, visible geometric albedo, and diameter, this computes the missing value using the standard C_hg relationship. If all three are provided, it validates that they are consistent.

Parameters:
  • h_mag – H magnitude of the object in the HG system.

  • vis_albedo – Visible geometric albedo.

  • diameter – Diameter of the object in km.

  • c_hg – The C_hg constant (default 1329.0 km).

Returns:

(h_mag, vis_albedo, diameter) with all three resolved.

Return type:

tuple

kete.flux.solar_flux(dist, wavelength)

Return the Solar flux density in Janskys from the 2000 ASTM Standard Extraterrestrial Spectrum Reference E-490-00: <https://www.nrel.gov/grid/solar-resource/spectra-astm-e490.html>

Returned values are flux densities in units of Janskys, scaled by 1 / dist^2 from the tabulated 1 au spectrum.

Parameters:
  • dist – Distance the object is from the Sun in au.

  • wavelength – Wavelength in nm.

kete.flux.sub_solar_temperature(sun_dist, vis_albedo, g_param, beaming, emissivity=0.9)

Compute the subsolar surface temperature in kelvin.

Parameters:
  • sun_dist – Distance from the object to the sun in AU.

  • vis_albedo – Visible geometric albedo.

  • g_param – G Phase parameter in the HG system.

  • beaming – The beaming parameter of the object.

  • emissivity – Emissivity of the object, 0.9 by default.

shape

class kete.shape.TriangleEllipsoid(n_div=6, x_scale=1.0, y_scale=1.0, z_scale=1.0)

A triangle-faceted ellipsoid shape, used for visualization of thermal models.

This generates a nearly-uniform triangulation of an ellipsoid using the algorithm from https://arxiv.org/abs/1502.04816.

Examples

(Source code, png, hires.png, pdf)

../_images/flux-1.png
Parameters:
  • n_div – Number of divisions from pole to equator. Total facet count is 8 * n_div^2. Must be at least 1.

  • x_scale – Scale factor along the x-axis.

  • y_scale – Scale factor along the y-axis.

  • z_scale – Scale factor along the z-axis.

areas

Area of each facet (normalized so total area is 1), shape (n,).

facets

Triangle vertices of each facet, shape (n, 3, 3).

normals

Unit normal vectors of each facet, shape (n, 3).

class kete.shape.Polyhedron(vertices, faces, gm)

Gravity field of a constant-density polyhedron.

The closed-form field of Werner and Scheeres (1997). The mesh must be closed, consistently wound counter-clockwise seen from outside, and free of degenerate faces. It is used where it is placed: fields are evaluated at positions relative to the mesh origin, and the center of mass is the volume centroid, see centroid. Units are whatever the vertices and gm are given in: with vertices in km and gm in km^3/s^2, accelerations are in km/s^2.

At and beyond far_field_radius (3 times bounding_radius) the field comes from the polyhedron’s exact spherical harmonic expansion, cut at the lowest degree that matches the closed form to 1e-11 (acceleration) and 1e-9 (gradient) relative on that sphere; it is built on the first evaluation there. The closed form costs a pass over every face and edge and loses relative precision far away, where its sums cancel toward the point-mass value. without_far_field() returns the closed form at every distance.

Parameters:
  • vertices – Vertex positions, shape (n, 3).

  • faces – Faces as 0-based vertex indices, shape (m, 3), counter-clockwise seen from outside.

  • gm – Gravitational parameter of the body, in the units of the vertices cubed per time squared.

bounding_radius

Largest distance of a vertex from the mesh origin.

centroid

Volume centroid, the center of mass at constant density, relative to the mesh origin.

faces

Faces as 0-based vertex indices, shape (m, 3).

far_field()

The far field as a SphericalHarmonics (built if needed), or None when it is turned off or no degree up to 40 met the tolerances, in which case the closed form is used everywhere.

far_field_radius

Distance from the mesh origin at and beyond which the far field is used, or None when it is turned off.

field(pos)

Acceleration at a position relative to the mesh origin.

Returns the acceleration and the solid angle the surface subtends at the position: 4 pi inside the body and 0 outside.

field_and_gradient(pos)

Acceleration, its gradient with respect to position (grad[i][j] is d accel_i / d pos_j), and the solid angle, at a position relative to the mesh origin.

gm

Gravitational parameter.

potential(pos)

Gravitational potential at a position relative to the mesh origin, positive, so that the acceleration is its gradient.

vertices

Vertices, shape (n, 3).

volume

Enclosed volume.

without_far_field()

The same polyhedron using the closed form at every distance.

class kete.shape.SphericalHarmonics(gm, radius, c, s, min_radius=None)

Gravity field given by fully normalized spherical harmonic coefficients.

U = GM / R sum_n sum_m (C_nm V_nm + S_nm W_nm) with V_nm = (R / r)^(n+1) P_nm(sin lat) cos(m lon) (W_nm with sin), P_nm the associated Legendre functions without the Condon-Shortley phase, and the coefficients fully normalized (the geodesy convention): an unnormalized J2 is C_20 = -J2 / sqrt(5). Positions are relative to the expansion origin, in the body frame, in the units of radius; gm sets the units of the results.

The series converges only outside the smallest sphere about the origin that contains all of the body’s mass (its Brillouin sphere). Given min_radius (the Brillouin radius or larger), an evaluation inside it raises; without it, only the origin does. The reference radius radius is a normalization choice and is not that limit.

Parameters:
  • gm – Gravitational parameter.

  • radius – Reference radius of the coefficients.

  • c – C_nm, one row per degree n with n + 1 entries.

  • s – S_nm, the same shape; S_n0 must be 0.

  • min_radius – Distance from the origin inside which an evaluation raises.

c

C_nm, one row per degree.

degree

Largest degree.

field(pos)

Acceleration at a position.

field_and_gradient(pos)

Acceleration and its gradient with respect to position (grad[i][j] is d accel_i / d pos_j) at a position.

static from_polyhedron(poly, degree)

The exact field of a constant-density Polyhedron to degree, expanded about the mesh origin, with the reference and minimum radius the mesh’s bounding radius; units are those of the polyhedron.

gm

Gravitational parameter.

min_radius

Distance from the origin inside which an evaluation raises, or None.

potential(pos)

Gravitational potential at a position, positive, so that the acceleration is its gradient.

radius

Reference radius.

s

S_nm, one row per degree.

truncated(degree)

The same field cut at degree.

kete.shape.read_obj(path)

Read the vertices and triangular faces of a Wavefront OBJ file.

Only v and f records are read; normals, texture coordinates and other records are ignored. Face indices may carry /-separated texture and normal indices, which are dropped, and may be negative (relative to the end of the vertex list), as the format allows. Faces are returned 0-based, in the order and winding of the file.

Parameters:

path (str | PathLike) – Path to the OBJ file.

Returns:

  • vertices – Vertex positions, shape (n, 3), in the units of the file.

  • faces – Faces as 0-based vertex indices, shape (m, 3).

Raises:

ValueError – If a face is not a triangle or an index is out of range.

Return type:

tuple[ndarray, ndarray]