skyscapes.physical_model.cached#
Pre-computed reflectivity physical model.
Holds a fixed (K, n_nu) plane-parallel-reflectivity array that was
produced by running some other AbstractPhysicalModel’s heavy
radiative transfer once. contrast becomes a cubic interpolation +
Lambert phase + (Rp/d)^2 lookup – microseconds per call vs.
seconds for an ExoJAX 2-stream RT.
- Use cases:
Coronagraphoto simulations where the physics is fixed across many evaluations (orbits, wavelengths, time samples).
ETC studies where you want fast forward-modeling against a canonical Earth-like atmosphere.
Not for HMC retrievals where parameters vary – the underlying expensive model is the right tool there.
The cache file format is a NumPy .npz with two keyword arrays
(reflectivity, nu_grid) and a small JSON-style header tag for
version-tracking.
Attributes#
Classes#
Physical model whose reflectivity spectrum has been pre-computed. |
Module Contents#
- skyscapes.physical_model.cached.CACHE_FORMAT_VERSION = 2#
- class skyscapes.physical_model.cached.PrecomputedPhysicalModel[source]#
Bases:
skyscapes.physical_model.base.AbstractPhysicalModelPhysical model whose reflectivity spectrum has been pre-computed.
- Attributes:
- reflectivity: Per-planet plane-parallel reflectivity
R(nu) on the wavenumber grid, shape
(K, n_nu). Already includes all the physics of the original physical model (absorption, Rayleigh, clouds, surface).
nu_grid: Wavenumber grid [cm^-1], shape
(n_nu,). n_nu: Length ofnu_grid(static for JIT).- reflectivity: Per-planet plane-parallel reflectivity
- reflectivity: jaxtyping.Array#
- nu_grid: jaxtyping.Array#
- classmethod from_physical_model(model)[source]#
Pre-compute the reflectivity from an existing physical model.
Calls the model’s internal
_reflectivity_all_planetsonce and packages the result. Requires the model to expose_reflectivity_all_planets,nu_grid, andn_nu– presentlyExoJaxPhysicalModelis the supported source.- Parameters:
- Return type:
- classmethod load(path)[source]#
Load a previously-saved cache file.
- Args:
path: Path to a
.npzfile produced bysave().- Returns:
A
PrecomputedPhysicalModelready to evaluate.- Raises:
- ValueError: if the file’s
cache_format_versiondiffers from the current code’s version (would silently produce wrong spectra otherwise).
- ValueError: if the file’s
- Parameters:
path (str | pathlib.Path)
- Return type:
- save(path)[source]#
Save the cached reflectivity to a
.npzfile.Idempotent and safe to call from JAX-traced contexts (the save itself is plain NumPy – callers should not call this inside a JIT region, but the data is just regular arrays).
- Parameters:
path (str | pathlib.Path)
- Return type:
None
- contrast(phase_angle_rad, dist_AU, wavelength_nm, Rp_Rearth)[source]#
Per-planet, per-time geometric-albedo contrast at one wavelength.
- Args:
phase_angle_rad: Star-planet-observer phase angle, shape
(K, T). dist_AU: Star-planet distance [AU], shape(K, T). wavelength_nm: Scalar wavelength [nm]. Rp_Rearth: Planet radius [Earth radii], shape(K,).- Returns:
Contrast =
A_g(lambda) * Lambert_phase(beta) * (Rp/d)^2, shape(K, T). The cached array stores the underlying model’s plane-parallel (spherical) reflectivity; we convert to geometric albedo via the Lambertian-sphere factor 2/3 (Seager 2010, eq 3.36) at call time – same convention asExoJaxPhysicalModel.contrast.
- Parameters:
phase_angle_rad (jaxtyping.Array)
dist_AU (jaxtyping.Array)
wavelength_nm (jaxtyping.Array)
Rp_Rearth (jaxtyping.Array)
- Return type:
jaxtyping.Array
- contrast_cube(phase_angle_rad, dist_AU, wavelengths_nm, Rp_Rearth)[source]#
Per-planet, per-time geometric-albedo contrast across wavelengths.
Returns shape
(W, K, T). Avoids per-wavelength recomputation by vectorising the interpolation; applies the Lambertian-sphere spherical-to-geometric conversion the same way ascontrast().- Parameters:
phase_angle_rad (jaxtyping.Array)
dist_AU (jaxtyping.Array)
wavelengths_nm (jaxtyping.Array)
Rp_Rearth (jaxtyping.Array)
- Return type:
jaxtyping.Array