function WDETREND, sig, TT ;+ ;NAME: ; WDETREND ; ;PURPOSE: ; To remove a linear bias from the "sig" data array. ; ;CATEGORY: ; Wavelets ; ;CALLING SEQUENCE: ; out = WDETREND(sig) ; ;INPUTS: ; sig = current data array/signal ; ;OUTPUTS: ; out = now detrended data array/signal ; TT = 'I' if image and 'S' if signal ; ;EXAMPLE ; IDL> ;Truncate sig array appropriately and get QMF ; IDL> WINTWAVE, sig, WaveType, ParVal, QMF, LD ; IDL> tt = 'S' if 1D dataset or tt = 'I' if 2D dataset ; IDL> ;Detrend dataset ; IDL> sig = WDETREND(sig, tt) ; IDL> See the detrended data ; IDL> If tt EQ 'S' then WPLOTIT, st, 1, sig ELSE WPLOTIT, st, 10, sig ; ;MODIFICATION HISTORY: ; Amara Graps September 1995. ; copyright (c) Amara Graps 1995, 1996. ;- TT = WSIGTYPE(sig, len, error) CASE error OF 1: BEGIN ;Valid array or matrix CASE TT OF 'I': BEGIN ;byte image..detrend row by row pval = BYTARR(len, len) ;initialize pval FOR ix = 0, len-1 DO BEGIN row = sig(*, ix) indx = BINDGEN(len) pfit = POLY_FIT(indx,row,1) ;fit poly of order 1 (get coeffs) ;Evaluate terms using coefficients pval(*,ix) = POLY(indx, pfit) END ;end END 'S': BEGIN ;signal x = FINDGEN(len) pfit = POLY_FIT(x, sig, 1) ;fit poly of order 1 (get coeffs) ;Evaluate terms using coefficients pval = POLY(x, pfit) END ENDCASE ;TT END ;valid array or matrix ELSE: PRINT, 'Not valid data/signal array or matrix!' ENDCASE ;error ;Remove linear trend sig = sig - pval RETURN, sig END ;of function wdetrend.pro