source: trunk/SRC/Interpolation/fromirr.pro @ 372

Last change on this file since 372 was 372, checked in by pinsard, 16 years ago

improvements of headers (alignments)

  • Property svn:keywords set to Id
File size: 3.9 KB
Line 
1;+
2;
3; @file_comments
4; interpolate data from an irregular 2D grid to any 2D grid.
5;
6; Only 1 method available = bilinear
7;
8; @categories
9; Interpolation
10;
11; @param method {in}{required}{type=string}
12; the interpolation method. must be 'bilinear'
13;
14; @param datain {in}{required}{type=2d array}
15; the input data to interpolate
16;
17; @param lonin {in}{required}{type=2d array}
18; the longitude of the input data
19;
20; @param latin {in}{required}{type=2d array}
21; the latitude of the input data.
22;
23; @param mskin {in}{required}{type=2d array or -1}
24; a 2D array, the land-sea mask of the input data (1 on ocean, 0 on land)
25; put -1 if input data are not masked
26;
27; @param lonout {in}{required}{type=1d or 2d array}
28; the longitude of the output data.
29;
30; @param latout {in}{required}{type=1d or 2d array}
31; the latitude of the output data.
32;
33; @param mskout {in}{required}{type=2d array or -1}
34; a 2D array, the land-sea mask of the output data (1 on ocean, 0 on land)
35; put -1 if output data are not masked
36;
37; @keyword WEIG {type=2d array}
38; (see ADDR)
39;
40; @keyword ADDR {type=2d array}
41; 1) at the first call of fromirr:
42; This keyword can be set to a named variable (undefined or equal to 0) into which the
43; addresses used to perform the interpolation will be copied when the current routine exits.
44; 2) Next, once this keyword is set to a defined 2d array, it is used to bypass the computation
45; of the weights and addresses used to perform the interpolation. In this case, fromirr simply
46; compute the interpolated field as:
47;          dataout = total(weig*datain[addr], 1)
48;          dataout = reform(dataout, jpio, jpjo, /over)
49;
50; In that case, method, lonin, latin, are not used (but are necessary).
51; lonout, latout are used only to know the output domain size
52;
53; @keyword
54; _EXTRA to be able to call fromirr with _extra keyword
55;
56; @returns
57; 2D array the interpolated data
58;
59; @restrictions
60; We supposed the data are located on a sphere, with a periodicity along
61; the longitude.
62; Note that the input data can contain the same cells several times
63; (like ORCA grid near the north pole boundary)
64;
65; @examples
66;
67;  To interpolate 1 field:
68;
69;   IDL> tncep = fromirr('bilinear', topa, glamt, gphit, tmask[*,*,0], lonout, latout, mskout)
70;
71;  or if you have several fields to interpolate from the same source and target grids
72;
73; 1) get back the weights and addresses in variables a and b
74;   (that must be undefined or equal to 0 before calling fromirr)
75;
76;   IDL> t1ncep = fromirr('bilinear', topa, glamt, gphit, tmask[*,*,0], lonout, latout, mskout $
77;                            , WEIG = a, ADDR = b)
78;   IDL> help, a, b
79;
80; 2) use a and b that are now defined to bypass the computation of the weights
81; and addresses and speed-up the computation!
82;
83;   IDL> t2ncep = fromirr('bilinear', topa, WEIG = a, ADDR = b)
84;
85; @history
86; June 2006: Sebastien Masson (smasson\@lodyc.jussieu.fr)
87;
88; @version
89; $Id$
90;
91;-
92FUNCTION fromirr, method, datain, lonin, latin, mskin, lonout, latout $
93                , mskout $
94                , WEIG=weig, ADDR=addr, _EXTRA=ex
95;
96  compile_opt strictarr, strictarrsubs
97;
98;---------------
99; atmospheric grid parameters
100;---------------
101    alon = lonin
102    alat = latin
103    get_gridparams, alon, alat, jpia, jpja, 2, /double
104;---------------
105; Oceanic grid parameters
106;---------------
107    olon = lonout
108    olat = latout
109    get_gridparams, olon, olat, jpio, jpjo, 2, /double
110;---------------
111; Compute weight and address
112;---------------
113  IF NOT (keyword_set(weig) AND keyword_set(addr)) THEN BEGIN
114    CASE method OF
115      'bilinear':compute_fromirr_bilinear_weigaddr, alon, alat, mskin, olon, olat, mskout, weig, addr
116      ELSE:BEGIN
117        ras = report(' unknown interpolation method... we stop')
118        stop
119      ENDELSE
120    ENDCASE
121  ENDIF
122;---------------
123; to the interpolation
124;---------------
125  dataout = total(weig*datain[addr], 1)
126  dataout = reform(dataout, jpio, jpjo, /over)
127;
128  RETURN, dataout
129END
Note: See TracBrowser for help on using the repository browser.