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