I am trying to interpolate a 48 x 86 grid that has wind speed data (the grid being time x height) to a 71 x 81 grid (also time x height). I am trying to use the interpn function from scipy.interpolate because from what I’ve read, it is the recommended function for interpolating regular grids. When i attempt use of this function, I get the title error (ValueError: One of the requested xi is out of bounds in dimension 0)
I have tried using the following:
This block of code represents the grid I want to interpolate my data onto.
rangeTime = np.arange(np.datetime64('2018-05-30T00:20:00'),np.datetime64('2018-05-31T00:00:00'),np.timedelta64(20,'m'))
rangeHeight = np.arange(200,4250,50)
rangeTime = rangeTime.astype("float64")
inTime, inHeight = np.meshgrid(rangeTime,rangeHeight,indexing='ij')
This is the data I want interpolated, and its dimensions are represented by:
times= ds.time.values #1d time array
heightvalues = ds.heights.values #48 x 86 grid with height data
height1d = heightvalues[0,:] #only need 1st slice, so I get 1d array with all my heights.
wspeed = ds.wspd.values #wind speed data, 48 x 86 grid
And finally I use the interpn function like so:
grid_wspeed = interpn((times,height1d),wspeed,(inTime,inHeight), method = 'linear')
I was expecting my wind speed data to be in a 71 x 81 grid. I don’t understand why I’m getting the ValueError. Thank you in advance for helping me.
DLW9900 is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.