;+ ; NAME: ; robomarg ; PURPOSE: (one line) ; Return the robust averages of each row or each column. ; DESCRIPTION: ; This routine calls robomean on a row-by-row or col-by-col basis ; to get the robust mean of each row or each column. The /GetRowMeans ; keyword returns a column containing the robust average of all of ; the rows. The /GetColMeans keyword returns a row with the robust ; averages of all the columns. /GetRowMeans is the default. ; CATEGORY: ; spectral extraction ; CALLING SEQUENCE: ; means = robomarg(array) ; INPUTS: ; array - Input array to be scanned. ; OPTIONAL INPUT PARAMETERS: ; KEYWORD INPUT PARAMETERS: ; GetRowMeans - FLAG, return a column which contains the ; robust means of each row. ; GetColMeans - FLAG, return a row which contains the ; robust means of each column. ; bad - bad pixel mask (1 = bad, 0 = good) ; OUTPUTS: ; means - The 1-D column or row with averages ; KEYWORD OUTPUT PARAMETERS: ; COMMON BLOCKS: ; SIDE EFFECTS: ; RESTRICTIONS: ; PROCEDURE: ; MODIFICATION HISTORY: ; 96/06/06, EFY, NASA Ames Research Center ; 96/10/17, EFY, changed to a function that returns means ; 01/11/02, LAY, add bad pixel mask option ;- function robomarg,array, $ GetRowMeans=x_dir, GetColMeans=y_dir, BAD = bad if keyword_set(x_dir) AND keyword_set(y_dir) then begin message,'Only one of GetRowMeans, GetColMeans keywords can be set at once.' endif if keyword_set(y_dir) then array = transpose(array) sz=size(array) nCol = sz(1) nRow = sz(2) if nCol eq 1 then return, array means = fltarr(nRow) for i = 0,nRow-1 do begin x = array[*,i] if keyword_set(bad) then begin b = bad[*,i] gd = where (b ne 1, ngd) if ngd eq 0 then begin means(i) = 0. endif else begin if ngd eq 1 then begin means(i) = x[gd[0]] endif else begin if stdev(x[gd], m) eq 0 then begin means(i) = m endif else begin robomean, x, 5.0, 0.5, avg,avgdev,stddev,var,skew,kurt,nfinal, bad=b bad[*,i]=b means(i) = avg endelse endelse endelse endif else begin ; not keyword_set(bad) if stdev(x, m) eq 0 then begin means(i) = m endif else begin robomean, x, 5.0, 0.5, avg,avgdev,stddev,var,skew,kurt,nfinal means(i) = avg endelse endelse endfor if keyword_set(y_dir) then array = transpose(array) return, means end