import python3 compatibility changes to tools/python from upstream
This commit is contained in:
@ -6,14 +6,14 @@ functionality that could be added, built on the Pizza.py modules (as
|
||||
explained below), send email to Steve Plimpton (sjplimp at
|
||||
sandia.gov).
|
||||
|
||||
log2txt.py convert thermo info in a LAMMPS log file to columns of numbers
|
||||
logplot.py plot 2 columns of thermo info from a LAMMPS log file
|
||||
dumpsort.py sort the snapshots of atoms in a LAMMPS dump file by atom ID
|
||||
dump2cfg.py convert a native LAMMPS dump file to CFG format
|
||||
dump2xyz.py convert a native LAMMPS dump file to XYZ format
|
||||
dump2pdb.py convert a native LAMMPS dump file to PDB format
|
||||
neb_combine.py combine multiple NEB dump files into one time series
|
||||
neb_final.py combine multiple NEB final states into one sequence of states
|
||||
log2txt.py convert thermo info in a LAMMPS log file to columns of numbers
|
||||
logplot.py plot 2 columns of thermo info from a LAMMPS log file
|
||||
dumpsort.py sort the snapshots of atoms in a LAMMPS dump file by atom ID
|
||||
dump2cfg.py convert a native LAMMPS dump file to CFG format
|
||||
dump2xyz.py convert a native LAMMPS dump file to XYZ format
|
||||
dump2pdb.py convert a native LAMMPS dump file to PDB format
|
||||
neb_combine.py combine multiple NEB dump files into one time series
|
||||
neb_final.py combine multiple NEB final states into one sequence of states
|
||||
|
||||
See the top of each script file for syntax, or just run it with no
|
||||
arguments to get a syntax message.
|
||||
@ -68,7 +68,7 @@ directory where your data files are.
|
||||
The latter requires 2 things:
|
||||
|
||||
1) that the script be made "executable", e.g. type "chmod +x log2txt.py"
|
||||
2) that the 1st line of the script is the path of the Python installed
|
||||
2) that the 1st line of the script is the path of the Python installed
|
||||
on your box, e.g. /usr/local/bin/python
|
||||
|
||||
IMPORTANT NOTE: If you run the logplot.py script using the 1st method
|
||||
|
||||
@ -16,7 +16,7 @@ from dump import dump
|
||||
from cfg import cfg
|
||||
|
||||
if len(sys.argv) != 8:
|
||||
raise StandardError, "Syntax: dump2cfg.py dumpfile Nid Ntype Nx Ny Nz cfgfile"
|
||||
sys.exit("Syntax: dump2cfg.py dumpfile Nid Ntype Nx Ny Nz cfgfile")
|
||||
|
||||
dumpfile = sys.argv[1]
|
||||
nid = int(sys.argv[2])
|
||||
|
||||
@ -18,7 +18,7 @@ from dump import dump
|
||||
from pdbfile import pdbfile
|
||||
|
||||
if len(sys.argv) != 8 and len(sys.argv) != 9:
|
||||
raise StandardError, "Syntax: dump2pdb.py dumpfile Nid Ntype Nx Ny Nz pdbfile template"
|
||||
sys.exit("Syntax: dump2pdb.py dumpfile Nid Ntype Nx Ny Nz pdbfile template")
|
||||
|
||||
dumpfile = sys.argv[1]
|
||||
nid = int(sys.argv[2])
|
||||
|
||||
@ -16,7 +16,7 @@ from dump import dump
|
||||
from xyz import xyz
|
||||
|
||||
if len(sys.argv) != 8:
|
||||
raise StandardError, "Syntax: dump2xyz.py dumpfile Nid Ntype Nx Ny Nz xyzfile"
|
||||
sys.exit("Syntax: dump2xyz.py dumpfile Nid Ntype Nx Ny Nz xyzfile")
|
||||
|
||||
dumpfile = sys.argv[1]
|
||||
nid = int(sys.argv[2])
|
||||
|
||||
@ -14,7 +14,7 @@ sys.path.append(path)
|
||||
from dump import dump
|
||||
|
||||
if len(sys.argv) != 4:
|
||||
raise StandardError, "Syntax: dumpsort.py oldfile N newfile"
|
||||
sys.exit("Syntax: dumpsort.py oldfile N newfile")
|
||||
|
||||
oldfile = sys.argv[1]
|
||||
ncolumn = int(sys.argv[2])
|
||||
|
||||
@ -12,23 +12,29 @@
|
||||
|
||||
from __future__ import print_function
|
||||
|
||||
import sys,os
|
||||
import sys,os,argparse
|
||||
path = os.environ["LAMMPS_PYTHON_TOOLS"]
|
||||
sys.path.append(path)
|
||||
from log import log
|
||||
|
||||
if len(sys.argv) < 3:
|
||||
raise Exception("Syntax: log2txt.py log.lammps data.txt X Y ...")
|
||||
# set up arg parser
|
||||
parser = argparse.ArgumentParser()
|
||||
parser.add_argument('lammpslog', help='name of the lammps log file')
|
||||
parser.add_argument('outname', help='name of the file to be written')
|
||||
parser.add_argument('cols', nargs='*', help='any number of column names, optional')
|
||||
parser.add_argument('-n', action='store_true', help='save column names as the header of the file')
|
||||
|
||||
logfile = sys.argv[1]
|
||||
datafile = sys.argv[2]
|
||||
columns = sys.argv[3:]
|
||||
args = parser.parse_args()
|
||||
logfile = args.lammpslog
|
||||
datafile = args.outname
|
||||
columns = args.cols
|
||||
writenames = args.n
|
||||
|
||||
lg = log(logfile)
|
||||
if columns == []:
|
||||
lg.write(datafile)
|
||||
lg.write(datafile, writenames)
|
||||
else:
|
||||
str = "lg.write(datafile,"
|
||||
for word in columns: str += '"' + word + '",'
|
||||
str = str[:-1] + ')'
|
||||
str = "lg.write(datafile, %r" % writenames
|
||||
for word in columns: str += ',"' + word + '"'
|
||||
str += ')'
|
||||
eval(str)
|
||||
|
||||
@ -8,7 +8,7 @@
|
||||
# once plot appears, you are in Python interpreter, type C-D to exit
|
||||
# Author: Steve Plimpton (Sandia), sjplimp at sandia.gov
|
||||
|
||||
import sys,os
|
||||
import sys,os,code
|
||||
path = os.environ["LAMMPS_PYTHON_TOOLS"]
|
||||
sys.path.append(path)
|
||||
from log import log
|
||||
@ -25,3 +25,4 @@ lg = log(logfile)
|
||||
x,y = lg.get(xlabel,ylabel)
|
||||
g = gnu()
|
||||
g.plot(x,y)
|
||||
code.interact()
|
||||
|
||||
@ -38,8 +38,7 @@ while iarg < narg:
|
||||
else: break
|
||||
|
||||
if iarg < narg or not outfile or not rfiles:
|
||||
print "Syntax: neb_combine.py -o outfile -b backfile -r dump1 dump2 ..."
|
||||
sys.exit()
|
||||
sys.exit("Syntax: neb_combine.py -o outfile -b backfile -r dump1 dump2 ...")
|
||||
|
||||
if os.path.exists(outfile): os.remove(outfile)
|
||||
|
||||
|
||||
@ -38,8 +38,7 @@ while iarg < narg:
|
||||
else: break
|
||||
|
||||
if iarg < narg or not outfile or not rfiles:
|
||||
print "Syntax: neb_final.py -o outfile -b backfile -r dump1 dump2 ..."
|
||||
sys.exit()
|
||||
sys.exit("Syntax: neb_final.py -o outfile -b backfile -r dump1 dump2 ...")
|
||||
|
||||
if os.path.exists(outfile): os.remove(outfile)
|
||||
|
||||
|
||||
@ -6,6 +6,8 @@
|
||||
# certain rights in this software. This software is distributed under
|
||||
# the GNU General Public License.
|
||||
|
||||
from __future__ import print_function
|
||||
|
||||
# cfg tool
|
||||
|
||||
oneline = "Convert LAMMPS snapshots to AtomEye CFG format"
|
||||
@ -65,33 +67,33 @@ class cfg:
|
||||
ylen = box[4]-box[1]
|
||||
zlen = box[5]-box[2]
|
||||
|
||||
print >>f,"Number of particles = %d " % len(atoms)
|
||||
print >>f,"# Timestep %d \n#\nA = 1.0 Angstrom" % time
|
||||
print >>f,"H0(1,1) = %20.10f A " % xlen
|
||||
print >>f,"H0(1,2) = 0.0 A "
|
||||
print >>f,"H0(1,3) = 0.0 A "
|
||||
print >>f,"H0(2,1) = 0.0 A "
|
||||
print >>f,"H0(2,2) = %20.10f A " % ylen
|
||||
print >>f,"H0(2,3) = 0.0 A "
|
||||
print >>f,"H0(3,1) = 0.0 A "
|
||||
print >>f,"H0(3,2) = 0.0 A "
|
||||
print >>f,"H0(3,3) = %20.10f A " % zlen
|
||||
print >>f,"#"
|
||||
print("Number of particles = %d " % len(atoms), file=f)
|
||||
print("# Timestep %d \n#\nA = 1.0 Angstrom" % time, file=f)
|
||||
print("H0(1,1) = %20.10f A " % xlen, file=f)
|
||||
print("H0(1,2) = 0.0 A ", file=f)
|
||||
print("H0(1,3) = 0.0 A ", file=f)
|
||||
print("H0(2,1) = 0.0 A ", file=f)
|
||||
print("H0(2,2) = %20.10f A " % ylen, file=f)
|
||||
print("H0(2,3) = 0.0 A ", file=f)
|
||||
print("H0(3,1) = 0.0 A ", file=f)
|
||||
print("H0(3,2) = 0.0 A ", file=f)
|
||||
print("H0(3,3) = %20.10f A " % zlen, file=f)
|
||||
print("#", file=f)
|
||||
|
||||
for atom in atoms:
|
||||
itype = int(atom[1])
|
||||
xfrac = (atom[2]-box[0])/xlen
|
||||
yfrac = (atom[3]-box[1])/ylen
|
||||
zfrac = (atom[4]-box[2])/zlen
|
||||
# print >>f,"1.0 %d %15.10f %15.10f %15.10f %15.10f %15.10f %15.10f " % (itype,xfrac,yfrac,zfrac,atom[5],atom[6],atom[7])
|
||||
print >>f,"1.0 %d %15.10f %15.10f %15.10f 0.0 0.0 0.0 " % (itype,xfrac,yfrac,zfrac)
|
||||
# print("1.0 %d %15.10f %15.10f %15.10f %15.10f %15.10f %15.10f " % (itype,xfrac,yfrac,zfrac,atom[5],atom[6],atom[7]), file=f)
|
||||
print("1.0 %d %15.10f %15.10f %15.10f 0.0 0.0 0.0 " % (itype,xfrac,yfrac,zfrac), file=f)
|
||||
|
||||
print time,
|
||||
print(time)
|
||||
sys.stdout.flush()
|
||||
n += 1
|
||||
|
||||
f.close()
|
||||
print "\nwrote %d snapshots to %s in CFG format" % (n,file)
|
||||
print("\nwrote %d snapshots to %s in CFG format" % (n,file))
|
||||
|
||||
# --------------------------------------------------------------------
|
||||
|
||||
@ -120,33 +122,33 @@ class cfg:
|
||||
ylen = box[4]-box[1]
|
||||
zlen = box[5]-box[2]
|
||||
|
||||
print >>f,"Number of particles = %d " % len(atoms)
|
||||
print >>f,"# Timestep %d \n#\nA = 1.0 Angstrom" % time
|
||||
print >>f,"H0(1,1) = %20.10f A " % xlen
|
||||
print >>f,"H0(1,2) = 0.0 A "
|
||||
print >>f,"H0(1,3) = 0.0 A "
|
||||
print >>f,"H0(2,1) = 0.0 A "
|
||||
print >>f,"H0(2,2) = %20.10f A " % ylen
|
||||
print >>f,"H0(2,3) = 0.0 A "
|
||||
print >>f,"H0(3,1) = 0.0 A "
|
||||
print >>f,"H0(3,2) = 0.0 A "
|
||||
print >>f,"H0(3,3) = %20.10f A " % zlen
|
||||
print >>f,"#"
|
||||
print("Number of particles = %d " % len(atoms), file=f)
|
||||
print("# Timestep %d \n#\nA = 1.0 Angstrom" % time, file=f)
|
||||
print("H0(1,1) = %20.10f A " % xlen, file=f)
|
||||
print("H0(1,2) = 0.0 A ", file=f)
|
||||
print("H0(1,3) = 0.0 A ", file=f)
|
||||
print("H0(2,1) = 0.0 A ", file=f)
|
||||
print("H0(2,2) = %20.10f A " % ylen, file=f)
|
||||
print("H0(2,3) = 0.0 A ", file=f)
|
||||
print("H0(3,1) = 0.0 A ", file=f)
|
||||
print("H0(3,2) = 0.0 A ", file=f)
|
||||
print("H0(3,3) = %20.10f A " % zlen, file=f)
|
||||
print("#", file=f)
|
||||
|
||||
for atom in atoms:
|
||||
itype = int(atom[1])
|
||||
xfrac = (atom[2]-box[0])/xlen
|
||||
yfrac = (atom[3]-box[1])/ylen
|
||||
zfrac = (atom[4]-box[2])/zlen
|
||||
# print >>f,"1.0 %d %15.10f %15.10f %15.10f %15.10f %15.10f %15.10f " % (itype,xfrac,yfrac,zfrac,atom[5],atom[6],atom[7])
|
||||
print >>f,"1.0 %d %15.10f %15.10f %15.10f 0.0 0.0 0.0 " % (itype,xfrac,yfrac,zfrac)
|
||||
# print("1.0 %d %15.10f %15.10f %15.10f %15.10f %15.10f %15.10f " % (itype,xfrac,yfrac,zfrac,atom[5],atom[6],atom[7]), file=f)
|
||||
print("1.0 %d %15.10f %15.10f %15.10f 0.0 0.0 0.0 " % (itype,xfrac,yfrac,zfrac), file=f)
|
||||
|
||||
print time,
|
||||
print(time)
|
||||
sys.stdout.flush()
|
||||
f.close()
|
||||
n += 1
|
||||
|
||||
print "\nwrote %s snapshots in CFG format" % n
|
||||
print("\nwrote %s snapshots in CFG format" % n)
|
||||
|
||||
# --------------------------------------------------------------------
|
||||
|
||||
@ -163,25 +165,25 @@ class cfg:
|
||||
ylen = box[4]-box[1]
|
||||
zlen = box[5]-box[2]
|
||||
|
||||
print >>f,"Number of particles = %d " % len(atoms)
|
||||
print >>f,"# Timestep %d \n#\nA = 1.0 Angstrom" % time
|
||||
print >>f,"H0(1,1) = %20.10f A " % xlen
|
||||
print >>f,"H0(1,2) = 0.0 A "
|
||||
print >>f,"H0(1,3) = 0.0 A "
|
||||
print >>f,"H0(2,1) = 0.0 A "
|
||||
print >>f,"H0(2,2) = %20.10f A " % ylen
|
||||
print >>f,"H0(2,3) = 0.0 A "
|
||||
print >>f,"H0(3,1) = 0.0 A "
|
||||
print >>f,"H0(3,2) = 0.0 A "
|
||||
print >>f,"H0(3,3) = %20.10f A " % zlen
|
||||
print >>f,"#"
|
||||
print("Number of particles = %d " % len(atoms), file=f)
|
||||
print("# Timestep %d \n#\nA = 1.0 Angstrom" % time, file=f)
|
||||
print("H0(1,1) = %20.10f A " % xlen, file=f)
|
||||
print("H0(1,2) = 0.0 A ", file=f)
|
||||
print("H0(1,3) = 0.0 A ", file=f)
|
||||
print("H0(2,1) = 0.0 A ", file=f)
|
||||
print("H0(2,2) = %20.10f A " % ylen, file=f)
|
||||
print("H0(2,3) = 0.0 A ", file=f)
|
||||
print("H0(3,1) = 0.0 A ", file=f)
|
||||
print("H0(3,2) = 0.0 A ", file=f)
|
||||
print("H0(3,3) = %20.10f A " % zlen, file=f)
|
||||
print("#", file=f)
|
||||
|
||||
for atom in atoms:
|
||||
itype = int(atom[1])
|
||||
xfrac = (atom[2]-box[0])/xlen
|
||||
yfrac = (atom[3]-box[1])/ylen
|
||||
zfrac = (atom[4]-box[2])/zlen
|
||||
# print >>f,"1.0 %d %15.10f %15.10f %15.10f %15.10f %15.10f %15.10f " % (itype,xfrac,yfrac,zfrac,atom[5],atom[6],atom[7])
|
||||
print >>f,"1.0 %d %15.10f %15.10f %15.10f 0.0 0.0 0.0 " % (itype,xfrac,yfrac,zfrac)
|
||||
# print("1.0 %d %15.10f %15.10f %15.10f %15.10f %15.10f %15.10f " % (itype,xfrac,yfrac,zfrac,atom[5],atom[6],atom[7]), file=f)
|
||||
print("1.0 %d %15.10f %15.10f %15.10f 0.0 0.0 0.0 " % (itype,xfrac,yfrac,zfrac), file=f)
|
||||
|
||||
f.close()
|
||||
|
||||
@ -16,15 +16,15 @@ oneline = "Read, write, manipulate dump files and particle attributes"
|
||||
|
||||
docstr = """
|
||||
d = dump("dump.one") read in one or more dump files
|
||||
d = dump("dump.1 dump.2.gz") can be gzipped
|
||||
d = dump("dump.*") wildcard expands to multiple files
|
||||
d = dump("dump.*",0) two args = store filenames, but don't read
|
||||
d = dump("dump.1 dump.2.gz") can be gzipped
|
||||
d = dump("dump.*") wildcard expands to multiple files
|
||||
d = dump("dump.*",0) two args = store filenames, but don't read
|
||||
|
||||
incomplete and duplicate snapshots are deleted
|
||||
if atoms have 5 or 8 columns, assign id,type,x,y,z (ix,iy,iz)
|
||||
atoms will be unscaled if stored in files as scaled
|
||||
|
||||
time = d.next() read next snapshot from dump files
|
||||
time = d.next() read next snapshot from dump files
|
||||
|
||||
used with 2-argument constructor to allow reading snapshots one-at-a-time
|
||||
snapshot will be skipped only if another snapshot has same time stamp
|
||||
@ -36,20 +36,20 @@ d.map(1,"id",3,"x") assign names to atom columns (1-N)
|
||||
|
||||
not needed if dump file is self-describing
|
||||
|
||||
d.tselect.all() select all timesteps
|
||||
d.tselect.one(N) select only timestep N
|
||||
d.tselect.none() deselect all timesteps
|
||||
d.tselect.skip(M) select every Mth step
|
||||
d.tselect.all() select all timesteps
|
||||
d.tselect.one(N) select only timestep N
|
||||
d.tselect.none() deselect all timesteps
|
||||
d.tselect.skip(M) select every Mth step
|
||||
d.tselect.test("$t >= 100 and $t < 10000") select matching timesteps
|
||||
d.delete() delete non-selected timesteps
|
||||
d.delete() delete non-selected timesteps
|
||||
|
||||
selecting a timestep also selects all atoms in the timestep
|
||||
skip() and test() only select from currently selected timesteps
|
||||
test() uses a Python Boolean expression with $t for timestep value
|
||||
Python comparison syntax: == != < > <= >= and or
|
||||
|
||||
d.aselect.all() select all atoms in all steps
|
||||
d.aselect.all(N) select all atoms in one step
|
||||
d.aselect.all() select all atoms in all steps
|
||||
d.aselect.all(N) select all atoms in one step
|
||||
d.aselect.test("$id > 100 and $type == 2") select match atoms in all steps
|
||||
d.aselect.test("$id > 100 and $type == 2",N) select matching atoms in one step
|
||||
|
||||
@ -60,24 +60,24 @@ d.aselect.test("$id > 100 and $type == 2",N) select matching atoms in one step
|
||||
Python comparison syntax: == != < > <= >= and or
|
||||
$name must end with a space
|
||||
|
||||
d.write("file") write selected steps/atoms to dump file
|
||||
d.write("file",head,app) write selected steps/atoms to dump file
|
||||
d.scatter("tmp") write selected steps/atoms to multiple files
|
||||
d.write("file") write selected steps/atoms to dump file
|
||||
d.write("file",head,app) write selected steps/atoms to dump file
|
||||
d.scatter("tmp") write selected steps/atoms to multiple files
|
||||
|
||||
write() can be specified with 2 additional flags
|
||||
headd = 0/1 for no/yes snapshot header, app = 0/1 for write vs append
|
||||
scatter() files are given timestep suffix: e.g. tmp.0, tmp.100, etc
|
||||
|
||||
d.scale() scale x,y,z to 0-1 for all timesteps
|
||||
d.scale(100) scale atom coords for timestep N
|
||||
d.unscale() unscale x,y,z to box size to all timesteps
|
||||
d.unscale(1000) unscale atom coords for timestep N
|
||||
d.wrap() wrap x,y,z into periodic box via ix,iy,iz
|
||||
d.unwrap() unwrap x,y,z out of box via ix,iy,iz
|
||||
d.owrap("other") wrap x,y,z to same image as another atom
|
||||
d.sort() sort atoms by atom ID in all selected steps
|
||||
d.sort("x") sort atoms by column value in all steps
|
||||
d.sort(1000) sort atoms in timestep N
|
||||
d.scale() scale x,y,z to 0-1 for all timesteps
|
||||
d.scale(100) scale atom coords for timestep N
|
||||
d.unscale() unscale x,y,z to box size to all timesteps
|
||||
d.unscale(1000) unscale atom coords for timestep N
|
||||
d.wrap() wrap x,y,z into periodic box via ix,iy,iz
|
||||
d.unwrap() unwrap x,y,z out of box via ix,iy,iz
|
||||
d.owrap("other") wrap x,y,z to same image as another atom
|
||||
d.sort() sort atoms by atom ID in all selected steps
|
||||
d.sort("x") sort atoms by column value in all steps
|
||||
d.sort(1000) sort atoms in timestep N
|
||||
|
||||
scale(), unscale(), wrap(), unwrap(), owrap() operate on all steps and atoms
|
||||
wrap(), unwrap(), owrap() require ix,iy,iz be defined
|
||||
@ -89,8 +89,8 @@ d.sort(1000) sort atoms in timestep N
|
||||
m1,m2 = d.minmax("type") find min/max values for a column
|
||||
d.set("$ke = $vx * $vx + $vy * $vy") set a column to a computed value
|
||||
d.setv("type",vector) set a column to a vector of values
|
||||
d.spread("ke",N,"color") 2nd col = N ints spread over 1st col
|
||||
d.clone(1000,"color") clone timestep N values to other steps
|
||||
d.spread("ke",N,"color") 2nd col = N ints spread over 1st col
|
||||
d.clone(1000,"color") clone timestep N values to other steps
|
||||
|
||||
minmax() operates on selected timesteps and atoms
|
||||
set() operates on selected timesteps and atoms
|
||||
@ -111,7 +111,7 @@ d.clone(1000,"color") clone timestep N values to other steps
|
||||
values at every timestep are set to value at timestep N for that atom ID
|
||||
useful for propagating a color map
|
||||
|
||||
t = d.time() return vector of selected timestep values
|
||||
t = d.time() return vector of selected timestep values
|
||||
fx,fy,... = d.atom(100,"fx","fy",...) return vector(s) for atom ID N
|
||||
fx,fy,... = d.vecs(1000,"fx","fy",...) return vector(s) for timestep N
|
||||
|
||||
@ -121,8 +121,8 @@ fx,fy,... = d.vecs(1000,"fx","fy",...) return vector(s) for timestep N
|
||||
index,time,flag = d.iterator(0/1) loop over dump snapshots
|
||||
time,box,atoms,bonds,tris = d.viz(index) return list of viz objects
|
||||
d.atype = "color" set column returned as "type" by viz
|
||||
d.extra("dump.bond") read bond list from dump file
|
||||
d.extra(data) extract bond/tri/line list from data
|
||||
d.extra("dump.bond") read bond list from dump file
|
||||
d.extra(data) extract bond/tri/line list from data
|
||||
|
||||
iterator() loops over selected timesteps
|
||||
iterator() called with arg = 0 first time, with arg = 1 on subsequent calls
|
||||
|
||||
@ -14,12 +14,12 @@ from __future__ import print_function
|
||||
oneline = "Create plots via GnuPlot plotting program"
|
||||
|
||||
docstr = """
|
||||
g = gnu() start up GnuPlot
|
||||
g.stop() shut down GnuPlot process
|
||||
g = gnu() start up GnuPlot
|
||||
g.stop() shut down GnuPlot process
|
||||
|
||||
g.plot(a) plot vector A against linear index
|
||||
g.plot(a,b) plot B against A
|
||||
g.plot(a,b,c,d,...) plot B against A, D against C, etc
|
||||
g.plot(a,b) plot B against A
|
||||
g.plot(a,b,c,d,...) plot B against A, D against C, etc
|
||||
g.mplot(M,N,S,"file",a,b,...) multiple plots saved to file0000.eps, etc
|
||||
|
||||
each plot argument can be a tuple, list, or Numeric/NumPy vector
|
||||
@ -32,21 +32,21 @@ g.mplot(M,N,S,"file",a,b,...) multiple plots saved to file0000.eps, etc
|
||||
|
||||
g("plot 'file.dat' using 2:3 with lines") execute string in GnuPlot
|
||||
|
||||
g.enter() enter GnuPlot shell
|
||||
g.enter() enter GnuPlot shell
|
||||
gnuplot> plot sin(x) with lines type commands directly to GnuPlot
|
||||
gnuplot> exit, quit exit GnuPlot shell
|
||||
gnuplot> exit, quit exit GnuPlot shell
|
||||
|
||||
g.export("data",range(100),a,...) create file with columns of numbers
|
||||
|
||||
all vectors must be of equal length
|
||||
could plot from file with GnuPlot command: plot 'data' using 1:2 with lines
|
||||
|
||||
g.select(N) figure N becomes the current plot
|
||||
g.select(N) figure N becomes the current plot
|
||||
|
||||
subsequent commands apply to this plot
|
||||
|
||||
g.hide(N) delete window for figure N
|
||||
g.save("file") save current plot as file.eps
|
||||
g.hide(N) delete window for figure N
|
||||
g.save("file") save current plot as file.eps
|
||||
|
||||
Set attributes for current plot:
|
||||
|
||||
|
||||
@ -102,7 +102,7 @@ class log:
|
||||
|
||||
# sort entries by timestep, cull duplicates
|
||||
|
||||
self.data.sort(key=(lambda elem: elem[0]))
|
||||
self.data.sort(key=(lambda elem: elem[0]))
|
||||
self.cull()
|
||||
self.nlen = len(self.data)
|
||||
print("read %d log entries" % self.nlen)
|
||||
@ -153,7 +153,7 @@ class log:
|
||||
|
||||
# --------------------------------------------------------------------
|
||||
|
||||
def write(self,filename,*keys):
|
||||
def write(self,filename,writenames,*keys):
|
||||
if len(keys):
|
||||
colmap = []
|
||||
for key in keys:
|
||||
@ -175,10 +175,12 @@ class log:
|
||||
f = open(filename,"w")
|
||||
|
||||
# write col names from dict in the right order
|
||||
colnames = [k for j in colmap for k,v in self.ptr.items() if v == j]
|
||||
for j in range(len(colnames)):
|
||||
if writenames:
|
||||
print("# ", file=f, end="")
|
||||
colnames = [k for j in colmap for k,v in self.ptr.items() if v == j]
|
||||
for j in range(len(colnames)):
|
||||
print(colnames[j], file=f, end=" ")
|
||||
print("\n", file=f, end="")
|
||||
print("\n", file=f, end="")
|
||||
|
||||
# write data
|
||||
for i in range(self.nlen):
|
||||
|
||||
@ -6,6 +6,8 @@
|
||||
# certain rights in this software. This software is distributed under
|
||||
# the GNU General Public License.
|
||||
|
||||
from __future__ import print_function
|
||||
|
||||
# xyz tool
|
||||
|
||||
oneline = "Convert LAMMPS snapshots to XYZ format"
|
||||
@ -56,18 +58,18 @@ class xyz:
|
||||
if flag == -1: break
|
||||
time,box,atoms,bonds,tris,lines = self.data.viz(which)
|
||||
|
||||
print >>f,len(atoms)
|
||||
print >>f,"Atoms"
|
||||
print(len(atoms), file=f)
|
||||
print("Atoms", file=f)
|
||||
for atom in atoms:
|
||||
itype = int(atom[1])
|
||||
print >>f,itype,atom[2],atom[3],atom[4]
|
||||
print(itype,atom[2],atom[3],atom[4], file=f)
|
||||
|
||||
print time,
|
||||
print(time)
|
||||
sys.stdout.flush()
|
||||
n += 1
|
||||
|
||||
f.close()
|
||||
print "\nwrote %d snapshots to %s in XYZ format" % (n,file)
|
||||
print("\nwrote %d snapshots to %s in XYZ format" % (n,file))
|
||||
|
||||
# --------------------------------------------------------------------
|
||||
|
||||
@ -91,17 +93,17 @@ class xyz:
|
||||
file = root + str(n)
|
||||
file += ".xyz"
|
||||
f = open(file,"w")
|
||||
print >>f,len(atoms)
|
||||
print >>f,"Atoms"
|
||||
print(len(atoms), file=f)
|
||||
print("Atoms", file=f)
|
||||
for atom in atoms:
|
||||
itype = int(atom[1])
|
||||
print >>f,itype,atom[2],atom[3],atom[4]
|
||||
print time,
|
||||
print(itype,atom[2],atom[3],atom[4], file=f)
|
||||
print(time)
|
||||
sys.stdout.flush()
|
||||
f.close()
|
||||
n += 1
|
||||
|
||||
print "\nwrote %s snapshots in XYZ format" % n
|
||||
print("\nwrote %s snapshots in XYZ format" % n)
|
||||
|
||||
# --------------------------------------------------------------------
|
||||
|
||||
@ -113,9 +115,9 @@ class xyz:
|
||||
which = self.data.findtime(time)
|
||||
time,box,atoms,bonds,tris,lines = self.data.viz(which)
|
||||
f = open(file,"w")
|
||||
print >>f,len(atoms)
|
||||
print >>f,"Atoms"
|
||||
print(len(atoms), file=f)
|
||||
print("Atoms", file=f)
|
||||
for atom in atoms:
|
||||
itype = int(atom[1])
|
||||
print >>f,itype,atom[2],atom[3],atom[4]
|
||||
print(itype,atom[2],atom[3],atom[4], file=f)
|
||||
f.close()
|
||||
|
||||
Reference in New Issue
Block a user