source: trunk/SRC/Interpolation/angle.pro @ 259

Last change on this file since 259 was 259, checked in by pinsard, 17 years ago

improvment of links in idldoc outputs by modification of shell script and some pro files. add test for pro2href.sh. see 62

  • Property svn:keywords set to Id
File size: 8.5 KB
Line 
1
2;+
3;
4; @file_comments
5; north stereographic polar projection
6;
7; @categories
8; Interpolation
9;
10; @param plam {in}{required}
11; longitude position
12;
13; @param pphi {in}{required}
14; latitude position
15;
16; @keyword DOUBLE {default=0}
17; use double precision (default is float)
18;
19; @returns
20; structure: {x:x, y:y} containing the point position in north stereographic polar projection
21;
22; @hidden
23;
24;-
25;
26FUNCTION fsnspp, plam, pphi, DOUBLE = double
27;
28  compile_opt idl2, strictarrsubs
29;
30  IF keyword_set(double) THEN BEGIN
31    a = 2.d * tan( !dpi/4.d - !dpi/180.d*pphi/2.d )
32    x = cos( !dpi/180.d*plam ) * a
33    y = sin( !dpi/180.d*plam ) * a
34  ENDIF ELSE BEGIN
35    a = 2. * tan( !pi/4. - !pi/180.*float(pphi)/2. )
36    x = cos( !pi/180.*float(plam) ) * a
37    y = sin( !pi/180.*float(plam) ) * a
38  ENDELSE
39  RETURN, {x:x, y:y}
40END
41;
42;+
43;
44; @file_comments
45; Compute angles between grid lines and direction of the North pole
46;(fom angle.F,v 2.2 in OPA8.2)
47;
48; @categories
49; Interpolation
50;
51; @param fileocemesh {in}{required}{type=scalar string}
52; a netcdf file that contains (at least) the following variables:
53;        glamt, gphit: longitudes and latitudes at T-points
54;        glamu, gphiu: longitudes and latitudes at U-points
55;        glamv, gphiv: longitudes and latitudes at V-points
56;        glamf, gphif: longitudes and latitudes at F-points
57;
58; @param gcosu {out}{type=2d array}
59; cosinus of the angle between grid lines at U points and direction of the North pole
60;
61; @param gsinu {out}{type=2d array}
62; sinus of the angle between grid lines at U points and direction of the North pole
63;
64; @param gcosv {out}{type=2d array}
65; cosinus of the angle between grid lines at V points and direction of the North pole
66;
67; @param gsinv {out}{type=2d array}
68; sinus of the angle between grid lines at V points and direction of the North pole
69;
70; @param gcost {out}{type=2d array}
71; cosinus of the angle between grid lines at T points and direction of the North pole
72;
73; @param gsint {out}{type=2d array}
74; sinus of the angle between grid lines at T points and direction of the North pole
75;
76; @param gcosf {out}{type=2d array}
77; cosinus of the angle between grid lines at F points and direction of the North pole
78;
79; @param gsinf {out}{type=2d array}
80; sinus of the angle between grid lines at F points and direction of the North pole
81;
82; @keyword IODIRECTORY {type=scalar string}{default=''}
83; the directory path where is located fileocemesh
84;
85; @keyword DOUBLE {type=1 or 0}{default=0}
86; put 1 to use double precision (default is float)
87;
88; @restrictions
89; to compute the lateral boundary conditions, we assume that:
90;     (1) the first line is similar to the second line
91;       =>    gcosu[*, 0] = gcosu[*, 1]
92;       =>    gsinu[*, 0] = gsinu[*, 1]
93;     (2) the grid follows OPA x and north pole periodicity rule (see <pro>lbcorca</pro>)
94;
95; @history
96;       Original :  96-07 (O. Marti)
97;                   98-06 (G. Madec)
98;       Feb 2005: IDL adaptation S. Masson
99;       May 2007: F points + call to <pro>lbcorca</pro>
100;
101; @version
102; $Id$
103;
104;-
105;
106PRO angle, fileocemesh, gcosu, gsinu, gcosv, gsinv, gcost, gsint, gcosf, gsinf $
107           , IODIRECTORY = iodirectory, DOUBLE = double
108;
109  compile_opt idl2, strictarrsubs
110;
111; 0. read oceanic grid parameters
112; ================================
113;
114  IF keyword_set(IODIRECTORY) THEN BEGIN
115    IF  strpos(iodirectory,'/',/reverse_search) NE (strlen(iodirectory)-1) THEN $
116      iodirectory = iodirectory+'/'
117  ENDIF ELSE iodirectory = ''
118  fileoce = iodirectory+fileocemesh
119;
120  fileoce = findfile(fileoce, count = okfile)
121  IF okfile NE 1 THEN BEGIN
122    ras = report('the file '+fileoce+' is not found... we stop')
123    stop
124  ENDIF
125;
126  cdfido = ncdf_open(fileoce[0])
127  ncdf_varget, cdfido, 'glamt', glamt
128  ncdf_varget, cdfido, 'glamu', glamu
129  ncdf_varget, cdfido, 'glamv', glamv
130  ncdf_varget, cdfido, 'glamf', glamf
131  ncdf_varget, cdfido, 'gphit', gphit
132  ncdf_varget, cdfido, 'gphiu', gphiu
133  ncdf_varget, cdfido, 'gphiv', gphiv
134  ncdf_varget, cdfido, 'gphif', gphif
135  ncdf_close, cdfido
136;
137  glamt = reform(glamt, /over)
138  glamu = reform(glamu, /over)
139  glamv = reform(glamv, /over)
140  glamf = reform(glamf, /over)
141  gphit = reform(gphit, /over)
142  gphiu = reform(gphiu, /over)
143  gphiv = reform(gphiv, /over)
144  gphif = reform(gphif, /over)
145;
146  sz = size(glamf, /dimension)
147  jpi = sz[0]
148  jpj = sz[1]
149;
150; I. Compute the cosinus and sinus
151; ================================
152; (computation done on the north stereographic polar plan
153;
154;   ... north pole direction & modulous (at t-point)
155  znpt = fsnspp( glamt, gphit, DOUBLE = double )
156  glamt = -1 & gphit = -1; free memory
157  znpt.x = - znpt.x
158  znpt.y = - znpt.y
159  znnpt = znpt.x*znpt.x + znpt.y*znpt.y
160;   ... north pole direction & modulous (at u-point)
161  znpu = fsnspp( glamu, gphiu, DOUBLE = double )
162  znpu00 = znpu
163  znpu0i = fsnspp( shift(glamu, 0, -1), shift(gphiu, 0, -1), DOUBLE = double )
164  glamu = -1 & gphiu = -1; free memory
165  znpu.x = - znpu.x
166  znpu.y = - znpu.y
167  znnpu = znpu.x*znpu.x + znpu.y*znpu.y
168;   ... north pole direction & modulous (at v-point)
169  znpv = fsnspp( glamv, gphiv, DOUBLE = double )
170  znpv00 = znpv
171  znpv01 = fsnspp( shift(glamv, 0, 1), shift(gphiv, 0, 1), DOUBLE = double )
172  glamv = -1 & gphiv = -1; free memory
173  znpv.x = - znpv.x
174  znpv.y = - znpv.y
175  znnpv = znpv.x*znpv.x + znpv.y*znpv.y
176;   ... north pole direction & modulous (at f-point)
177  znpf = fsnspp( glamf, gphif, DOUBLE = double )
178  znpf00 = znpf
179  znpf01 = fsnspp( shift(glamf, 0, 1), shift(gphif, 0, 1), DOUBLE = double )
180  znpf10 = fsnspp( shift(glamf, 1, 0), shift(gphif, 1, 0), DOUBLE = double )
181  glamf = -1 & gphif = -1; free memory
182  znpf.x = - znpf.x
183  znpf.y = - znpf.y
184  znnpf = znpf.x*znpf.x + znpf.y*znpf.y
185;
186
187;   ... j-direction: v-point segment direction (t-point)
188  zxvvt = znpv00.x - znpv01.x
189  zyvvt = znpv00.y - znpv01.y
190  zmnpvt = sqrt ( temporary(znnpt) * ( zxvvt*zxvvt + zyvvt*zyvvt )  )
191  znpv00 = -1 & znpv01 = -1; free memory
192  IF keyword_set(double) THEN zmnpvt = 1.e-14 > zmnpvt $
193  ELSE zmnpvt = 1.e-6 > zmnpvt
194;   ... j-direction: f-point segment direction (u-point)
195  zxffu = znpf00.x - znpf01.x
196  zyffu = znpf00.y - znpf01.y
197  zmnpfu = sqrt ( temporary(znnpu) * ( zxffu*zxffu + zyffu*zyffu )  )
198  znpf01 = -1; free memory
199  IF keyword_set(double) THEN zmnpfu = 1.e-14 > zmnpfu $
200  ELSE zmnpfu = 1.e-6 > zmnpfu
201;   ... i-direction: f-point segment direction (v-point)
202  zxffv = znpf00.x - znpf10.x
203  zyffv = znpf00.y - znpf10.y
204  znpf00 = -1 & znpf10 = -1 ; free memory
205  zmnpfv = sqrt ( temporary(znnpv) * ( zxffv*zxffv + zyffv*zyffv )  )
206  IF keyword_set(double) THEN zmnpfv = 1.e-14 > zmnpfv $
207  ELSE zmnpfv = 1.e-6 > zmnpfv
208;   ... j-direction: u-point segment direction (f-point)
209  zxuuf = znpu0i.x - znpu00.x
210  zyuuf = znpu0i.y - znpu00.y
211  zmnpuf = sqrt ( temporary(znnpf) * ( zxuuf*zxuuf + zyuuf*zyuuf )  )
212  znpu00 = -1 & znpu0i = -1; free memory
213  IF keyword_set(double) THEN zmnpuf = 1.e-14 > zmnpuf $
214  ELSE zmnpuf = 1.e-6 > zmnpuf
215
216;   ... cosinus and sinus using scalar and vectorial products
217  gsint = ( znpt.x*zyvvt - znpt.y*zxvvt ) / zmnpvt
218  gcost = ( znpt.x*zxvvt + znpt.y*zyvvt ) / zmnpvt
219;   ... cosinus and sinus using scalar and vectorial products
220  gsinu = ( znpu.x*zyffu - znpu.y*zxffu ) / zmnpfu
221  gcosu = ( znpu.x*zxffu + znpu.y*zyffu ) / zmnpfu
222;   ... cosinus and sinus using scalar and vectorial products
223;       (caution, rotation of 90 degres)
224  gsinv =  ( znpv.x*zxffv + znpv.y*zyffv ) / zmnpfv
225  gcosv = -( znpv.x*zyffv - znpv.y*zxffv ) / zmnpfv
226;   ... cosinus and sinus using scalar and vectorial products
227  gsinf = ( znpf.x*zyuuf - znpf.y*zxuuf ) / zmnpuf
228  gcosf = ( znpf.x*zxuuf + znpf.y*zyuuf ) / zmnpuf
229;
230; II. Geographic mesh
231; ===================
232;
233;       bad = where(abs(glamf-shift(glamf, 0, 1)) LT 1.e-8)
234;       IF bad[0] NE -1 THEN BEGIN
235;         gcosu[bad] = 1.
236;         gsinu[bad] = 0.
237;       ENDIF
238;       bad = where(abs(gphif-shift(gphif, 1, 0)) LT 1.e-8)
239;       IF bad[0] NE -1 THEN BEGIN
240;         gcosv[bad] = 1.
241;         gsinv[bad] = 0.
242;       ENDIF
243;
244; III. Lateral boundary conditions
245; ================================
246;
247  gcost[*, 0] = gcost[*, 1]
248  gsint[*, 0] = gsint[*, 1]
249  gcosu[*, 0] = gcosu[*, 1]
250  gsinu[*, 0] = gsinu[*, 1]
251;
252  IF keyword_set(double) THEN sgn = 1.d ELSE sgn = 1.
253  dummy = lbcorca(gcost, 'T',  sgn, /correction)
254  dummy = lbcorca(gsint, 'T', -sgn, /correction)
255  dummy = lbcorca(gcosu, 'U',  sgn, /correction)
256  dummy = lbcorca(gsinu, 'U', -sgn, /correction)
257  dummy = lbcorca(gcosv, 'V',  sgn, /correction)
258  dummy = lbcorca(gsinv, 'V', -sgn, /correction)
259  dummy = lbcorca(gcosf, 'F',  sgn, /correction)
260  dummy = lbcorca(gsinf, 'F', -sgn, /correction)
261;
262
263  RETURN
264END
Note: See TracBrowser for help on using the repository browser.