Skip to content

Commit

Permalink
fixed some of the doc problems
Browse files Browse the repository at this point in the history
  • Loading branch information
wkerzendorf committed Jun 22, 2015
1 parent c45e9f3 commit 3a204a8
Show file tree
Hide file tree
Showing 12 changed files with 161 additions and 18 deletions.
20 changes: 20 additions & 0 deletions docs/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,26 @@
# Load all of the global Astropy configuration
from astropy_helpers.sphinx.conf import *

#extensions = [
# 'sphinx.ext.autodoc',
# 'sphinx.ext.intersphinx',
# 'sphinx.ext.todo',
# 'sphinx.ext.coverage',
# 'sphinx.ext.pngmath',
# 'sphinx.ext.inheritance_diagram',
# 'astropy_helpers.sphinx.ext.numpydoc',
# 'astropy_helpers.sphinx.ext.astropyautosummary',
# 'astropy_helpers.sphinx.ext.automodsumm',
# 'astropy_helpers.sphinx.ext.automodapi',
# 'astropy_helpers.sphinx.ext.tocdepthfix',
# 'astropy_helpers.sphinx.ext.doctest',
# 'astropy_helpers.sphinx.ext.changelog_links',
# 'astropy_helpers.sphinx.ext.viewcode', # Use patched version of viewcode
# 'astropy_helpers.sphinx.ext.smart_resolver'
# ]
extensions.pop(extensions.index('astropy_helpers.sphinx.ext.automodsumm'))
extensions.pop(extensions.index('astropy_helpers.sphinx.ext.automodapi'))

# Get configuration information from setup.cfg
from distutils import config
conf = config.ConfigParser()
Expand Down
15 changes: 15 additions & 0 deletions docs/getting_started.rst
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.
21 changes: 13 additions & 8 deletions docs/index.rst
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/``
10 changes: 10 additions & 0 deletions docs/install.rst
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
10 changes: 0 additions & 10 deletions docs/packagename/index.rst

This file was deleted.

15 changes: 15 additions & 0 deletions tardisnuclear/io/read_henke.py
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', ''))


1 change: 1 addition & 0 deletions tardisnuclear/io/tests/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@

4 changes: 4 additions & 0 deletions tardisnuclear/io/tests/test_henke.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@


def test_henke_fe():
pass
Empty file added tardisnuclear/models.py
Empty file.
1 change: 1 addition & 0 deletions tardisnuclear/models/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
__author__ = 'wkerzend'
77 changes: 77 additions & 0 deletions tardisnuclear/models/base.py
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
5 changes: 5 additions & 0 deletions tardisnuclear/models/supernova.py
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

0 comments on commit 3a204a8

Please sign in to comment.