-
Notifications
You must be signed in to change notification settings - Fork 8
/
Copy pathtestOTIS.py
42 lines (30 loc) · 1.04 KB
/
testOTIS.py
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
import otis_tide_pred as otp
import numpy as np
import matplotlib.pyplot as plt
import datetime
modfile = './DATA/Model_haw'
# test ordinal dates
dates = [datetime.datetime(2001, 4, 3),
datetime.datetime(2001, 4, 4),
datetime.datetime(2001, 4, 5)]
lon = np.array([198, 199, ])
lat = np.array([21, 19])
dates = np.array([datetime.datetime.toordinal(d) for d in dates])
h, u, v = otp.tide_pred(modfile, lon, lat, dates,conlist=None)
# test datetime dates
dates = [datetime.datetime(2001, 4, 3),
datetime.datetime(2001, 4, 4),
datetime.datetime(2001, 4, 5)]
lon = np.array([198, 199, ])
lat = np.array([21, 19])
h, u, v = otp.tide_pred(modfile, lon, lat, dates,conlist=None)
# test numpy datetime64 dates
dates = np.arange(np.datetime64('2001-04-03'),
np.datetime64('2001-05-03'), dtype='datetime64[h]' )
lon = np.array([198, 199, ])
lat = np.array([21, 19])
h, u, v = otp.tide_pred(modfile, lon, lat, dates,conlist=None)
print(np.shape(h))
fig, ax = plt.subplots()
ax.plot(dates, u, dates, v)
plt.show()