- Timestamp:
- 07/06/06 16:10:25 (18 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/SRC/Interpolation/compute_fromreg_bilinear_weigaddr.pro
r121 r125 1 1 ;+ 2 ; @file_comments compute the weight and address needed to interpolate data from a 3 ; "regular grid" to any grid using the bilinear method 4 ; 2 ; @file_comments 3 ; compute the weight and address needed to interpolate data from a 4 ; "regular grid" to any grid using the bilinear method 5 ; 5 6 ; @categories interpolation 6 7 ; 7 ; @param alonin {in}{required} longitudeof the input data 8 ; @param alatin {in}{required} latitude of the input data 9 ; @param olonin {in}{required} longitude of the output data 10 ; @param olat {in}{required} latitude of the output data 11 ; 12 ; @keyword /NONORTHERNLINE activate if you don't whant to take into8 ; @param alonin {in}{required} longitudeof the input data 9 ; @param alatin {in}{required} latitude of the input data 10 ; @param olonin {in}{required} longitude of the output data 11 ; @param olat {in}{required} latitude of the output data 12 ; 13 ; @keyword NONORTHERNLINE activate if you don't want to take into 13 14 ; account the northen line of the input data when perfoming the 14 ; @keyword /NOSOUTHERNLINE activate if you don't whant to take into15 ; @keyword NOSOUTHERNLINE activate if you don't want to take into 15 16 ; account the southern line of the input data when perfoming the 16 17 ; interpolation. … … 24 25 ; 25 26 ; @restrictions 26 ; - 27 ; 28 ; 29 ; - 30 ; 31 ; - 32 ; 33 ; 27 ; - the input grid must be a "regular grid", defined as a grid for which each 28 ; lontitudes lines have the same latitude and each latitudes columns have the 29 ; same longitude. 30 ; - We supposed the data are located on a sphere, with a periodicity along 31 ; the longitude. 32 ; - points located out of the southern and northern boundaries are interpolated 33 ; using a linear interpolation only along the longitudinal direction. 34 ; 34 35 ; @history 35 ; November 2005: Sebastien Masson (smasson\@lodyc.jussieu.fr) 36 ; 36 ; November 2005: Sebastien Masson (smasson\@lodyc.jussieu.fr) 37 ; 37 38 ; @version $Id$ 38 39 ; 39 40 ;- 40 ;41 ;----------------------------------------------------------42 ;----------------------------------------------------------43 41 ; 44 42 PRO compute_fromreg_bilinear_weigaddr, alonin, alatin, olonin, olat, weig, addr $ … … 61 59 IF maxalon-minalon GE 360. THEN stop 62 60 ; alon must be monotonically increasing 63 IF array_equal(sort(alon), lindgen(jpia)) NE 1 THEN BEGIN 61 IF array_equal(sort(alon), lindgen(jpia)) NE 1 THEN BEGIN 64 62 shiftx = -(where(alon EQ min(alon)))[0] 65 63 alon = shift(alon, shiftx) 66 64 IF array_equal(sort(alon), lindgen(jpia)) NE 1 THEN stop 67 65 ENDIF ELSE shiftx = 0 68 ; for longitude periodic bo ndary condition we add the fist69 ; column on the right side of the array and 66 ; for longitude periodic boundary condition we add the fist 67 ; column on the right side of the array and 70 68 alon = [alon, alon[0]+360.] 71 69 jpia = jpia+1L … … 76 74 IF array_equal(sort(alat), lindgen(jpja)) NE 1 THEN stop 77 75 ; 78 if keyword_set(nonorthernline) then BEGIN 76 if keyword_set(nonorthernline) then BEGIN 79 77 jpja = jpja - 1L 80 78 alat = alat[0: jpja-1L] 81 79 ENDIF 82 if keyword_set(nosouthernline) then BEGIN 80 if keyword_set(nosouthernline) then BEGIN 83 81 alat = alat[1: jpja-1L] 84 82 jpja = jpja - 1L … … 103 101 ; if the ocean point is out of the atm grid, we use closest neighbor 104 102 ; interpolation 105 ; 103 ; 106 104 ; for each T point of oce grid, we find in which armospheric cell it is 107 105 ; located. … … 113 111 ; for longitude, each ocean points must be located in atm cell. 114 112 IF (where(pos[0, *] EQ -1))[0] NE -1 THEN stop 115 ; no ocean point should be located westward of the left bo ndary of the116 ; atm cell in which it is supposed to be located 113 ; no ocean point should be located westward of the left boundary of the 114 ; atm cell in which it is supposed to be located 117 115 IF total(olon LT alon[pos[0, *]]) NE 0 THEN stop 118 ; no ocean point should be located eastward of the right bo ndary of the119 ; atm cell in which it is supposed to be located 116 ; no ocean point should be located eastward of the right boundary of the 117 ; atm cell in which it is supposed to be located 120 118 IF total(olon GT alon[pos[0, *]+1]) NE 0 THEN stop 121 119 ; … … 124 122 ; we change the coordinates of each ocean points to fit into a 125 123 ; rectangle defined by: 126 ; 124 ; 127 125 ; y2 *------------* 128 126 ; | | … … 143 141 IF max(indx) GT jpia-2 THEN stop ; checks... 144 142 IF max(indy) GT jpja-2 THEN stop ; checks... 145 ; x coordinates of the atm cell 143 ; x coordinates of the atm cell 146 144 x1 = alon[indx] 147 145 x2 = alon[indx+1] … … 149 147 divi = temporary(x2)-x1 150 148 glamnew = (olon-x1)/temporary(divi) 151 x1 = -1 ; free memory 152 olon = -1 ; free memory 153 ; y coordinates of the atm cell 149 x1 = -1 ; free memory 150 olon = -1 ; free memory 151 ; y coordinates of the atm cell 154 152 y1 = alat[indy] 155 153 y2 = alat[indy+1] ; … … 159 157 IF zero[0] NE -1 THEN divi[zero] = 1. 160 158 gphinew = (olat-y1)/temporary(divi) 161 y1 = -1 ; free memory 159 y1 = -1 ; free memory 162 160 ; checks... 163 161 IF min(glamnew) LT 0 THEN stop … … 166 164 ; weight and address array used for bilinear interpolation. 167 165 xaddr = lonarr(4, jpio*jpjo) 168 xaddr[0, *] = indx 166 xaddr[0, *] = indx 169 167 xaddr[1, *] = indx + 1L 170 168 xaddr[2, *] = indx + 1L 171 xaddr[3, *] = indx 172 ; 169 xaddr[3, *] = indx 170 ; 173 171 yaddr = lonarr(4, jpio*jpjo) 174 172 yaddr[0, *] = indy … … 181 179 weig[1, *] = glamnew * (1.-gphinew) 182 180 weig[2, *] = glamnew * gphinew 183 weig[3, *] = (1.-glamnew) * gphinew 181 weig[3, *] = (1.-glamnew) * gphinew 184 182 ; free memory 185 183 gphinew = -1 … … 190 188 ybad = olat[bad] 191 189 ; the ocean points that are not located into an atm cell should be 192 ; located northward of the northern boundary of the atm grid 193 ; or southward of the southern boundary of the atm grid 190 ; located northward of the northern boundary of the atm grid 191 ; or southward of the southern boundary of the atm grid 194 192 IF total(ybad GE min(alat) AND ybad LE max(alat)) GE 1 THEN stop 195 193 ; … … 223 221 IF revy EQ 1 THEN yaddr = jpja - 1L - temporary(yaddr) 224 222 ; ; 225 addr = temporary(yaddr)*jpia + temporary(xaddr) 223 addr = temporary(yaddr)*jpia + temporary(xaddr) 226 224 ; 227 225 return
Note: See TracChangeset
for help on using the changeset viewer.