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

Last change on this file since 205 was 205, checked in by smasson, 17 years ago

improve the use of high frequency calendar

  • Property svn:keywords set to Id
File size: 3.5 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;
[157]7; @categories
8; Interpolation
[110]9;
[163]10; @param method {in}{required}{type=string}
[136]11; a string defining the interpolation method. must be 'bilinear'
[110]12;
[163]13; @param datain {in}{required}{type=2d array}
[136]14; a 2D array the input data to interpolate
15;
[205]16; @param lonin {in}{required}{type=2d array}
[136]17; a 2D array defining the longitude of the input data
18;
[205]19; @param latin {in}{required}{type=2d array}
[136]20; a 2D array defining the latitude of the input data.
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}
[136]27; 1D or 2D array defining the longitude of the output data.
28;
[205]29; @param latout {in}{required}{type=1d or 2d array}
[136]30; 1D or 2D array defining the latitude of the output data.
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}
40; 2D arrays, weig and addr are the weight and addresses used to
[136]41; perform the interpolation:
[110]42;          dataout = total(weig*datain[addr], 1)
43;          dataout = reform(dataout, jpio, jpjo, /over)
[136]44; Those keywords can be set to named variables (that are undefined or equal to 0) into which the
45; values will be copied when the current routine exits. Next, they can be used to perform
[163]46; the interpolation without computing again those 2 parameters. This greatly
[136]47; speed-up the interpolation! In that case, lonin, latin, lonout and latout are not necessary.
[110]48;
[136]49; @returns
50; 2D array the interpolated data
[110]51;
[125]52; @restrictions
53; We supposed the data are located on a sphere, with a periodicity along
54; the longitude.
55; Note that the input data can contain the same cells several times
56; (like ORCA grid near the north pole boundary)
[110]57;
58; @examples
[125]59;
[118]60; IDL> tncep = fromirr('bilinear', topa, glamt, gphit, tmask[*,*,0], lonout, latout, mskout)
[110]61;
[125]62;  or
[110]63;
[118]64; IDL> t1ncep = fromirr('bilinear', topa, glamt, gphit, tmask[*,*,0], lonout, latout, mskout $
[110]65;                            , WEIG = a, ADDR = b)
[118]66; IDL> help, a, b
67; IDL> t2ncep = fromirr('bilinear', topa, WEIG = a, ADDR = b)
[110]68;
69; @history
[125]70;  June 2006: Sebastien Masson (smasson\@lodyc.jussieu.fr)
71;
[118]72; @version $Id$
73;
[110]74;-
75;----------------------------------------------------------
76;----------------------------------------------------------
77;
78FUNCTION fromirr, method, datain, lonin, latin, mskin, lonout, latout, mskout $
79                  , WEIG = weig, ADDR = addr
80;
[125]81  compile_opt strictarr, strictarrsubs
[110]82;
83;---------------
84; atmospheric grid parameters
85;---------------
86    alon = lonin
87    alat = latin
88    get_gridparams, alon, alat, jpia, jpja, 2, /double
89;---------------
90; Oceanic grid parameters
91;---------------
92    olon = lonout
93    olat = latout
94    get_gridparams, olon, olat, jpio, jpjo, 2, /double
95;---------------
96; Compute weight and address
97;---------------
[113]98  IF NOT (keyword_set(weig) AND keyword_set(addr)) THEN BEGIN
[110]99    CASE method OF
100      'bilinear':compute_fromirr_bilinear_weigaddr, alon, alat, mskin, olon, olat, mskout, weig, addr
[125]101      ELSE:BEGIN
[110]102        print, ' unknown interpolation method... we stop'
103        stop
104      ENDELSE
105    ENDCASE
106  ENDIF
107;---------------
108; to the interpolation
109;---------------
110  dataout = total(weig*datain[addr], 1)
111  dataout = reform(dataout, jpio, jpjo, /over)
112;
113  RETURN, dataout
114END
Note: See TracBrowser for help on using the repository browser.