From b7091392446b3cf08330b56ceb7cfba379f76b0d Mon Sep 17 00:00:00 2001 From: Christian Vogl Date: Mon, 30 Jul 2018 17:32:43 +0200 Subject: [PATCH 1/2] Fix indexing errors --- tardis/montecarlo/formal_integral.py | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/tardis/montecarlo/formal_integral.py b/tardis/montecarlo/formal_integral.py index d2972131a12..1b0e3bd8156 100644 --- a/tardis/montecarlo/formal_integral.py +++ b/tardis/montecarlo/formal_integral.py @@ -115,8 +115,8 @@ def make_source_function(self): # the transition l->u Jbluelu = runner.j_blue_estimator * Jbluelu_norm_factor - upper_level_index = atomic_data.lines.set_index(['atomic_number', 'ion_number', 'level_number_upper']).index.copy() - e_dot_lu = pd.DataFrame(Edotlu, index=upper_level_index) + upper_level_index = atomic_data.lines.index.droplevel('level_number_lower') + e_dot_lu = pd.DataFrame(Edotlu, index=upper_level_index) e_dot_u = e_dot_lu.groupby(level=[0, 1, 2]).sum() e_dot_u.index.names = ['atomic_number', 'ion_number', 'source_level_number'] # To make the q_ul e_dot_u product work, could be cleaner transitions = atomic_data.macro_atom_data[atomic_data.macro_atom_data.transition_type == -1].copy() @@ -124,11 +124,12 @@ def make_source_function(self): tmp = plasma.transition_probabilities[(atomic_data.macro_atom_data.transition_type == -1).values] q_ul = tmp.set_index(transitions_index) t = model.time_explosion.value - wave = atomic_data.lines.wavelength_cm[transitions.transition_line_id].values.reshape(-1,1) - att_S_ul = ( wave * (q_ul * e_dot_u) * t / (4*np.pi) ) + lines = atomic_data.lines.set_index('line_id') + wave = lines.wavelength_cm.loc[transitions.transition_line_id].values.reshape(-1,1) + att_S_ul = (wave * (q_ul * e_dot_u) * t / (4 * np.pi)) result = pd.DataFrame(att_S_ul.as_matrix(), index=transitions.transition_line_id.values) - att_S_ul = result.ix[atomic_data.lines.index.values].values + att_S_ul = result.ix[lines.index.values].values # Jredlu should already by in the correct order, i.e. by wavelength of # the transition l->u (similar to Jbluelu) From b2b34bc0de9fbdf35c2ff445a9a01515053bd415 Mon Sep 17 00:00:00 2001 From: Christian Vogl Date: Mon, 30 Jul 2018 17:51:28 +0200 Subject: [PATCH 2/2] Fix indentation --- tardis/montecarlo/formal_integral.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/tardis/montecarlo/formal_integral.py b/tardis/montecarlo/formal_integral.py index 1b0e3bd8156..2545189ca63 100644 --- a/tardis/montecarlo/formal_integral.py +++ b/tardis/montecarlo/formal_integral.py @@ -116,7 +116,7 @@ def make_source_function(self): Jbluelu = runner.j_blue_estimator * Jbluelu_norm_factor upper_level_index = atomic_data.lines.index.droplevel('level_number_lower') - e_dot_lu = pd.DataFrame(Edotlu, index=upper_level_index) + e_dot_lu = pd.DataFrame(Edotlu, index=upper_level_index) e_dot_u = e_dot_lu.groupby(level=[0, 1, 2]).sum() e_dot_u.index.names = ['atomic_number', 'ion_number', 'source_level_number'] # To make the q_ul e_dot_u product work, could be cleaner transitions = atomic_data.macro_atom_data[atomic_data.macro_atom_data.transition_type == -1].copy() @@ -124,9 +124,9 @@ def make_source_function(self): tmp = plasma.transition_probabilities[(atomic_data.macro_atom_data.transition_type == -1).values] q_ul = tmp.set_index(transitions_index) t = model.time_explosion.value - lines = atomic_data.lines.set_index('line_id') + lines = atomic_data.lines.set_index('line_id') wave = lines.wavelength_cm.loc[transitions.transition_line_id].values.reshape(-1,1) - att_S_ul = (wave * (q_ul * e_dot_u) * t / (4 * np.pi)) + att_S_ul = (wave * (q_ul * e_dot_u) * t / (4 * np.pi)) result = pd.DataFrame(att_S_ul.as_matrix(), index=transitions.transition_line_id.values) att_S_ul = result.ix[lines.index.values].values