I am trying to store the results of v_tide for each time delta and for each grid point. I need to store the v_tide results which are dependent on the latitude, longitude and time.
If for example the time vector has dimensions 120x1, latitude 101x121 and longitude 101x121, then the dimensions of the v_tide matrix are 120x101x121.
northward_velocity = fes.Handler("ocean", "memory", configuration_file)
# eastward_velocity = fes.Handler("ocean", "memory", configuration_file)
# GRID
lats = np.arange(1, 2, 0.5)
lons = np.arange(-79, -78, 0.5)
assert lons.shape == lats.shape
size = lats.size
lons, lats = np.meshgrid(lons, lats)
# DATES
ai, mi, di = 2019, 6, 3
af, mf, df = 2019, 6, 4
dates = datetime(ai, mi, di)
step = timedelta(minutes=60)
# DATENUM
def datenum(dt):
mdn = dt + timedelta(days = 366)
frac = (dt - datetime(dt.year,dt.month,dt.day,0,0,0)).seconds/86400.0
return mdn.toordinal() + frac
dat=np.empty(lons.shape,dtype='datetime64[us]')
while dates < datetime(af, mf, df):
dat.fill(dates)
v_tide, _ = northward_velocity.vector(lats.ravel(), lons.ravel(), dat.ravel())
# u_tide, lp = eastward_velocity.vector(lats.ravel(), lons.ravel(), dates.ravel())
dates += step