photomancy
Divination from light.
photomancy is a JAX-native engine for Bayesian inference and value of information over astrophysical scenes observed by direct imaging. It is part of the Habitable Worlds Observatory simulation suite: orbix builds the geometry, skyscapes builds the scene, and photomancy divines the scene back from the data, producing posteriors over the scene parameters, the Bayesian evidence for model comparison, and the expected information gain of a candidate next observation.
The engine is forward-model agnostic. A fit is a logdensity over a partitioned scene
PyTree, assembled from three plug-ins, a forward model, a likelihood, and a prior, and run
through a uniform backend that returns one posterior. The same inference machinery serves
orbit fitting today and disk, atmosphere, and image-domain fitting as those forward models
come online, so an improvement to a sampler or to the information-gain calculation reaches
every domain at once.
Installation
pip install photomancy
photomancy requires Python 3.11 or newer and is in early development, so the API may still
change. For a source checkout with the test and documentation extras, clone the repository
and run pip install -e ".[test,docs]".
Quick start
A domain supplies three plug-ins over a scene, and the engine turns them into a fit:
from photomancy import LaplaceBackend, build_scene_logdensity
# forward: scene -> predicted data
# likelihood: predicted -> scalar log-likelihood
# prior: an AbstractPrior over the fitted leaves
logdensity, z0, unravel = build_scene_logdensity(
scene, forward_model=forward, likelihood=likelihood, prior=prior
)
posterior = LaplaceBackend().run(logdensity, z0)
samples = posterior.sample(key, 1000) # (1000, d), flat parameter space
log_evidence = posterior.evidence
The orbit, disk, and atmosphere domains package these plug-ins for their own data, so a typical fit calls a domain helper rather than wiring the three pieces by hand.
What it does
- Posteriors over scene parameters behind one interface (
sample,log_prob,evidence), whichever backend produced them. - Bayesian evidence and Bayes factors for model comparison and detection, answering questions such as whether an orbit needs eccentricity or whether a spectral feature is present.
- Multimodal posteriors as evidence-weighted mixtures, so period aliases and mirror ambiguities are carried honestly rather than collapsed onto one answer.
- Sequential updating, where a posterior becomes the prior for the next observation through
to_prior, so information accumulates across a campaign. - Expected information gain over candidate observations, turning a fit into a recommendation for where to look next.
Backends
Every backend exposes one method, run(logdensity, init, key) -> Posterior, and sees only
the flat logdensity, never the scene or the forward model, so a new sampler becomes useful
to every domain at once.
| Backend | Method | Returns |
|---|---|---|
LaplaceBackend |
MAP optimization plus the eigenvalue-clamped inverse Hessian | a Gaussian posterior and the Laplace evidence |
LaplaceMixtureBackend |
multi-start Laplace, weighted by evidence | a mixture of Gaussians over the modes |
PathfinderBackend |
quasi-Newton variational inference | a Gaussian posterior and the ELBO |
PathfinderMixtureBackend |
multi-start Pathfinder, weighted by ELBO | a mixture of Gaussians over the modes |
NUTSBackend |
the No-U-Turn sampler with window adaptation | equally weighted samples |
MCLMCBackend |
microcanonical Langevin Monte Carlo | equally weighted samples |
SMCBackend |
adaptive-tempered sequential Monte Carlo | samples and the evidence |
JaxnsBackend |
nested sampling | samples and the evidence for model comparison |
Documentation
The full documentation lives in
docs/ and builds with Sphinx
once the docs extra is installed:
sphinx-build -b html docs docs/_build/html
It covers the architecture and design principles, a mathematical treatment of the fit, the evidence, and the information gain, and worked examples for a visual walkthrough on an abstract problem and for orbit fitting. If the JAX and Bayesian vocabulary is unfamiliar, the glossary defines the terms the rest of the documentation relies on.
Status
Orbit fitting is implemented across radial-velocity, astrometry, and imaging data, and disk fitting rides the same engine. Atmospheric retrieval is in progress, and image-domain fitting against a coronagraph forward is the next major target. On the backend side, a stochastic variational backend with a normalizing-flow guide is planned.
License
photomancy is released under the MIT license, see LICENSE.
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file photomancy-0.1.0.tar.gz.
File metadata
- Download URL: photomancy-0.1.0.tar.gz
- Upload date:
- Size: 85.3 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via:
twine/6.1.0 CPython/3.13.14
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
26bcbcef9a488666a2903d0c4f4ef18a753fb0fc3381aa9b813ee6329edbc5cb
|
|
| MD5 |
ff7173b953d0ee2d40036f9ddfb90b5a
|
|
| BLAKE2b-256 |
6ce71708e4f608d72e861807ddec83aa7702a502ce2c495fc097e5dc345bb893
|
Provenance
The following attestation bundles were made for photomancy-0.1.0.tar.gz:
Publisher:
publish-to-pypi.yml on CoreySpohn/photomancy
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
photomancy-0.1.0.tar.gz -
Subject digest:
26bcbcef9a488666a2903d0c4f4ef18a753fb0fc3381aa9b813ee6329edbc5cb - Sigstore transparency entry: 2214198505
- Sigstore integration time:
-
Permalink:
CoreySpohn/photomancy@853ea7e33856bd29b1c86e0eef03f20306c8c714 -
Branch / Tag:
refs/tags/v0.1.0 - Owner: https://github.com/CoreySpohn
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish-to-pypi.yml@853ea7e33856bd29b1c86e0eef03f20306c8c714 -
Trigger Event:
push
-
Statement type:
File details
Details for the file photomancy-0.1.0-py3-none-any.whl.
File metadata
- Download URL: photomancy-0.1.0-py3-none-any.whl
- Upload date:
- Size: 99.5 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via:
twine/6.1.0 CPython/3.13.14
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
4effa1bd75db3d24fb24d9f833f00e19ea91746fb73c9766274457df8cfefe34
|
|
| MD5 |
6af95d771ca63cdea53799268fbe20fe
|
|
| BLAKE2b-256 |
ae15ebd830e97f495ca559d483b8e83eb9307aca873cdcf542fcc765ec390130
|
Provenance
The following attestation bundles were made for photomancy-0.1.0-py3-none-any.whl:
Publisher:
publish-to-pypi.yml on CoreySpohn/photomancy
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
photomancy-0.1.0-py3-none-any.whl -
Subject digest:
4effa1bd75db3d24fb24d9f833f00e19ea91746fb73c9766274457df8cfefe34 - Sigstore transparency entry: 2214198645
- Sigstore integration time:
-
Permalink:
CoreySpohn/photomancy@853ea7e33856bd29b1c86e0eef03f20306c8c714 -
Branch / Tag:
refs/tags/v0.1.0 - Owner: https://github.com/CoreySpohn
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish-to-pypi.yml@853ea7e33856bd29b1c86e0eef03f20306c8c714 -
Trigger Event:
push
-
Statement type: