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

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

add $ in Calendar, Grid, Interpolation, Obsolete and Postscript *.pro files, add svn:keywords Id to all these files, some improvements in header

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