1 #====================================================================== |
1 #====================================================================== |
2 # L I B G M . P L |
2 # L I B G M . P L |
3 # doc: Sun Feb 20 14:43:47 2011 |
3 # doc: Sun Feb 20 14:43:47 2011 |
4 # dlm: Sat Apr 20 20:05:51 2013 |
4 # dlm: Tue Nov 18 12:42:30 2014 |
5 # (c) 2011 A.M. Thurnherr |
5 # (c) 2011 A.M. Thurnherr |
6 # uE-Info: 62 0 NIL 0 0 72 2 2 4 NIL ofnI |
6 # uE-Info: 22 53 NIL 0 0 70 2 2 4 NIL ofnI |
7 #====================================================================== |
7 #====================================================================== |
8 |
8 |
9 # HISTORY: |
9 # HISTORY: |
10 # Feb 20, 2011: - created |
10 # Feb 20, 2011: - created |
11 # Feb 28, 2011: - cosmetics |
11 # Feb 28, 2011: - cosmetics |
16 # - return nan for omega outside internal-wave band |
16 # - return nan for omega outside internal-wave band |
17 # Mar 29, 2012: - re-wrote using definition of B(omega) from Munk (1981) |
17 # Mar 29, 2012: - re-wrote using definition of B(omega) from Munk (1981) |
18 # Aug 23, 2012: - cosmetics? |
18 # Aug 23, 2012: - cosmetics? |
19 # Sep 7, 2012: - made N0, E0, b, jstar global |
19 # Sep 7, 2012: - made N0, E0, b, jstar global |
20 # Dec 28, 2012: - added allowance for small roundoff error to Sw() |
20 # Dec 28, 2012: - added allowance for small roundoff error to Sw() |
|
21 # Oct 6, 2014: - made omega optional in Sw() |
|
22 # Nov 18, 2014: - made b & jstar mandatory for Sw() |
21 |
23 |
22 require "$ANTS/libEOS83.pl"; |
24 require "$ANTS/libEOS83.pl"; |
23 |
25 |
24 my($pi) = 3.14159265358979; |
26 my($pi) = 3.14159265358979; |
25 |
27 |
51 # level. Interestingly, the only N dependence is in m and m*. As far |
53 # level. Interestingly, the only N dependence is in m and m*. As far |
52 # as I know, little is known about its intermittency compared to horizontal |
54 # as I know, little is known about its intermittency compared to horizontal |
53 # velocity. Since w WKB-scales inversely with N, the largest signals should |
55 # velocity. Since w WKB-scales inversely with N, the largest signals should |
54 # be in the abyss where you therefore likely have the best chance of |
56 # be in the abyss where you therefore likely have the best chance of |
55 # measuring it. |
57 # measuring it. |
|
58 # |
|
59 # E. Kunze (email, Sep 19, 2013): |
|
60 # |
|
61 # S[w](omega, m) = PI*E0*b*[f*sqrt(omega^2-f^2)/omega]*[jstar/(m+mstar)^2] with |
|
62 # |
|
63 # S[w](m) = PI*E0*b*N*f*[jstar/(m+mstar)^2] |
|
64 # |
|
65 # where the nondimensional spectral energy level E0 = 6.3e-5, stratification |
|
66 # lengthscale b = 1500 m, jstar = 3, mstar = jstar*PI*N/b/N0, and N0 = |
|
67 # 5.3e-3 rad/s. |
|
68 # |
|
69 # NOTES: |
|
70 # - b=1500m is a likely typo, as Gregg & Kunze (1991) have b=1300m |
|
71 # - k_z == m |
|
72 # |
56 #====================================================================== |
73 #====================================================================== |
57 |
74 |
58 sub m($$) # vertical wavenumber as a function of mode number & stratification params |
75 sub m($$) # vertical wavenumber as a function of mode number & stratification params |
59 { |
76 { |
60 my($j,$N,$omega) = @_; |
77 my($j,$N,$omega) = @_; |
61 |
78 |
62 return defined($omega) && ($omega <= $GM_N0) |
79 return defined($omega) && ($omega <= $GM_N0) |
63 ? $pi / $GM_b * sqrt(($N**2 - $omega**2) / ($GM_N0**2 - $omega**2)) * $j |
80 ? $pi / $GM_b * sqrt(($N**2 - $omega**2) / ($GM_N0**2 - $omega**2)) * $j |
64 : $pi * $j * $N / ($GM_b * $GM_N0); # valid, except in vicinity of buoyancy turning frequency (p. 285) |
81 : $pi * $j * $N / ($GM_b * $GM_N0); # valid, except in vicinity of buoyancy turning frequency (Munk 1981, p.285) |
65 } |
82 } |
66 |
83 |
67 sub B($) # structure function (omega dependence) |
84 sub B($) # structure function (omega dependence) |
68 { # NB: f must be defined |
85 { # NB: f must be defined |
69 my($omega) = @_; |
86 my($omega) = @_; |
71 unless defined($f); |
88 unless defined($f); |
72 return 2 / $pi * $f / $omega / sqrt($omega**2 - $f**2); |
89 return 2 / $pi * $f / $omega / sqrt($omega**2 - $f**2); |
73 } |
90 } |
74 |
91 |
75 |
92 |
76 sub Sw($$$$) |
93 sub Sw(@) |
77 { |
94 { |
78 my($omega,$m,$lat,$N) = &antsFunUsage(4,'fff','<frequency[1/s]> <vertical wavenumber[rad/m]> <lat[deg]> <N[rad/s]>',@_); |
95 my($omega,$m,$lat,$b,$jstar,$N) = |
|
96 &antsFunUsage(-5,'fff','[frequency[1/s]] <vertical wavenumber[rad/m]> <lat[deg]> <N[rad/s]> <b[m]> <j*>',@_); |
79 |
97 |
80 local($f) = abs(&f($lat)); |
98 if (defined($N)) { # Sw(omega,m) |
81 $omega += $PRACTICALLY_ZERO if ($omega < $f); |
99 local($f) = abs(&f($lat)); |
82 $omega -= $PRACTICALLY_ZERO if ($omega > $N); |
100 $omega += $PRACTICALLY_ZERO if ($omega < $f); |
83 return nan if ($omega < $f || $omega > $N); |
101 $omega -= $PRACTICALLY_ZERO if ($omega > $N); |
84 |
102 return nan if ($omega < $f || $omega > $N); |
85 my($GM_b) = 1300; #m # pycnocline lengthscale |
103 my($mstar) = &m($jstar,$N,$omega); |
86 |
104 return $GM_E0 * $b * 2 * $f**2/$omega**2/B($omega) * $jstar / ($m+$mstar)**2; |
87 my($mstar) = &m($GM_jstar,$N,$omega); |
105 } else { # Sw(m) |
88 |
106 $N = $lat; # shift arguments to account for missing omega |
89 return $GM_E0 * $GM_b * 2 * $f**2/$omega**2/B($omega) * $GM_jstar / ($m+$mstar)**2; |
107 $lat = $m; |
|
108 local($f) = abs(&f($lat)); |
|
109 $m = $omega; |
|
110 undef($omega); |
|
111 my($mstar) = &m($jstar,$N); |
|
112 return $pi * $GM_E0 * $b * $N * $f * $jstar / ($m+$mstar)**2; |
|
113 } |
90 } |
114 } |
91 |
115 |
92 #---------------------------------------------------------------------- |
116 #---------------------------------------------------------------------- |
93 # GM76, as per Gregg and Kunze (JGR 1991) |
117 # GM76, as per Gregg and Kunze (JGR 1991) |
94 # - beta is vertical wavenumber (m above) |
118 # - beta is vertical wavenumber (m above) |