;------------------------------------------------------------------ ;+ ; NAME: ; ELEFIND ; PURPOSE: ; This function finds magnetic field elements in a magnetogram. ; It returns the maximum value, the location of the maximum ; value, the size in pixels, and the element number for each ; magnetic element found. An element is defined as a contiguous ; region in the image with the absolute value greater than ; a set cutoff value. Only elements with a size greater than ; the minimum value are returned. ; CATEGORY: ; POLAR ; CALLING SEQUENCE: ; retval = ELEFIND(mag,cutoff,minsize,maxsize,ycut) ; INPUTS: ; mag = input magnetogram ; cutoff = minimum field strength of a region ; minsize = minimum size of a region ; maxsize = maximum size of a region ; ycut = y cutoff value ; KEYWORD PARAMETERS: ; OUTPUTS: ; retval ; COMMON BLOCKS: ; NOTES: ; MODIFICATION HISTORY: ; J. Varsik, 14 Mar. 1996 ;- ;------------------------------------------------------------------- function elefind,mag,cutoff,minsize, maxsize, ycut magsiz = size(mag) xax = magsiz(1) retval = replicate({region, id: 0, max: 0.0, xpos: 0, ypos: 0, size: 0},$ 400) absmag = abs(mag) absmagc = absmag gt cutoff amagrl = label_region(absmagc) hmag = histogram(amagrl,reverse_indices=r) print," reg no. max. x y size" l = 0 for i = 0, n_elements(hmag)-1 do begin p = r(r(i):r(i+1)-1) qa = absmag(p) qnum = n_elements(qa) if ((qnum gt minsize) and (qnum lt maxsize)) then begin qamax = max(qa,j) q = mag(p) qmax = q(j) k = p(j) ix = k mod xax iy = k / xax if ycut gt 180 then begin if iy lt ycut then begin print,i,qmax,ix,iy,qnum retval(l) = {region,i,qmax,ix,iy,qnum} l = l + 1 endif endif else begin if iy lt ycut then begin print,i,qmax,ix,iy,qnum retval(l) = {region,i,qmax,ix,iy,qnum} l = l + 1 endif endelse endif endfor retval = retval(0:l-1) return,retval end