-
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
c45e9f3
commit 3a204a8
Showing
12 changed files
with
161 additions
and
18 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
*************** | ||
Getting started | ||
*************** | ||
|
||
The first useful thing is to create a lightcurve model for a Ni56 powered | ||
explosion. Here the values for the different are given in units of solar | ||
masses:: | ||
|
||
>>> from tardisnuclear import models | ||
>>> sn_model = models.make_bolometric_model(ni56=1.0) | ||
>>> sn_model | ||
<BolometricLightCurve(ni56=1.0)> | ||
|
||
It is however very likely that this will fail due to the inavailabilty of the | ||
necessary nuclear data. The nuclear data. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,13 +1,18 @@ | ||
Documentation | ||
============= | ||
TARDIS Nuclear | ||
============== | ||
|
||
This is an affiliated package for the AstroPy package. The documentation for | ||
this package is here: | ||
TARDIS Nuclear is a framework to calculate the energy budget from nuclear | ||
decay in supernovae. It is a companion package to the TARDIS SN radiative | ||
transfer code and in the future these packages are intended to work together. | ||
Furthermore, this code can be used to calculate simple bolometric lightcurves. | ||
|
||
.. toctree:: | ||
:maxdepth: 2 | ||
:maxdepth: 2 | ||
|
||
install.rst | ||
getting_started.rst | ||
|
||
|
||
|
||
|
||
packagename/index.rst | ||
|
||
.. note:: Do not edit this page - instead, place all documentation for the | ||
affiliated package inside ``packagename/`` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
************ | ||
Installation | ||
************ | ||
|
||
``tardisnuclear`` has several dependencies that are easiest installed via | ||
`Anaconda <http://continuum.io/downloads>`_ and all further instructions will | ||
assume that you use that for your installation. The first package that needs | ||
to be installed is pyne:: | ||
|
||
conda install -c cyclus -c pyne pyne=0.5.0 |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
import requests | ||
from bs4 import BeautifulSoup | ||
|
||
base_url = 'http://henke.lbl.gov/cgi-bin/pert_cgi.pl' | ||
|
||
|
||
def get_photo_absorption_cross_section(element_code, energy): | ||
data = requests.get(base_url, data=dict( | ||
Element=element_code, Energy=energy)) | ||
bs = BeautifulSoup(data.text) | ||
for item in bs.find_all('li'): | ||
if item.text.startswith('Photo'): | ||
return float(item.text.split(':')[1].strip().replace('cm^2/g', '')) | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
|
||
|
||
def test_henke_fe(): | ||
pass |
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
__author__ = 'wkerzend' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,77 @@ | ||
import numpy as np | ||
|
||
from astropy.modeling import FittableModel, Parameter | ||
from astropy import units as u | ||
from pyne import nucname | ||
|
||
from tardisnuclear.ejecta import Ejecta, msun_to_cgs | ||
from tardisnuclear.rad_trans import SimpleLateTime | ||
from tardisnuclear.nuclear_data import NuclearData | ||
|
||
mpc_to_cm = u.Mpc.to(u.cm) | ||
|
||
class BaseBolometricLightCurve(FittableModel): | ||
inputs = ('epoch', ) | ||
outputs = ('luminosity', ) | ||
|
||
def __init__(self, **kwargs): | ||
super(BaseBolometricLightCurve, self).__init__(**kwargs) | ||
self._init_ejecta(kwargs) | ||
nuclear_data = NuclearData(self.ejecta.get_all_children_nuc_name()) | ||
self.rad_trans = SimpleLateTime(self.ejecta, nuclear_data) | ||
|
||
def _init_ejecta(self, isotope_dict): | ||
titled_isotope_dict = {name.title():value * u.Msun | ||
for name, value in isotope_dict.items()} | ||
self.ejecta = Ejecta.from_masses(**titled_isotope_dict) | ||
|
||
def _update_ejecta(self, isotope_masses): | ||
assert len(isotope_masses) == len(self.param_names) | ||
total_mass = np.sum(isotope_masses) | ||
self.ejecta.mass_g = total_mass * msun_to_cgs | ||
for isotope_name, isotope_mass in zip(self.param_names, isotope_masses): | ||
self.ejecta[isotope_name.title()] = isotope_mass / total_mass | ||
|
||
def evaluate(self, epoch, *args): | ||
self._update_ejecta(args) | ||
return self.rad_trans.total_bolometric_light_curve(epoch) | ||
|
||
|
||
def make_bolometric_model(**kwargs): | ||
""" | ||
Make a bolometric lightcurve model | ||
:param kwargs: | ||
:return: | ||
""" | ||
class_dict = {} | ||
class_dict['__init__'] = BaseBolometricLightCurve.__init__ | ||
init_kwargs = {} | ||
for isotope_name in kwargs: | ||
if not nucname.isnuclide(isotope_name): | ||
raise ValueError('{0} is not a nuclide name') | ||
class_dict[isotope_name.lower()] = Parameter() | ||
init_kwargs[isotope_name.lower()] = kwargs[isotope_name] | ||
BolometricLightCurve = type('BolometricLightCurve', | ||
(BaseBolometricLightCurve, ), class_dict) | ||
|
||
return BolometricLightCurve(**init_kwargs) | ||
|
||
class RSquared(FittableModel): | ||
inputs = ('luminosity', ) | ||
outputs = ('luminosity_density', ) | ||
|
||
#Distance in Mpc | ||
distance = Parameter() | ||
|
||
|
||
def evaluate(self, luminosity, distance): | ||
return luminosity / (4 * np.pi * (distance * mpc_to_cm)**2) | ||
|
||
|
||
class BolometricChi2Likelihood(FittableModel): | ||
|
||
inputs = ('luminosity_density', ) | ||
outputs = ('log_likelihood') | ||
|
||
def __init__(self, epochs, ): | ||
pass |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
from astropy import modeling | ||
|
||
class BaseHomologousRadial1D(object): | ||
def __init__(self, abundances, densities): | ||
pass |