Skip to content

Commit

Permalink
Fix Issue #564
Browse files Browse the repository at this point in the history
astropy<1.1.0 uses a different value for 'u' when converting quantities
than the one specified as constants.u.
In astropy>=1.1 unit.u is changed to be equal to constants.u.
By using constants.u, our results will be independant of the astropy
version.

This change required an update of the reference-files for
test_plasmas_full.py and test_tardis_full.py.

Resolves: #564
  • Loading branch information
yeganer committed May 18, 2016
1 parent 5e8da02 commit 1c5ccd7
Show file tree
Hide file tree
Showing 5 changed files with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion tardis/atomic.py
Original file line number Diff line number Diff line change
Expand Up @@ -416,7 +416,12 @@ def __init__(self, atom_data, ionization_data, levels_data, lines_data, macro_at

self.atom_data = DataFrame(atom_data.__array__())
self.atom_data.set_index('atomic_number', inplace=True)
self.atom_data.mass = units.Quantity(self.atom_data.mass.values, 'u').cgs
# We have to use constants.u because astropy uses different values for the unit u and the constant.
# This is changed in later versions of astropy (the value of constants.u is used in all cases)
if units.u.cgs == constants.u.cgs:
self.atom_data.mass = units.Quantity(self.atom_data.mass.values, 'u').cgs
else:
self.atom_data.mass = constants.u.cgs * self.atom_data.mass.values

self.ionization_data = DataFrame(ionization_data.__array__())
self.ionization_data.set_index(['atomic_number', 'ion_number'], inplace=True)
Expand Down
Binary file modified tardis/plasma/tests/data/plasma_test_data.h5
Binary file not shown.
Binary file modified tardis/tests/data/simple_test_j_blue_estimator.npy
Binary file not shown.
Binary file modified tardis/tests/data/simple_test_luminosity_density_lambda.npy
Binary file not shown.
Binary file not shown.

0 comments on commit 1c5ccd7

Please sign in to comment.