PRO fancy ;+ ; NAME: ; fancy ; PURPOSE: ; Displaying of time series. Allows adding of labels ; CATEGORY: ; Plotting ; CALLING SEQUENCE: ; fancy ; CALLS: ; echo,fan_plot,fan_read,spitplot ; INPUTS: ; From ASCII files (as e.g. created by the TFANCY procedure) ; OUTPUTS: ; Plots to terminal. PostScript files. Hardcopies. ; INCLUDE: @compile_opt.pro ; On error, return to caller ; COMMON BLOCKS: (shared with FAN_READ and FAN_PLOT) common CFANCY, ipmax,ip,btyp,blow,bup common TFANCY, year0,doy0,tunit,T0,F0,T1,F1,T2,F2,T3,F3,T4,F4,T5,F5 common SFANCY, iparr,ipio,ipauto,iptitle,ipsym,iplin,ipthick,ipslab,ipslabxy common DEVICES, plotdev common LABELS, ploti,plotlab,plotx,ploty,plotcomm,plotsz ; CALLS: ; InitVar ; RESTRICTIONS: ; Header of ASCII file must contain year and doy defining time origin. ; Times must be given in hours since the time origin ; PROCEDURE: ; - Choose between linear/logarithmic y-axis ; - Add labels at location selected with spin-hair cursor ; - Add labels for Y-axis (blank by default) ; - Overlay multiple time series ; - Use same Y-axis for overlay or draw new Y-axis ; ; ip+1 # time series currently in memory ; iparr indices (from [0,ip]) of time series selected for plotting ; MODIFICATION HISTORY: ; MAY-1991, Paul Hick (ARC) ;- ipmax = 5 ; Max # time series is ipmax+1 InitVar, ip , -1 ; Time series index InitVar, iparr , -1 InitVar, ploti , -1 InitVar, ipslabxy, [-1,-1] Option = [ 'eXit', $ 'Read data file', $ 'Select time series', $ 'Customize time series display', $ 'Label using graphics cursor', $ 'Hardcopy', $ 'clear Arrays', $ 'clear Plot'] cOption = ['X','R','S','C','L','H','A','P'] nOption = n_elements(Option) availab = replicate(0B,nOption) availab[0] = 1B select = 0 theplot = 0B MENU: data_read = ip NE -1 ; Data in memory data_full = ip EQ ipmax ; Data arrays are full plot_made = iparr[0] NE -1 ; Time series has been selected plot_full = plot_made AND n_elements(iparr) EQ ipmax availab[1] = NOT data_full availab[2] = data_read AND NOT plot_full availab[3] = plot_made availab[4] = plot_made availab[5] = plot_made availab[6] = data_read availab[7] = plot_made IF plot_made AND theplot THEN fan_plot twin, /hide print, ' FANCY Menu:' FOR A=0,nOption-1 DO IF availab[A] then echo, Option[A] select = (select+1) < 4 A = cOption[select] REPEAT BEGIN REPEAT BEGIN echo, ' Your choice', A A = strupcase(strmid(A,0,1)) select = (where(A EQ cOption))[0] ENDREP UNTIL select NE -1 ENDREP UNTIL availab[select] theplot = 0B CASE select OF 0: RETURN 1: fan_read 2: BEGIN message, /info, '# TIME SERIES IN MEMORY : '+strcompress(ip+1,/rem) IF (where(btyp GE 0, A))[0] NE -1 then message, /info, $ '# HXIS TIME SERIES : '+strcompress(fix(A),/remove_all) FOR I=0,ip DO BEGIN IF (where(iparr EQ I))[0] EQ -1 THEN BEGIN CASE btyp[I] OF 0: BEGIN CASE blow[I] OF bup[I]: print, format='(2(A,I1))', ' Plot ',I,' : count rate in band ',blow[I] ELSE: print, format='(3(A,I1))', ' Plot ',I,' : count rate in bands ',blow[I],' through ',bup[I] ENDCASE END 1: print, format='(3(A,I1))', ' Plot ',I,' : temperature based on ratio of bands ',blow[I],' and ',bup[I] 2: print, format='(3(A,I1))', ' Plot ',I,' : emission measure based on ratio of bands ',blow[I],' and ',bup[I] ELSE: print, format='(A,I1,A)',' Plot ',I,' : time series' ENDCASE ENDIF ENDFOR echo, 'Select time series', I, 0, ip IF NOT plot_made THEN BEGIN iparr = I ipio = 0 ipauto = 1 iptitle = '' ipsym = n_elements(iparr)-1 ipslab = '' iplin = 0 ipthick = 1. ENDIF ELSE BEGIN iparr = [iparr,I] ipio = [ipio,0] ipauto = [ipauto,1] iptitle = [iptitle,''] ipsym = [ipsym,n_elements(iparr)-1] ipslab = [ipslab,''] iplin = [iplin,0] ipthick = [ipthick,1.] ENDELSE nparr = n_elements(iparr) theplot = 1B END 3: BEGIN SUBMENU: IF !d.name EQ 'TEK' THEN BEGIN A = '' & read, '', A & davis, 1 & twin, /hide ENDIF print print, 'Submenu for customizing time series:' print, '0. Back to main menu print, '1. Linear or logarithmic scale for Y-axis print, '2. Titles for Y-axis print, '3. Symbols to mark data points print, '4. Line types to connect data points print, '5. Line thickness print, '6. Labels for selected symbols IF nparr GT 1 THEN $ print, '7. Auto scaling or scaling of first time series select = 1 echo, 'Choose option', select, 0, 6+(nparr GT 1) CASE select OF 0: BEGIN theplot = 1B & goto, MENU & END 1: BEGIN echo, '0 = linear Y-axis / 1 = logarithmic Y-axis / 2 = Back to submenu' FOR I=0,nparr-1 DO BEGIN A = ipio[I] echo, 'Times series #'+strcompress(iparr[I]), A,0,2 if A eq 2 then goto, SUBMENU ipio[I] = A ENDFOR END 2: BEGIN echo, 'Type string for title / 2 = Back to submenu for I=0,nparr-1 do begin A = iptitle[I] echo, 'Times series #'+strcompress(iparr[I]), A if A eq '2' then goto, SUBMENU iptitle[I] = A ENDFOR END 3: BEGIN echo, '0=No mark / 1=+ / 2=* / 3 =. / 4=diamond' echo, '5=triangle / 6=square / 7=X / 8=User / *** 9=Back to submenu FOR I=0,nparr-1 DO BEGIN A = ipsym[I] echo, 'Times series #'+strcompress(iparr[I]), A, 0, 9 IF A EQ 9 THEN goto, SUBMENU ipsym[I] = A*( (ipsym[I] GE 0)-(ipsym[I] LT 0) ) ENDFOR END 4: BEGIN echo, '-1/No line/0=Solid/1=Dotted/2=Dashed/3=DashDot/4=DashDotDotDot/5 = LongDash/ *** 6 =Back to submenu FOR I=0,nparr-1 DO BEGIN A = iplin[I] echo, 'Times series #'+strcompress(iparr[I]), A, -1, 6 CASE A OF 6: goto, SUBMENU -1: ipsym[I] = abs(ipsym[I]) ELSE: BEGIN iplin[I] = A & ipsym[I] = -abs(ipsym[I]) END ENDCASE ENDFOR END 5: BEGIN echo, 'Line thickness: 1=normal, 2=double wide, etc. / *** 0 = Back to submenu FOR I=0,nparr-1 DO BEGIN IF ipsym[I] LE 0 THEN BEGIN A = ipthick[I] echo, 'Times series #'+strcompress(iparr[I]), A IF A EQ 0 THEN goto, SUBMENU ipthick = min([A,1.]) ENDIF ELSE echo, 'Points for time series #'+strcompress(iparr[I])+' not connected ENDFOR END 6: BEGIN FOR I=0,nparr-1 DO BEGIN A = ipslab[I] echo, 'Label for series #'+strcompress(iparr[I])+'(- to clear)', A CASE A OF '-': ipslab[I] = '' '' : ipslab[I] = '' ELSE: ipslab[I] = A ENDCASE ENDFOR IF (where(ipslab ne ''))[0] ne -1 then begin twin, /show & davis, 0 echo, 'Click position to fix position labels pcursor, xpos,ypos, /normal ipslabxy = [xpos,ypos] ENDIF ELSE ipslabxy = [-1,-1] END 7: BEGIN echo, '0 = fixed scaling / 1 = auto scaling / 2 = Back to submenu echo, '(zeroth timeseries is autoscaled)' FOR I=1,nparr-1 DO BEGIN A = ipauto[I] IF A EQ ipauto[0] THEN BEGIN echo, 'Times series #'+strcompress(iparr[I]), A, 0, 2 IF A EQ 2 THEN goto, SUBMENU ipauto[I] = A ENDIF ELSE echo, 'Opposite lin/log scaling for time series #'+strcompress(I) ENDFOR END ENDCASE goto, SUBMENU END 4: BEGIN echo, 'Add labels into plot at location selected with graphics cursor lab = ".." & echo, 'Label (0 = STOP; - = Clear all labels)', lab WHILE lab NE '0' AND lab NE '-' DO BEGIN sz = 1. & echo, 'Character size (1=normal)', sz & sz = max([sz,1.0]) echo, 'Click to fix position for label twin, /show & davis, 0 & pcursor, xpos,ypos, /normal ploti = ploti+1 & si = strcompress(ploti,/rem) szi = strcompress(sz,/remove_all) comm = 'xyouts, plotx['+si+'],ploty['+si+'],/normal,charsize='+ $ szi+', plotlab['+si+']' IF ploti EQ 0 THEN BEGIN plotlab = lab & plotsz = sz plotx = xpos & ploty = ypos plotcomm = comm ENDIF ELSE BEGIN plotlab = [plotlab ,lab ] & plotsz = [plotsz,sz] plotx = [plotx ,xpos] & ploty = [ploty ,ypos] plotcomm = [plotcomm,comm] ENDELSE STAT = execute(comm) lab = ".." & echo, 'Label (0 = STOP; - = Clear all labels)', lab ENDWHILE IF lab EQ '-' THEN BEGIN ploti = -1 & echo, 'AXIS LABELS CLEARED' & END theplot = 1B END 5: BEGIN set_plot, plotdev fan_plot plotfile = 'IDL.'+plotdev A = 0B & echo, 'Keep '+plotdev+' file', A, /logical IF A THEN BEGIN A = plotfile & echo, /file, 'Rename '+plotdev+' file', A ENDIF spitplot, plotfile, keep=A END 6: BEGIN ip = -1 & echo, 'DATA ARRAYS CLEARED' & END 7: BEGIN iparr = -1 & echo, 'PLOT CLEARED' & twin, /hide, /delete & END ENDCASE goto, MENU RETURN & END