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

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

header improvements : type of parameters and keywords, default values, spell checking + idldoc assistant (IDL online_help)

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