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