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

Last change on this file since 371 was 371, checked in by pinsard, 16 years ago

improvements of headers (alignments of IDL prompt in examples)

  • Property svn:keywords set to Id
File size: 3.9 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;
[271]51; @keyword
52; _EXTRA to be able to call fromirr with _extra keyword
53;
[136]54; @returns
55; 2D array the interpolated data
[110]56;
[125]57; @restrictions
58; We supposed the data are located on a sphere, with a periodicity along
59; the longitude.
60; Note that the input data can contain the same cells several times
61; (like ORCA grid near the north pole boundary)
[110]62;
63; @examples
[125]64;
[228]65;  To interpolate 1 field:
66;
[371]67;   IDL> tncep = fromirr('bilinear', topa, glamt, gphit, tmask[*,*,0], lonout, latout, mskout)
[110]68;
[228]69;  or if you have several fields to interpolate from the same source and target grids
[110]70;
[228]71; 1) get back the weights and addresses in variables a and b
72;   (that must be undefined or equal to 0 before calling fromirr)
73;
[371]74;   IDL> t1ncep = fromirr('bilinear', topa, glamt, gphit, tmask[*,*,0], lonout, latout, mskout $
[110]75;                            , WEIG = a, ADDR = b)
[371]76;   IDL> help, a, b
[228]77;
[238]78; 2) use a and b that are now defined to bypass the computation of the weights
79; and addresses and speed-up the computation!
[228]80;
[371]81;   IDL> t2ncep = fromirr('bilinear', topa, WEIG = a, ADDR = b)
[110]82;
83; @history
[125]84;  June 2006: Sebastien Masson (smasson\@lodyc.jussieu.fr)
85;
[231]86; @version
87; $Id$
[118]88;
[110]89;-
[325]90FUNCTION fromirr, method, datain, lonin, latin, mskin, lonout, latout $
91                , mskout $
[327]92                , WEIG=weig, ADDR=addr, _EXTRA=ex
[110]93;
[125]94  compile_opt strictarr, strictarrsubs
[110]95;
96;---------------
97; atmospheric grid parameters
98;---------------
99    alon = lonin
100    alat = latin
101    get_gridparams, alon, alat, jpia, jpja, 2, /double
102;---------------
103; Oceanic grid parameters
104;---------------
105    olon = lonout
106    olat = latout
107    get_gridparams, olon, olat, jpio, jpjo, 2, /double
108;---------------
109; Compute weight and address
110;---------------
[113]111  IF NOT (keyword_set(weig) AND keyword_set(addr)) THEN BEGIN
[110]112    CASE method OF
113      'bilinear':compute_fromirr_bilinear_weigaddr, alon, alat, mskin, olon, olat, mskout, weig, addr
[125]114      ELSE:BEGIN
[236]115        ras = report(' unknown interpolation method... we stop')
[110]116        stop
117      ENDELSE
118    ENDCASE
119  ENDIF
120;---------------
121; to the interpolation
122;---------------
123  dataout = total(weig*datain[addr], 1)
124  dataout = reform(dataout, jpio, jpjo, /over)
125;
126  RETURN, dataout
127END
Note: See TracBrowser for help on using the repository browser.