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

Last change on this file since 362 was 327, checked in by pinsard, 17 years ago

modification of headers : mainly blanks around = sign for keywords in declaration of function and pro

  • Property svn:keywords set to Id
File size: 4.1 KB
RevLine 
[59]1;+
2;
[136]3; @file_comments
[125]4; interpolate data from a "regular/rectangular grid" to any grid.
[163]5;   2 methods available: bilinear and imoms3
[238]6;   A "regular/rectangular grid" is defined as a grid for which
7; each longitude lines have the same latitude and each latitude columns
8; have the same longitude.
[125]9;
[157]10; @categories
11; Interpolation
[59]12;
[163]13; @param method {in}{required}{type=string}
[238]14; the interpolation method.
[136]15; must be 'bilinear' or 'imoms3'
[59]16;
[163]17; @param datain {in}{required}{type=2d array}
[238]18; the input data to interpolate
[136]19;
[205]20; @param lonin {in}{required}{type=1d or 2d array}
[238]21; the longitude of the input data
[136]22;
[205]23; @param latin {in}{required}{type=1d or 2d array}
[238]24; the latitude of the input data
[136]25;
[205]26; @param lonout {in}{required}{type=1d or 2d array}
[238]27; the longitude of the output data
[136]28;
[163]29; @param latout {in}{required}{type=1d or 2d array}
[238]30; the latitude of the output data
[136]31;
[228]32; @keyword WEIG {type=2d array or variable name}
[163]33; (see ADDR)
34;
[228]35; @keyword ADDR {type=2d array or variable name}
36; 1) at the first call of fromreg:
37; This keyword can be set to a named variable (undefined or equal to 0) into which the
38; addresses used to perform the interpolation will be copied when the current routine exits.
39; 2) Next, once this keyword is set to a defined 2d array, it is used to bypass the computation
40; of the weights and addresses used to perform the interpolation. In this case, fromreg simply
41; compute the interpolated field as:
[59]42;          dataout = total(weig*datain[addr], 1)
43;          dataout = reform(dataout, jpio, jpjo, /over)
[228]44; In that case, method, lonin, latin, are not used (but are necessary).
45; lonout, latout are used only to know the output domain size
[59]46;
[125]47; @keyword NONORTHERNLINE
[163]48; activate if you don't want to take into account the northern line
49; of the input data when performing the interpolation.
50;
[125]51; @keyword NOSOUTHERNLINE
[163]52; activate if you don't want to take into account the southern line
53; of the input data when performing the interpolation.
[59]54;
[271]55; @keyword
56; _EXTRA to be able to call fromreg with _extra keyword
57;
[136]58; @returns
59; 2D array the interpolated data
[59]60;
[125]61; @restrictions
62; We supposed the data are located on a sphere, with a periodicity along the
63; longitude.
[59]64;
[125]65; @examples
[59]66;
[228]67;  To interpolate 1 field:
68;
[125]69; IDL> topa = fromreg('bilinear', tncep, xncep, yncep, glamt, gphit)
[59]70;
[228]71;  or if you have several fields to interpolate from the same source and target grids
72;
73; 1) get back the weights and addresses in variables a and b
[238]74;   (that must be undefined or equal to 0 before calling fromreg
[59]75;
[125]76; IDL> t1opa = fromreg('bilinear', t1ncep, xncep, yncep, glamt, gphit, WEIG = a, ADDR = b)
77; IDL> help, a, b
78;
[228]79; 2) use a and b that are now defined to bypass the computation of the weights and addresses
80; and speed-up the computation!
81;
82; IDL> t2opa = fromreg('bilinear', t2ncep, xncep, yncep, glamt, gphit, WEIG = a, ADDR = b)
83;
[101]84; @history
[125]85;  November 2005: Sebastien Masson (smasson\@lodyc.jussieu.fr)
[118]86;
[231]87; @version
88; $Id$
[118]89;
[59]90;-
91FUNCTION fromreg, method, datain, lonin, latin, lonout, latout $
[327]92                  , WEIG=weig, ADDR=addr $
93                  , NONORTHERNLINE=nonorthernline $
94                  , NOSOUTHERNLINE=nosouthernline, _EXTRA=ex
[59]95;
[125]96  compile_opt idl2, strictarrsubs
[59]97;
98;---------------
99; atmospheric grid parameters
100;---------------
101    alon = lonin
102    alat = latin
103    get_gridparams, alon, alat, jpia, jpja, 1, /double
104;---------------
105; Oceanic grid parameters
106;---------------
107    olon = lonout
108    olat = latout
109    get_gridparams, olon, olat, jpio, jpjo, 2, /double
110;---------------
111; Compute weight and address
112;---------------
[113]113  IF NOT (keyword_set(weig) AND keyword_set(addr)) THEN BEGIN
[59]114    CASE method OF
115      'bilinear':compute_fromreg_bilinear_weigaddr, alon, alat, olon, olat, weig, addr, NONORTHERNLINE = nonorthernline, NOSOUTHERNLINE = nosouthernline
116      'imoms3':  compute_fromreg_imoms3_weigaddr,   alon, alat, olon, olat, weig, addr, NONORTHERNLINE = nonorthernline, NOSOUTHERNLINE = nosouthernline
[125]117      ELSE:BEGIN
[236]118        ras = report(' unknown interpolation method... we stop')
[59]119        stop
120      ENDELSE
121    ENDCASE
122  ENDIF
123;
124  dataout = total(weig*datain[addr], 1)
125  dataout = reform(dataout, jpio, jpjo, /over)
126;
127  RETURN, dataout
128END
Note: See TracBrowser for help on using the repository browser.