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

Last change on this file since 113 was 113, checked in by smasson, 18 years ago

bugfix in fromirr and fromreg + add full path to call IDL in save saxo

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