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

Last change on this file since 125 was 125, checked in by pinsard, 18 years ago

improvements of Interpolation/*.pro header

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