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

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

improvements of Interpolation/*.pro header

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