How to interpolate elements of an array in python?

Asked

Viewed 155 times

1

Good afternoon, you guys! I’m new to python and I’m trying to interpolate values between two columns of a rectangular matrix. Initially I created a matrix of zeros (nx=383 nz=125). Then I filled the matrix in the positions nx=5 and nx=380. I would like to fill the positions between these two points with an interpolation of the values on these two points. I am tempted to interpolation 1d and 2d but they both complain that the dimensions aren’t the same. Can anyone help me? Grateful

# coding: utf-8

# In[1]:


import numpy as np
import matplotlib.pyplot as plt
import math
from scipy.interpolate import interp1d
from scipy.interpolate import griddata


# In[2]:


nx = 383
nz = 125


# In[7]:


perfilf=model[380, 0:125] 
plt.plot( perfilf )
plt.title("perfilf")
plt.show()


# In[8]:


perfili=model[5, 0:125] 
plt.plot( perfili )
plt.title("perfili")
plt.show()


# In[9]:


m0=np.zeros((nx,nz))
m0[5,:] = perfili
m0[380,:]=perfilf
plt.imshow(m0.T, aspect='auto')
plt.title("teste")
plt.colorbar()
plt.show()
No answers

Browser other questions tagged

You are not signed in. Login or sign up in order to post.