Skip to main content

HUGH MCDOUGALL 2024



LITMUS

Lag Inference Through the Mixed Use of Samplers

LITMUS is an in-progress program that uses modern statistical techniques, like nested sampling and stochastic variational inference, in combination with cutting edge programming tools like the just-in-time compilation framework jax and its bayesian modelling package NumPyro, to perform the messy task of lag recovery in AGN reverberation mapping.

LITMUS

If you have any questions, contact the author directly at hughmcdougallemail@gmail.com.


Installation

Simple Installation

First make sure you have a recent version of python running (3.10-3.12) and then install directly from the git repo:

pip install "git+https://github.com/HughMcDougall/litmus"

Explicit Installation

If you find the above doesn't work, try first installing the dependencies one by one, starting with the commonplace python packages:

pip install numpy matplotlib scikit-learn

Then the JAX ecosystem and numpyro utilities:

pip install jax jaxlib jaxopt
pip install numpyro tinygp

For plotting utilties we need chainconsumer, which needs a newer version of scipy, which in turn requires a newish version of python.

Requires Using python 3.11-3.12:

pip install scipy
pip install chainconsumer

Nested Sampling
If you want to make use of jaxns nested sampling, you'll need to install it with:

pip install etils tensorflow_probability
pip install jaxns

Note: You have bump into some trouble installing tensorflow_probability if you don't have cmake installed.


Usage

First Timers

import numpy as np
import matplotlib.pyplot as plt

import litmus
mymock = litmus.mocks.mock(3)
lc_1, lc_2 = mymock.lc_1, mymock.lc_2
mymock.plot()

Now, choose a model and set its priors(at time of writing only GP_simple, which models both lightcurves as scaled and shifted damped random walks, is implemented). For example suppose we know want to narrow our lag search range to [0,100] days, and know that the lightcurves are normalized to have zero mean:

my_model = litmus.models.GP_simple()
my_model.set_priors(
    {
    'lag': [0,100]
    'mean': [0,0]
    'rel_mean': [0,0]
    }
)

Now we choose a fitting method and tune it accordingly.

fitting_method = litmus.fitting_methods.hessian_scan(stat_model=my_model,
                                                  Nlags=32,
                                                  init_samples=5_000,
                                                  grid_bunching=0.8,
                                                  optimizer_args={'tol': 1E-3,
                                                                  'maxiter': 256,
                                                                  'increase_factor': 1.1,
                                                                  },
                                                  optimizer_args_init={'tol': 1E-4,
                                                                  'maxiter': 1024,
                                                                  'increase_factor': 1.01,
                                                                  },
                                                  reverse=False,
                                                  debug=False
                                                  )

Finally, wrap this in a LITMUS object, adding the lightcurves to it, which makes running and getting results out as simple as a single line of code:

litmus_handler = litmus.LITMUS(fitting_method)

litmus_handler.add_lightcurve(lc_1)
litmus_handler.add_lightcurve(lc_2)

Now, fire off the fitting procedure:

litmus_handler.fit()

And finally plot the model parameters to see how we did:

litmus_handler.lag_plot()
litmus_handler.plot_parameters()
litmus_handler.plot_diagnostics()


Metadata

Release files for litmus-rm 0.9.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for litmus-rm 0.9.0
File Size Uploaded Provenance Actions
litmus_rm-0.9.0.tar.gz 52.3 kB Without provenance Details for litmus_rm-0.9.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for litmus-rm 0.9.0
File Interpreter ABI Platform Actions
litmus_rm-0.9.0-py3-none-any.whl Python 3 none any Details for litmus_rm-0.9.0-py3-none-any.whl

Total release size: 109.7 kB

Release files / litmus_rm-0.9.0.tar.gz

Download URL litmus_rm-0.9.0.tar.gz
Size 52.3 kB
Tags Source
SHA-256 checksum
How to use checksums
1685456c6c1356447e5c8009e1e397b50e33066a7141c74005f32d28a9547e1e
BLAKE2b-256 checksum
How to use checksums
98c10ad5b2cfe9433f25a3d3b73c840d1920955a0cffa614d52cab01b3b0fc94
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via uv/0.8.22

Release files / litmus_rm-0.9.0-py3-none-any.whl

Download URL litmus_rm-0.9.0-py3-none-any.whl
Size 57.5 kB
Tags Python 3
SHA-256 checksum
How to use checksums
c502507276f21bfece27ff1946f8f997fb5ba7ef3dbef7b6e35a183a1410a264
BLAKE2b-256 checksum
How to use checksums
4f76300ab66fbb37000cd71e8aae13389e97d9a84fb207faf2c2431fa36b0feb
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via uv/0.8.22

Security for litmus-rm 0.9.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

0.9.0 This release

2 release files No provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page