[59] | 1 | ;+ |
---|
| 2 | ; |
---|
[101] | 3 | ; @file_comments interpolate data from a "regular/rectangular grid" to any grid. |
---|
[59] | 4 | ; 2 metods availables: bilinear and imoms3 |
---|
[69] | 5 | ; A "regular/rectangular grid" is defined as a grid for which each lontitudes lines have |
---|
[59] | 6 | ; the same latitude and each latitudes columns have the same longitude. |
---|
| 7 | ; |
---|
[101] | 8 | ; @categories interpolation |
---|
[59] | 9 | ; |
---|
[101] | 10 | ; @examples |
---|
| 11 | ; dataout = fromreg(method, datain [, lonin, latin, lonout, latout]) |
---|
[59] | 12 | ; |
---|
[101] | 13 | ; @param method {in}{required} a string defining the interpolation method. |
---|
[59] | 14 | ; must be 'bilinear' or 'imoms3' |
---|
[101] | 15 | ; @param datain {in}{required} a 2D array the input data to interpolate |
---|
[113] | 16 | ; @param lonin {in}{required} 1D or 2D array defining the longitude of the input data |
---|
| 17 | ; @param latin {in}{required} 1D or 2D array defining the latitude of the input data |
---|
| 18 | ; @param lonout {in}{required} 1D or 2D array defining the longitude of the output data |
---|
| 19 | ; @param lonout {in}{required} 1D or 2D array defining the latitude of the output data |
---|
[59] | 20 | ; |
---|
[110] | 21 | ; @keyword WEIG (see ADDR) |
---|
| 22 | ; @keyword ADDR 2D arrays, weig and addr are the weight and addresses used to |
---|
[59] | 23 | ; perform the interpolation: |
---|
| 24 | ; dataout = total(weig*datain[addr], 1) |
---|
| 25 | ; dataout = reform(dataout, jpio, jpjo, /over) |
---|
[113] | 26 | ; Those keywords can be set to named variables (that are undefined or equal to 0) into which the |
---|
| 27 | ; values will be copied when the current routine exits. Next, they can be used to perform |
---|
[59] | 28 | ; the interpolation whithout computing again those 2 parameters. In that |
---|
| 29 | ; case, lonin, latin, lonout and latout are not necessary. |
---|
| 30 | ; |
---|
[101] | 31 | ; @keyword /NONORTHERNLINE and /NOSOUTHERNLINE activate if you don't whant to take into |
---|
[59] | 32 | ; account the northen/southern line of the input data when perfoming the |
---|
| 33 | ; interpolation. |
---|
| 34 | ; |
---|
[101] | 35 | ; @returns 2D array: the interpolated data |
---|
[59] | 36 | ; |
---|
[101] | 37 | ; @restrictions We supposed the data are located on a sphere, with a |
---|
| 38 | ; periodicity along the longitude. |
---|
[59] | 39 | ; |
---|
[101] | 40 | ; @examples |
---|
[59] | 41 | ; |
---|
| 42 | ; topa = fromreg('bilinear', tncep, xncep, yncep, glamt, gphit) |
---|
| 43 | ; |
---|
| 44 | ; or |
---|
| 45 | ; |
---|
| 46 | ; t1opa = fromreg('bilinear', t1ncep, xncep, yncep, glamt, gphit, WEIG = a, ADDR = b) |
---|
| 47 | ; help, a, b |
---|
| 48 | ; t2opa = fromreg('bilinear', t2ncep, xncep, WEIG = a, ADDR = b) |
---|
| 49 | ; |
---|
[101] | 50 | ; @history |
---|
| 51 | ; November 2005: Sebastien Masson (smasson\@lodyc.jussieu.fr) |
---|
[59] | 52 | ; |
---|
| 53 | ;- |
---|
| 54 | ;---------------------------------------------------------- |
---|
| 55 | ;---------------------------------------------------------- |
---|
| 56 | ; |
---|
| 57 | FUNCTION fromreg, method, datain, lonin, latin, lonout, latout $ |
---|
| 58 | , WEIG = weig, ADDR = addr $ |
---|
| 59 | , NONORTHERNLINE = nonorthernline $ |
---|
| 60 | , NOSOUTHERNLINE = nosouthernline |
---|
| 61 | ; |
---|
[114] | 62 | compile_opt idl2, strictarrsubs |
---|
[59] | 63 | ; |
---|
| 64 | ;--------------- |
---|
| 65 | ; atmospheric grid parameters |
---|
| 66 | ;--------------- |
---|
| 67 | alon = lonin |
---|
| 68 | alat = latin |
---|
| 69 | get_gridparams, alon, alat, jpia, jpja, 1, /double |
---|
| 70 | ;--------------- |
---|
| 71 | ; Oceanic grid parameters |
---|
| 72 | ;--------------- |
---|
| 73 | olon = lonout |
---|
| 74 | olat = latout |
---|
| 75 | get_gridparams, olon, olat, jpio, jpjo, 2, /double |
---|
| 76 | ;--------------- |
---|
| 77 | ; Compute weight and address |
---|
| 78 | ;--------------- |
---|
[113] | 79 | IF NOT (keyword_set(weig) AND keyword_set(addr)) THEN BEGIN |
---|
[59] | 80 | CASE method OF |
---|
| 81 | 'bilinear':compute_fromreg_bilinear_weigaddr, alon, alat, olon, olat, weig, addr, NONORTHERNLINE = nonorthernline, NOSOUTHERNLINE = nosouthernline |
---|
| 82 | 'imoms3': compute_fromreg_imoms3_weigaddr, alon, alat, olon, olat, weig, addr, NONORTHERNLINE = nonorthernline, NOSOUTHERNLINE = nosouthernline |
---|
| 83 | ELSE:BEGIN |
---|
| 84 | print, ' unknown interpolation method... we stop' |
---|
| 85 | stop |
---|
| 86 | ENDELSE |
---|
| 87 | ENDCASE |
---|
| 88 | ENDIF |
---|
| 89 | ; |
---|
| 90 | dataout = total(weig*datain[addr], 1) |
---|
| 91 | dataout = reform(dataout, jpio, jpjo, /over) |
---|
| 92 | ; |
---|
| 93 | RETURN, dataout |
---|
| 94 | END |
---|