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