I'm tryin to bilerp a cell into one value using python for a NetCDF data set. I'm new to python and I can't understand what I'm doing wrong here. I have a 2d array and I give the four points by iterating through the dataset dataArr. I use Lerp method for the calculation. Somehow when I pass the 3 values it seems to consider it as more than 3. What am I doing wrong here? Thanks in adv.
This is the error I get>> self.Lerp((dataArr[i][j]),(dataArr[i+1][j]),fraction) takes exactly 3 arguments (4 given)
def compute(self,varval):
vars=self.data.variables
for var in vars:
if var==varval:
ntimes, ny, nx=vars[var].shape #inherit the method above.
print(ntimes, ny, nx)
#create the old computational grid.
computational_grid=np.zeros((ny,nx),dtype=int)
fraction=.5
newnx,newny =(nx*fraction,ny*fraction)
new_computational_grid=np.zeros((newny,newnx),dtype=int)
phy_value_arr=self.get_data(varval)
t=10 #send this t value with coords
dataArr=self.data.variables['tos'][t]
for i in range(0,(ny-1),1):
for j in range(0,(nx-1),1):
a=self.Lerp((dataArr[i][j]),(dataArr[i+1][j]),fraction)
b=self.Lerp((dataArr[i][j]),(dataArr[i+1][j]),fraction)
self.tempY.append(self.Lerp(a,b,fraction))
tempY.reshape(newnx,newny)
pcolormesh(self.tempY)
colorbar()
def Lerp( _a, _b, _t) :
return _a+(_b-_a)*_t
You call Lerp like tihs:
self.Lerp(a,b,fraction)
By definition it will put self as the first argument. Thus you will have four in total. However, you define Lerp as
def Lerp( _a, _b, _t) : #<- this takes only three arguments
I think it should be:
def Lerp(self, _a, _b, _t) : #<- this takes four, and self is first one
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.