; NAME : magplot ; PURPOSE : ; display magnetograms and field lines ; CATEGORY : ; solar magnetic field computation package (MAGPACK2) ; CALLING SEQUENCE : ; magplot, mparam, rdata ; INPUTS : ; mparam : magnetogram parameters ; rdata : magnetogram data ; if these are not specified, data will be read from files ; OPTIONAL INPUT PARAMETERS : ; none ; KEYWORD PARAMETERS : ; filename = data file name(s) ; dir = directory where data exist ; if not specified, NAOJ standard data directory is set ; nomenu : if specified, data are assumed to be already in ; rdata array, and file selection menu is not displayed ; askloffile : if specified and a standard field line file ; (*.L) is not found, an alternative file name ; can be typed in from keyboard ; whitebg = white background (default is dark background) ; printer = name of printing device ('ps' is the default) ; OUTPUTS : ; creates magnetogram plot ; if mparam and rdata arguments are given, these data are returned ; to the calling program ; COMMON BLOCKS : none ; SIDE EFFECTS : window #0 and #2 will be used ; RESTRICTIONS : X-window environment is assumed ; PROCEDURE : ; ; MODIFICATION HISTORY : ; T.Sakurai, 1992, 1993 ; ;------------------------------------------------------------------------ ; pro magplot, mparam, rdata, $ filename=filename, dir=dir, $ nomenu=nomenu, askloffile=askloffile, whitebg=whitebg, $ printer=printer, printdir=printdir olddir = ' ' spawn, 'pwd', olddir other = '' exit_prog = '' on_memory = '' if keyword_set(nomenu) then begin menu1=0 ; menu1 controls directory selection menu menu2=0 ; menu2 controls file selection menu endif else begin menu1=1 menu2=2 endelse if keyword_set(askloffile) then askloffile1=1 else askloffile1=0 if not keyword_set(printer) then printer='ps' disp_dev = !d.name if n_elements(printdir) eq 0 then printdir = getenv('HOME') outfile= printdir+'/magpack2.'+printer plotted=0 magdir = '.' if n_elements( filename ) eq 0 then begin magfile0 = ' ' filenames = '' endif else begin magfile0 = filename filenames = filename menu1=0 if ( n_elements( filename ) eq 1 and $ strpos( filename,'*') eq -1 and $ strpos( filename,'?') eq -1 ) then menu2=1 endelse if n_elements(dir) eq 0 then begin ; assume NAOJ/Mitaka standard data directory spawn,'ls /solar/okayama', years years = years( where( strmid(years,0,2) eq '19') ) magdirs0 = '/solar/okayama/' + strmid(years,0,4) magdirs0 = [ '/solar/flare/fieldlines', magdirs0, other ] endif else $ magdirs0 = [ dir, other ] top: show_area = 0 show_lines = 0 asklof = askloffile1 magfile = magfile0 ; select directory if ( menu1 eq 1 ) then begin if n_elements(rdata) gt 0 then $ magdirs = [ magdirs0, on_memory ] $ else $ magdirs = magdirs0 magdirs = [ magdirs, exit_prog ] dirno = wmenu( magdirs ) magdir = magdirs(dirno) if magdir eq exit_prog then goto, fin if magdir eq on_memory then goto, skip_read retry: if magdir eq other then begin print, format="('enter directory of magnetograms > ', $)" read, magdir print, format="('name of magnetogram file (CR for menu) > ',$)" magfile = ' ' read, magfile endif cd, magdir endif ; select file if ( menu2 eq 2 ) then begin ; magnetogram files have names '*.D' if ( strlen(strtrim(magfile)) eq 0 ) then magfile = '*.[DJ]' if ( n_elements(magfile) gt 1 or $ strpos(magfile,'*') ne -1 or $ strpos(magfile,'?') ne -1 ) then begin filenames = findfile(magfile, count=count) if count eq 0 then begin print, 'no data exist in: ', magdir goto, fin endif if ( count eq 1 ) then magfile = filenames(0) if ( menu1 eq 0 and n_elements(rdata) gt 0 ) then $ filenames = [ filenames, on_memory, exit_prog ] if n_elements(filenames) gt 1 then begin fileno = wmenu(filenames) magfile = filenames(fileno) if magfile eq exit_prog then goto, fin if magfile eq on_memory then goto, skip_read endif endif endif ; read magnetogram if ( menu2 gt 0 ) then readm, mparam, rdata, filename=magfile skip_read: ; field line files have names '*.L' loffile = magfile+'' ; to avoid bug of ver.2.1 (see bug1.pro) strput, loffile, 'L', strlen(magfile)-1 dummy = findfile( loffile, count=count ) if count eq 1 then begin loffile1 = ' ' if asklof eq 1 then begin print, loffile, $ format="('name of field-line file (default=',a,') > ',$)" read, loffile1 if ( strlen(strtrim(loffile1)) gt 0 ) then loffile=loffile1 endif endif else begin loffile='' if asklof eq 1 then begin print, format="('name of field-line file > ', $)" read, loffile if loffile ne '' then asklof = 0 endif endelse wdelete, 0, 0 wdelete, 2 window, 0, title='IDL 0 : MAGPACK2 display', xsize=640, ysize=600 plot_again: ; display observed area if ( show_area eq 0 ) then begin print,format="('obs.area : 0=skip, 1=show',$)" repeat read, show_area until ( show_area eq 0 or show_area eq 1 ) if ( show_area ne 0 ) then dispr, mparam endif ; display magnetogram dispm, mparam, rdata, whitebg=whitebg, /noask, switch=switch ; display field lines if ( strlen(strtrim(loffile)) gt 0 ) then begin print,format="('field lines : 0=skip, 1=show ',$)" repeat read, show_lines until ( show_lines eq 0 or show_lines eq 1 ) if ( show_lines ne 0 ) then $ displ, mparam, filename=loffile, whitebg=whitebg endif cmd = ' ' re_enter1: if ( menu1 eq 0 and menu2 lt 2 ) then $ print, format="('1=plot again, 2=hardcopy, 9=exit > ',$)" $ else $ print, format="('1=plot again, 2=hardcopy, 3=file menu, 9=exit > ',$)" re_enter2: read, cmd case cmd of '1': goto, plot_again '2': begin set_plot, printer if not plotted then device, filename=outfile plotted =1 plotm, mparam, rdata, switch=switch if ( show_lines ne 0 ) then $ plotl, mparam, filename=loffile set_plot, disp_dev goto, re_enter1 end '3': begin if menu1 eq 0 and menu2 lt 2 then goto, re_enter2 menu2 = 2 goto, top end '9': begin if plotted then begin set_plot, printer device, /close set_plot, disp_dev print, 'output is written to ',outfile endif goto, fin end else: goto, re_enter2 endcase goto, top fin: cd, olddir(0) return end