Skip to content

Commit

Permalink
added a conda requirements and made the nndc reader better
Browse files Browse the repository at this point in the history
  • Loading branch information
wkerzendorf committed Jun 22, 2015
1 parent 863b603 commit 52a4491
Show file tree
Hide file tree
Showing 5 changed files with 29 additions and 7 deletions.
6 changes: 6 additions & 0 deletions tardisnuclear/conda-requirements
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
astropy
python
beautiful-soup
lxml
pytables=3.1.1
hdf5=1.8.14
2 changes: 1 addition & 1 deletion tardisnuclear/io/__init__.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
from tardisnuclear.io.read_nndc import (get_decay_radiation,
from tardisnuclear.io.nndc.base import (get_decay_radiation,
store_decay_radiation,
download_decay_radiation)
Empty file.
26 changes: 21 additions & 5 deletions tardisnuclear/io/read_nndc.py → tardisnuclear/io/nndc/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,15 +10,31 @@
from astropy import units as u

#getting the data_path
import tardisnuclear
data_path = os.path.join(tardisnuclear.__path__[0], 'data')

data_path = os.path.join(os.path.expanduser('~/.tardisnuclear'))



from pyne import nucname
from abc import ABCMeta


def _get_nuclear_database_path():
if not os.path.exists(data_path):
os.mkdir(data_path)
return os.path.join(data_path, 'decay_radiation.h5')

def _sanitize_nuclear_string(nuclear_string):
try:
sanitized_nuclear_string = nucname.name(nuclear_string)
except RuntimeError:
raise ValueError('{0} not a valid isotope string'.format(
nuclear_string))
else:
return sanitized_nuclear_string

def download_decay_radiation(nuclear_string):
nuclear_string = nuclear_string.title()
nuclear_string = _sanitize_nuclear_string(nuclear_string)
base_url = ('http://www.nndc.bnl.gov/chart/decaysearchdirect.jsp?'
'nuc={nucname}&unc=nds')

Expand Down Expand Up @@ -77,7 +93,7 @@ def store_decay_radiation_from_ejecta(ejecta, force_update=False):


def store_decay_radiation(nuclear_string, force_update=False):
nuclear_string = nuclear_string.title()
nuclear_string = _sanitize_nuclear_string(nuclear_string)
fname = os.path.join(data_path, 'decay_radiation.h5')
with pd.HDFStore(fname, mode='a') as ds:
if nuclear_string in ds and not force_update:
Expand All @@ -101,7 +117,7 @@ def store_decay_radiation(nuclear_string, force_update=False):


def get_decay_radiation(nuclear_string, data_set_idx=0):
nuclear_string = nuclear_string.title()
nuclear_string = _sanitize_nuclear_string(nuclear_string)
fname = os.path.join(data_path, 'decay_radiation.h5')
with pd.HDFStore(fname, mode='r') as ds:
current_keys = [key for key in ds.keys()
Expand Down
2 changes: 1 addition & 1 deletion tardisnuclear/models/__init__.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
__author__ = 'wkerzend'
from tardisnuclear.models.base import make_bolometric_model

0 comments on commit 52a4491

Please sign in to comment.