source: trunk/SRC/Interpolation/file_interp.pro @ 367

Last change on this file since 367 was 362, checked in by smasson, 16 years ago

bugfix related to the used of NaN and missing values, replave nan_value by missing_value keyword

  • Property svn:keywords set to Id
File size: 21.0 KB
Line 
1;+
2;
3; @hidden
4;
5;-
6FUNCTION call_interp2d, data, inlon, inlat, inmask, outlon, outlat $
7                      , INIRR=inirr, METHOD=method, SMOOTH=smooth $
8                      , WEIG=weig, ADDR=addr, MISSING_VALUE=missing_value, _EXTRA=ex
9;
10  compile_opt idl2, strictarrsubs
11;
12; for byte, short and long, convert to double before extrapolation and interpolation
13  intype = size(data, /type)
14  if intype LE 3 THEN data = double(temporary(data))
15;
16; take care of NaN values
17  nanmsk = finite(data)
18  IF total(nanmsk) NE n_elements(nanmsk) THEN BEGIN
19    data[where(nanmsk EQ 0b)] = 1.e20 ; put large value to be sure they are removed during the interpolation
20    mask = inmask * temporary(nanmsk)
21  ENDIF ELSE mask = inmask
22;
23  tpmiss = size(missing_value, /type)
24  IF tpmiss NE 0 AND tpmiss NE 7 THEN BEGIN
25    CASE 1 OF
26      missing_value GT 1.e6:mask = temporary(mask) * (data LT (missing_value-10.))
27      missing_value LT -1.e6:mask = temporary(mask) * (data GT (missing_value+10.))
28      abs(missing_value) LT 1.e-6:mask = temporary(mask) * (abs(data) GT 1.e-6)
29      ELSE:mask = temporary(mask) * (data NE missing_value)
30    ENDCASE
31  ENDIF
32; extrapolation
33    IF keyword_set(smooth) THEN data = extrapsmooth(temporary(data), mask, /x_periodic, _extra = ex) $
34    ELSE data = extrapolate(temporary(data), mask, /x_periodic, _extra = ex)
35; interpolation
36  IF NOT keyword_set(inirr) THEN BEGIN
37    data = fromreg(method, temporary(data), inlon, inlat, outlon, outlat, WEIG = weig, ADDR = addr, _extra = ex)
38  ENDIF ELSE BEGIN
39    data = fromirr(method, temporary(data), inlon, inlat, -1, outlon, outlat, -1, WEIG = weig, ADDR = addr)
40  ENDELSE
41
42  if intype LE 3 THEN data = round(temporary(data))
43
44  RETURN, data
45END
46;+
47;
48; @file_comments
49; interpolate a NetCDF file from a grid to another (both regular or not)
50;
51; @categories
52; Interpolation, NetCDF
53;
54; @param filein {in}{type=scalar string}
55; input file name (must exist)
56;
57; @param fileout {in}{type=scalar string}
58; output file name (will be overwritten if already exist)
59;
60; @param gridout {in}{type=scalar string}
61; output grid file name (must exist and must contain the
62; longitude and latitude axis as 1D or 2D arrays)
63;
64; @keyword GRIDIN {type=scalar string}{default=set to filein}
65; define the input grid file name. It must exist and must contain the
66; longitude and latitude axis as 1D or 2D arrays. Useful if
67; filein file doesn't contain longitude and latitude axis
68;
69; @keyword MASKIN {type=scalar string}{default=set to gridin}
70; define the input mask file name. It must exist. The mask will be
71; determined through <pro>ncdf_getmask</pro> according to the keywords
72; inmaskname, ininvmask, inuseasmask, inmissing_value, inaddscl_before
73; (see below)
74;
75; @keyword MASKOUT {type=scalar string}{default=set to gridout}
76; define the output mask file name. It must exist. The mask will be
77; determined through <pro>ncdf_getmask</pro> according to the keywords
78; outmaskname, outinvmask, outuseasmask, outmissing_value,
79; outaddscl_before (see below).
80;
81; @keyword KEEP {type=string array}{default=all variables}
82; array defining the name of the variables that must be kept in the
83; output file
84;
85; @keyword REMOVE {type=string array}{default=empty}
86; array defining the name of the variables that will be removed in the
87; output file
88;
89; @keyword METHOD {type=scalar string}{default='bilinear'}
90; interpolation method: can be only 'bilinear' (or 'imoms3' if the input grid
91; is a "regular" grid). A "regular/rectangular grid" is defined as a
92; grid for which each longitude lines have the same latitude and each
93; latitude columns have the same longitude.
94;
95; @keyword SMOOTH {type=scalar 0 or 1}{default=0}
96; activate to use <pro>extrapsmooth</pro> instead of
97; <pro>extrapolate</pro> when extrapolating input data over masked
98; points.
99;
100; @keyword SET_XDIMNAME {type=scalar string}{default=not used}
101; used to defined the name of x dimension in filein input file when
102; gridin keyword is used and when the x dimension name is not the same
103; in filein and gridin files. By default, we assume both file have the
104; same x dimension name.
105;
106; @keyword SET_YDIMNAME {type=scalar string}{default=not used}
107; same as set_xdimname but for y dimension
108;
109; @keyword SET_XAXISNAME {type=scalar string}{default=not used}
110; used to defined the name of the variable containing the x axis in
111; filein input file when gridin keyword is used and when its variable
112; containing the x axis name is not the same. By default, we assume
113; both file have the same x axis name. Not that if filein includes x
114; axis there is no point to use gridin
115;
116; @keyword SET_YAXISNAME {type=scalar string}{default=not used}
117; same as set_xaxisname but for y dimension
118;
119; @keyword INMASKNAME {type=scalar string}{default=not used}
120; A string giving the name of the variable in the file maskin that
121; contains the land/sea mask
122;
123; @keyword OUTMASKNAME {type=scalar string}{default=not used}
124; same as inmaskname but for output mask file maskout
125;
126; @keyword ININVMASK {default=0}{type=scalar: 0 or 1}
127; Inverse the land/sea mask of the input mask file maskin (that should
128; have 0/1 values for land/sea)
129;
130; @keyword OUTINVMASK {default=0}{type=scalar: 0 or 1}
131; same as ininvmask but for output mask file maskout
132;
133; @keyword INUSEASMASK {type=scalar string}
134; A string giving the name of the variable in the input mask file
135; that will be used to build the input land/sea mask. In this case the
136; mask is based on the first record (if record dimension
137; exists). The input mask is build according to operator defined by INTESTOP
138; keyword (default NE) and the testing values defined as
139;   1) the second word of TESTOP if existing
140;   2) MISSING_VALUE keyword
141;   3) attribute missing_value or _fillvalue of the variable USEASMASK
142;   4) !Values.f_nan (can be used only with NE and EQ operators)
143;
144; @keyword OUTUSEASMASK {type=scalar string}
145; same as inuseasmask but for output mask file maskout
146;
147; @keyword INMISSING_VALUE {type=scalar}
148; To define (or redefine if the attribute is already existing) the
149; missing values used with INUSEASMASK keyword to build the input mask.
150; Note that this value is not used if INTESTOP keyword is given and
151; contains 2 words.
152; Note: do not mismatch with MISSING_VALUE used to detect missing
153; values at reach record.   
154;
155; @keyword OUTMISSING_VALUE {type=scalar}
156; same as inmissing_value but for output mask file maskout
157;
158; @keyword INTESTOP {default='NE'} {type=scalar string, for example 'GT 0.5'}
159; a string describing the type of test that will be done to define the
160; input mask. The test is performed on the variable specified by INUSEASMASK
161; keyword.
162; INTESTOP can contain 1 or 2 words. The first word is the operator
163; definition: "EQ" "NE" "GE" "GT" "LE" "LT" (default is NE). The
164; second word define the testing value. If INTESTOP contains only 1
165; word, then the test value is denifed by
166;   1) INMISSING_VALUE keyword
167;   2) attribute missing_value or _fillvalue of the variable INUSEASMASK
168;   3) !Values.f_nan (can be used only with NE and EQ operators)
169;
170; @keyword OUTTESTOP {default='NE'} {type=scalar string, for example 'GT 0.5'}
171; same as INTESTOP but for output mask file maskout
172;
173; @keyword INADDSCL_BEFORE {default=0}{type=scalar: 0 or 1}
174; put 1 to apply add_offset and scale factor on data before looking for
175; missing values when using INUSEASMASK keyword
176;
177; @keyword OUTADDSCL_BEFORE {default=0}{type=scalar: 0 or 1}
178; same as inaddscl_before but for output mask file maskout
179;
180; @keyword MISSING_VALUE {type=scalar}{default=defined by attribute missing_value or _fillvalue}
181; (Re)define the missing value in input data (missing values are treated
182; like masked values and will be filled with extrapolation before
183; interpolation).
184; Note: do not mismatch with (IN/OUT)MISSING_VALUE which are missing value
185; used (in association with (IN/OUT)USEASMASK) to built the mask (that
186; does not change from one record to another).
187; Note: this value will be apply to all interpolated variables
188;
189; @keyword ADDR {type=2d array or variable name}
190; 1) at the first call of file_interp:
191;   This keyword can be set to a named variable (undefined or equal to
192;   0) into which the addresses used to perform the interpolation will
193;   be copied when the current routine exits.
194; 2) Next, once this keyword is set to a defined 2d array, it is used
195;   to bypass the computation of the weights and addresses used to
196;   perform the interpolation. In this case, interpolation is much
197;   faster
198;
199; @keyword WEIG {type=2d array or variable name}
200; (see ADDR)
201;
202; @keyword INXAXISNAME {default='x', 'longitude', 'nav_lon', 'lon', 'lon_rho' or 'NbLongitudes'}{type=scalar string}
203; A string giving the name of the variable containing the x axis in
204; the input grid file gridin
205;
206; @keyword INYAXISNAME {default='y', 'latitude', 'nav_lat','lat', 'lat_rho' or 'NbLatitudes'}{type=scalar string}
207; same as inxaxisname but for the y axis in the input grid file gridin
208;
209; @keyword OUTXAXISNAME {default='x', 'longitude', 'nav_lon', 'lon', 'lon_rho' or 'NbLongitudes'}{type=scalar string}
210; same as inxaxisname but for output grid file gridout
211;
212; @keyword OUTYAXISNAME {default='y', 'latitude', 'nav_lat','lat', 'lat_rho' or 'NbLatitudes'}{type=scalar string}
213; same as inyaxisname but for output grid file gridout
214;
215; @keyword  _EXTRA
216; to use <pro>extrapolate</pro>, <pro>extrapsmooth</pro> and <pro>fromreg</pro> keywords
217;
218; @uses
219; <pro>extrapsmooth</pro>, <pro>extrapolate</pro>, <pro>fromreg</pro> and <pro>fromirr</pro>
220;
221; @restrictions
222;
223; - perform only horizontal interpolations on scalar fields
224; - all masked and missing values are filled before interpolation
225;   -> output data are not masked and have values everywhere.
226; - attributes (like valid_min...) are not updated
227; - see restrictions of <pro>fromreg</pro> and <pro>fromirr</pro>
228; - output mask is not used but, if the input file contains the mask
229;   in a variable (defined by inmaskname), this variable will contain
230;   the output mask in the ouput file
231;
232; @examples
233;
234; IDL> file_interp, filein, fileout, gridout, inxaxisname = 'lo', inyaxisname = 'la', keep = ['lo', 'la', 'cond_sed']
235;
236; IDL> file_interp, in, out, gdout, inuseasmask = 'sst', inmissing_value = -1.00000e+30, missing_value = -1000.00
237;
238; @history
239;  September 2007: Sebastien Masson (smasson\@locean-ipsl.upmc.fr)
240;
241; @version
242; $Id$
243;
244;-
245PRO file_interp, filein, fileout, gridout, GRIDIN=gridin, MASKIN=maskin, MASKOUT=maskout $
246               , KEEP=keep, REMOVE=remove, METHOD=method, SMOOTH=smooth $
247               , SET_XDIMNAME=set_xdimname, SET_YDIMNAME=set_ydimname $
248               , SET_XAXISNAME=set_xaxisname, SET_YAXISNAME=set_yaxisname $
249               , INMASKNAME=inmaskname, ININVMASK=ininvmask $
250               , INUSEASMASK=inuseasmask, INMISSING_VALUE=inmissing_value $
251               , INADDSCL_BEFORE=inaddscl_before, INTESTOP = intestop $
252               , OUTMASKNAME=outmaskname, OUTINVMASK=outinvmask $
253               , OUTUSEASMASK=outuseasmask, OUTMISSING_VALUE=outmissing_value $
254               , OUTADDSCL_BEFORE=outaddscl_before, OUTTESTOP = outtestop $
255               , MISSING_VALUE=MISSING_VALUE, WEIG=weig, ADDR=addr $
256               , INXAXISNAME=inxaxisname, INYAXISNAME=inyaxisname $
257               , OUTXAXISNAME=outxaxisname, OUTYAXISNAME=outyaxisname $
258               , _EXTRA=ex
259;
260  compile_opt idl2, strictarrsubs
261  revision = '$Id$'
262;
263  IF NOT keyword_set(method) THEN method = 'bilinear'
264;
265; input filenames checks...
266;
267  inid = ncdf_open(filein)
268  ininq = ncdf_inquire(inid)
269
270  outid = ncdf_create(fileout, /clobber)
271  ncdf_control, outid, /nofill
272
273  IF NOT keyword_set(gridin) THEN gridin = filein
274
275  IF NOT keyword_set(maskin) THEN maskin = gridin
276  IF NOT keyword_set(maskout) THEN maskout = gridout
277;
278; Copy global attributes
279;
280  FOR i = 0, ininq.ngatts-1 DO BEGIN
281    name = ncdf_attname(inid, i, /global)
282    dummy = ncdf_attcopy(inid, name, outid, /in_global, /out_global)
283  ENDFOR
284  ncdf_attput, outid, 'Created_by', revision, /GLOBAL
285;
286; x/y dim and x/yaxis informations
287;
288  ncdf_getaxis, gridin, indimidx, indimidy, inlon, inlat, xdimname = inxdimname, ydimname = inydimname $
289                , xaxisname = inxaxisname, yaxisname = inyaxisname
290  get_gridparams, inlon, inlat, jpiin, jpjin, 2
291  IF keyword_set(set_xdimname) THEN inxdimname = set_xdimname
292  IF keyword_set(set_ydimname) THEN inydimname = set_ydimname
293  IF keyword_set(set_xaxisname) THEN inxaxisname = set_xaxisname
294  IF keyword_set(set_yaxisname) THEN inyaxisname = set_yaxisname
295;
296  ncdf_getaxis, gridout, outdimidx, outdimidy, outlon, outlat, xaxisname = outxaxisname, yaxisname = outyaxisname
297  get_gridparams, outlon, outlat, jpiout, jpjout, 2
298;
299; masks
300;
301  inmask = ncdf_getmask(maskin, MASKNAME = inmaskname, INVMASK = ininvmask, USEASMASK = inuseasmask $
302                       , MISSING_VALUE = inmissing_value, ADDSCL_BEFORE = inaddscl_before, TESTOP = intestop)
303  inmasksz = size(inmask, /dimensions)
304  IF size(inmask, /n_dimensions) EQ 2 THEN inmasksz = [inmasksz, 0]
305  IF n_elements(inmaskname) EQ 0 THEN inmaskname = 'not defined' ; default definition
306  outmask = ncdf_getmask(maskout, MASKNAME = outmaskname, INVMASK = outinvmask, USEASMASK = outuseasmask $
307                        , MISSING_VALUE = outmissing_value, ADDSCL_BEFORE = outaddscl_before, TESTOP = outtestop)
308;
309; irregular grids?
310;
311  CASE 0 OF
312    array_equal(inlon[*, 0], inlon[*, jpjin-1]):inirr = 1b
313    array_equal(inlat[0, *], inlat[jpiin-1, *]):inirr = 1b
314    array_equal(inlon, inlon[*, 0]#replicate(1, jpjin)):inirr = 1b
315    array_equal(inlat, replicate(1, jpiin)#(inlat[0, *])[*]):inirr = 1b
316    ELSE:inirr = 0b
317  ENDCASE
318  CASE 0 OF
319    array_equal(outlon[*, 0], outlon[*, jpjout-1]):outirr = 1b
320    array_equal(outlat[0, *], outlat[jpiout-1, *]):outirr = 1b
321    array_equal(outlon, outlon[*, 0]#replicate(1, jpjout)):outirr = 1b
322    array_equal(outlat, replicate(1, jpiout)#(outlat[0, *])[*]):outirr = 1b
323    ELSE:outirr = 0b
324  ENDCASE
325
326  IF inirr AND method NE 'bilinear' THEN stop
327;
328; Dimensions
329;
330  indimsz = lonarr(ininq.ndims)
331  outdimsz = lonarr(ininq.ndims)
332  outdimid = lonarr(ininq.ndims)
333  FOR i = 0, ininq.ndims-1 DO BEGIN
334    ncdf_diminq, inid, i, name, size
335    indimsz[i] = size
336    outdimsz[i] = size
337    CASE 1 OF
338      strlowcase(name) EQ strlowcase(inxdimname): BEGIN
339        outdimid[i] = ncdf_dimdef(outid, name, jpiout)
340        outdimsz[i] = jpiout
341        indimx = i
342        outdimx = outdimid[i]
343      END
344      strlowcase(name) EQ strlowcase(inydimname): BEGIN
345        outdimid[i] = ncdf_dimdef(outid, name, jpjout)
346        outdimsz[i] = jpjout
347        indimy = i
348        outdimy = outdimid[i]
349      END
350      i EQ ininq.recdim: outdimid[i] = ncdf_dimdef(outid, name, /UNLIMITED)
351      ELSE: outdimid[i] = ncdf_dimdef(outid, name, size)
352    ENDCASE
353  ENDFOR
354;
355; Variables
356;
357  outvarid = lonarr(ininq.nvars)
358  FOR i = 0, ininq.nvars-1 DO BEGIN
359    varinq = ncdf_varinq(inid, i)
360    okvar = 1
361    IF keyword_set(keep) THEN okvar = total(strlowcase(keep) EQ strlowcase(varinq.name)) EQ 1
362    IF keyword_set(remove) THEN okvar = total(strlowcase(remove) EQ strlowcase(varinq.name)) EQ 0
363    IF okvar THEN BEGIN
364      IF varinq.ndims EQ 0 THEN BEGIN ; scalar variable
365        outvarid[i] = ncdf_vardef(outid, varinq.name $
366                                  , BYTE = varinq.datatype EQ 'BYTE', CHAR = varinq.datatype EQ 'CHAR' $
367                                  , SHORT = varinq.datatype EQ 'INT' OR varinq.datatype EQ 'SHORT' $
368                                  , LONG = varinq.datatype EQ 'LONG' $
369                                  , FLOAT = varinq.datatype EQ 'FLOAT', DOUBLE = varinq.datatype EQ 'DOUBLE')
370      ENDIF ELSE BEGIN          ; array
371        CASE 1 OF
372          strlowcase(varinq.name) EQ strlowcase(inxaxisname):BEGIN ; xaxis
373            IF outirr THEN dimvar = [outdimx, outdimy] ELSE dimvar = [outdimx]
374          END
375          strlowcase(varinq.name) EQ strlowcase(inyaxisname):BEGIN ; yaxis
376            IF outirr THEN dimvar = [outdimx, outdimy] ELSE dimvar = [outdimy]
377          END
378          strlowcase(varinq.name) EQ strlowcase(inmaskname):BEGIN ; mask
379            IF outmask[0] NE -1 THEN dimvar = outdimid[varinq.dim] ELSE dimvar = -1
380          END
381          (total(varinq.dim EQ indimx) + total(varinq.dim EQ indimx)) EQ 1: dimvar = -1 ; strange variable...
382          ELSE: dimvar = outdimid[varinq.dim]
383        ENDCASE
384        IF dimvar[0] NE -1 THEN BEGIN
385          outvarid[i] = ncdf_vardef(outid, varinq.name, dimvar $
386                                    , BYTE = varinq.datatype EQ 'BYTE', CHAR = varinq.datatype EQ 'CHAR' $
387                                    , SHORT = varinq.datatype EQ 'INT' OR varinq.datatype EQ 'SHORT' $
388                                    , LONG = varinq.datatype EQ 'LONG' $
389                                    , FLOAT = varinq.datatype EQ 'FLOAT', DOUBLE = varinq.datatype EQ 'DOUBLE')
390        ENDIF ELSE outvarid[i] = - 1
391      ENDELSE
392; Variables attributes
393      IF outvarid[i] NE - 1 THEN BEGIN
394        FOR j = 0, varinq.natts-1 DO BEGIN
395          name = ncdf_attname(inid, i, j)
396          dummy = ncdf_attcopy(inid, i, name, outid, outvarid[i])
397        ENDFOR
398      ENDIF
399    ENDIF ELSE outvarid[i] = -1
400  ENDFOR
401;
402  ncdf_control, outid, /endef
403;
404  FOR i = 0, ininq.nvars-1 DO BEGIN
405    IF outvarid[i] NE -1 THEN BEGIN
406      varinq = ncdf_varinq(inid, i)
407      IF varinq.ndims GE 2 THEN BEGIN
408        interp = varinq.dim[0] EQ indimx AND varinq.dim[1] EQ indimy
409      ENDIF ELSE interp = 0b
410      CASE 1 OF
411        strlowcase(varinq.name) EQ strlowcase(inxaxisname):BEGIN ; x axis
412          IF outirr THEN ncdf_varput, outid, outvarid[i], outlon $
413          ELSE ncdf_varput, outid, outvarid[i], outlon[*, 0]
414        END
415        strlowcase(varinq.name) EQ strlowcase(inyaxisname):BEGIN ; y axis
416          IF outirr THEN ncdf_varput, outid, outvarid[i], outlat $
417          ELSE ncdf_varput, outid, outvarid[i], reform(outlat[0, *])
418        END
419        strlowcase(varinq.name) EQ strlowcase(inmaskname):BEGIN ; mask
420          ncdf_varput, outid, outvarid[i], outmask
421        END
422        ELSE:BEGIN
423          IF n_elements(missing_value) NE 0 THEN var_missing_value = MISSING_VALUE $
424          ELSE ncdf_getatt, inid, i, MISSING_VALUE = var_missing_value
425          CASE varinq.ndims OF
426            0:BEGIN             ; salar
427              ncdf_varget, inid, i, data
428              ncdf_varput, outid, outvarid[i], temporary(data)
429            END
430            1:BEGIN             ; 1D
431              ncdf_varget, inid, i, data
432              ncdf_varput, outid, outvarid[i], temporary(data)
433            END
434            2:BEGIN             ; 2D
435              ncdf_varget, inid, i, data
436              IF interp THEN data = call_interp2d(temporary(data), inlon, inlat, inmask[*, *, 0], outlon, outlat $
437                                                  , INIRR = inirr, METHOD = method, SMOOTH = smooth $
438                                                  , WEIG = weig, ADDR = addr, MISSING_VALUE = var_missing_value, _extra = ex)
439              ncdf_varput, outid, outvarid[i], temporary(data)
440            END
441            3:BEGIN             ; 3D
442              FOR k = 0, indimsz[varinq.dim[2]]-1 DO BEGIN
443                incnt = [indimsz[varinq.dim[0: 1]], 1]
444                outcnt = [outdimsz[varinq.dim[0: 1]], 1]
445                off = [0, 0, k]
446                ncdf_varget, inid, i, data, offset = off, count = incnt
447                IF n_elements(inmasksz) GE 3 THEN BEGIN
448                  IF inmasksz[2] EQ indimsz[varinq.dim[2]] AND varinq.dim[2] NE ininq.recdim THEN tmpmsk = inmask[*, *, k] $
449                  ELSE tmpmsk = inmask[*, *, 0]
450                ENDIF ELSE tmpmsk = inmask[*, *, 0]
451                IF interp THEN data = call_interp2d(temporary(data), inlon, inlat, temporary(tmpmsk), outlon, outlat $
452                                                    , INIRR = inirr, METHOD = method, SMOOTH = smooth $
453                                                    , WEIG = weig, ADDR = addr, MISSING_VALUE = var_missing_value, _extra = ex)
454                ncdf_varput, outid, outvarid[i], temporary(data), offset = off, count = outcnt
455              ENDFOR
456            END
457            4:BEGIN             ; 4D
458              FOR t = 0, indimsz[varinq.dim[3]]-1 DO BEGIN
459                FOR k = 0, indimsz[varinq.dim[2]]-1 DO BEGIN
460                  incnt = [indimsz[varinq.dim[0: 1]], 1, 1]
461                  outcnt = [outdimsz[varinq.dim[0: 1]], 1, 1]
462                  off = [0, 0, k, t]
463                  ncdf_varget, inid, i, data, offset = off, count = incnt
464                  IF n_elements(inmasksz) GE 3 THEN BEGIN
465                    IF inmasksz[2] EQ indimsz[varinq.dim[2]] THEN tmpmsk = inmask[*, *, k] ELSE tmpmsk = inmask
466                  ENDIF ELSE tmpmsk = inmask[*, *, 0]
467                  IF interp THEN data = call_interp2d(temporary(data), inlon, inlat, temporary(tmpmsk), outlon, outlat $
468                                                      , INIRR = inirr, METHOD = method, SMOOTH = smooth $
469                                                      , WEIG = weig, ADDR = addr, MISSING_VALUE = var_missing_value, _extra = ex)
470                  ncdf_varput, outid, outvarid[i], temporary(data), offset = off, count = outcnt
471                ENDFOR
472              ENDFOR
473            END
474          ENDCASE
475        END
476      ENDCASE
477    ENDIF
478  ENDFOR
479
480  ncdf_close, inid
481  ncdf_close, outid
482
483  return
484END
Note: See TracBrowser for help on using the repository browser.