Commit 6f73ee4b authored by Philippe Delandmeter's avatar Philippe Delandmeter
Browse files

Merge branch 'tpxo_velocities' into 'master'

tpxo: flag to get tidal velocity instead of transport

See merge request !98
parents d309afee 750cd0fa
Pipeline #2224 failed with stage
in 31 minutes and 29 seconds
......@@ -532,14 +532,11 @@ def read_temporal_serie(file_name, time=None, output_netcdf=None):
write_file(output_netcdf[0], region=None, time=time, data=[(output_netcdf[1], valVec)])
return (time, valVec)
def tpxo_tide(region, time, data_file_name=None):
def tpxo_tide(region, time, data_file_name=None, export_as_transport=True):
"""Give TPXO tides data
This function will download the files tpxo and generate the data at the requested time steps.
It will return the tpxo tides as variables (ssh, ssu, ssv)
It will return the tpxo tides as variables (ssh, u, v) with u and v as transport (default) or velocity
keyword arguments:
......@@ -549,6 +546,8 @@ def tpxo_tide(region, time, data_file_name=None):
Time object of the instant at which put the data
* data_file_name
name of the netcdf data file where tides are exported (optional)
* export_transport
flag to specify whether exports are water transport [m^2/s] (True) or velocity [m/s] (False) (default: True)
lonlat = Coordinate_system(region, data_proj='+proj=latlong +ellps=WGS84')
h = u = v = np.empty((1,1))
......@@ -557,8 +556,11 @@ def tpxo_tide(region, time, data_file_name=None):
h_file_name = slim_private.dgftp.get( ("/slim_data/tides/%s" % h_file_name) )
u_file_name = slim_private.dgftp.get( ("/slim_data/tides/%s" % u_file_name) )
tide_ssh = dgpy.slimFunctionTpxo(h_file_name,'ha','hp','lon_z','lat_z')
tide_u = dgpy.slimFunctionTpxo(u_file_name,'Ua','up','lon_u','lat_u')
tide_v = dgpy.slimFunctionTpxo(u_file_name,'Va','vp','lon_v','lat_v')
varUtpxo = 'Ua' if export_as_transport else 'ua'
varVtpxo = 'Va' if export_as_transport else 'va'
factor = 1 if export_as_transport else 0.01 # from cm/s to m/s for velocities
tide_u = dgpy.slimFunctionTpxo(u_file_name,varUtpxo,'up','lon_u','lat_u')
tide_v = dgpy.slimFunctionTpxo(u_file_name,varVtpxo,'vp','lon_v','lat_v')
if not region._empty:
lonlat_coordinates = lonlat.coordinates * 180 / np.pi
n = np.size(time._time)
......@@ -569,8 +571,8 @@ def tpxo_tide(region, time, data_file_name=None):
v = np.empty((n,m))
for i in range(n):
h[i,:] = tide_ssh.getAtPoints(lonlat_coordinates, time._time[i])[:,0]
u[i,:] = tide_u.getAtPoints(lonlat_coordinates, time._time[i])[:,0]
v[i,:] = tide_v.getAtPoints(lonlat_coordinates, time._time[i])[:,0]
u[i,:] = factor*np.array(tide_u.getAtPoints(lonlat_coordinates, time._time[i]))[:,0]
v[i,:] = factor*np.array(tide_v.getAtPoints(lonlat_coordinates, time._time[i]))[:,0]
(u, v) = lonlat.rotate(u,v)
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment