I have an array that I want to interpolate along the 1st axis. At the moment, I am doing this, as in this example:
import numpy as np
from scipy.interpolate import interp1d
array = np.random.randint(0, 9, size=(100, 100, 100))
new_array = np.zeros((1000, 100, 100))
x = np.arange(0, 100, 1)
x_new = np.arange(0, 100, 0.1)
for i in x:
for j in x:
f = interp1d(x, array[:, i, j])
new_array[:, i, j] = f(xnew)
The data used are 10-year averaged values of 5 days for each latitude and longitude in the domain. I want to create an array of daily values.
I also tried using splines. I really do not know how they work, but it was not much faster.
Is there any way to do this without using for loops? If you need to use for loops, are there other ways to speed this up?
Thanks in advance for any suggestions.
source
share