|
2 | 2 | import numpy as np
|
3 | 3 | import seawater as sw
|
4 | 4 |
|
| 5 | +# =========================================================== |
| 6 | +# SURFACE AGEOSTROPHIC VELOCITY |
| 7 | +# =========================================================== |
| 8 | +def curvature(ssh_grad, dxt, dyt): |
| 9 | + ''' Curvature of the sea surface height contours |
| 10 | + ============================================================================== |
| 11 | + INPUT: |
| 12 | + SSH = sea surface height gradient [Y,X] |
| 13 | + dxt = zonal distance between the grid cells in meter [Y,X] |
| 14 | + dyt = meridional distance between the grid cells in meter [Y,X] |
| 15 | +
|
| 16 | + OUTPUT: |
| 17 | + k = curvature of the flow |
| 18 | + ============================================================================== |
| 19 | + ''' |
| 20 | + |
| 21 | + ssh_grad_y, ssh_grad_x = ssh_grad[0], ssh_grad[1] |
| 22 | + |
| 23 | + # Terms in the norminator |
| 24 | + nominator_1st = (np.gradient(ssh_grad_y/dyt)[0]/dyt)*(ssh_grad_x/dxt)**2 |
| 25 | + nominator_2nd = (np.gradient(ssh_grad_x/dxt)[1]/dxt)*(ssh_grad_y/dyt)**2 |
| 26 | + nominator_3rd = 2*(np.gradient(ssh_grad_y/dyt)[1]/dxt)*(ssh_grad_x/dxt)*(ssh_grad_y/dyt) |
| 27 | + |
| 28 | + # Terms in the denominator |
| 29 | + denominator_1st = (ssh_grad_x/dxt)**2 |
| 30 | + denominator_2nd = (ssh_grad_y/dyt)**2 |
| 31 | + denominator = pow(denominator_1st + denominator_2nd, 3/2) |
| 32 | + |
| 33 | + k = (-1*nominator_1st - 1*nominator_2nd + 2*nominator_3rd)/denominator |
| 34 | + |
| 35 | + return k |
| 36 | + |
| 37 | +def ageostrophic_vel(LON, LAT, SSH): |
| 38 | + ''' Surface ageostrophic velocity from gradient wind balance through the |
| 39 | + combination of the surface geostrophic velocity and curvature of the flow |
| 40 | + ============================================================================== |
| 41 | + INPUT: |
| 42 | + LON = longitudes [Y,X] |
| 43 | + LAT = latitude [Y,X] |
| 44 | + SSH = sea surface height in meter [Y,X] |
| 45 | +
|
| 46 | + OUTPUT: |
| 47 | + u_ag_vel = zonal component of the surface ageostrophic velocity |
| 48 | + v_ag_vel = meridional component of the surface ageostrophic velocity |
| 49 | + ============================================================================== |
| 50 | + ''' |
| 51 | + g = 9.8 |
| 52 | + f = sw.f(LAT) |
| 53 | + [trash,dlonx] = np.gradient(LON) |
| 54 | + dx = dlonx*np.cos(LAT*np.pi/180)*111195. |
| 55 | + [dlaty,trash] = np.gradient(LAT) |
| 56 | + dy = dlaty*111195. |
| 57 | + SSH_gradient = np.gradient(SSH) |
| 58 | + k = curvature(SSH_gradient, dx, dy) |
| 59 | + |
| 60 | + ## Estimating the surface geostrophic velocity from SSH |
| 61 | + u_geo_vel = (-g/f)*(SSH_gradient[0]/dy) |
| 62 | + v_geo_vel = (g/f)*(SSH_gradient[1]/dx) |
| 63 | + ## Reconstructing the surface velocity from the combinantion of the geostrophic velocity and curvature of the flow |
| 64 | + u_total = (2*u_geo_vel)/(1 + np.sqrt(1 + 4*k*np.sqrt(u_geo_vel**2 + v_geo_vel**2)/f)) |
| 65 | + v_total = (2*v_geo_vel)/(1 + np.sqrt(1 + 4*k*np.sqrt(u_geo_vel**2 + v_geo_vel**2)/f)) |
| 66 | + ## Computing the surface ageostrophic velocity as the difference between the total and geostrophic fields |
| 67 | + u_ag_vel = u_total - u_geo_vel |
| 68 | + v_ag_vel = v_total - v_geo_vel |
| 69 | + |
| 70 | + return u_ag_vel, v_ag_vel |
| 71 | + |
5 | 72 | # ===========================================================
|
6 | 73 | # DYNAMICAL MODES AMPLITUDE
|
7 | 74 | # ===========================================================
|
|
0 commit comments