# Start writing code here...
1 + 1
This is me practicing with modulo operator
import numpy as np
x = np.array([2, 1.4 , 5, 6, 9.2])
y = np.array([-1.1, 2, 33, 11, 4.5])
a = .5
xnew = (x-2)
ynew = (y-2)
print("xnew and ynew" , xnew, " ", ynew)
xnew = xnew % a
ynew = ynew % a
print("xnew and ynew modulo 0.5 are " , xnew, " ", ynew)
-3.1 / .5
This is useful stuff for our research ...
x = [0, 0.05883, 0.10385, .16138, .22843, .30785, .35412, .4025, 0.4476] #alpha values
ysqu = [.8428, .8362, .8304, .8262, .8123, .8046, .8042,.80751, .79295] # phi_critical values
ytri = [.8428,0.834536,0.827745,0.82761,0.819201,0.79921,0.789193,0.788091,0.784619 ]
w = [0, .070, .125, .195, .281, .383, .439, .500, .564] #n_f values
import matplotlib.pyplot as plt
plt.plot(w,ysqu, 'rs' , markerfacecolor = 'w')
plt.plot(w,ytri, 'g^', markerfacecolor = 'w')
plt.title("Jan 23,24 Pressure sweep data: phi_c vs. n_f")
plt.xlabel('n_f')
plt.ylabel('phi_c')
plt.show()
plt.plot(x,ysqu, 'rs' )
plt.plot(x,ytri, 'g^' )
plt.title("Jan 23, 24 Pressure sweep data: phi_c vs. alpha")
plt.xlabel('alpha')
plt.ylabel('phi_c')
plt.show()
import numpy as np
X_COORDINATE = np.linspace(0.0, 10.0, num=100); Z_COORDINATE = X_COORDINATE; C_I = np.sin(X_COORDINATE * Z_COORDINATE)
import matplotlib.pyplot as plt
import numpy as np
from matplotlib.colors import LogNorm
from scipy.interpolate import interp2d
x_list = np.array(X_COORDINATE)
z_list = np.array(Z_COORDINATE)
C_I_list = np.array(C_I)
# f will be a function with two arguments (x and z coordinates),
# but those can be array_like structures too, in which case the
# result will be a matrix representing the values in the grid
# specified by those arguments
f = interp2d(x_list,z_list,C_I_list,kind="linear")
x_coords = np.arange(min(x_list),max(x_list)+1)
z_coords = np.arange(min(z_list),max(z_list)+1)
c_i = f(x_coords,z_coords)
fig = plt.imshow(c_i,
extent=[min(x_list),max(x_list),min(z_list),max(z_list)],
origin="lower", interpolation='bicubic')
# Show the positions of the sample points, just to have some reference
fig.axes.set_autoscale_on(False)
plt.scatter(x_list,z_list,400,facecolors='none')
plt.colorbar()
plt.show()
from pylab import plot,show
y = [1.0, 2.4, 1.7, 0.3, 0.6]
x = [0.0, 1.0, 2.5, 3.9, 4.7]
#plot(y)
plot(x,y, "ro")
plot(x,y,'k')
show()
from numpy import linspace, sin
x = linspace(0,10,1000)
y = sin(x)
plot(x,y)
show()
from numpy import loadtxt
data = loadtxt("values.txt", float)
plot(data[:,0],data[:,1], "co")
plot(data[:,0],data[:,1], 'b')
show()
xpoints = []
ypoints = []
for x in linspace(0,10,1000):
xpoints.append(x)
ypoints.append(sin(x))
plot(xpoints,ypoints)
show()
ypoints = np.power(ypoints,2)
zpoints = np.power(1 - ypoints, .5)
import pylab as py
import numpy as np
py.plot(xpoints,ypoints, 'c')
py.plot(xpoints,ypoints, 'b')
py.plot(xpoints,zpoints,'c')
py.ylim(-1.5,1.5)
py.xlabel("x axis"); py.ylabel("y axis")
show()
in_array1 = [0, math.pi / 2, np.pi / 3, np.pi]
out_array1 = np.sin(in_array1)
py.scatter(in_array1, out_array1)
in_array = np.linspace(-np.pi, np.pi, 12)
out_array = np.sin(in_array)
py.plot(in_array, out_array, "r" )
py.scatter(in_array, out_array)
from pylab import imshow,show, gray, jet
from numpy import loadtxt
data = loadtxt("circular.txt",float)
imshow(data)
jet()
show()
from math import sqrt,sin,pi
from numpy import empty
from pylab import imshow,gray,show
wavelength = 5.0
k = 2*pi/wavelength
xi0 = 1.0
separation = 20.0 # Separation of centers in cm
side = 100.0 # Side of the square in cm
points = 500 # Number of grid points along each side
spacing = side/points # Spacing of points in cm
# Calculate the positions of the centers of the circles
x1 = side/2 + separation/2
y1 = side/2
x2 = side/2 - separation/2
y2 = side/2
# Make an array to store the heights
xi = empty([points,points],float)
# Calculate the values in the array
for i in range(points):
y = spacing*i
for j in range(points):
x = spacing*j
r1 = ((x-x1)**2+(y-y1)**2) ** 0.5
r2 = ((x-x2)**2+(y-y2)**2) **0.5
xi[i,j] = xi0*sin(k*r1) + xi0*sin(k*r2)
# Make the plot
imshow(xi,origin="lower",extent=[0,side,0,side])
gray()
show()
from math import sqrt,sin,pi
from numpy import empty
from pylab import imshow,gray,show
wavelength = 5.0
k = 2*pi/wavelength
xi0 = 1.0
separation = 20.0 # Separation of centers in cm
side = 100.0 # Side of the square in cm
points = 500 # Number of grid points along each side
spacing = side/points # Spacing of points in cm
# Calculate the positions of the centers of the circles
x1 = side/2 + separation/2
y1 = side/2
x2 = side/2 - separation/2
y2 = side/2
# Make an array to store the heights
xi = empty([points,points],float)
# Calculate the values in the array
for i in range(points):
y = spacing*i
for j in range(points):
x = spacing*j
r1 = ((x-x1)**2+(y-y1)**2) ** 0.5
r2 = ((x-x2)**2+(y-y2)**2) **0.5
xi[i,j] = xi0*sin(k*r1) + xi0*sin(k*r2)
# Make the plot
imshow(xi,origin="lower",extent=[0,side,0,side])
#gray()
show()
from math import sqrt,sin,pi
from numpy import empty
from pylab import imshow,gray,show
wavelength = 5.0
k = 2*pi/wavelength
xi0 = 1.0
separation = 20.0 # Separation of centers in cm
side = 100.0 # Side of the square in cm
points = 500 # Number of grid points along each side
spacing = side/points # Spacing of points in cm
# Calculate the positions of the centers of the circles
x1 = side/2 + separation/2
y1 = side/2
x2 = side/2 - separation/2
y2 = side/2
# Make an array to store the heights
xi = empty([points,points],float)
# Calculate the values in the array
for i in range(points):
y = spacing*i
for j in range(points):
x = spacing*j
r1 = ((x-x1)**2+(y-y1)**2) ** 0.5
r2 = ((x-x2)**2+(y-y2)**2) **0.5
xi[i,j] = xi0*sin(k*r1) + xi0*sin(k*r2)
# Make the plot
imshow(xi,origin="lower",extent=[0,side,0,side])
gray()
show()