#1
Having a hard time with this seemingly easy concept
I have a data array,X, of 1958x36x72
1958 is the time dimension
36 is lat dimension
72 is long dimension
There are NaNs in both the temporal and spatial sense
What I have done is set a 50% criterion on the data to keep. In other words, if over the course of the time domain, there is a NaN less than 50% of the time in the lat/long index, I keep the data. If not, I rewrite it as a NaN.
As such, I have a new data array,Y, where values are identical to X if NaNs in the temporal sense are less than 50%. However, the grid spaces where NaNs exist over 50%, they are now all NaNs at that gridpoint.
Here is what I am trying to achieve:
For the grid points that meet my threashold, I want to interpolate the data to fill in those missing points that currently have NaNs (only in the arrays that have NaNs less than 50% of the time)
However, I am not having much luck in terms of coding this up. I am using Matlab
Here are two recent cases where I have been playing around with this
1)
Code:
time = 1:1:1958;
temp_anom_crit_interp = interp2(time,temp_anomlay_criterion,time,'spline')

2)
Code:
for t= 1:1958
for i = 1:36
for j = 1:72
temp_anom_crit_interp(t,i,j) = interp(temp_anomlay_criterion(t,i,j),r); %have NO idea what to use for r in my case
end
end
end
I feel I am having a hard time grasping understanding which function to use. If anyone has any insight or experience along these lines, it would be greatly helpful
thread starter
macrumors P6
#7
Hmm not sure how to isolate my nonnan parts to get X,Y,Z as I think the index is important when I interpolate. As far as interpolation, I would prefer to keep the values if there and only interpolate the missing ones.
Thanks for the help and for offering to take a look. I have attached a representative sample. cc is 5 successive time steps late in the period and ccs is early. ccs will have nans at grid points in the time aspect that cc will not. I am trying to backfill ccs time steps at the gridpoints based on the gridpoint values in cc moreorless

 File size:
 47.3 KB
 Views:
 28

 File size:
 15.3 KB
 Views:
 19