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

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