Lightweight cosmological distance utilities for lensing forecasts.
Project description
CosmoDJ
CosmoDJ is a lightweight JAX package for cosmological distance calculations, written for strong-lensing cosmology forecasts and NumPyro workflows. The package currently provides angular-diameter distances, transverse and radial comoving distances, luminosity distances, and time-delay distances for CPL dark-energy cosmologies.
The default cosmology is Planck18Cosmology, implemented as a CosmoDJ parameter object. Runtime distance calculations are performed with JAX rather than Astropy. Astropy is used for physical constants and in tests as a reference implementation.
Installation
For local development:
cd /yourpath
pip install -e .
After PyPI release:
pip install CosmoDJ
Basic Usage
from cosmodj import angular_diameter_distance, angular_diameter_distances
Da = angular_diameter_distance(1.0) # Mpc, default Planck18Cosmology
Dl, Ds, Dls = angular_diameter_distances(0.5, 2.0) # Mpc
angular_diameter_distance accepts scalar or array-like redshifts:
import jax.numpy as jnp
from cosmodj import angular_diameter_distance
z = jnp.array([0.5, 1.0, 2.0])
Da = angular_diameter_distance(z)
Custom Cosmology
from cosmodj import Cosmology, angular_diameter_distance
cosmo = Cosmology(
Omegam=0.32,
Omegak=0.0,
w0=-1.0,
wa=0.0,
H0=70.0,
)
Da = angular_diameter_distance(1.0, cosmo)
Dictionary inputs are also supported:
from cosmodj import angular_diameter_distances
cosmo = {"Omegam": 0.32, "Omegak": 0.0, "w0": -1.0, "wa": 0.0, "h0": 70.0}
Dl, Ds, Dls = angular_diameter_distances(0.5, 2.0, cosmo)
NumPyro Example
import jax.numpy as jnp
import numpyro
import numpyro.distributions as dist
from cosmodj import Cosmology, angular_diameter_distance
def model():
Omegam = numpyro.sample("Omegam", dist.Uniform(0.2, 0.4))
H0 = numpyro.sample("H0", dist.Uniform(60.0, 80.0))
cosmo = Cosmology(Omegam=Omegam, Omegak=0.0, w0=-1.0, wa=0.0, H0=H0)
z = jnp.array([0.5, 1.0])
Da = angular_diameter_distance(z, cosmo)
numpyro.sample("Da_obs", dist.Normal(Da, 20.0), obs=jnp.array([1250.0, 1650.0]))
Citation
If you use this package in a publication, please cite:
@ARTICLE{2024MNRAS.527.5311L,
author = {{Li}, Tian and {Collett}, Thomas E. and {Krawczyk}, Coleman M. and {Enzi}, Wolfgang},
title = "{Cosmology from large populations of galaxy-galaxy strong gravitational lenses}",
journal = {\mnras},
keywords = {gravitational lensing: strong, galaxies: structure, cosmological parameters, dark energy, cosmology: observations, Astrophysics - Cosmology and Nongalactic Astrophysics},
year = 2024,
month = jan,
volume = {527},
number = {3},
pages = {5311-5323},
doi = {10.1093/mnras/stad3514},
archivePrefix = {arXiv},
eprint = {2307.09271},
primaryClass = {astro-ph.CO},
adsurl = {https://ui.adsabs.harvard.edu/abs/2024MNRAS.527.5311L},
adsnote = {Provided by the SAO/NASA Astrophysics Data System}
}
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 cosmodj-0.0.1.tar.gz.
File metadata
- Download URL: cosmodj-0.0.1.tar.gz
- Upload date:
- Size: 6.6 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.11.14
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
d55d8b120f4c82d2e78ca7ca4283852987b507a447760f1d164bfdbecdd66bde
|
|
| MD5 |
6122dc46f926de20f09ad5be166bfea8
|
|
| BLAKE2b-256 |
e45c29479d19c41438fbf3b9465688a6214ee0be70a9851f7eb5bf8b12d107ae
|
File details
Details for the file cosmodj-0.0.1-py3-none-any.whl.
File metadata
- Download URL: cosmodj-0.0.1-py3-none-any.whl
- Upload date:
- Size: 6.1 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.11.14
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
824d0a6fb152a0a4f2c1da54be1f9f46587f2f6b3b8443c1f77b81aff777b757
|
|
| MD5 |
61b5ab0095522deb38862d3eb1f41b4e
|
|
| BLAKE2b-256 |
d3ae0e9d1023eabeffd1eadf2777e0cfc7edfd66ed9e9c566a57d5e2e6a32dee
|