source: trunk/SRC/Interpolation/fromreg.pro @ 157

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

header improvements + xxx doc

  • Property svn:keywords set to Id
File size: 3.4 KB
Line 
1;+
2;
3; @file_comments
4; interpolate data from a "regular/rectangular grid" to any grid.
5;   2 methods availables: bilinear and imoms3
6;   A "regular/rectangular grid" is defined as a grid for which each lontitudes lines have
7;   the same latitude and each latitudes columns have the same longitude.
8;
9; @categories
10; Interpolation
11;
12; @param method {in}{required}
13; a string defining the interpolation method.
14; must be 'bilinear' or 'imoms3'
15;
16; @param datain {in}{required}
17; a 2D array the input data to interpolate
18;
19; @param lonin {in}{optional}
20; 1D or 2D array defining the longitude of the input data
21;
22; @param latin {in}{optional}
23; 1D or 2D array defining the latitude of the input data
24;
25; @param lonout {in}{optional}
26; 1D or 2D array defining the longitude of the output data
27;
28; @param latout {in}{required}
29; 1D or 2D array defining the latitude of the output data
30;
31; @keyword WEIG (see ADDR)
32; @keyword ADDR 2D arrays, weig and addr are the weight and addresses used to
33; perform the interpolation:
34;          dataout = total(weig*datain[addr], 1)
35;          dataout = reform(dataout, jpio, jpjo, /over)
36; Those keywords can be set to named variables (that are undefined or equal to 0) into which the
37; values will be copied when the current routine exits. Next, they can be used to perform
38; the interpolation whithout computing again those 2 parameters. In that
39; case, lonin, latin, lonout and latout are not necessary.
40;
41; @keyword NONORTHERNLINE
42; @keyword NOSOUTHERNLINE
43; activate if you don't want to take into account the northen/southern line
44; of the input data when perfoming the interpolation.
45;
46; @returns
47; 2D array the interpolated data
48;
49; @restrictions
50; We supposed the data are located on a sphere, with a periodicity along the
51; longitude.
52;
53; @examples
54;
55; IDL> topa = fromreg('bilinear', tncep, xncep, yncep, glamt, gphit)
56;
57;  or
58;
59; IDL> t1opa = fromreg('bilinear', t1ncep, xncep, yncep, glamt, gphit, WEIG = a, ADDR = b)
60; IDL> help, a, b
61; IDL> t2opa = fromreg('bilinear', t2ncep, xncep, WEIG = a, ADDR = b)
62;
63; @history
64;  November 2005: Sebastien Masson (smasson\@lodyc.jussieu.fr)
65;
66; @version $Id$
67;
68;-
69;----------------------------------------------------------
70;----------------------------------------------------------
71;
72FUNCTION fromreg, method, datain, lonin, latin, lonout, latout $
73                  , WEIG = weig, ADDR = addr $
74                  , NONORTHERNLINE = nonorthernline $
75                  , NOSOUTHERNLINE = nosouthernline
76;
77  compile_opt idl2, strictarrsubs
78;
79;---------------
80; atmospheric grid parameters
81;---------------
82    alon = lonin
83    alat = latin
84    get_gridparams, alon, alat, jpia, jpja, 1, /double
85;---------------
86; Oceanic grid parameters
87;---------------
88    olon = lonout
89    olat = latout
90    get_gridparams, olon, olat, jpio, jpjo, 2, /double
91;---------------
92; Compute weight and address
93;---------------
94  IF NOT (keyword_set(weig) AND keyword_set(addr)) THEN BEGIN
95    CASE method OF
96      'bilinear':compute_fromreg_bilinear_weigaddr, alon, alat, olon, olat, weig, addr, NONORTHERNLINE = nonorthernline, NOSOUTHERNLINE = nosouthernline
97      'imoms3':  compute_fromreg_imoms3_weigaddr,   alon, alat, olon, olat, weig, addr, NONORTHERNLINE = nonorthernline, NOSOUTHERNLINE = nosouthernline
98      ELSE:BEGIN
99        print, ' unknown interpolation method... we stop'
100        stop
101      ENDELSE
102    ENDCASE
103  ENDIF
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.