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

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

add interpolation from irregular grid

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