KilonovaNet: Kilonova Surrogate Modelling
A conditional variational autoencoder (cVAE) framework for producing continuous surrogate spectra for kilonova models.
This package provides the interface to predict spectra. It does not provide an interface to do the data prep for training and training itself. The currently trained and provided models are:
This work requires the use of pyphot; pyphot requires hdf5. See their installation intructions to see how to install that for your system. Then, if you install KilonovaNet via pip, dependencies (including pyphot) should install properly.
Installation
Install via pip:
pip install kilonovanet
Usage
In order to produce surrogate spectra, you will need to specify the model and torch files. These are not included in this package, you must download them separately from the KilonovaNet github from data and model folders.
After you have the files in your system, you can produce spectra with the following:
import kilonovanet
import numpy as np
metadata_file = "data/metadata_bulla_bns.json"
torch_file = "models/bulla-bns-latent-20-hidden-1000-CV-4-2021-04-21-epoch-200.pt"
times = np.array([1.2, 2.2])
physical_parameters = np.array([1.0e-2, 9.0e-2, 3.0e1, 3.0e-1])
model = kilonovanet.Model(metadata_file, torch_file)
spectra = model.predict_spectra(physical_parameters, times)
In order to produce some photometric observations, the following have to be specified:
- the model
- the corresponding parameters of the model (see their papers, repositories, etc.)
- the times post-merger to produce the observations
- the filters in which to produce the observations
I have specified some filters in the github folder filter_data, but any filter transmission curves should work properly.
After you have filter profiles, use the following to produce synthetic photometric observations:
import kilonovanet
import numpy as np
metadata_file = "data/metadata_bulla_bns.json"
torch_file = "models/bulla-bns-latent-20-hidden-1000-CV-4-2021-04-21-epoch-200.pt"
filter_lib = "data/filter_data"
times = np.array([1.2, 1.2, 1.2, 2.2, 2.2, 2.2, 2.2])
filters = np.array(["LSST_u", "LSST_z", "LSST_y", "LSST_u", "LSST_z", "LSST_y"])
distance = 40.0 * 10 ** 6 * 3.086e18 # 40 Mpc in cm
physical_parameters = np.array([1.0e-2, 9.0e-2, 3.0e1, 3.0e-1])
model = kilonovanet.Model(metadata_file, torch_file, filter_library_path=filter_lib)
mags = model.predict_magnitudes(physical_parameters, times=times, filters=filters,
distance=distance)
If you intend to use the same set of observations often, e.g. when doing an
MCMC-based fit, you can specify all of them in an Observations object and
then simply call model.predict_magnitudes(physical_parameters).
Metadata
Release files for kilonovanet 0.1.1
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| kilonovanet-0.1.1.tar.gz | 7.1 kB | Without provenance | Details for kilonovanet-0.1.1.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| kilonovanet-0.1.1-py3-none-any.whl | Python 3 | none | any | Details for kilonovanet-0.1.1-py3-none-any.whl |
Total release size: 14.8 kB
Release files / kilonovanet-0.1.1.tar.gz
| Download URL | kilonovanet-0.1.1.tar.gz |
|---|---|
| Size | 7.1 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
bdcf330c33a807a511522244acf6ede48a2edf024f4f0fc0d111587d33e28042
|
|
BLAKE2b-256 checksum How to use checksums |
3fdd7a062a375cf51586d947b6dedcbab4d70a1e1caaa5dad62d93d867eb0232
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/3.7.1 importlib_metadata/4.8.2 pkginfo/1.8.2 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.8.0
|
Release files / kilonovanet-0.1.1-py3-none-any.whl
| Download URL | kilonovanet-0.1.1-py3-none-any.whl |
|---|---|
| Size | 7.7 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
7833b896a324592e2c7be48cd2653859af61fce437b52e3745ce0bf726f4d7a0
|
|
BLAKE2b-256 checksum How to use checksums |
b984be8bcc1114feb08b74a03697a85209764fcbb8545ea8e5b251766bd9de13
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/3.7.1 importlib_metadata/4.8.2 pkginfo/1.8.2 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.8.0
|
Security for kilonovanet 0.1.1
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.