Calculate Microlensing Observables
Project description
LensCalcPy
Install
pip install LensCalcPy
How to use
This package is primarily used to calculate the expected rate of microlensing events for a given population of lenses. At its core, the package is designed to compute integrals of the form:
$\frac{d\Gamma}{dM,dd_L,d\hat{t},du_\text{min}} = \frac{2}{\sqrt{u_T^2 - u_{\rm{min}}^2}} \frac{v_T^4}{v_c^2} \exp \Big[ -\frac{v_T^2}{v_c^2}\Big] n(d_L) f(M) \varepsilon(\hat{t}),$
which is the differential rate for a given line of sight over $d_L$, mass function $f(M)$, event duration $\hat{t}$, and minimum impact parameter $u_\text{min}$. In practice, the user can define the parameters of their survey (Line of sight, cadence, observation duration) and compute observables such as the distribution of crossing times $t_E$, total expected events, etc.
The full documentation can be found here. The source code, located in nbs, is intended to be easily interacrtable and modularizable, so adding functionality is straightforward. For real-world examples, see the notebooks in the examples folder. Below are some minimal examples for PBH (Primordial Black Hole) lenses and UBO (Unbound Objects) lenses. Here, the line of sight is towards M31, the Andromeda galaxy.
We can calculate the distribution of crossing times for a given PBH population
f_pbh = 1 # fraction of dark matter in PBHs
ts = np.logspace(-2, 1, 20)
pbhs = [Pbh(10**(i), f_pbh, l=l, b=b) for i in np.linspace(-9, -7, 3)]
result = np.zeros((len(pbhs), len(ts)))
for i, pbh in enumerate(pbhs):
result[i, :] = pbh.compute_differential_rate(ts)
for i, pbh in enumerate(pbhs):
plt.loglog(ts, result[i], label=r"$M_{\rm{PBH}} = $" + scientific_format(pbh.mass,0) + "$M_{\odot}$")
plt.xlabel(r"$t_E$ [h]", fontsize=16)
plt.ylabel(r"$d\Gamma/dt$ [events/star/hr/hr]", fontsize=16)
plt.xlim(1e-2, 1e1)
plt.ylim(1e-10, 1e-4)
plt.legend()
plt.show()
Similarly, we can calculate the distribution of crossing times for an FFP population with mass function $\frac{dM}{d \log(M)} \propto M^{-p}$
p = 1
fp = Ffp(p, l=l, b=b)
def differential_rate_mw_mass(m, tcad = 0.07, tobs= 3, finite=True):
return fp.differential_rate_mw_mass(m, tcad=tcad, tobs=tobs, finite=finite)
m_arr = np.logspace(-15, -3, 20)
with Pool() as pool:
func = functools.partial(differential_rate_mw_mass, tcad=0.07, tobs=3, finite=True)
diff_rates = np.array(list(tqdm(pool.imap(func, m_arr), total=len(m_arr))))
100%|██████████| 20/20 [00:08<00:00, 2.29it/s]
plt.loglog(m_arr/3e-6, diff_rates, label=r'Finite Source, $t_{\rm{cad}} = 4.2 ~\rm{min}$', color='k')
plt.ylim(1e-24, 1e-9)
plt.xlim(np.min(m_arr)/3e-6, 1e1)
plt.xlabel("Mass [$M_{\oplus}$]")
plt.ylabel(r"$d\Gamma/dM$ [events/star/hr/mass]")
plt.title('MW lens, M31 source')
plt.legend()
plt.show()
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
Built Distribution
File details
Details for the file LensCalcPy-0.0.4.tar.gz
.
File metadata
- Download URL: LensCalcPy-0.0.4.tar.gz
- Upload date:
- Size: 235.4 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.1 CPython/3.9.7
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | b6738f4af3d4bffa4426f8180592e0ec9608a22ac539a692a0446813f7ebed5d |
|
MD5 | 0589ba399d3e143cc9ff328485fceac3 |
|
BLAKE2b-256 | f053bccc84e8ef1b15d7df50af87fa6e87fa6960f152f86a9e12757cc418ac6d |
File details
Details for the file LensCalcPy-0.0.4-py3-none-any.whl
.
File metadata
- Download URL: LensCalcPy-0.0.4-py3-none-any.whl
- Upload date:
- Size: 249.8 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.1 CPython/3.9.7
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 9b97959a757c8c9d6f2cc7151f881b2500e727758de5986127b78dc6bf042c01 |
|
MD5 | 1a8632def94d68555eaa613e3a118fec |
|
BLAKE2b-256 | 70adcb9fbdc39b10dd683e7306bc233238859cb2bba168193b610ae5fbe408dc |