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

Last change on this file since 161 was 157, checked in by navarro, 18 years ago

header improvements + xxx doc

  • Property svn:keywords set to Id
File size: 3.3 KB
Line 
1;+
2;
3; @file_comments
4; interpolate data from an irregular 2D grid to any 2D grid.
5;   Only 1 method available = bilinear
6;
7; @categories
8; Interpolation
9;
10; @param method {in}{required}
11; a string defining the interpolation method. must be 'bilinear'
12;
13; @param datain {in}{required}
14; a 2D array the input data to interpolate
15;
16; @param lonin {in}{optional}
17; a 2D array defining the longitude of the input data
18;
19; @param latin {in}{optional}
20; a 2D array defining the latitude of the input data.
21;
22; @param mskin {in}{optional}
23; a 2D array, the land-sea mask of the input data (1 on ocean, 0 on land)
24;
25; @param lonout {in}{optional}
26; 1D or 2D array defining the longitude of the output data.
27;
28; @param latout {in}{optional}
29; 1D or 2D array defining the latitude of the output data.
30;
31; @param mskout {in}{required}
32; a 2D array, the land-sea mask of the ouput data (1 on ocean, 0 on land)
33;
34; @keyword WEIG (see ADDR)
35; @keyword ADDR 2D arrays, weig and addr are the weight and addresses used to
36; perform the interpolation:
37;          dataout = total(weig*datain[addr], 1)
38;          dataout = reform(dataout, jpio, jpjo, /over)
39; Those keywords can be set to named variables (that are undefined or equal to 0) into which the
40; values will be copied when the current routine exits. Next, they can be used to perform
41; the interpolation whithout computing again those 2 parameters. This greatly
42; speed-up the interpolation! In that case, lonin, latin, lonout and latout are not necessary.
43;
44; @returns
45; 2D array the interpolated data
46;
47; @restrictions
48; We supposed the data are located on a sphere, with a periodicity along
49; the longitude.
50; Note that the input data can contain the same cells several times
51; (like ORCA grid near the north pole boundary)
52;
53; @examples
54;
55; IDL> tncep = fromirr('bilinear', topa, glamt, gphit, tmask[*,*,0], lonout, latout, mskout)
56;
57;  or
58;
59; IDL> t1ncep = fromirr('bilinear', topa, glamt, gphit, tmask[*,*,0], lonout, latout, mskout $
60;                            , WEIG = a, ADDR = b)
61; IDL> help, a, b
62; IDL> t2ncep = fromirr('bilinear', topa, WEIG = a, ADDR = b)
63;
64; @history
65;  June 2006: Sebastien Masson (smasson\@lodyc.jussieu.fr)
66;
67; @version $Id$
68;
69;-
70;----------------------------------------------------------
71;----------------------------------------------------------
72;
73FUNCTION fromirr, method, datain, lonin, latin, mskin, lonout, latout, mskout $
74                  , WEIG = weig, ADDR = addr
75;
76  compile_opt strictarr, strictarrsubs
77;
78;---------------
79; atmospheric grid parameters
80;---------------
81    alon = lonin
82    alat = latin
83    get_gridparams, alon, alat, jpia, jpja, 2, /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;---------------
93  IF NOT (keyword_set(weig) AND keyword_set(addr)) THEN BEGIN
94    CASE method OF
95      'bilinear':compute_fromirr_bilinear_weigaddr, alon, alat, mskin, olon, olat, mskout, weig, addr
96      ELSE:BEGIN
97        print, ' unknown interpolation method... we stop'
98        stop
99      ENDELSE
100    ENDCASE
101  ENDIF
102;---------------
103; to the interpolation
104;---------------
105  dataout = total(weig*datain[addr], 1)
106  dataout = reform(dataout, jpio, jpjo, /over)
107;
108  RETURN, dataout
109END
Note: See TracBrowser for help on using the repository browser.