FUNCTION TimeInterpol, FF, TT, T, Unit, _extra=_extra ;+ ; NAME: ; TimeInterpol ; PURPOSE: ; Interpolation of a function of time. ; CATEGORY: ; Tell time ; CALLING SEQUENCE: ; F = TimeInterpol(FF, TT, T, Unit, _extra=_extra) ; INPUTS: ; FF array[n]; type: any numerical array ; list of function values ; TT array[n]; type: time structure ; list of times where function values FF are supplied ; T array[m]; type: time structure ; list of times where interpolates are needed ; OPTIONAL INPUT PARAMETERS: ; Unit scalar; type: integer; default: TimeUnit(/days) ; time units used for the interpolation (see PROCEDURE) ; _extra=_extra ; extra keyword passed to IDL function 'interpol' ; OUTPUTS: ; F array[n]; type: same as FF ; list of interpolated values at times T ; INCLUDE: @compile_opt.pro ; On error, return to caller ; CALLS: ; InitVar, IsType, TimeUnit, TimeOp, SyncDims ; PROCEDURE: ; Input arrays TT and T are converted to time differences relative to ; TT[0] in units specified by the Unit argument. Interpolation is done ; with the IDL interpol function using these time difference arrays. ; MODIFICATION HISTORY: ; MAR-2001, Paul Hick (UCSD/CASS) ; SEP-2001, Paul Hick (UCSD/CASS) ; Added interpolation on multidimensional arrays ; JAN-2004, Paul Hick (UCSD/CASS; pphick@ucsd.edu) ; Added check for new time of time structure ;- InitVar, Unit, TimeUnit(/days) T0 = TT[0] TTU = TimeOp(/subtract, TT, T0, unit) TU = TimeOp(/subtract, T, T0, unit) sz = size(FF) nz = sz[0] CASE nz OF 0 : F = interpol(FF, TTU, TU, _extra=_extra) ; Scalar 1 : F = interpol(FF, TTU, TU, _extra=_extra) ; 1-dim array ELSE: BEGIN mz = sz[nz+2]/sz[nz] FF = reform(FF, mz, sz[nz], /overwrite) F = make_array(type=IsType(FF), dim=[mz,n_elements(TU)]) FOR i=0,mz-1 DO F[i,*] = interpol(FF[i,*],TTU, TU, _extra=_extra) SyncDims, FF, size=sz END ENDCASE RETURN, F & END