function plot_lcur, struct, array, ref_time, noplot=noplot, qblowup=qblowup, $ psym=psym, symsize=symsize, $ plotr=plotr, title=title, $ nohard=nohard, qhard=qhard, $ nomultiset=nomultiset, multiset=multiset, $ qreset=qreset, $ extra1=extra1, qextra1=qextra1, $ xsel=xsel, ysel=ysel, $ ynozero=ynozero, $ nowhere=nowhere, $ fem = fem, $ yrange = yrange ; ;+ ;NAME: ; plot_lcur ;PURPOSE: ; Plot a light curve and allow the user to blowup ; on certain areas. It returns the subscripts of ; the last selected region. ;CALLING SEQUENCE: ; ss = plot_lcur(roadmap, roadmap.sxs1) ; ss = plot_lcur(roadmap, /nodata, qblowup=qblowup) ; ss = plot_lcur(index, gt_sum_l(index), plotr=a, title=title) ; ss = plot_lcur(index, gt_sum_l(index), /nohard) ;INPUT: ; struct - the structure that holds the .time and .day fields ; If struct is a floating point array, and ref_time is ; not passed in, then PLOT will be used instead of UTPLOT ; array - the array to be plotted ;OPTIONAL INPUT: ; ref_time- The reference time to use with UTPLOT. If it is ; undefined, then struct(0) is used. Must be in form of ; a structure (.time, .day fields) (?) ;OPTIONAL KEYWORD INPUT: ; noplot - If set, do not plot any data, but allow the user ; to select a starting and ending time to be blown ; up (used for cases where the data to be plotted is ; more complex) ; psym - the plotting symbol used. Default is 1 (a + sign) ; title - A title string for the plot ; nohard - If set, do not allow or display the hardcopy capabiltiy ; nomultiset - If set, do not allow multiple selection ; extra1 - A string with a description to be used for the lower left ; box/right button key option ; nowhere - If set, then do not do a "where" to find the subscripts ; of the selected times. It is used in conjunction with ; the /NOPLOT option and the XSEL value is passed back ; to be used by the calling routine ;OPTIONAL KEYWORD OUTPUT: ; qblowup - used with the /noplot option. Tells the calling ; procedure that the user wants a blowup of the ; selected area. ; plotr - Returns the min and max subscripts of the input ; vector that were used for the last plot (refresh of ; the screen). This allows a programmer to plot light ; curves for the extracted datasets AND for a larger ; region that goes beyond the extracted datasets. ; Bob Bentley requested this capability ; multiset- If the user wants to select multiple start and end times, ; using the middle button on the left box, the resulting ; matrix of 2xN subscripts will be returned, where the ; (0,*) is the starting subscript and (1,*) is the end. ; Using the reset option will clear the accumulated ; marks. ; qhard - used with the /noplot option. Tells the calling ; procedure that the user wants a hardcopy of the ; selected area. ; qhard - used with the /noplot option. Tells the calling ; procedure that the user wants to reset to the full ; range. ; qextra1 - if bottom left box/right button was select, return ; true ; xsel - the x data coordinates selected. ; ysel - the y data coordinates selected. ;RESTRICTIONS: ; Only works on workstations that have a puck to allow the ; CURSOR function to work. ;HISTORY: ; Written 4-Mar-92 by M.Morrison ; 20-Mar-92 (MDM) - Added "plotr" and "title" options ; - Also added hard copy capability ; 20-Mar-92 (MDM) - Added the "multiset" option ; 29-Apr-92 (MDM) - Removed the /DELETE command from hardcopy ; option ; 29-Apr-92 (MDM) - Added "qhard" and "qreset" option ; 2-May-92 (MDM) - Added "extra1" and "qextra1" options as ; well as "xsel" and "ysel" option ; 5-May-92 (MDM) - Changed "extra" option to use box_cursor ; to mark the box to select ; - Added "nomultiset" option ; 26-May-92 (MDM) - Expanded to work with TEK plotting device ; 29-May-92 (MDM) - Added "ynozero" ; 9-Jun-92 (MDM) - Adjusted so that an floating array can be passed in ; as the X parameter (previously it had to be a structure) ; 14-Jul-93 (MDM) - Added SYMSIZE ; 25-Jul-94 (MDM) - Moved the print statement for the instructions outside ; of the loop ; 10-Mar-95 (MDM) - Modified to accept a floating point array as "x" input ; and to simply plot "x" versus "y" if REF_TIME is not ; passed in (ie: not to call UTPLOT) ; 15-Jan-95 (LWA) - Replaced indgen with lindgen to handle larger arrays. ;- ; qsimple_plot = (data_type(struct) eq 4) and (n_elements(ref_time) eq 0) ; qdebug = 0 if (n_elements(psym) eq 0) then psym = 1 if (n_elements(ref_time) eq 0) then ref_time = struct(0) if (n_elements(title) eq 0) then title = '' if (n_elements(symsize) eq 0) then symsize = 1 if (n_elements(ynozero) eq 0) then ynozero = 0 ; if (!d.name eq 'X') then begin if (!d.window eq -1) then window else wshow factor = 1 end else begin ;assumes TEK factor = 6 end qextra1 = 0 ; siz = size(struct) typ = siz( siz(0)+1 ) if (typ eq 8) then x = int2secarr(struct, ref_time) else x = struct ; xmin = min(x) xmax = max(x) ss = lindgen(n_elements(x)) ss0 = ss ; ymin0 = min(array) ymax0 = max(array) if (n_elements(xsel) ne 0) then xsel0 = xsel else xsel0 = [xmin, xmax] ;needed because of /noplot option ;in order to remember what was done last ;if don't want to require they always give ;a start and a stop if (n_elements(ysel) ne 0) then ysel0 = ysel else ysel0 = [min(array), max(array)] xsel = 0 ysel = 0 ; plotr = [0, n_elements(x)-1] multiset = 0 ; ;----- MDM moved print statement outside of the loop 25-Jul-94 print, 'Use Middle key on plot to exit print, ' On plot, use left key to mark starting time, right key to mark ending time print, ' On lower right box, use left key to blowup, right key to reset to full view print, ' On lower left box, use left key to hardcopy, middle key for multiple set marking' if (!d.name eq 'TEK') then begin print, ' For TEK device, use key L, M, and R to signify left/middle/right buttons end ; nx = !d.x_size box = 30*factor xx1 = [nx, nx-box, nx-box, nx, nx] yy1 = [ 0, 0, box, box, 0] xx2 = [ 0, box, box, 0, 0] yy2 = [ 0, 0, box, box, 0] qdone = 0 qplot = 1 qreset = 0 while (not qdone) do begin print, '************ Currently there are ', strtrim(n_elements(ss), 2), ' points selected if ((not keyword_set(noplot)) and qplot) then begin if (qsimple_plot) then begin plot, struct(ss), array(ss), psym=psym, title = title, ynozero=ynozero, symsize=symsize end else begin utplot, struct(ss), array(ss), ref_time, psym=psym, title = title, ynozero=ynozero, symsize=symsize, yrange = yrange, fem = fem end plotr = [min(ss), max(ss)] end ; str = '!18' if (keyword_set(nohard)) then str = str + ' /' else str = str + 'Hardcopy/' if (keyword_set(nomultiset)) then str = str + ' /' else str = str + 'Multi/' if (keyword_set(extra1)) then str = str + extra1 + '!3' else str = str + '!3' polyfill, xx1, yy1, /device & xyouts, nx-box-130*factor, 0, '!18Blowup/ /Reset!3', size=1.4, /device, font=-1 polyfill, xx2, yy2, /device & xyouts, box+10*factor, 0, str, size=1.4, /device, font=-1 ; cursor, x0, y0, /data, /down case !d.name of 'X': button = !err 'TEK': begin button = -1 if (strupcase(string(byte(!err))) eq 'L') then button = 1 if (strupcase(string(byte(!err))) eq 'M') then button = 2 if (strupcase(string(byte(!err))) eq 'R') then button = 4 if (button eq -1) then print, 'Key not recognized. Use L,M,R please', string(7b) end else: button = -1 ;trap on this case? endcase temp = convert_coord(x0,y0,/data,/to_device) x0dev = temp(0) y0dev = temp(1) ;y position in device coordinates if (qdebug) then print, button, y0 ; if (button eq 1) then begin & xmin0 = x0 & xmax0 = xmax & end ;temporary working min/max variables if (button eq 4) then begin & xmax0 = x0 & xmin0 = xmin & end ; qbox1 = ((y0dev lt box) and (x0dev gt (nx-box))) qbox2 = ((y0dev lt box) and (x0dev lt box)) qplot = 0 qblowup = 0 qhard = 0 case 1 of qbox1: begin if (button eq 1) then begin ;blow up option qblowup = 1 qplot = 1 end if (button eq 4) then begin ;reset qreset = 1 qplot = 1 ss = lindgen(n_elements(struct)) xmin = min(x) ;reset min/max to the full range xmax = max(x) multiset = 0 xsel = 0 ysel = 0 xsel0 = [xmin, xmax] ysel0 = [min(array), max(array)] end end qbox2: begin if ((button eq 1) and (not keyword_set(nohard))) then begin ;hard copy if (not keyword_set(noplot)) then begin dsave = !d.name set_plot, 'ps' n1 = n_elements(ss) n2 = plotr(1) - plotr(0) + 1 sss = lindgen(n2) + plotr(0) if (qsimple_plot) then begin plot, struct(sss), array(sss), psym=psym, title = title, ynozero=ynozero, symsize=symsize end else begin utplot, struct(sss), array(sss), ref_time, psym=psym, title = title, ynozero=ynozero, symsize=symsize end if (sss(0) ne ss(0)) then begin if (typ eq 8) then xmark = int2secarr(struct(ss(0)), ref_time) else xmark = struct(ss(0)) plot_vline, xmark end if (sss(n2-1) ne ss(n1-1)) then begin if (typ eq 8) then xmark = int2secarr(struct(ss(n1-1)), ref_time) else xmark = struct(ss(n1-1)) plot_vline, xmark end ;pprint, /delete pprint set_plot, dsave end else begin qhard = 1 end end if (button eq 2) then begin ;multiple set selection temp = [min(ss), max(ss)] if (n_elements(multiset) le 1) then multiset = temp else multiset = [[multiset], [temp]] if (n_elements(xsel) le 1) then begin xsel = xsel0 ysel = ysel0 end else begin xsel = [[xsel], [xsel0]] ysel = [[ysel], [ysel0]] end end if (button eq 4) then begin ;extra option 1 box_cursor, xx0, yy0, nx0, ny0, /message temp0 = convert_coord(xx0,yy0,/device,/to_data) temp1 = convert_coord(xx0+nx0,yy0+ny0,/device,/to_data) xsel0 = [temp0(0), temp1(0)] ysel0 = [temp0(1), temp1(1)] if (n_elements(xsel) le 1) then begin xsel = xsel0 ysel = ysel0 end else begin xsel = [[xsel], [xsel0]] ysel = [[ysel], [ysel0]] end qextra1 = 1 ;; qdone = 1 end end else: begin if ((button eq 1) or (button eq 4)) then begin if (button eq 1) then ymin0 = y0 if (button eq 4) then ymax0 = y0 if (ymax0 lt ymin0) then begin ;reverse to have ymin0 be the lower value tmp = ymin0 ymin0 = ymax0 ymax0 = tmp end ysel0 = [ymin0, ymax0] ss0 = 0 if (not keyword_set(nowhere)) then ss0 = where((x ge xmin0) and (x le xmax0)) if (ss0(0) eq -1) then begin print, 'No datasets selected with current selection of times', string(7b) print, 'Not updating "SS" vector end else begin ss = ss0 plot_vline, x0 xmin = xmin0 ;only update min/max if it is a good value xmax = xmax0 xsel0(0) = xmin xsel0(1) = xmax end end else begin qdone = 1 end end endcase if ((!d.name eq 'TEK') and (button eq -1)) then qdone = 0 ;reset - not done if they made a mistake if (keyword_set(noplot) and qblowup) then qdone = 1 if (keyword_set(noplot) and qhard) then qdone = 1 if (keyword_set(noplot) and qreset) then qdone = 1 end ; if (n_elements(xsel) le 1) then begin xsel = xsel0 ysel = ysel0 end ; return, ss end