; ; Copyright (C) 2007 Regents of the University of California ; ; This program is free software; you can redistribute it and/or modify ; it under the terms of the GNU General Public License as published by ; the Free Software Foundation; either version 2 of the License, or ; (at your option) any later version. ; ; This program is distributed in the hope that it will be useful, ; but WITHOUT ANY WARRANTY; without even the implied warranty of ; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ; GNU General Public License for more details. ; ; You should have received a copy of the GNU General Public License ; along with this program; if not, write to the Free Software ; Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA ; PRO plot_energies,xlo=xlo,xhi=xhi,ylo=ylo,yhi=yhi,file=file ; ; Read in data from energies.dat and make plots ; ; Usage: plot_energies [,xlo=] [,xhi=] [,ylo=] [,yhi=] [,file=] ; ; Checks for prior energies.dat in run series if file not specified ; i.e., energies1.dat, energies2.dat, ..., energies.dat ; ; 12-06-03 dave bercik: created ; 09-04-08 dave bercik: allow file to be general; add padding to plots; ; legend changed form /data to /device dependent ; ON_ERROR, 2 RESTORE,'energies_template.sav' padfac = 0.03 IF (N_ELEMENTS(file) EQ 0) THEN BEGIN f = SHIFT(FILE_SEARCH('energies*.dat', COUNT = fcount), -1) IF (fcount EQ 1) THEN BEGIN data = READ_ASCII('energies.dat', TEMPLATE = energies_template) ENDIF ELSE IF (fcount GT 1) THEN BEGIN data = READ_ASCII(f(0), TEMPLATE = energies_template) tags = TAG_NAMES(data) FOR i = 1, fcount - 1 DO BEGIN a = data b = READ_ASCII(f(i), TEMPLATE = energies_template) data = CREATE_STRUCT(tags(0), [a.(0), b.(0)], $ tags(1), [a.(1), b.(1)], tags(2), [a.(2), b.(2)], $ tags(3), [a.(3), b.(3)], tags(4), [a.(4), b.(4)], $ tags(5), [a.(5), b.(5)]) ENDFOR ENDIF ELSE BEGIN PRINT, "No data files found" RETURN ENDELSE ENDIF ELSE BEGIN data = READ_ASCII(file, TEMPLATE = energies_template) ENDELSE ; ; Plots ; IF (N_ELEMENTS(xlo) EQ 0) THEN BEGIN xlength = MAX(data.(0)) - MIN(data.(0)) xlo = MIN(data.(0)) - padfac*xlength ENDIF IF (N_ELEMENTS(xhi) EQ 0) THEN BEGIN xlength = MAX(data.(0)) - MIN(data.(0)) xhi = MAX(data.(0)) + padfac*xlength ENDIF IF (N_ELEMENTS(ylo) EQ 0) THEN ylo = 5.0e-10 IF (N_ELEMENTS(yhi) EQ 0) THEN yhi = 5.0 WINDOW, 0, XSIZE = 750, YSIZE = 750 !P.MULTI = [0, 2, 2, 0] !X.STYLE = 1 !Y.STYLE = 1 chars = 1.3 ; ; plot 1 -- kinetic energy ; ylength = MAX(data.(2)) - MIN(data.(2)) ylo1 = MIN(data.(2)) - padfac*ylength yhi1 = MAX(data.(2)) + padfac*ylength PLOT, data.(0), data.(2), TITLE = 'Total Kinetic Energy', $ XRANGE = [xlo, xhi], YRANGE = [ylo1,yhi1], CHARSIZE = chars ; ; plot 2 -- thermal energy fluctuations ; ylength = MAX(data.(4)) - MIN(data.(4)) ylo1 = MIN(data.(4)) - padfac*ylength yhi1 = MAX(data.(4)) + padfac*ylength PLOT, data.(0), data.(4), TITLE = 'Total Thermal Energy Fluctuations', $ XRANGE = [xlo, xhi], YRANGE = [ylo1,yhi1], CHARSIZE = chars ; ; plot 3 -- magnetic energy fluctuations ; ylength = MAX(data.(3)) - MIN(data.(3)) ylo1 = MIN(data.(3)) - padfac*ylength yhi1 = MAX(data.(3)) + padfac*ylength PLOT, data.(0), data.(3), TITLE = 'Total Magnetic Energy', $ XRANGE = [xlo, xhi], YRANGE = [ylo1,yhi1], CHARSIZE = chars ; ; plot 4 -- all energy fluctuations ; etot = data.(2) + data.(3) + data.(4) PLOT_IO, data.(0), data.(4)/etot, $ TITLE = 'Relative Total Energy Fluctuations', XRANGE = [xlo, xhi], $ YRANGE = [ylo, yhi], LINESTYLE = 1, CHARSIZE = chars OPLOT, data.(0), data.(2)/etot OPLOT, data.(0), data.(3)/etot,LINESTYLE = 2 XYOUTS, [650, 650, 650], [140, 120, 100], $ ['Kinetic', 'Thermal', 'Magnetic'], CHARSIZE = chars, COLOR = 254, /DEVICE PLOTS, [605, 640], [144, 144], LINESTYLE = 0, COLOR = 254, /DEVICE PLOTS, [605, 640], [124, 124], LINESTYLE = 1, COLOR = 254, /DEVICE PLOTS, [605, 640], [104, 104], LINESTYLE = 2, COLOR = 254, /DEVICE !P.MULTI = 0 END