[59] | 1 | ;+ |
---|
[232] | 2 | ; |
---|
[136] | 3 | ; @file_comments |
---|
[125] | 4 | ; north stereographic polar projection |
---|
[59] | 5 | ; |
---|
[231] | 6 | ; @categories |
---|
[157] | 7 | ; Interpolation |
---|
| 8 | ; |
---|
[118] | 9 | ; @param plam {in}{required} |
---|
[202] | 10 | ; longitude position |
---|
[59] | 11 | ; |
---|
[125] | 12 | ; @param pphi {in}{required} |
---|
[202] | 13 | ; latitude position |
---|
[118] | 14 | ; |
---|
[136] | 15 | ; @keyword DOUBLE {default=0} |
---|
| 16 | ; use double precision (default is float) |
---|
[118] | 17 | ; |
---|
[101] | 18 | ; @returns |
---|
[262] | 19 | ; structure: {x:x, y:y} containing the point position in north stereographic |
---|
| 20 | ; polar projection |
---|
[59] | 21 | ; |
---|
[202] | 22 | ; @hidden |
---|
[59] | 23 | ; |
---|
| 24 | ;- |
---|
| 25 | ; |
---|
| 26 | FUNCTION fsnspp, plam, pphi, DOUBLE = double |
---|
[114] | 27 | ; |
---|
| 28 | compile_opt idl2, strictarrsubs |
---|
| 29 | ; |
---|
[59] | 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 |
---|
[125] | 37 | y = sin( !pi/180.*float(plam) ) * a |
---|
[59] | 38 | ENDELSE |
---|
| 39 | RETURN, {x:x, y:y} |
---|
| 40 | END |
---|
[242] | 41 | ; |
---|
[101] | 42 | ;+ |
---|
[238] | 43 | ; |
---|
| 44 | ; @file_comments |
---|
| 45 | ; Compute angles between grid lines and direction of the North pole |
---|
[101] | 46 | ;(fom angle.F,v 2.2 in OPA8.2) |
---|
| 47 | ; |
---|
[231] | 48 | ; @categories |
---|
[202] | 49 | ; Interpolation |
---|
| 50 | ; |
---|
| 51 | ; @param fileocemesh {in}{required}{type=scalar string} |
---|
| 52 | ; a netcdf file that contains (at least) the following variables: |
---|
[247] | 53 | ; glamt, gphit: longitudes and latitudes at T-points |
---|
[101] | 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 | ; |
---|
[202] | 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 | ; |
---|
[247] | 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 | ; |
---|
[202] | 82 | ; @keyword IODIRECTORY {type=scalar string}{default=''} |
---|
| 83 | ; the directory path where is located fileocemesh |
---|
| 84 | ; |
---|
[247] | 85 | ; @keyword DOUBLE {type=1 or 0}{default=0} |
---|
[202] | 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] |
---|
[259] | 93 | ; (2) the grid follows OPA x and north pole periodicity rule (see <pro>lbcorca</pro>) |
---|
[202] | 94 | ; |
---|
| 95 | ; @history |
---|
| 96 | ; Original : 96-07 (O. Marti) |
---|
| 97 | ; 98-06 (G. Madec) |
---|
| 98 | ; Feb 2005: IDL adaptation S. Masson |
---|
[259] | 99 | ; May 2007: F points + call to <pro>lbcorca</pro> |
---|
[202] | 100 | ; |
---|
[231] | 101 | ; @version |
---|
| 102 | ; $Id$ |
---|
[238] | 103 | ; |
---|
[101] | 104 | ;- |
---|
[59] | 105 | ; |
---|
[247] | 106 | PRO angle, fileocemesh, gcosu, gsinu, gcosv, gsinv, gcost, gsint, gcosf, gsinf $ |
---|
[59] | 107 | , IODIRECTORY = iodirectory, DOUBLE = double |
---|
| 108 | ; |
---|
[238] | 109 | compile_opt idl2, strictarrsubs |
---|
| 110 | ; |
---|
[59] | 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 |
---|
[236] | 122 | ras = report('the file '+fileoce+' is not found... we stop') |
---|
[59] | 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 | ; |
---|
[247] | 146 | sz = size(glamf, /dimension) |
---|
| 147 | jpi = sz[0] |
---|
| 148 | jpj = sz[1] |
---|
| 149 | ; |
---|
[59] | 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 ) |
---|
[247] | 162 | znpu00 = znpu |
---|
| 163 | znpu0i = fsnspp( shift(glamu, 0, -1), shift(gphiu, 0, -1), DOUBLE = double ) |
---|
[59] | 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 |
---|
[247] | 176 | ; ... north pole direction & modulous (at f-point) |
---|
| 177 | znpf = fsnspp( glamf, gphif, DOUBLE = double ) |
---|
| 178 | znpf00 = znpf |
---|
[59] | 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 |
---|
[247] | 182 | znpf.x = - znpf.x |
---|
| 183 | znpf.y = - znpf.y |
---|
| 184 | znnpf = znpf.x*znpf.x + znpf.y*znpf.y |
---|
| 185 | ; |
---|
| 186 | |
---|
[59] | 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 ) ) |
---|
[247] | 191 | znpv00 = -1 & znpv01 = -1; free memory |
---|
[59] | 192 | IF keyword_set(double) THEN zmnpvt = 1.e-14 > zmnpvt $ |
---|
[125] | 193 | ELSE zmnpvt = 1.e-6 > zmnpvt |
---|
[59] | 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 $ |
---|
[125] | 200 | ELSE zmnpfu = 1.e-6 > zmnpfu |
---|
[59] | 201 | ; ... i-direction: f-point segment direction (v-point) |
---|
| 202 | zxffv = znpf00.x - znpf10.x |
---|
[125] | 203 | zyffv = znpf00.y - znpf10.y |
---|
[247] | 204 | znpf00 = -1 & znpf10 = -1 ; free memory |
---|
[59] | 205 | zmnpfv = sqrt ( temporary(znnpv) * ( zxffv*zxffv + zyffv*zyffv ) ) |
---|
| 206 | IF keyword_set(double) THEN zmnpfv = 1.e-14 > zmnpfv $ |
---|
[125] | 207 | ELSE zmnpfv = 1.e-6 > zmnpfv |
---|
[247] | 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 | |
---|
[59] | 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 |
---|
[247] | 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 |
---|
[59] | 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 | ; |
---|
[125] | 247 | gcost[*, 0] = gcost[*, 1] |
---|
| 248 | gsint[*, 0] = gsint[*, 1] |
---|
| 249 | gcosu[*, 0] = gcosu[*, 1] |
---|
| 250 | gsinu[*, 0] = gsinu[*, 1] |
---|
[59] | 251 | ; |
---|
[247] | 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 | |
---|
[59] | 263 | RETURN |
---|
| 264 | END |
---|