import numpy as np
import matplotlib.pyplot as plt
import matplotlib.image as mpimg
# from google.colab import drive
# drive.mount('/content/drive/')
#images_path='/content/drive/MyDrive/Colab Notebooks/zapatocaImage.jpeg'
#img = mpimg.imread(images_path)
#plt.imshow(img)
#plt.show()
def gaussiana(x,a,b,c):
exponente = -(x-b)**2 / (2 * c**2)
y = a * np.exp(exponente)
return y
x = np.arange(-15,15,0.1)
y1 = gaussiana(x,4,-5,np.pi)
y2 = gaussiana(x,-3,-2,1)
y3 = gaussiana(x,1,2,4)
plt.plot(x,y1,"r-")
plt.plot(x,y2,"g--")
plt.plot(x,y3,"k-.")
[<matplotlib.lines.Line2D at 0x7f7b6f218760>]
x = np.arange(0,5,0.1)
y = np.arange(0,7,0.1)
print(x.shape)
print(y.shape)
(50,) (70,)
print(x)
[0. 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 1. 1.1 1.2 1.3 1.4 1.5 1.6 1.7 1.8 1.9 2. 2.1 2.2 2.3 2.4 2.5 2.6 2.7 2.8 2.9 3. 3.1 3.2 3.3 3.4 3.5 3.6 3.7 3.8 3.9 4. 4.1 4.2 4.3 4.4 4.5 4.6 4.7 4.8 4.9]
yy, xx = np.meshgrid(x,y)
print(xx.shape)
print(yy.shape)
(70, 50) (70, 50)
print(xx)
[[0. 0. 0. ... 0. 0. 0. ] [0.1 0.1 0.1 ... 0.1 0.1 0.1] [0.2 0.2 0.2 ... 0.2 0.2 0.2] ... [6.7 6.7 6.7 ... 6.7 6.7 6.7] [6.8 6.8 6.8 ... 6.8 6.8 6.8] [6.9 6.9 6.9 ... 6.9 6.9 6.9]]
print(yy)
[[0. 0.1 0.2 ... 4.7 4.8 4.9] [0. 0.1 0.2 ... 4.7 4.8 4.9] [0. 0.1 0.2 ... 4.7 4.8 4.9] ... [0. 0.1 0.2 ... 4.7 4.8 4.9] [0. 0.1 0.2 ... 4.7 4.8 4.9] [0. 0.1 0.2 ... 4.7 4.8 4.9]]
def gauss2D(x, y, a=1, b=0, c=1, x0=0, y0=0):
exponente = -((x-x0)**2 + (y-y0)**2) / (2*c**2)
z = a * np.exp(exponente) + b
return z
a = 4
b = 2
c = 0.5
zz = gauss2D(xx,yy,a,b,c,2,3)
zz2 = gauss2D(xx,yy,-5,1,1,3.5,2.5)
plt.imshow(zz+zz2,cmap="gray")
plt.colorbar()
<matplotlib.colorbar.Colorbar at 0x7f7b6e92b370>
fig = plt.figure()
ax = fig.gca(projection='3d')
ax.plot_surface(xx,yy, zz+zz2, rstride=3, cstride=3, linewidth=1, antialiased=True,cmap="rainbow")
<mpl_toolkits.mplot3d.art3d.Poly3DCollection at 0x7f7b6e8c03a0>
np.savetxt("valoresenz.txt",zz)
np.savetxt?
import pickle
A = np.random.randint(low=1,high=101,size=(5,5))
print(A)
[[66 8 92 1 91] [81 84 87 99 13] [88 2 77 15 82] [ 4 83 87 87 20] [16 36 49 57 1]]
file = open('miarchivo', 'wb')
pickle.dump(A, file)
file.close()
file = open('miarchivo', 'rb')
B = pickle.load(file)
file.close()
print(B)
[[66 8 92 1 91] [81 84 87 99 13] [88 2 77 15 82] [ 4 83 87 87 20] [16 36 49 57 1]]
np.savetxt?