source: trunk/SRC/Computation/bsf.pro @ 493

Last change on this file since 493 was 493, checked in by pinsard, 10 years ago

fix some typos in comments

  • Property svn:keywords set to Id
File size: 3.9 KB
Line 
1;+
2;
3; @file_comments
4; compute the barotropic (along the model grid) stream function in Sv using
5; the following equation: total(total(e2u*e3u*un),3), 2, /cumulative)/1.e6
6;
7; @categories
8; diagnostics
9;
10; @param z3d {in} {type=3D xyz array}
11; zonal velocity
12;
13; @keyword NOSTRUCTURE {default=0}{type=scalar: 0 or 1}
14; activate if you do not want that msf returns a structure
15; but only the array referring to the field.
16;
17; @keyword REFPOINT {type=2 element vector}
18; a 2 element vector [x,y] giving the (approximative) position of the
19; point that should be taken as a reference. This position should be
20; given with the same coordinates system as the one used in
21; glam/gphi. see example
22;
23; @keyword REFVALUE {type=scalar} {default=0.}
24; the bsf value that we want to specify at the position defined by refpoint
25;
26; @keyword TRANSPORT {type=scalar: 0 or 1} {default=0.}
27; activate to specify that z3d is not a zonal current but a zonal
28; transport (e2u*e3u*un)
29;
30; @returns {type=2D xy array}
31; barotropic stream function in Sv
32;
33; @uses
34; <pro>cm_4mesh</pro>
35; <pro>cm_4data</pro>
36; <pro>grille</pro>
37; <pro>litchamp</pro>
38; <pro>fitintobox</pro>
39;
40; @restrictions
41; - T and U boxzoom parameters must be the same
42; - to be valid, mask must be equal to 0 at the bottom and on each
43;   side of the domain along x direction
44; - define the common variables (of cm_4data)
45;       varname = 'BSF'
46;       varunit = 'Sv'
47;       vargrid = 'F'
48;
49; @examples
50;
51;   IDL> initorca05
52;   IDL> file = '/Volumes/pim/F31/oce/1y/F31_1y_0040_0040_grid_U.nc'
53;   IDL> un = read_ncdf('vozocrtx', 0, 0, /timestep, file = file)
54;   IDL> bar = bsf(un, refvalue = 0., refpoint = [0, 20])
55;   IDL> plt, bar, -150, 150, int = 10, style = 'so0so', format = '(i4)', lct = 64
56;
57; @history
58; Gurvan Madec, Christian Ethe, Claude Talandier and Sebastien Masson, Dec 2008
59;
60; @version
61; $Id$
62;
63;-
64;
65FUNCTION bsf, z3d, NOSTRUCTURE = nostructure, REFPOINT = refpoint, REFVALUE = refvalue, TRANSPORT = transport
66;
67  compile_opt idl2, strictarrsubs
68;
69@cm_4mesh
70@cm_4data
71;
72  CASE 1 OF
73    firstxt NE firstxu OR lastxt NE lastxu: return, report('T and U box must be defined over the same x indexes, use /memeindices when calling domdef')
74    firstyt NE firstyu OR lastyt NE lastyu: return, report('T and U box must be defined over the same y indexes, use /memeindices when calling domdef')
75    ELSE:
76  ENDCASE
77;
78  grille, -1, -1, -1, -1, nx, ny, nz, firstx, firsty, firstz, lastx, lasty, lastz, grid = 'T'
79  umsk = (umask())[firstx:lastx, firsty:lasty, firstz:lastz]
80  IF total(umsk[*, *, nz-1]) NE 0 THEN return, report('The bottom of the box (defined by lastzt) must be set to land value (=0)')
81  IF total(umsk[*, 0, *]) NE 0 THEN return, report('southern boundary must be land point if you want to compute the bsf with this function')
82;
83  un = litchamp(z3d)
84  IF size(un, /n_dimensions) NE 3 THEN return, report('input data must be a 3D array')
85  un = fitintobox(temporary(un))
86;
87; current -> transport
88  IF NOT keyword_set(transport) THEN un = temporary(un) * e3u_3d(/e2)
89  utr = temporary(umsk) * temporary(un)
90; compute the bsf
91  bsf = 1.e-6 * total(total(temporary(utr), 3), 2, /cumulative)
92; set bsf to 0 in the largest continent... no done...
93  IF keyword_set(refpoint) THEN BEGIN
94    refind = neighbor(refpoint[0], refpoint[1], glamf[firstx:lastx, firsty:lasty], gphif[firstx:lastx, firsty:lasty], SPHERE = key_onearth)
95    IF n_elements(refvalue) EQ 0 THEN refval = - bsf[refind[0]] ELSE refval = refvalue - bsf[refind[0]]
96    bsf = temporary(bsf) + refval
97  ENDIF
98  IF keyword_set(flagdata) THEN bsf[nx-1, *] = !values.f_nan
99;
100; update data informations
101  varname = 'BSF'
102  varunit = 'Sv'
103  vargrid = 'F'
104;
105  IF keyword_set(nostructure) THEN return, bsf
106
107  IF keyword_set(key_forgetold) THEN BEGIN
108    return, {arr:temporary(bsf), grid:vargrid, unit:varunit, experiment:varexp, name:varname}
109  ENDIF ELSE BEGIN
110    return, {tab:temporary(bsf), grille:vargrid, unite:varunit, experience:varexp, nom:varname}
111  ENDELSE
112
113END
Note: See TracBrowser for help on using the repository browser.