Changeset 202 for trunk/SRC/Interpolation
- Timestamp:
- 01/12/07 12:00:06 (17 years ago)
- Location:
- trunk/SRC/Interpolation
- Files:
-
- 1 added
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/SRC/Interpolation/angle.pro
r157 r202 8 8 ; 9 9 ; @param plam {in}{required} 10 ; longitude position 10 11 ; 11 12 ; @param pphi {in}{required} 13 ; latitude position 12 14 ; 13 15 ; @keyword DOUBLE {default=0} … … 15 17 ; 16 18 ; @returns 17 ; gsinu,gcosu : sinus and cosinus of the angle 18 ; gsinv,gcosv between north-south direction 19 ; gsint,gcost and the j-direction of the mesh 20 ; 21 ; @restrictions 22 ; to compute the lateral boundary conditions, we assume that: 23 ; (1) the first line is similar to the second line 24 ; => gcosu[*, 0] = gcosu[*, 1] 25 ; => gsinu[*, 0] = gsinu[*, 1] 26 ; (2) the grid follows OPA x periodicity rule, first column is 27 ; equal to the next to last column 28 ; => gcosv[0, *] = gcosv[jpj-2, *] 29 ; => gsinv[0, *] = gsinv[jpj-2, *] 30 ; 31 ; 32 ; @history 33 ; Original : 96-07 (O. Marti) 34 ; 98-06 (G. Madec) 35 ; Feb 2005: IDL adaptation S. Masson 36 ; 37 ; @version $Id$ 19 ; structure: {x:x, y:y} containing the point position in north stereographic polar projection 20 ; 21 ; @hidden 38 22 ; 39 23 ;- … … 56 40 ;--------- 57 41 ;+ 58 ; @file_comments Compute angles between grid lines and direction of the North 42 ; @file_comments Compute angles between grid lines and direction of the North pole 59 43 ;(fom angle.F,v 2.2 in OPA8.2) 60 44 ; 61 ; @param fileocemesh {in}{required} a netcdf file that contains (at least): 45 ; @categories 46 ; Interpolation 47 ; 48 ; @param fileocemesh {in}{required}{type=scalar string} 49 ; a netcdf file that contains (at least) the following variables: 62 50 ; glamu, gphiu: longitudes and latitudes at U-points 63 51 ; glamv, gphiv: longitudes and latitudes at V-points 64 52 ; glamf, gphif: longitudes and latitudes at F-points 65 53 ; 66 ; @param gcosu {in}{required} 67 ; @param gsinu {in}{required} 68 ; @param gcosv {in}{required} 69 ; @param gsinv {in}{required} 70 ; @param gcost {in}{required} 71 ; @param gsint {in}{required} 72 ; @keyword IODIRECTORY the directory path where is located fileocemesh 73 ; @keyword DOUBLE {default=0} use double precision (default is float) 54 ; @param gcosu {out}{type=2d array} 55 ; cosinus of the angle between grid lines at U points and direction of the North pole 56 ; 57 ; @param gsinu {out}{type=2d array} 58 ; sinus of the angle between grid lines at U points and direction of the North pole 59 ; 60 ; @param gcosv {out}{type=2d array} 61 ; cosinus of the angle between grid lines at V points and direction of the North pole 62 ; 63 ; @param gsinv {out}{type=2d array} 64 ; sinus of the angle between grid lines at V points and direction of the North pole 65 ; 66 ; @param gcost {out}{type=2d array} 67 ; cosinus of the angle between grid lines at T points and direction of the North pole 68 ; 69 ; @param gsint {out}{type=2d array} 70 ; sinus of the angle between grid lines at T points and direction of the North pole 71 ; 72 ; @keyword IODIRECTORY {type=scalar string}{default=''} 73 ; the directory path where is located fileocemesh 74 ; 75 ; @keyword DOUBLE {type=1 ou 2}{default=0} 76 ; put 1 to use double precision (default is float) 77 ; 78 ; @restrictions 79 ; to compute the lateral boundary conditions, we assume that: 80 ; (1) the first line is similar to the second line 81 ; => gcosu[*, 0] = gcosu[*, 1] 82 ; => gsinu[*, 0] = gsinu[*, 1] 83 ; (2) the grid follows OPA x periodicity rule, first column is 84 ; equal to the next to last column 85 ; => gcosv[0, *] = gcosv[jpj-2, *] 86 ; => gsinv[0, *] = gsinv[jpj-2, *] 87 ; 88 ; @history 89 ; Original : 96-07 (O. Marti) 90 ; 98-06 (G. Madec) 91 ; Feb 2005: IDL adaptation S. Masson 92 ; 93 ; @version $Id$ 74 94 ;- 75 95 ;--------- -
trunk/SRC/Interpolation/compute_fromirr_bilinear_weigaddr.pro
r157 r202 8 8 ; Interpolation 9 9 ; 10 ; @param olonin {in}{required} 10 ; @param olonin {in}{required}{type=2d array} 11 11 ; longitude of the input data 12 12 ; 13 ; @param olat {in}{required} 13 ; @param olat {in}{required}{type=2d array} 14 14 ; latitude of the input data 15 15 ; 16 ; @param omsk {in}{required} 16 ; @param omsk {in}{required}{type=2d array or -1} 17 17 ; land/sea mask of the input data 18 ; 19 ; @param alonin {in}{required} 18 ; put -1 if input data are not masked 19 ; 20 ; @param alonin {in}{required}{type=2d array} 20 21 ; longitude of the output data 21 22 ; 22 ; @param alat {in}{required} 23 ; @param alat {in}{required}{type=2d array} 23 24 ; latitude of the output data 24 25 ; 25 ; @param amsk {in}{required} 26 ; @param amsk {in}{required}{type=2d array or -1} 26 27 ; land/sea mask of the output data 27 ; 28 ; @param weig {out} 29 ; @param addr {out} 28 ; put -1 if output data are not masked 29 ; 30 ; @param weig {out}{type=2d array} 31 ; (see ADDR) 32 ; 33 ; @param addr {out}{type=2d array} 30 34 ; 2D arrays, weig and addr are the weight and addresses used to 31 35 ; perform the interpolation: … … 44 48 ; and the weight is redistributed on the remaining "water" corners 45 49 ; - points located out of the southern and northern boundaries or in cells 46 ; containing only land points are set the the same value as their closest neighbor l50 ; containing only land points are set the the same value as their closest neighbor 47 51 ; 48 52 ; @history … … 61 65 ; 62 66 jpio = (size(olonin, /dimensions))[0] 63 jpjo = (size(olonin, /dimensions))[1] 67 jpjo = (size(olonin, /dimensions))[1] 68 ; mask check 69 IF n_elements(omsk) EQ 1 AND omsk[0] EQ -1 THEN omsk = replicate(1b, jpio, jpjo) 70 IF n_elements(amsk) EQ 1 AND amsk[0] EQ -1 THEN amsk = replicate(1b, jpia, jpja) 71 IF n_elements(omsk) NE jpio*jpjo THEN BEGIN 72 print, 'input grid mask do not have the good size' 73 stop 74 ENDIF 75 IF n_elements(amsk) NE jpia*jpja THEN BEGIN 76 print, 'output grid mask do not have the good size' 77 stop 78 ENDIF 64 79 ; 65 80 ; longitude, between 0 and 360 … … 71 86 IF out[0] NE -1 THEN olon[out] = olon[out]+360 72 87 ; 73 ; we work only on the water points 74 owater = where(omsk EQ 1) 75 nowater = n_elements(owater) 88 ; we work only on the ouput grid water points 76 89 awater = where(amsk EQ 1) 77 90 nawater = n_elements(awater) … … 167 180 IF ind NE -1 THEN BEGIN 168 181 ind = good[ind] 169 ; we keep its address170 foraddr[n] = ind171 182 ; now, we morph the quadrilateral ocean cell into the reference square (0 -> 1) 172 183 ; in addition we get the corrdinates of the atmospheric point in this new morphed square … … 189 200 one = where(abs(1-xy) LT 1e-4) 190 201 IF one[0] NE -1 THEN xy[one] = 1 191 ; some (useless) checks... 192 IF xy[0] LT 0 OR xy[0] GT 1 THEN stop 193 IF xy[0] LT 0 OR xy[0] GT 1 THEN stop 202 ; some checks... 203 tmpmsk = omsk[celladdr[*, ind]] 204 CASE 1 OF 205 xy[0] LT 0 OR xy[0] GT 1 : stop 206 xy[1] LT 0 OR xy[1] GT 1 : stop 207 xy[0] EQ 0 AND xy[1] EQ 0 AND tmpmsk[0] EQ 0 : foraddr[n] = -1 208 xy[0] EQ 1 AND xy[1] EQ 0 AND tmpmsk[1] EQ 0 : foraddr[n] = -1 209 xy[0] EQ 1 AND xy[1] EQ 1 AND tmpmsk[2] EQ 0 : foraddr[n] = -1 210 xy[0] EQ 0 AND xy[1] EQ 1 AND tmpmsk[3] EQ 0 : foraddr[n] = -1 211 xy[0] EQ 0 AND (tmpmsk[0]+tmpmsk[3]) EQ 0 : foraddr[n] = -1 212 xy[0] EQ 1 AND (tmpmsk[1]+tmpmsk[2]) EQ 0 : foraddr[n] = -1 213 xy[1] EQ 0 AND (tmpmsk[0]+tmpmsk[1]) EQ 0 : foraddr[n] = -1 214 xy[1] EQ 1 AND (tmpmsk[2]+tmpmsk[3]) EQ 0 : foraddr[n] = -1 215 ELSE: BEGIN 216 ; we keep its address 217 foraddr[n] = ind 194 218 ; keep the new coordinates 195 forweight[n, 0] = xy[0] 196 forweight[n, 1] = xy[1] 219 forweight[n, 0] = xy[0] 220 forweight[n, 1] = xy[1] 221 END 222 ENDCASE 223 224 225 197 226 ENDIF ELSE foraddr[n] = -1 198 227 ENDIF ELSE foraddr[n] = -1 … … 237 266 ; weights normalization 238 267 totalweig = total(newaweig, 1) 268 IF min(totalweig, max = ma) EQ 0 then stop 269 IF ma GT 1 then stop 239 270 newaweig = newaweig/(replicate(1., 4)#totalweig) 240 271 totalweig = total(newaweig, 1) -
trunk/SRC/Interpolation/compute_fromreg_bilinear_weigaddr.pro
r163 r202 7 7 ; Interpolation 8 8 ; 9 ; @param alonin{in}{required} 9 ; @param alonin{in}{required}{type=2d array} 10 10 ; longitude of the input data 11 11 ; 12 ; @param alatin {in}{required} 12 ; @param alatin {in}{required}{type=2d array} 13 13 ; latitude of the input data 14 14 ; 15 ; @param olonin {in}{required} 15 ; @param olonin {in}{required}{type=2d array} 16 16 ; longitude of the output data 17 17 ; 18 ; @param olat {in}{required} 18 ; @param olat {in}{required}{type=2d array} 19 19 ; latitude of the output data 20 20 ; 21 ; @keyword NONORTHERNLINE 22 ; activateif you don't want to take into21 ; @keyword NONORTHERNLINE {type=scalar 0 or 1}{default=0} 22 ; put 1 if you don't want to take into 23 23 ; account the northen line of the input data when performing the interpolation. 24 24 ; 25 ; @keyword NOSOUTHERNLINE 26 ; activateif you don't want to take into25 ; @keyword NOSOUTHERNLINE {type=scalar 0 or 1}{default=0} 26 ; put 1 if you don't want to take into 27 27 ; account the southern line of the input data when performing the interpolation. 28 28 ; 29 ; @param weig {out} 30 ; @param addr {out} 29 ; @param weig {out}{type=2d array} 30 ; (see ADDR) 31 ; 32 ; @param addr {out}{type=2d array} 31 33 ; 2D arrays, weig and addr are the weight and addresses used to 32 34 ; perform the interpolation: -
trunk/SRC/Interpolation/compute_fromreg_imoms3_weigaddr.pro
r163 r202 8 8 ; Interpolation 9 9 ; 10 ; @param alonin {in}{required} 10 ; @param alonin {in}{required}{type=2d array} 11 11 ; longitude of the input data 12 12 ; 13 ; @param alatin {in}{required} 13 ; @param alatin {in}{required}{type=2d array} 14 14 ; latitude of the input data 15 15 ; 16 ; @param olonin {in}{required} 16 ; @param olonin {in}{required}{type=2d array} 17 17 ; longitude of the output data 18 ; @param olat {in}{required} 18 ; 19 ; @param olat {in}{required}{type=2d array} 19 20 ; latitude of the output data 20 21 ; 21 ; @keyword NONORTHERNLINE 22 ; @keyword NOSOUTHERNLINE 23 ; activate if you don't want to take into account the northen/southern line 24 ; of the input data when performing the interpolation. 25 ; 26 ; @param weig {out} 27 ; @param addr {out} 22 ; @keyword NONORTHERNLINE {type=scalar 0 or 1}{default=0} 23 ; put 1 if you don't want to take into 24 ; account the northen line of the input data when performing the interpolation. 25 ; 26 ; @keyword NOSOUTHERNLINE {type=scalar 0 or 1}{default=0} 27 ; put 1 if you don't want to take into 28 ; account the southern line of the input data when performing the interpolation. 29 ; 30 ; @param weig {out}{type=2d array} 31 ; (see ADDR) 32 ; 33 ; @param addr {out}{type=2d array} 28 34 ; 2D arrays, weig and addr are the weight and addresses used to 29 35 ; perform the interpolation: -
trunk/SRC/Interpolation/extrapolate.pro
r199 r202 1 1 ;+ 2 2 ; @file_comments 3 ; extrapolate data (zinput) where maskinput eq 0 by filling 4 ; step by step the coastline points with the mean value of the 8 neighbourgs. 3 ; extrapolate data (zinput) where maskinput eq 0 by filling step by 4 ; step the coastline points with the mean value of the 8 neighbourgs 5 ; (weighted by their mask value). 5 6 ; 6 7 ; @categories 7 8 ; Interpolation 8 9 ; 9 ; @param zinput {in}{required} 10 ; @param zinput {in}{required}{type=2d array} 10 11 ; data to be extrapolate 11 12 ; 12 ; @param maskinput {in}{required} 13 ; @param maskinput {in}{required}{type=2d array or -1} 14 ; a 2D array, the land-sea mask of the output data (1 on ocean, 0 on land) 15 ; put -1 if input data are not masked 13 16 ; 14 ; @param nb_iteration {in}{optional} 15 ; number of iteration 17 ; @param nb_iteration {in}{optional}{type=integer scalar}{default=10.E20} 18 ; Maximum number if iterations done in the extrapolation process. If there 19 ; is no more masked values we exit extrapolate before reaching nb_iteration 20 ; (to be sure to fill everything, you can use a very large value) 16 21 ; 17 ; @keyword x_periodic 18 ; @keyword MINVAL 19 ; @keyword MAXVAL 20 ; @keyword GE0 22 ; @keyword x_periodic {type=scalar, 0 or 1}{default=0} 23 ; put 1 to specify that the data are periodic along x axis 24 ; 25 ; @keyword MINVAL {type=scalar}{default=not used} 26 ; to specify a minimum value to the extrapolated values 27 ; 28 ; @keyword MAXVAL {type=scalar}{default=not used} 29 ; to specify a maximum value to the extrapolated values 30 ; 31 ; @keyword GE0 {type=scalar 0 or 1}{default=0} 32 ; put 1 to force the extrapolated values to be larger than 0, same as using minval=0. 33 ; 34 ; @returns {type=2d array} 35 ; the extrapolated array 36 ; 37 ; @examples 38 ; IDL> a=extrapolate(dist(jpi,jpj),tmask[*,*,0],/x_periodic) 39 ; IDL> tvplus, a 40 ; IDL> tvplus, a*(1-tmask[*,*,0]) 41 ; get the coastline: 42 ; IDL> a=extrapolate(tmask[*,*,0],tmask[*,*,0],1,/x_periodic) 43 ; IDL> tvplus, a-tmask[*,*,0] 44 ; 45 ; @history 46 ; Originaly written by G. Roulet 47 ; Sebastien Masson (smasson\@lodyc.jussieu.fr) 21 48 ; 22 49 ; @version $Id$ 23 50 ; 24 51 ;- 25 FUNCTION extrapolate, zinput, maskinput, nb_iteration, x_periodic = x_periodic, MINVAL = minval, MAXVAL = maxval, GE0 = ge0 52 FUNCTION extrapolate, zinput, maskinput, nb_iteration, x_periodic = x_periodic $ 53 , MINVAL = minval, MAXVAL = maxval, GE0 = ge0 26 54 ; 27 55 compile_opt idl2, strictarrsubs … … 42 70 ; 43 71 ztmp = bytarr(nx+2, ny+2) 72 IF n_elements(maskinput) EQ 1 AND maskinput[0] EQ -1 THEN maskinput = replicate(1b, nx, ny) 73 IF n_elements(maskinput) NE nx*ny THEN BEGIN 74 print, 'input grid mask do not have the good size' 75 return, -1 76 ENDIF 44 77 ztmp[1:nx, 1:ny] = byte(maskinput) 45 78 msk = temporary(ztmp) -
trunk/SRC/Interpolation/fromirr.pro
r163 r202 20 20 ; a 2D array defining the latitude of the input data. 21 21 ; 22 ; @param mskin {in}{optional}{type=2d array }22 ; @param mskin {in}{optional}{type=2d array or -1} 23 23 ; a 2D array, the land-sea mask of the input data (1 on ocean, 0 on land) 24 ; put -1 if input data are not masked 24 25 ; 25 26 ; @param lonout {in}{optional}{type=1d or 2d array} … … 29 30 ; 1D or 2D array defining the latitude of the output data. 30 31 ; 31 ; @param mskout {in}{required}{type=2d array }32 ; @param mskout {in}{required}{type=2d array or -1} 32 33 ; a 2D array, the land-sea mask of the output data (1 on ocean, 0 on land) 34 ; put -1 if output data are not masked 33 35 ; 34 36 ; @keyword WEIG {type=2d array}
Note: See TracChangeset
for help on using the changeset viewer.