Giter Club home page Giter Club logo

kilonovanet's Introduction

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).

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.