@@ -28,12 +28,14 @@ def speed(u, v, xgrid, hboundary="extend", hfill_value=None):
28
28
for moving to rho grid.
29
29
From xgcm documentation:
30
30
A flag indicating how to handle boundaries:
31
+
31
32
* None: Do not apply any boundary conditions. Raise an error if
32
33
boundary conditions are required for the operation.
33
34
* 'fill': Set values outside the array boundary to fill_value
34
35
(i.e. a Neumann boundary condition.)
35
36
* 'extend': Set values outside the array to the nearest array
36
37
value. (i.e. a limited form of Dirichlet boundary condition.
38
+
37
39
hfill_value: float, optional
38
40
Passed to `grid` method calls; horizontal boundary fill value
39
41
selection for moving to rho grid.
@@ -122,19 +124,22 @@ def uv_geostrophic(zeta, f, xgrid, hboundary="extend", hfill_value=None, which="
122
124
for moving f to rho grid.
123
125
From xgcm documentation:
124
126
A flag indicating how to handle boundaries:
127
+
125
128
* None: Do not apply any boundary conditions. Raise an error if
126
129
boundary conditions are required for the operation.
127
130
* 'fill': Set values outside the array boundary to fill_value
128
131
(i.e. a Neumann boundary condition.)
129
132
* 'extend': Set values outside the array to the nearest array
130
133
value. (i.e. a limited form of Dirichlet boundary condition.
134
+
131
135
hfill_value: float, optional
132
136
Passed to `grid` method calls; horizontal boundary selection
133
137
for moving f to rho grid.
134
138
From xgcm documentation:
135
139
The value to use in the boundary condition with `boundary='fill'`.
136
140
which: string, optional
137
141
Which components of geostrophic velocity to return.
142
+
138
143
* 'both': return both components of hgrad
139
144
* 'xi': return only xi-direction.
140
145
* 'eta': return only eta-direction.
@@ -147,10 +152,16 @@ def uv_geostrophic(zeta, f, xgrid, hboundary="extend", hfill_value=None, which="
147
152
148
153
Notes
149
154
-----
150
- vg = g * zeta_eta / (d eta * f) # on v grid
151
- ug = -g * zeta_xi / (d xi * f) # on u grid
155
+
156
+ ug = -g * zeta_eta / (d eta * f) # on u grid
157
+
158
+ vg = g * zeta_xi / (d xi * f) # on v grid
159
+
152
160
Translation to Python of Matlab copy of surf_geostr_vel of IRD Roms_Tools.
153
161
162
+ Good resourcefor more information:
163
+ https://uw.pressbooks.pub/ocean285/chapter/geostrophic-balance/
164
+
154
165
Examples
155
166
--------
156
167
>>> xroms.uv_geostrophic(ds.zeta, ds.f, xgrid)
@@ -162,11 +173,13 @@ def uv_geostrophic(zeta, f, xgrid, hboundary="extend", hfill_value=None, which="
162
173
if which in ["both" , "xi" ]:
163
174
164
175
# calculate derivatives of zeta
165
- dzetadxi = hgrad (zeta , xgrid , which = "xi " )
176
+ dzetadeta = hgrad (zeta , xgrid , which = "eta" , hcoord = "u " )
166
177
167
178
# calculate geostrophic velocities
168
179
ug = (
169
- - g * dzetadxi / to_u (f , xgrid , hboundary = hboundary , hfill_value = hfill_value )
180
+ - g
181
+ * dzetadeta
182
+ / to_u (f , xgrid , hboundary = hboundary , hfill_value = hfill_value )
170
183
)
171
184
172
185
ug .attrs ["name" ] = "ug"
@@ -175,13 +188,12 @@ def uv_geostrophic(zeta, f, xgrid, hboundary="extend", hfill_value=None, which="
175
188
ug .name = ug .attrs ["name" ]
176
189
177
190
if which in ["both" , "eta" ]:
191
+
178
192
# calculate derivatives of zeta
179
- dzetadeta = hgrad (zeta , xgrid , which = "eta " )
193
+ dzetadxi = hgrad (zeta , xgrid , which = "xi" , hcoord = "v " )
180
194
181
195
# calculate geostrophic velocities
182
- vg = (
183
- g * dzetadeta / to_v (f , xgrid , hboundary = hboundary , hfill_value = hfill_value )
184
- )
196
+ vg = g * dzetadxi / to_v (f , xgrid , hboundary = hboundary , hfill_value = hfill_value )
185
197
186
198
vg .attrs ["name" ] = "vg"
187
199
vg .attrs ["long_name" ] = "geostrophic v velocity"
@@ -214,12 +226,14 @@ def EKE(ug, vg, xgrid, hboundary="extend", hfill_value=None):
214
226
for moving to rho grid.
215
227
From xgcm documentation:
216
228
A flag indicating how to handle boundaries:
229
+
217
230
* None: Do not apply any boundary conditions. Raise an error if
218
231
boundary conditions are required for the operation.
219
232
* 'fill': Set values outside the array boundary to fill_value
220
233
(i.e. a Neumann boundary condition.)
221
234
* 'extend': Set values outside the array to the nearest array
222
235
value. (i.e. a limited form of Dirichlet boundary condition.
236
+
223
237
hfill_value: float, optional
224
238
Passed to `grid` method calls; horizontal boundary selection
225
239
for moving to rho grid.
@@ -272,12 +286,14 @@ def dudz(u, xgrid, sboundary="extend", sfill_value=None):
272
286
calculating z derivative.
273
287
From xgcm documentation:
274
288
A flag indicating how to handle boundaries:
289
+
275
290
* None: Do not apply any boundary conditions. Raise an error if
276
291
boundary conditions are required for the operation.
277
292
* 'fill': Set values outside the array boundary to fill_value
278
293
(i.e. a Neumann boundary condition.)
279
294
* 'extend': Set values outside the array to the nearest array
280
295
value. (i.e. a limited form of Dirichlet boundary condition.
296
+
281
297
sfill_value: float, optional
282
298
Passed to `grid` method calls; vertical boundary fill value
283
299
associated with sboundary input.
@@ -321,12 +337,14 @@ def dvdz(v, xgrid, sboundary="extend", sfill_value=None):
321
337
calculating z derivative.
322
338
From xgcm documentation:
323
339
A flag indicating how to handle boundaries:
340
+
324
341
* None: Do not apply any boundary conditions. Raise an error if
325
342
boundary conditions are required for the operation.
326
343
* 'fill': Set values outside the array boundary to fill_value
327
344
(i.e. a Neumann boundary condition.)
328
345
* 'extend': Set values outside the array to the nearest array
329
346
value. (i.e. a limited form of Dirichlet boundary condition.
347
+
330
348
sfill_value: float, optional
331
349
Passed to `grid` method calls; vertical boundary fill value
332
350
associated with sboundary input.
@@ -372,12 +390,14 @@ def vertical_shear(dudz, dvdz, xgrid, hboundary="extend", hfill_value=None):
372
390
for moving dudz and dvdz to rho grid.
373
391
From xgcm documentation:
374
392
A flag indicating how to handle boundaries:
393
+
375
394
* None: Do not apply any boundary conditions. Raise an error if
376
395
boundary conditions are required for the operation.
377
396
* 'fill': Set values outside the array boundary to fill_value
378
397
(i.e. a Neumann boundary condition.)
379
398
* 'extend': Set values outside the array to the nearest array
380
399
value. (i.e. a limited form of Dirichlet boundary condition.
400
+
381
401
hfill_value: float, optional
382
402
Passed to `grid` method calls; horizontal boundary selection
383
403
for moving to rho grid.
@@ -439,12 +459,14 @@ def relative_vorticity(
439
459
for calculating horizontal derivatives of u and v.
440
460
From xgcm documentation:
441
461
A flag indicating how to handle boundaries:
462
+
442
463
* None: Do not apply any boundary conditions. Raise an error if
443
464
boundary conditions are required for the operation.
444
465
* 'fill': Set values outside the array boundary to fill_value
445
466
(i.e. a Neumann boundary condition.)
446
467
* 'extend': Set values outside the array to the nearest array
447
468
value. (i.e. a limited form of Dirichlet boundary condition.
469
+
448
470
hfill_value: float, optional
449
471
Passed to `grid` method calls; horizontal boundary selection
450
472
fill value.
@@ -455,12 +477,14 @@ def relative_vorticity(
455
477
for calculating horizontal derivatives of u and v.
456
478
From xgcm documentation:
457
479
A flag indicating how to handle boundaries:
480
+
458
481
* None: Do not apply any boundary conditions. Raise an error if
459
482
boundary conditions are required for the operation.
460
483
* 'fill': Set values outside the array boundary to fill_value
461
484
(i.e. a Neumann boundary condition.)
462
485
* 'extend': Set values outside the array to the nearest array
463
486
value. (i.e. a limited form of Dirichlet boundary condition.
487
+
464
488
sfill_value: float, optional
465
489
Passed to `grid` method calls; vertical boundary selection
466
490
fill value.
@@ -537,12 +561,14 @@ def convergence(
537
561
for calculating horizontal derivatives of u and v.
538
562
From xgcm documentation:
539
563
A flag indicating how to handle boundaries:
564
+
540
565
* None: Do not apply any boundary conditions. Raise an error if
541
566
boundary conditions are required for the operation.
542
567
* 'fill': Set values outside the array boundary to fill_value
543
568
(i.e. a Neumann boundary condition.)
544
569
* 'extend': Set values outside the array to the nearest array
545
570
value. (i.e. a limited form of Dirichlet boundary condition.
571
+
546
572
hfill_value: float, optional
547
573
Passed to `grid` method calls; horizontal boundary selection
548
574
fill value.
@@ -553,12 +579,14 @@ def convergence(
553
579
for calculating horizontal derivatives of u and v.
554
580
From xgcm documentation:
555
581
A flag indicating how to handle boundaries:
582
+
556
583
* None: Do not apply any boundary conditions. Raise an error if
557
584
boundary conditions are required for the operation.
558
585
* 'fill': Set values outside the array boundary to fill_value
559
586
(i.e. a Neumann boundary condition.)
560
587
* 'extend': Set values outside the array to the nearest array
561
588
value. (i.e. a limited form of Dirichlet boundary condition.
589
+
562
590
sfill_value: float, optional
563
591
Passed to `grid` method calls; vertical boundary selection
564
592
fill value.
@@ -660,12 +688,14 @@ def ertel(
660
688
horizontal grid changes too.
661
689
From xgcm documentation:
662
690
A flag indicating how to handle boundaries:
691
+
663
692
* None: Do not apply any boundary conditions. Raise an error if
664
693
boundary conditions are required for the operation.
665
694
* 'fill': Set values outside the array boundary to fill_value
666
695
(i.e. a Neumann boundary condition.)
667
696
* 'extend': Set values outside the array to the nearest array
668
697
value. (i.e. a limited form of Dirichlet boundary condition.
698
+
669
699
hfill_value: float, optional
670
700
Passed to `grid` method calls; horizontal boundary selection
671
701
fill value.
@@ -678,12 +708,14 @@ def ertel(
678
708
all vertical grid changes too.
679
709
From xgcm documentation:
680
710
A flag indicating how to handle boundaries:
711
+
681
712
* None: Do not apply any boundary conditions. Raise an error if
682
713
boundary conditions are required for the operation.
683
714
* 'fill': Set values outside the array boundary to fill_value
684
715
(i.e. a Neumann boundary condition.)
685
716
* 'extend': Set values outside the array to the nearest array
686
717
value. (i.e. a limited form of Dirichlet boundary condition.
718
+
687
719
sfill_value: float, optional
688
720
Passed to `grid` method calls; vertical boundary selection
689
721
fill value.
0 commit comments