def resample_photosphere(opacities, photosphere, opacity_index):
""" Resample photospheric quantities onto a new opacity scale. """
if opacity_index is None:
return photosphere
resampled_photosphere = np.zeros(photosphere.shape)
n_quantities = photosphere.shape[1]
for i in range(n_quantities):
if i == opacity_index: continue
# Create spline function.
tk = \
interpolate.splrep(photosphere[:, opacity_index], photosphere[:, i])
# Evaluate photospheric quantities at the new opacities
resampled_photosphere[:, i] = interpolate.splev(opacities.flatten(), tk)
# Update photosphere with new opacities
resampled_photosphere[:, opacity_index] = opacities
return resampled_photosphere
评论列表
文章目录