;+ ; NAME cavity_width.pro ; ; FUNCTION Determine coronal cavity width. ; ; SYNTAX cavity_width, xdim, ydim, xcen, ycen, pixrs, roll, pos=1 ; ; xdim, ydim image dimensions ; xcen, ycen sun center ; pixrs pixels/Rsun ; roll angle (deg) of solar north w.r.t. +Y axis. ; rpos vector of radius values [Rsun] ; apos vector of angle values [degrees] ; xpos vector of x-dimension coordinates. ; ypos vector of y-dimension coordinates. ; numpos number of positions measured ; ; pos Optional position number label. ; pfile Optional output file name. ; disp_label Option to display position number. ; ; PROCEDURES rcoord Coordinate conversion: [radius,angle] <--> [x,y] ; ; HISTORY Andrew L. Stanger HAO/NCAR 2 Dec 2004 ;- PRO cw, xdim, ydim, xcen, ycen, pixrs, roll, $ rpos, apos, xpos, ypos, ascanmin, ascanmax, $ radtop, angtop, r1, r2, $ numpos, pos=pos, pfile=pfile, disp_label=disp_label ;--- Annotation colors: white = 255 red = 254 green = 253 blue = 252 grey = 251 yellow = 250 black = 0 cs = 1.0 ; IF (STRLOWCASE (!version.os) EQ 'irix') THEN cfac = 1.0 ELSE cfac = 2.0 ; cs = cfac * 1.0 IF (KEYWORD_SET (pos)) THEN pos_num = pos $ ELSE pos_num = 1 print, 'cavity_width> pos_num: ', pos_num ;--- Draw azimuthal arcs at 1/3 & 2/3 of the cavity height. print, 'cavity_width> ascanmin/ascanmax: ', ascanmin, ascanmax anginc = 0.5 angrange = 40.0 angmid = angtop angbeg = angtop - angrange * 0.5 itmax = 160 itmax = FIX (angrange / anginc + 0.5) print, 'cavity_width> xcen/ycen: ', xcen, ycen print, 'cavity_width> pixrs: ', pixrs print, 'cavity_width> radtop/angtop: ', radtop, angtop print, 'cavity_width> r1/r2: ', r1, r2 FOR it = 0, itmax DO $ BEGIN ;{ angle = it * anginc + angbeg ierr = rcoord (r1, angle, x1, y1, 1, roll, xcen, ycen, pixrs) ierr = rcoord (r2, angle, x2, y2, 1, roll, xcen, ycen, pixrs) ; print, 'cavity_width> r1/angle: ', r1, angle, ' x1/y1: ', x1, y1 PLOTS, [x1-1, x1+1], [y1-1, y1+1], /DEVICE, color=green PLOTS, [x1-1, x1+1], [y1+1, y1-1], /DEVICE, color=green PLOTS, [x2-1, x2+1], [y2-1, y2+1], /DEVICE, color=green PLOTS, [x2-1, x2+1], [y2+1, y2-1], /DEVICE, color=green END ;} ;--- Create arrays for angle, radius & position values. angbuf = FLTARR (100) radbuf = FLTARR (100) xbuf = INTARR (100) ybuf = INTARR (100) angle = 0.0 radius = 0.0 ;--- Use mouse to identify cavity edges along arcs drawn onto the image. TVCRS, xcen, ycen ; Enable cursor PRINT, 'Use mouse and click at the left & right edges of the cavity' PRINT, 'along BOTH the lower and upper azimuthal arcs.' PRINT, 'Click middle mouse button to terminate position measurements.' i = 0 WHILE ( 1 ) DO $ BEGIN ;{ CURSOR, rxcur, rycur, /DEVICE, WAIT=3 IF (!ERR EQ 2) THEN GOTO, quit ; Done if middle button clicked. ierror = rcoord (radius, angle, rxcur, rycur, -1, roll, xcen, ycen, pixrs) ; PRINT, 'x, y: ', rxcur, rycur, ' radius, angle: ', radius, angle PRINT, FORMAT = '("[x,y]: ", i4, i4, " [r,th]: ", F5.2, " Rsun ", F7.2, " degrees")', $ rxcur, rycur, radius, angle WAIT, 0.5 ;--- Write Region information into log file. ; OPENW, lulog, logfile, /GET_LUN ; PRINTF, lulog, 'Mouse-Defined Curved Wedge Region: ', $ ; STRING (aoinum, FORMAT='(i3)') ; PRINTF, lulog, STRING (rmin, FORMAT='(F7.2)'), ' --> ', $ ; STRING (rmax, FORMAT='(F7.2)'), ' Rsun ', $ ; STRING (angmin, FORMAT='(F7.2)'), ' --> ', $ ; STRING (angmax, FORMAT='(F7.2)'), ' degrees' ; PRINTF, lulog, 'polygon vertices file: ', pvfile ; CLOSE, lulog ; FREE_LUN, lulog ;--- Write info to screen. ; PRINT, STRING (rmin, FORMAT='(F7.2)'), ' --> ', $ ; STRING (rmax, FORMAT='(F7.2)'), ' Rsun ', $ ; STRING (angmin, FORMAT='(F7.2)'), ' --> ', $ ; STRING (angmax, FORMAT='(F7.2)'), ' degrees' ;--- Draw an "+" to mark cursor position. xv = [rxcur - 3, rxcur + 3] yv = [rycur, rycur] PLOTS, xv, yv, /DEVICE, color=red xv = [rxcur, rxcur ] yv = [rycur - 3, rycur + 3] PLOTS, xv, yv, /DEVICE, color=red IF (KEYWORD_SET (disp_label)) THEN $ XYOUTS, rxcur+5, rycur, STRTRIM (STRING (pos_num), 2), $ charsize=cs, /DEVICE, color=red ;--- Write information to text file. IF (KEYWORD_SET (pfile)) THEN $ BEGIN CLOSE, 21 OPENU, 21, pfile, /APPEND spos_num = STRING (pos_num, FORMAT='(I3)') sradius = STRING (radius, FORMAT='(F6.2)') sangle = STRING (angle , FORMAT='(F8.2)') PRINTF, 21, 'Position #', spos_num, ' radius:', sradius, $ ' P.A.:', sangle CLOSE, 21 END radbuf [i] = radius angbuf [i] = angle xbuf [i] = rxcur ybuf [i] = rycur i = i + 1 pos_num = pos_num + 1 END ;} quit: WAIT, 1.0 ;--- Copy information to arrays with the correct dimension lengths. numpos = i rpos = FLTARR (i) apos = FLTARR (i) xpos = FLTARR (i) ypos = FLTARR (i) rpos [0:i-1] = radbuf [0:i-1] apos [0:i-1] = angbuf [0:i-1] xpos [0:i-1] = xbuf [0:i-1] ypos [0:i-1] = ybuf [0:i-1] print, 'cavity_width> numpos: ', numpos print, 'cavity_width> rpos : ', rpos print, 'cavity_width> apos : ', apos pos = pos_num END