(mostly simple) IDL codes



Hogbom Clean
Cross-correlation alignment / offset calcuation


IDL is not great at doing things along axes. For example, in python, if you wanted the standard deviation along one axis of a 2D array, you would write std(x,axis=1) or better yet x.std(axis=1) . In IDL, to achieve similar functionality, I needed to write this code (syntax highlighting uses Google Code Prettify which is not IDL-compatible). However, IDL 8.0 allows to you do std(array,dim=1) now.
; stddevaxis
; takes an n-dimensional array in variable 'x' and returns the
; standard deviation along the axis specified by 'dimension'
; should be equivalent to Python's std(x,axis=n)
; OPTIONS:
;   NAN allows you to specify that NAN values should be ignored
;   _extra parameters can be passed to stddev if a 1-d array is passed
;       or the usual stddev is desired
function stddevaxis,x,dimension=dimension,nan=nan,_extra=extra 
    if keyword_set(dimension) then begin
        dimsize = size(x,/dim)
        dimmean = total(x,dimension,nan=nan) / float(dimsize[dimension-1])
        dimvar = total( (x - dimmean#replicate(1,dimsize[dimension-1]))^2 ,dimension,nan=nan)$
            / float(dimsize[dimension-1])
        dimstd = sqrt(dimvar)
        return,dimstd
    endif else return,stddev(x,nan=nan,_extra=extra)
    end

# #