From 5e8da02027e3c03f50a7ac9dafa338925ca4fdee Mon Sep 17 00:00:00 2001 From: yeganer Date: Tue, 17 May 2016 22:00:33 +0200 Subject: [PATCH] Change the way AtomData quantities are initialized Quantities are initialized as units.Quantity instead of constructing a Quantity by multiplicating with a unit. --- tardis/atomic.py | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/tardis/atomic.py b/tardis/atomic.py index 59c66667da0..ec5d8b9e670 100644 --- a/tardis/atomic.py +++ b/tardis/atomic.py @@ -9,7 +9,8 @@ import numpy as np import pandas as pd from scipy import interpolate -from astropy import table, units +import astropy +from astropy import table, units, constants from pandas import DataFrame @@ -415,19 +416,18 @@ 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.Unit('u').to('g', self.atom_data.mass.values) + self.atom_data.mass = units.Quantity(self.atom_data.mass.values, 'u').cgs self.ionization_data = DataFrame(ionization_data.__array__()) self.ionization_data.set_index(['atomic_number', 'ion_number'], inplace=True) - self.ionization_data.ionization_energy = units.Unit('eV').to('erg', - self.ionization_data.ionization_energy.values) + self.ionization_data.ionization_energy = units.Quantity(self.ionization_data.ionization_energy.values, 'eV').cgs self.levels = DataFrame(levels_data.__array__()) - self.levels.energy = units.Unit('eV').to('erg', self.levels.energy.values) + self.levels.energy = units.Quantity(self.levels.energy.values, 'eV').cgs self.lines = DataFrame(lines_data.__array__()) - self.lines['nu'] = units.Unit('angstrom').to('Hz', self.lines['wavelength'], units.spectral()) - self.lines['wavelength_cm'] = units.Unit('angstrom').to('cm', self.lines['wavelength']) + self.lines['nu'] = units.Quantity(self.lines['wavelength'], 'angstrom').to('Hz', units.spectral()) + self.lines['wavelength_cm'] = units.Quantity(self.lines['wavelength'], 'angstrom').cgs