Skip to main content

Microlensing event simulation with a refactored C++ core and Python API

Project description

License: GPL v3 DOI arXiv

genulens

genulens ("generate microlensing") simulates microlensing events with the Galactic model of Koshimoto, Baba & Bennett (2021), ApJ, 917, 78. The model is optimized for bulge sightlines and is most appropriate around |l| < 10 deg and |b| < 7 deg.

The v2 branch keeps the historical command-line simulator and adds a refactored C++ core, direct Python bindings, source-forward isochrone workflows, genstars-style extinction-map support, custom Python likelihoods, and optical-depth/event-rate summary APIs.

For the full guide, start from docs/. GitHub displays docs/README.md automatically when opening that directory.

Installation

Released Linux x86_64 and macOS arm64 wheels can be installed with:

pip install genulens

The wheels include the compiled extension, command-line executable, bundled input tables, and the GSL shared libraries needed by the extension. macOS x86_64 may fall back to a source build and therefore requires a system GSL installation.

Source builds, including pip install --no-binary genulens genulens and pip install git+https://github.com/nkoshimoto/genulens.git, require a system GSL installation.

To build from a source checkout, genulens requires a C++ compiler, CMake, and GSL.

Check that GSL is visible:

gsl-config --libs

Clone and build:

git clone https://github.com/nkoshimoto/genulens.git
cd genulens
make

If GSL is installed in a non-standard prefix:

GSL_ROOT=/path/to/gsl make

The same GSL shared libraries must be visible at runtime. On Linux with a non-standard GSL prefix, set for example:

export LD_LIBRARY_PATH=/path/to/gsl/lib:$LD_LIBRARY_PATH

Build the Python extension:

make python
PYTHONPATH=build python -c "import genulens; print(genulens.__file__)"

The Python extension can also be built from source with:

pip install .

For a non-standard GSL prefix, pass GSL_ROOT to pip:

GSL_ROOT=/path/to/gsl pip install .

For source installs from a non-standard GSL prefix, the built extension records the linked GSL path in its install RPATH. If your platform strips or ignores that RPATH, set LD_LIBRARY_PATH or the platform equivalent at runtime.

Editable installs are supported in environments with scikit-build-core and pybind11:

pip install -e .

Other build targets:

make pre_gapmoe
make test
make clean

CLI and Python

The historical CLI remains available:

./genulens

The Python API calls the same C++ simulation core directly. It does not run ./genulens as a subprocess and does not parse CLI stdout.

import pandas as pd
import genulens

cfg = genulens.Config(l=1.0, b=-3.9, n_simu=20_000, seed=42)
result = genulens.simulate(cfg)
df = pd.DataFrame(result.to_numpy(), columns=result.columns)

See docs/quickstart.md and docs/python_api.md for details.

Documentation

Notebook examples:

The original command-line usage guide remains available as Usage.pdf.

Citation

Please cite Koshimoto, Baba & Bennett (2021) and Koshimoto & Ranc (2021), Zenodo.4784948 if you use this code in your research.

A separate star simulator, genstars, is also available.

The copyright of the included supplementary code option.cpp belongs to Ian A. Bond and Takahiro Sumi.

Release History

  • v2: refactored C++ core, direct Python API, source-forward isochrone support, extinction-map support, custom Python likelihoods, and rate-summary APIs.
  • v1.2, June-July 2022: importance sampling, NSD component, updated Galactic Center position, revised usage documentation, and related genstars release.
  • v1.1, June 2021: switched to the GSL random number generator.
  • v1.0, May 2021: initial public release.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

genulens-2.0.0a2.tar.gz (75.9 MB view details)

Uploaded Source

Built Distributions

If you're not sure about the file name format, learn more about wheel file names.

genulens-2.0.0a2-cp313-cp313-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl (80.0 MB view details)

Uploaded CPython 3.13manylinux: glibc 2.27+ x86-64manylinux: glibc 2.28+ x86-64

genulens-2.0.0a2-cp313-cp313-macosx_14_0_arm64.whl (75.6 MB view details)

Uploaded CPython 3.13macOS 14.0+ ARM64

genulens-2.0.0a2-cp312-cp312-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl (80.0 MB view details)

Uploaded CPython 3.12manylinux: glibc 2.27+ x86-64manylinux: glibc 2.28+ x86-64

genulens-2.0.0a2-cp312-cp312-macosx_14_0_arm64.whl (75.6 MB view details)

Uploaded CPython 3.12macOS 14.0+ ARM64

genulens-2.0.0a2-cp311-cp311-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl (80.0 MB view details)

Uploaded CPython 3.11manylinux: glibc 2.27+ x86-64manylinux: glibc 2.28+ x86-64

genulens-2.0.0a2-cp311-cp311-macosx_14_0_arm64.whl (75.6 MB view details)

Uploaded CPython 3.11macOS 14.0+ ARM64

genulens-2.0.0a2-cp310-cp310-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl (80.0 MB view details)

Uploaded CPython 3.10manylinux: glibc 2.27+ x86-64manylinux: glibc 2.28+ x86-64

genulens-2.0.0a2-cp310-cp310-macosx_14_0_arm64.whl (75.6 MB view details)

Uploaded CPython 3.10macOS 14.0+ ARM64

genulens-2.0.0a2-cp39-cp39-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl (80.0 MB view details)

Uploaded CPython 3.9manylinux: glibc 2.27+ x86-64manylinux: glibc 2.28+ x86-64

genulens-2.0.0a2-cp39-cp39-macosx_14_0_arm64.whl (75.6 MB view details)

Uploaded CPython 3.9macOS 14.0+ ARM64

File details

Details for the file genulens-2.0.0a2.tar.gz.

File metadata

  • Download URL: genulens-2.0.0a2.tar.gz
  • Upload date:
  • Size: 75.9 MB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for genulens-2.0.0a2.tar.gz
Algorithm Hash digest
SHA256 ef5226291f3187b6c1d2c8c65961c5048a8a51b6276bbd2495575ee809a41f29
MD5 ec12d4cc287d65f0639d8c3105ec823d
BLAKE2b-256 061939254a8980758bdb8763901673b6e037bcc0907086bf91413d5475879c73

See more details on using hashes here.

Provenance

The following attestation bundles were made for genulens-2.0.0a2.tar.gz:

Publisher: wheels.yml on nkoshimoto/genulens

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file genulens-2.0.0a2-cp313-cp313-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl.

File metadata

File hashes

Hashes for genulens-2.0.0a2-cp313-cp313-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 ac210a32f9b607e988d797dc0ff6d67377bbcdacf60fb49e94ac7b29e7b26ee6
MD5 6f8b93c48852aa6896cf81e30d1ddd11
BLAKE2b-256 573c6a577bb148c405f1eecae0b209f8ba6fe1e5efa93db3638ec95bf55433fa

See more details on using hashes here.

Provenance

The following attestation bundles were made for genulens-2.0.0a2-cp313-cp313-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl:

Publisher: wheels.yml on nkoshimoto/genulens

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file genulens-2.0.0a2-cp313-cp313-macosx_14_0_arm64.whl.

File metadata

File hashes

Hashes for genulens-2.0.0a2-cp313-cp313-macosx_14_0_arm64.whl
Algorithm Hash digest
SHA256 6a2d6e76f148b9ed701b2438c0bd7eb923e66fb5c90e643e7d83b8c373be7cb8
MD5 923634a8bc8491a67d5cd417253bdaac
BLAKE2b-256 573784a416c470eac50e9dad651677da4ed9b2c3c1d437dcca31bf8596f9add2

See more details on using hashes here.

Provenance

The following attestation bundles were made for genulens-2.0.0a2-cp313-cp313-macosx_14_0_arm64.whl:

Publisher: wheels.yml on nkoshimoto/genulens

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file genulens-2.0.0a2-cp312-cp312-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl.

File metadata

File hashes

Hashes for genulens-2.0.0a2-cp312-cp312-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 2fe7fb651555552a379deb8cfa5f4eb5fd50b017c177eee30b5cb27b0a3acc94
MD5 a67cd22600aee85a584cb7df022cd4a2
BLAKE2b-256 8f29dea8f299a1b381cf02b8ae8cccad5baaabae60d53300ecebadf93d349f73

See more details on using hashes here.

Provenance

The following attestation bundles were made for genulens-2.0.0a2-cp312-cp312-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl:

Publisher: wheels.yml on nkoshimoto/genulens

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file genulens-2.0.0a2-cp312-cp312-macosx_14_0_arm64.whl.

File metadata

File hashes

Hashes for genulens-2.0.0a2-cp312-cp312-macosx_14_0_arm64.whl
Algorithm Hash digest
SHA256 d2e663e0f52c42d3e6f917a94e1fb19d0d00abf8facc0abb69154f0d95f44ba6
MD5 2064a57c425bd0c1277a3305eeef3cfb
BLAKE2b-256 34e06986ddb2e3928fe37b0201264e107943fd533ddbb15910028cfda78f1002

See more details on using hashes here.

Provenance

The following attestation bundles were made for genulens-2.0.0a2-cp312-cp312-macosx_14_0_arm64.whl:

Publisher: wheels.yml on nkoshimoto/genulens

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file genulens-2.0.0a2-cp311-cp311-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl.

File metadata

File hashes

Hashes for genulens-2.0.0a2-cp311-cp311-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 1ea2c38e6f785a6dd4e3ebc6d571a1e82ad0dcd48b307d0bb696127f11d3fc4d
MD5 19f4be4068fe73f8095dc4ff591c83c6
BLAKE2b-256 807bdf379d7c4368b4f7665ce008aa309b1da9ca48ebc8938fba8f7ecf5f6d55

See more details on using hashes here.

Provenance

The following attestation bundles were made for genulens-2.0.0a2-cp311-cp311-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl:

Publisher: wheels.yml on nkoshimoto/genulens

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file genulens-2.0.0a2-cp311-cp311-macosx_14_0_arm64.whl.

File metadata

File hashes

Hashes for genulens-2.0.0a2-cp311-cp311-macosx_14_0_arm64.whl
Algorithm Hash digest
SHA256 00e59d3b21f097d9d246a4db7fb7d3b29744e58655bc52fbee36e2c711f66879
MD5 b1017715b2efe03b26b0e133db0a94c3
BLAKE2b-256 d17bb0c30f5f36487dee884cf46b213973dc5b2867b44dd9d7323bfe17ca0943

See more details on using hashes here.

Provenance

The following attestation bundles were made for genulens-2.0.0a2-cp311-cp311-macosx_14_0_arm64.whl:

Publisher: wheels.yml on nkoshimoto/genulens

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file genulens-2.0.0a2-cp310-cp310-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl.

File metadata

File hashes

Hashes for genulens-2.0.0a2-cp310-cp310-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 b6074614cf4b6ff44d139037857de29328e6917485843edb3a647a622109646e
MD5 27b9a65c0c11bdbc9aecc734788a3d36
BLAKE2b-256 e6bc599df55f3d3fc736e53720c2934a0ab82391b4110399ed2af64ec1de9c17

See more details on using hashes here.

Provenance

The following attestation bundles were made for genulens-2.0.0a2-cp310-cp310-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl:

Publisher: wheels.yml on nkoshimoto/genulens

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file genulens-2.0.0a2-cp310-cp310-macosx_14_0_arm64.whl.

File metadata

File hashes

Hashes for genulens-2.0.0a2-cp310-cp310-macosx_14_0_arm64.whl
Algorithm Hash digest
SHA256 121faf230d76e8cdb354087ed113a15e49e35d80add46a0d4cedb63ae0a14d80
MD5 349b53229b9ecfb30f914e51e4a0860e
BLAKE2b-256 14a0b8c4381b02b36b409c328cd019e93bfdceb1f52a564fe54888aa28276872

See more details on using hashes here.

Provenance

The following attestation bundles were made for genulens-2.0.0a2-cp310-cp310-macosx_14_0_arm64.whl:

Publisher: wheels.yml on nkoshimoto/genulens

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file genulens-2.0.0a2-cp39-cp39-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl.

File metadata

File hashes

Hashes for genulens-2.0.0a2-cp39-cp39-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 eda37ad3b01ed17b4e06d3590e0a872395521be61c8ba3c3da74701ece3b5d89
MD5 a65f0f5926a75d250b5088ddd35f3de8
BLAKE2b-256 b6bee7c2a53a877d19bc69ba45bb2585cdc7c7cb3a540e1d3ca5d609f23821b7

See more details on using hashes here.

Provenance

The following attestation bundles were made for genulens-2.0.0a2-cp39-cp39-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl:

Publisher: wheels.yml on nkoshimoto/genulens

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file genulens-2.0.0a2-cp39-cp39-macosx_14_0_arm64.whl.

File metadata

File hashes

Hashes for genulens-2.0.0a2-cp39-cp39-macosx_14_0_arm64.whl
Algorithm Hash digest
SHA256 34c37a9312cff2388fb4b1e4622a4bef1d2778d67d538d2c87c4ff7e90a9013a
MD5 3d96f5018f3cb1263ac91acfd59eef99
BLAKE2b-256 b18f6c222ee447af1a69f8b96aaff04ecb2dbef5d29de21cc74bce3f75cbec28

See more details on using hashes here.

Provenance

The following attestation bundles were made for genulens-2.0.0a2-cp39-cp39-macosx_14_0_arm64.whl:

Publisher: wheels.yml on nkoshimoto/genulens

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page