Skip to main content

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

Project description

License: GPL v3 DOI arXiv PyPI

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 alpha release 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.

Install From PyPI

The Python package is available on PyPI:

pip install genulens

Binary wheels are currently published for Linux x86_64 and macOS arm64. These wheels include the compiled extension, the genulens command-line executable, bundled input tables, and the GSL shared libraries needed by the extension.

Other platforms, including macOS x86_64 and Windows, may fall back to a source build. Source builds require a system GSL installation.

Build From Source

Source builds include:

pip install --no-binary genulens genulens
pip install git+https://github.com/nkoshimoto/genulens.git

To build from a 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 the checkout 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 installed command-line simulator remains available as:

genulens

From a source-tree build, use ./genulens or build/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.

The pre_gapmoe histogram helpers are also available from Python when installed from a wheel or source build:

import genulens

rho = genulens.pre_gapmoe.rho_profile(l=1.0, b=-3.9, SOURCE=1)
rho_array = rho.to_numpy()

See docs/pre_gapmoe.md for the helper API and CLI options.

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.0.0 alpha 3: Python API for bundled pre_gapmoe helper tables.
  • v2.0.0 alpha: PyPI package, 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.0a3.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.0a3-cp313-cp313-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl (80.8 MB view details)

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

genulens-2.0.0a3-cp313-cp313-macosx_14_0_arm64.whl (75.9 MB view details)

Uploaded CPython 3.13macOS 14.0+ ARM64

genulens-2.0.0a3-cp312-cp312-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl (80.8 MB view details)

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

genulens-2.0.0a3-cp312-cp312-macosx_14_0_arm64.whl (75.9 MB view details)

Uploaded CPython 3.12macOS 14.0+ ARM64

genulens-2.0.0a3-cp311-cp311-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl (80.8 MB view details)

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

genulens-2.0.0a3-cp311-cp311-macosx_14_0_arm64.whl (75.9 MB view details)

Uploaded CPython 3.11macOS 14.0+ ARM64

genulens-2.0.0a3-cp310-cp310-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl (80.8 MB view details)

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

genulens-2.0.0a3-cp310-cp310-macosx_14_0_arm64.whl (75.9 MB view details)

Uploaded CPython 3.10macOS 14.0+ ARM64

genulens-2.0.0a3-cp39-cp39-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl (80.8 MB view details)

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

genulens-2.0.0a3-cp39-cp39-macosx_14_0_arm64.whl (75.9 MB view details)

Uploaded CPython 3.9macOS 14.0+ ARM64

File details

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

File metadata

  • Download URL: genulens-2.0.0a3.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.0a3.tar.gz
Algorithm Hash digest
SHA256 6bb31196cb7989d4c17660ee01f33f40ef86afe6fe4489d28d891cb121857294
MD5 4347f39f56a9f3e3c2d9b233518b09ee
BLAKE2b-256 38971a56ef3f1d0b96fb6f602ce32dc1b2df2ee4c8bedec05f936f959e0c6f3d

See more details on using hashes here.

Provenance

The following attestation bundles were made for genulens-2.0.0a3.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.0a3-cp313-cp313-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl.

File metadata

File hashes

Hashes for genulens-2.0.0a3-cp313-cp313-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 c877bbae0d17bf23080eb71b7238a0579c17907926253f4bae0e4fcfe34a5178
MD5 c808c3cc30d1757af84511cdccc5d2ac
BLAKE2b-256 f1d986cf743019dffe5329f75893d72f4e12ae4a67f13f1a368d0e53f0d7a535

See more details on using hashes here.

Provenance

The following attestation bundles were made for genulens-2.0.0a3-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.0a3-cp313-cp313-macosx_14_0_arm64.whl.

File metadata

File hashes

Hashes for genulens-2.0.0a3-cp313-cp313-macosx_14_0_arm64.whl
Algorithm Hash digest
SHA256 e96eb9bead7081b7fd7002dbb41b8eeb7b1410a29f25cac5a547d1aab1373580
MD5 263aeecd10d694dd66f84e76ae5ecee2
BLAKE2b-256 6aedf8cdd0a4caf6d420ed4bbd7ef4176aa6e844d7268085ceb8eb387770fa17

See more details on using hashes here.

Provenance

The following attestation bundles were made for genulens-2.0.0a3-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.0a3-cp312-cp312-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl.

File metadata

File hashes

Hashes for genulens-2.0.0a3-cp312-cp312-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 3a20478c01ed1d3ac14b9155c8183f6cf4be094e56286cbe42d862d61aab0a6b
MD5 e3201070b03925859f19f41ace9359cf
BLAKE2b-256 8d6206d717cd963b658a47e05fd9dbe89e7824dbf5a3891b75230e68dd5c8cbb

See more details on using hashes here.

Provenance

The following attestation bundles were made for genulens-2.0.0a3-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.0a3-cp312-cp312-macosx_14_0_arm64.whl.

File metadata

File hashes

Hashes for genulens-2.0.0a3-cp312-cp312-macosx_14_0_arm64.whl
Algorithm Hash digest
SHA256 3f9f723326a4d8592fbf44c3235996ae78373f26b4c849bc44eaf96df43dd45a
MD5 63739bed9a4ef7ee30b8724bc457ae42
BLAKE2b-256 1886f7da3c610f1b20cf773545915e9e05da6dc73cd29535dbe55118dd22a3df

See more details on using hashes here.

Provenance

The following attestation bundles were made for genulens-2.0.0a3-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.0a3-cp311-cp311-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl.

File metadata

File hashes

Hashes for genulens-2.0.0a3-cp311-cp311-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 5cc1d27d3d3483b521d5af673f3f7b41468334b54cae6cc9b3955eb442fec377
MD5 42c4cb81ad12249fc88b56031eb850ac
BLAKE2b-256 1f1f48e82d57a8cf0443fd338171602bcd1aff519a37daa1c4db0d3d6c94f6c4

See more details on using hashes here.

Provenance

The following attestation bundles were made for genulens-2.0.0a3-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.0a3-cp311-cp311-macosx_14_0_arm64.whl.

File metadata

File hashes

Hashes for genulens-2.0.0a3-cp311-cp311-macosx_14_0_arm64.whl
Algorithm Hash digest
SHA256 23724978107af16e79868b3b9fdd2044b42c6141383874af6ec4fc4f618caa6f
MD5 b811a4ca68bf0c13c8c142b6d0dbda38
BLAKE2b-256 bd51c35e08f109ae87e66a946e1cf9766f2e258a596655d161f77d26b52bf7de

See more details on using hashes here.

Provenance

The following attestation bundles were made for genulens-2.0.0a3-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.0a3-cp310-cp310-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl.

File metadata

File hashes

Hashes for genulens-2.0.0a3-cp310-cp310-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 def835af333e05e2e7f662790291c90899b059b8b58019e75d6b587a83ecb44d
MD5 78c6b0038e02c6857c3abbc7755e116d
BLAKE2b-256 d4e6dabda193e5a08107578017511d56ed179d419e27608a0b4fe444f297cf9f

See more details on using hashes here.

Provenance

The following attestation bundles were made for genulens-2.0.0a3-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.0a3-cp310-cp310-macosx_14_0_arm64.whl.

File metadata

File hashes

Hashes for genulens-2.0.0a3-cp310-cp310-macosx_14_0_arm64.whl
Algorithm Hash digest
SHA256 1cbbeff56d2570fa40954dfe58e307ef65bca6f1c71b53ef607b8ec3fe9531c1
MD5 e5f23cdf5be17979ade99833ca4c22a1
BLAKE2b-256 9b81900ef915cc811bfe7175ad1851efcadbcccccab4e5e56b3c7b66a9fc8d87

See more details on using hashes here.

Provenance

The following attestation bundles were made for genulens-2.0.0a3-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.0a3-cp39-cp39-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl.

File metadata

File hashes

Hashes for genulens-2.0.0a3-cp39-cp39-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 94ee2991d27311def2d52dd0fc59346c524ded22a6666024663003b0c385bac4
MD5 dfb84b107e6549f4aaf0d49f531e5cd3
BLAKE2b-256 47d105f3f9bb06042e11aee2c785bd63558637ab8a00862eb6a9ab1a7c098a73

See more details on using hashes here.

Provenance

The following attestation bundles were made for genulens-2.0.0a3-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.0a3-cp39-cp39-macosx_14_0_arm64.whl.

File metadata

File hashes

Hashes for genulens-2.0.0a3-cp39-cp39-macosx_14_0_arm64.whl
Algorithm Hash digest
SHA256 857929bf30c466b29df6b7b2b0c2ea05b6a57ce70c4e3e3311f80127a9950bbd
MD5 6b46385b7ae7c8e391beb1e5d846f8c1
BLAKE2b-256 81de2644fd45b7068e0d202e162306617829ff120fc342a1a210d4898d307eb2

See more details on using hashes here.

Provenance

The following attestation bundles were made for genulens-2.0.0a3-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