Skip to content

Commit

Permalink
making atomic data reads read-only
Browse files Browse the repository at this point in the history
  • Loading branch information
wkerzendorf committed Mar 4, 2014
1 parent c5ad44e commit fe6723a
Showing 1 changed file with 8 additions and 8 deletions.
16 changes: 8 additions & 8 deletions tardis/atomic.py
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ def read_hdf5_data(fname, dset_name):
returns the respective
"""

h5_file = h5py.File(fname)
h5_file = h5py.File(fname, 'r')
dataset = h5_file[dset_name]
data = np.asarray(dataset)
# data_units = dataset.attrs['units']
Expand Down Expand Up @@ -153,7 +153,7 @@ def read_levels_data(fname=None):


def read_synpp_refs(fname):
data_table = h5py.File(fname)['synpp_refs']
data_table = h5py.File(fname, 'r')['synpp_refs']

return data_table.__array__()

Expand Down Expand Up @@ -196,7 +196,7 @@ def read_zeta_data(fname):
if not os.path.exists(fname):
raise IOError('HDF5 File doesn\'t exist')

h5_file = h5py.File(fname)
h5_file = h5py.File(fname, 'r')

if 'zeta_data' not in h5_file.keys():
raise ValueError('zeta_data not available in this HDF5-data file. It can not be used with NebularAtomData')
Expand All @@ -214,7 +214,7 @@ def read_collision_data(fname):
if not os.path.exists(fname):
raise IOError('HDF5 File doesn\'t exist')

h5_file = h5py.File(fname)
h5_file = h5py.File(fname, 'r')

if 'collision_data' not in h5_file.keys():
raise ValueError('collision_data not available in this HDF5-data file. It can not be used with NLTE')
Expand All @@ -227,7 +227,7 @@ def read_collision_data(fname):

def read_ion_cx_data(fname):
try:
h5_file = h5py.File(fname)
h5_file = h5py.File(fname, 'r')
ion_cx_th_data = h5_file['ionization_cx_threshold']
ion_cx_sp_data = h5_file['ionization_cx_support']
return ion_cx_th_data, ion_cx_sp_data
Expand All @@ -244,7 +244,7 @@ def read_macro_atom_data(fname):
if not os.path.exists(fname):
raise IOError('HDF5 File doesn\'t exist')

h5_file = h5py.File(fname)
h5_file = h5py.File(fname, 'r')

if 'macro_atom_data' not in h5_file.keys():
raise ValueError('Macro Atom Data (macro_atom_data) is not in this HDF5-data file. '
Expand Down Expand Up @@ -316,7 +316,7 @@ def from_hdf5(cls, fname=None):
levels_data = read_levels_data(fname)
lines_data = read_lines_data(fname)

with h5py.File(fname) as h5_file:
with h5py.File(fname, 'r') as h5_file:
h5_datasets = h5_file.keys()

if 'macro_atom_data' in h5_datasets:
Expand Down Expand Up @@ -349,7 +349,7 @@ def from_hdf5(cls, fname=None):
collision_data=(collision_data, collision_data_temperatures), synpp_refs=synpp_refs,
ion_cx_data=ion_cx_data)

with h5py.File(fname) as h5_file:
with h5py.File(fname, 'r') as h5_file:
atom_data.uuid1 = h5_file.attrs['uuid1']
atom_data.md5 = h5_file.attrs['md5']
atom_data.version = h5_file.attrs.get('database_version', None)
Expand Down

0 comments on commit fe6723a

Please sign in to comment.