针对问题 (1),此方法有效:
import yt
from yt.units import dimensions
from yt.units.yt_array import YTArray
import numpy as np
spNms = ['H2', 'H', 'O2', 'OH', 'H2O', 'HO2', 'H2O2', 'CH3', 'CH4', 'CO', 'CO2', 'CH2O', 'C2H2', 'C2H4', 'C2H6', 'NH3', 'NO', 'HCN', 'N2']
HfO = [0.0, 216269222.374, 0.0, 2292826.50902, -13423893.4949, 316904.97153, -4001375.87653, 9689965.02785, -4668373.7711, -3946437.03767, \
-8941308.52674, -3859845.44206, 8707735.03834, 1870243.41835, -2788439.10336, -2695065.81111, 3009074.80936, 4937073.18373, 0.0]
omgdot = ['H2_reaction_rate mea', 'H_reaction_rate mean', 'O2_reaction_rate mea', 'OH_reaction_rate mea', 'H2O_reaction_rate me', 'HO2_reaction_rate me', \
'H2O2_reaction_rate m', 'CH3_reaction_rate me', 'CH4_reaction_rate me', 'CO_reaction_rate mea', 'CO2_reaction_rate me', 'CH2O_reaction_rate m', \
'C2H2_reaction_rate m', 'C2H4_reaction_rate m', 'C2H6_reaction_rate m', 'NH3_reaction_rate me', 'NO_reaction_rate mea', 'HCN_reaction_rate me', \
'N2_reaction_rate mea']
#print 'HfO[16]',HfO[16]
#print 'omgdot[16]',omgdot[16]
#print 'HfO.shape',HfO.shape
#print 'omgdot.shape',omgdot.shape
def _HRR(field, data):
#data._debug()
Nx = data['Tmean'].shape
HRR=YTArray(np.zeros(Nx))
i=0
for sp in spNms:
HRR=HRR+(HfO[i]*data[omgdot[i]])
i=i+1
HRR = -HRR
return HRR
yt.add_field(('gas','HRR'), function=_HRR)
ds = yt.load("/data1/ahoffie/iw-dm-4/HighTempLowNOx/JICF_EXP/Scaled_GT_run_12mmPre_r2/out_jicf/post/merged_stats_00027_00034")
prj = yt.ProjectionPlot(ds, 'z', 'HRR', method='integrate', weight_field='rho mean')
prj.save('HRR_prj.png')