Skip to content

Commit

Permalink
Fix formal integral (#853)
Browse files Browse the repository at this point in the history
* Fix indexing errors

* Fix indentation
  • Loading branch information
chvogl authored and wkerzendorf committed Jul 30, 2018
1 parent df2bdf1 commit 7a86d20
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions tardis/montecarlo/formal_integral.py
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ 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()
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
Expand All @@ -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)
Expand Down

0 comments on commit 7a86d20

Please sign in to comment.