Galactic prior tools for microlensing event modeling
Project description
gapmoe
gapmoe provides Galactic prior tools for microlensing event modeling. The
current public API builds event-local histogram products with the genulens
pre_gapmoe Python API, loads those products in Python, and evaluates Galactic
density/prior terms for physical microlensing parameters.
The canonical public parameter order is:
ML, DL, DS, mu_N, mu_E
where ML is in solar masses, DL and DS are in kpc, and proper motions are
in mas/yr.
Install
From PyPI:
pip install gapmoe
For local development:
pip install -e ".[dev]"
For the core NumPy backend only:
pip install -e .
Optional extras:
.[jax]: JAX histogram/prior backend..[examples]: notebook plotting/sampling dependencies..[dev]: JAX, examples, and pytest.
genulens Dependency
gapmoe depends on genulens>=2.0.0a3. A normal pip install gapmoe installs
genulens, including the bundled pre_gapmoe helper executables used by
genulens.pre_gapmoe.
Check what backend PreRunner will use:
from gapmoe import PreRunner
runner = PreRunner()
env = runner.check_environment()
print(runner.backend)
print(env.ok)
print(env.backend)
By default, PreRunner(backend="auto") uses the installed genulens.pre_gapmoe
Python API. For development against a source checkout, pass backend="cli" or
genulens_root=... to run the local CLI helpers instead:
git clone https://github.com/nkoshimoto/genulens.git ../genulens
make -C ../genulens/pre_gapmoe
runner = PreRunner(genulens_root="../genulens")
The CLI backend resolves a checkout from genulens_root=...,
GAPMOE_GENULENS_ROOT, GENULENS_ROOT, or nearby default candidates. It can
also try make automatically with PreRunner(..., auto_build=True).
Minimal Usage
from gapmoe import GalacticPrior, HistogramDensity, PreRunner
runner = PreRunner(
output_dir="example/pre_runner_outputs",
)
pre_run = runner.run(
ra_deg=270.0,
dec_deg=-30.0,
run_name="demo",
)
density = HistogramDensity.from_pre_run(pre_run)
prior = GalacticPrior(density)
logp = prior.log_prob(
0.3, # ML [Msun]
5.0, # DL [kpc]
8.0, # DS [kpc]
5.0, # mu_N [mas/yr]
2.0, # mu_E [mas/yr]
)
If histogram files already exist:
density = HistogramDensity.from_paths("mass.dat", "rho.dat", "murel.dat")
prior = GalacticPrior(density)
JAX Backend
The JAX backend mirrors the NumPy histogram semantics:
from gapmoe import HistogramDensity, JaxGalacticPrior, JaxHistogramDensity
np_density = HistogramDensity.from_paths("mass.dat", "rho.dat", "murel.dat")
jax_density = JaxHistogramDensity.from_numpy(np_density)
jax_prior = JaxGalacticPrior(jax_density)
The JAX backend is currently intended for batched evaluation workflows such as
jax.vmap. Histogram lookup is piecewise and uses nearest (DS, DL) murel
blocks, so differentiability has not been validated. A future normalizing-flow
backend is the better target for smooth gradients.
Source Selection
Normal gapmoe usage assumes rho.dat was generated with genulens source
selection enabled. PreRunner passes SOURCE=1 to calc_rho_profile by
default. HistogramDensity.from_paths(...) requires source-density columns by
default and uses rhoD_S_tot for the source-distance factor.
Examples
Current notebooks:
example/pre_runner.ipynb: generate event-local histogram files.example/emcee_physical_params.ipynb: sample the physical-parameter Galactic prior withemceeand compare with raw genulens Monte Carlo output in the final corner plot.
Generated pre-run files under example/pre_runner_outputs/ are intentionally
ignored by git.
Tests
pytest -q
The test suite uses a small committed histogram fixture under
tests/fixtures/small_source_default/ and mocks the genulens.pre_gapmoe
integration path.
Legacy Modules
gapmoe.gapmoe, gapmoeJax.py, and older parameter-conversion modules remain
for compatibility while the public API stabilizes. New code should prefer:
PreRunnerHistogramDensity/JaxHistogramDensityGalacticPrior/JaxGalacticPriorgapmoe.parameterizations
Project details
Release history Release notifications | RSS feed
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 gapmoe-0.1.0.tar.gz.
File metadata
- Download URL: gapmoe-0.1.0.tar.gz
- Upload date:
- Size: 31.3 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
a29cc1a2ca250784baa3e489fecc1ef46a892167eb3b8a116cd5bb7c7f9f57d6
|
|
| MD5 |
ae70a25593301f956612da14358864d1
|
|
| BLAKE2b-256 |
71d7fab340c17cf4afad4f0bcb43bbd2d7feea247f122c22c4e16e9d8e73cc11
|
Provenance
The following attestation bundles were made for gapmoe-0.1.0.tar.gz:
Publisher:
publish.yml on NunotaKansuke/gapmoe
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
gapmoe-0.1.0.tar.gz -
Subject digest:
a29cc1a2ca250784baa3e489fecc1ef46a892167eb3b8a116cd5bb7c7f9f57d6 - Sigstore transparency entry: 2064760094
- Sigstore integration time:
-
Permalink:
NunotaKansuke/gapmoe@8b7f94628fad1fabfba0ca5c2e03086ba1a3d67b -
Branch / Tag:
refs/tags/v0.1.0 - Owner: https://github.com/NunotaKansuke
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@8b7f94628fad1fabfba0ca5c2e03086ba1a3d67b -
Trigger Event:
release
-
Statement type:
File details
Details for the file gapmoe-0.1.0-py3-none-any.whl.
File metadata
- Download URL: gapmoe-0.1.0-py3-none-any.whl
- Upload date:
- Size: 33.9 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
be14b0e4ae78990ccc08305f1340637d3f2745adcecf80a29db95d0120e72cb2
|
|
| MD5 |
90b166924944b52b60129bec5bdc099a
|
|
| BLAKE2b-256 |
e916b5f272a5d1fd92757433af22e12632a4efc5cf54737df81a35f055bdb844
|
Provenance
The following attestation bundles were made for gapmoe-0.1.0-py3-none-any.whl:
Publisher:
publish.yml on NunotaKansuke/gapmoe
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
gapmoe-0.1.0-py3-none-any.whl -
Subject digest:
be14b0e4ae78990ccc08305f1340637d3f2745adcecf80a29db95d0120e72cb2 - Sigstore transparency entry: 2064760098
- Sigstore integration time:
-
Permalink:
NunotaKansuke/gapmoe@8b7f94628fad1fabfba0ca5c2e03086ba1a3d67b -
Branch / Tag:
refs/tags/v0.1.0 - Owner: https://github.com/NunotaKansuke
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@8b7f94628fad1fabfba0ca5c2e03086ba1a3d67b -
Trigger Event:
release
-
Statement type: