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

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

improvements/corrections of some *.pro headers

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