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