-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathwaveTheory.py
More file actions
112 lines (82 loc) · 2.08 KB
/
Copy pathwaveTheory.py
File metadata and controls
112 lines (82 loc) · 2.08 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
#!/usr/bin/python
import os
from pylab import *
import numpy as np
from PIL import Image
#import Image
def waveNumHunt(T, h):
if type(T) == list:
T = np.array(T)
if type(h) == list:
h = np.array(h)
D = np.array([0.6666666666, 0.3555555555, 0.1608465608, 0.0632098765, 0.0217540484, 0.0065407983])
L0 = 9.81 * T**2 / (2.*np.pi)
k0 = 2. * np.pi / L0
k0h = k0 * h
aux = D[0] * k0h + D[1] * k0h**2 + D[2] * k0h**3 + D[3] * k0h**4 + D[4] * k0h**5 + D[5] * k0h**6
kh = k0h * np.sqrt( 1. + ( k0h * ( 1. + aux ))**-1 )
k = kh / h
L = 2. * np.pi / k
return L
#H = 0.01
#h = 0.4
#T = 1.0
H = float(input("Please enter H: "))
h = float(input("Please enter h: "))
T = float(input("Please enter T: "))
# Calculations
L = waveNumHunt(T, h)
print ('L =',L,'m')
g = 9.81
a = h/(g*pow(T,2.0))
b = H/(g*pow(T,2.0))
xMin = 5.34*pow(10,-4.0)
xMinPix = 402
xMax = 0.2
xMaxPix = 1977
yMin = 0.00005
yMinPix = 1865
yMax = 0.05
yMaxPix = 28
if a > xMax:
a = xMax
elif a < xMin:
a = xMin
if b > yMax:
b = yMax
elif b < yMin:
b = yMin
auxX = 612*log10(xMax/a)
auxY = 612*log10(b/yMin)
coordX = xMaxPix - auxX
coordY = yMinPix - auxY
# Plot
#figure(num=1, figsize=(40, 50), dpi=80)
pathname = os.path.abspath('.')
image1=Image.open('teoria.png')
arr=np.asarray(image1)
imshow(arr) #, aspect='auto')
#imsave('teoria1.png',image) #, image)
file_path='teoria1.png'
#im.save= (file_path)
#plt.imshow(arr.reshape([sqrtimg,sqrtimg]))
#plt.imsave(file_path, arr) #img.reshape([sqrtimg,sqrtimg]))
#import scipy.misc
#scipy.misc.imsave(file_path, arr)
'''
#Save pic
basewidth = 500
#img = Image.open('somepic.jpg')
wpercent = (basewidth/float(image.size[0]))
hsize = int((float(image.size[1])*float(wpercent)))
img = image.resize((basewidth,hsize), Image.ANTIALIAS)
#img.save('sompic.jpg')
'''
plot(coordX,coordY,'ro',markersize=12)
plot(coordX,coordY,'k.')
plot(coordX,coordY,'kx',markersize=12)
title('H = '+"%.2f"%H+' m; T = '+"%.2f"%T+' s; h = '+"%.2f"%h+' m.');
xlim(-30,2030)
ylim(2200,-30)
savefig(file_path,dpi=300)
show()