source: trunk/SRC/Interpolation/fromirr.pro @ 260

Last change on this file since 260 was 238, checked in by pinsard, 17 years ago

improvements/corrections of some *.pro headers

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