source: trunk/Interpolation/fromreg.pro @ 59

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

upgrade of Interpolation according to cerbere.lodyc.jussieu.fr: /usr/home/smasson/SAXO_RD/

  • Property svn:executable set to *
File size: 3.6 KB
Line 
1;+
2; NAME: fromreg
3;
4; PURPOSE: interpolate data from a "regular grid" to any grid.
5;   2 metods availables: bilinear and imoms3
6;
7;   In the case on 'bilinear interpolation':
8;   A "regular grid" is defined as a grid for which each lontitudes lines have
9;   the same latitude and each latitudes columns have the same longitude.
10;   
11;
12;   In the case on 'imoms3 interpolation':
13;   A "regular grid" is defined as a grid for which lontitudes and latitudes
14;   are regularly spaced.
15;   
16; CATEGORY:interpolation
17;
18; CALLING SEQUENCE: dataout = fromreg(method, datain [, lonin, latin, lonout, latout])
19;
20; INPUTS:
21;    method: a string defining the interpolation method.
22;            must be 'bilinear' or 'imoms3'
23;    datain: a 2D array the input data to interpolate
24;    lonin and latin: longitude/latitude of the input data. optionals if
25;            WEIG and ADDR keywords used.
26;    lonout and latout: longitude/latitude of the output data. optionals if
27;            WEIG and ADDR keywords used.
28;
29; KEYWORD PARAMETERS:
30;
31;     WEIG, ADDR: 2D arrays, weig and addr are the weight and addresses used to
32;     perform the interpolation:
33;          dataout = total(weig*datain[addr], 1)
34;          dataout = reform(dataout, jpio, jpjo, /over)
35;     Those keywords can be set to named variables into which the values will be
36;     copied when the current routine exits. Next, they can be used to perform
37;     the interpolation whithout computing again those 2 parameters. In that
38;     case, lonin, latin, lonout and latout are not necessary.
39;
40;     /NONORTHERNLINE and /NOSOUTHERNLINE: activate if you don't whant to take into
41;          account the northen/southern line of the input data when perfoming the
42;          interpolation.
43;
44; OUTPUTS: 2D array: the interpolated data
45;
46; COMMON BLOCKS: none
47;
48; SIDE EFFECTS: ?
49;
50; RESTRICTIONS:We supposed the data are located on a sphere, with a periodicity along
51;              the longitude.
52;
53; EXAMPLE:
54
55;  topa = fromreg('bilinear', tncep, xncep, yncep, glamt, gphit)
56;
57;  or
58;
59;  t1opa = fromreg('bilinear', t1ncep, xncep, yncep, glamt, gphit, WEIG = a, ADDR = b)
60;  help, a, b
61;  t2opa = fromreg('bilinear', t2ncep, xncep, WEIG = a, ADDR = b)
62;
63; MODIFICATION HISTORY:
64;  November 2005: Sebastien Masson (smasson@lodyc.jussieu.fr)
65;
66;-
67;
68;----------------------------------------------------------
69;----------------------------------------------------------
70;
71FUNCTION fromreg, method, datain, lonin, latin, lonout, latout $
72                  , WEIG = weig, ADDR = addr $
73                  , NONORTHERNLINE = nonorthernline $
74                  , NOSOUTHERNLINE = nosouthernline
75;
76  compile_opt strictarr, strictarrsubs
77;
78  IF NOT (keyword_set(weig) AND keyword_set(addr)) THEN BEGIN
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    CASE method OF
95      'bilinear':compute_fromreg_bilinear_weigaddr, alon, alat, olon, olat, weig, addr, NONORTHERNLINE = nonorthernline, NOSOUTHERNLINE = nosouthernline
96      'imoms3':  compute_fromreg_imoms3_weigaddr,   alon, alat, olon, olat, weig, addr, NONORTHERNLINE = nonorthernline, NOSOUTHERNLINE = nosouthernline
97      ELSE:BEGIN
98        print, ' unknown interpolation method... we stop'
99        stop
100      ENDELSE
101    ENDCASE
102  ENDIF
103;
104  dataout = total(weig*datain[addr], 1)
105  dataout = reform(dataout, jpio, jpjo, /over)
106;
107  RETURN, dataout
108END
Note: See TracBrowser for help on using the repository browser.