请问如何使用numba加速以下代码?
def compute_tau(self, var, atm):
''' compute the optical depth '''
# reset to zero
#print(var)
#var.tau = np.array(var.tau)
var.tau.fill(0)
#var.tau = np.zeros( (nz+1, var.nbin) )
# absorption species
absp_sp = set.union(var.photo_sp,var.ion_sp)
for j in range(nz-1,-1,-1):
for sp in absp_sp:
# summing over all T-dependentphoto species
if sp in vulcan_cfg.T_cross_sp:
var.tau[j] += var.y[j,species.index(sp)] * atm.dz[j] * var.cross_T[sp][j] # 1-D shape of nbins from the j level
else: # summing over all T-independent photo species
var.tau[j] += var.y[j,species.index(sp)] * atm.dz[j] * var.cross[sp] # only the j-th laye
for sp in vulcan_cfg.scat_sp: # scat_sp are not necessary photo_sp, e.g. He
var.tau[j] += var.y[j,species.index(sp)] * atm.dz[j] * var.cross_scat[sp]
# adding the layer above at the end of species loop
var.tau[j] += var.tau[j+1]
直接在函数前面加@njit会报错: