get rid of (evil) tabs and trailing whitespace in bundled Pizza.py components
This commit is contained in:
@ -3,7 +3,7 @@
|
||||
#
|
||||
# Copyright (2005) Sandia Corporation. Under the terms of Contract
|
||||
# DE-AC04-94AL85000 with Sandia Corporation, the U.S. Government retains
|
||||
# certain rights in this software. This software is distributed under
|
||||
# certain rights in this software. This software is distributed under
|
||||
# the GNU General Public License.
|
||||
|
||||
# cfg tool
|
||||
@ -11,14 +11,14 @@
|
||||
oneline = "Convert LAMMPS snapshots to AtomEye CFG format"
|
||||
|
||||
docstr = """
|
||||
c = cfg(d) d = object containing atom coords (dump, data)
|
||||
c = cfg(d) d = object containing atom coords (dump, data)
|
||||
|
||||
c.one() write all snapshots to tmp.cfg
|
||||
c.one("new") write all snapshots to new.cfg
|
||||
c.many() write snapshots to tmp0000.cfg, tmp0001.cfg, etc
|
||||
c.many("new") write snapshots to new0000.cfg, new0001.cfg, etc
|
||||
c.single(N) write snapshot for timestep N to tmp.cfg
|
||||
c.single(N,"file") write snapshot for timestep N to file.cfg
|
||||
c.single(N) write snapshot for timestep N to tmp.cfg
|
||||
c.single(N,"file") write snapshot for timestep N to file.cfg
|
||||
"""
|
||||
|
||||
# History
|
||||
@ -46,7 +46,7 @@ class cfg:
|
||||
|
||||
def __init__(self,data):
|
||||
self.data = data
|
||||
|
||||
|
||||
# --------------------------------------------------------------------
|
||||
|
||||
def one(self,*args):
|
||||
@ -68,16 +68,16 @@ class cfg:
|
||||
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(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(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,"#"
|
||||
|
||||
|
||||
for atom in atoms:
|
||||
itype = int(atom[1])
|
||||
xfrac = (atom[2]-box[0])/xlen
|
||||
@ -85,14 +85,14 @@ class cfg:
|
||||
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 time,
|
||||
sys.stdout.flush()
|
||||
n += 1
|
||||
|
||||
|
||||
f.close()
|
||||
print "\nwrote %d snapshots to %s in CFG format" % (n,file)
|
||||
|
||||
|
||||
# --------------------------------------------------------------------
|
||||
|
||||
def many(self,*args):
|
||||
@ -104,7 +104,7 @@ class cfg:
|
||||
which,time,flag = self.data.iterator(flag)
|
||||
if flag == -1: break
|
||||
time,box,atoms,bonds,tris,lines = self.data.viz(which)
|
||||
|
||||
|
||||
if n < 10:
|
||||
file = root + "000" + str(n)
|
||||
elif n < 100:
|
||||
@ -112,7 +112,7 @@ class cfg:
|
||||
elif n < 1000:
|
||||
file = root + "0" + str(n)
|
||||
else:
|
||||
file = root + str(n)
|
||||
file = root + str(n)
|
||||
file += ".cfg"
|
||||
f = open(file,"w")
|
||||
|
||||
@ -123,16 +123,16 @@ class cfg:
|
||||
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(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(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,"#"
|
||||
|
||||
|
||||
for atom in atoms:
|
||||
itype = int(atom[1])
|
||||
xfrac = (atom[2]-box[0])/xlen
|
||||
@ -140,14 +140,14 @@ class cfg:
|
||||
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 time,
|
||||
sys.stdout.flush()
|
||||
f.close()
|
||||
n += 1
|
||||
|
||||
|
||||
print "\nwrote %s snapshots in CFG format" % n
|
||||
|
||||
|
||||
# --------------------------------------------------------------------
|
||||
|
||||
def single(self,time,*args):
|
||||
@ -166,16 +166,16 @@ class cfg:
|
||||
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(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(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,"#"
|
||||
|
||||
|
||||
for atom in atoms:
|
||||
itype = int(atom[1])
|
||||
xfrac = (atom[2]-box[0])/xlen
|
||||
@ -183,5 +183,5 @@ class cfg:
|
||||
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)
|
||||
|
||||
|
||||
f.close()
|
||||
|
||||
@ -3,7 +3,7 @@
|
||||
#
|
||||
# Copyright (2005) Sandia Corporation. Under the terms of Contract
|
||||
# DE-AC04-94AL85000 with Sandia Corporation, the U.S. Government retains
|
||||
# certain rights in this software. This software is distributed under
|
||||
# certain rights in this software. This software is distributed under
|
||||
# the GNU General Public License.
|
||||
|
||||
# dump tool
|
||||
@ -12,15 +12,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
|
||||
atoms will be unscaled if stored in files as scaled
|
||||
self-describing column names assigned
|
||||
self-describing column names assigned
|
||||
|
||||
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
|
||||
@ -31,21 +31,21 @@ time = d.next() read next snapshot from dump files
|
||||
d.map(1,"id",3,"x") assign names to 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
|
||||
|
||||
@ -56,24 +56,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
|
||||
head = 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
|
||||
@ -85,8 +85,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
|
||||
@ -107,17 +107,17 @@ 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
|
||||
|
||||
atom() returns vectors with one value for each selected timestep
|
||||
vecs() returns vectors with one value for each selected atom in the timestep
|
||||
|
||||
index,time,flag = d.iterator(0/1) loop over dump snapshots
|
||||
index,time,flag = d.iterator(0/1) loop over dump snapshots
|
||||
time,box,atoms,bonds,tris,lines = d.viz(index) return list of viz objects
|
||||
d.atype = "color" set column returned as "type" by viz
|
||||
d.extra(obj) extract bond/tri/line info from obj
|
||||
d.atype = "color" set column returned as "type" by viz
|
||||
d.extra(obj) extract bond/tri/line info from obj
|
||||
|
||||
iterator() loops over selected timesteps
|
||||
iterator() called with arg = 0 first time, with arg = 1 on subsequent calls
|
||||
@ -137,7 +137,7 @@ d.extra(obj) extract bond/tri/line info from obj
|
||||
if extra() used to define lines, else NULL
|
||||
atype is column name viz() will return as atom type (def = "type")
|
||||
extra() extracts bonds/tris/lines from obj each time viz() is called
|
||||
obj can be data object for bonds, cdata object for tris and lines,
|
||||
obj can be data object for bonds, cdata object for tris and lines,
|
||||
bdump object for bonds, tdump object for tris, ldump object for lines.
|
||||
mdump object for tris
|
||||
"""
|
||||
@ -227,7 +227,7 @@ class dump:
|
||||
for word in words: self.flist += glob.glob(word)
|
||||
if len(self.flist) == 0 and len(list) == 1:
|
||||
raise StandardError,"no dump file specified"
|
||||
|
||||
|
||||
if len(list) == 1:
|
||||
self.increment = 0
|
||||
self.read_all()
|
||||
@ -270,7 +270,7 @@ class dump:
|
||||
self.tselect.all()
|
||||
|
||||
# print column assignments
|
||||
|
||||
|
||||
if len(self.names):
|
||||
print "assigned columns:",self.names2str()
|
||||
else:
|
||||
@ -304,15 +304,15 @@ class dump:
|
||||
snap = self.read_snapshot(f)
|
||||
if not snap:
|
||||
self.nextfile += 1
|
||||
if self.nextfile == len(self.flist): return -1
|
||||
if self.nextfile == len(self.flist): return -1
|
||||
f.close()
|
||||
self.eof = 0
|
||||
continue
|
||||
self.eof = 0
|
||||
continue
|
||||
self.eof = f.tell()
|
||||
f.close()
|
||||
try:
|
||||
self.findtime(snap.time)
|
||||
continue
|
||||
continue
|
||||
except: break
|
||||
|
||||
# select the new snapshot with all its atoms
|
||||
@ -334,7 +334,7 @@ class dump:
|
||||
# assign column names (file must be self-describing)
|
||||
# set scale_original to 0/1/-1 for unscaled/scaled/unknown
|
||||
# convert xs,xu to x in names
|
||||
|
||||
|
||||
def read_snapshot(self,f):
|
||||
try:
|
||||
snap = Snap()
|
||||
@ -351,7 +351,7 @@ class dump:
|
||||
else: snap.boxstr = words[1].strip()
|
||||
if "xy" in snap.boxstr: snap.triclinic = 1
|
||||
else: snap.triclinic = 0
|
||||
|
||||
|
||||
words = f.readline().split()
|
||||
if len(words) == 2:
|
||||
snap.xlo,snap.xhi,snap.xy = float(words[0]),float(words[1]),0.0
|
||||
@ -372,7 +372,7 @@ class dump:
|
||||
else:
|
||||
snap.zlo,snap.zhi,snap.yz = \
|
||||
float(words[0]),float(words[1]),float(words[2])
|
||||
|
||||
|
||||
item = f.readline()
|
||||
if len(self.names) == 0:
|
||||
self.scale_original = -1
|
||||
@ -401,7 +401,7 @@ class dump:
|
||||
else: self.names[words[i]] = i
|
||||
if xflag == 0 and yflag == 0 and zflag == 0: self.scale_original = 0
|
||||
if xflag == 1 and yflag == 1 and zflag == 1: self.scale_original = 1
|
||||
|
||||
|
||||
if snap.natoms:
|
||||
words = f.readline().split()
|
||||
ncol = len(words)
|
||||
@ -424,7 +424,7 @@ class dump:
|
||||
|
||||
# --------------------------------------------------------------------
|
||||
# map atom column names
|
||||
|
||||
|
||||
def map(self,*pairs):
|
||||
if len(pairs) % 2 != 0:
|
||||
raise StandardError, "dump map() requires pairs of mappings"
|
||||
@ -509,7 +509,7 @@ class dump:
|
||||
atoms[:,y] = (atoms[:,y] - snap.ylo)*h1inv + \
|
||||
(atoms[:,z] - snap.zlo)*h3inv
|
||||
atoms[:,z] = (atoms[:,z] - snap.zlo)*h2inv
|
||||
|
||||
|
||||
# --------------------------------------------------------------------
|
||||
# unscale coords from 0-1 to box size for all snapshots or just one
|
||||
# use 6 params as h-matrix to treat orthogonal or triclinic boxes
|
||||
@ -564,7 +564,7 @@ class dump:
|
||||
atoms[:,x] = snap.xlo + atoms[:,x]*h0 + atoms[:,y]*h5 + atoms[:,z]*h4
|
||||
atoms[:,y] = snap.ylo + atoms[:,y]*h1 + atoms[:,z]*h3
|
||||
atoms[:,z] = snap.zlo + atoms[:,z]*h2
|
||||
|
||||
|
||||
# --------------------------------------------------------------------
|
||||
# wrap coords from outside box to inside
|
||||
|
||||
@ -577,7 +577,7 @@ class dump:
|
||||
ix = self.names["ix"]
|
||||
iy = self.names["iy"]
|
||||
iz = self.names["iz"]
|
||||
|
||||
|
||||
for snap in self.snaps:
|
||||
xprd = snap.xhi - snap.xlo
|
||||
yprd = snap.yhi - snap.ylo
|
||||
@ -599,7 +599,7 @@ class dump:
|
||||
ix = self.names["ix"]
|
||||
iy = self.names["iy"]
|
||||
iz = self.names["iz"]
|
||||
|
||||
|
||||
for snap in self.snaps:
|
||||
xprd = snap.xhi - snap.xlo
|
||||
yprd = snap.yhi - snap.ylo
|
||||
@ -612,10 +612,10 @@ class dump:
|
||||
# --------------------------------------------------------------------
|
||||
# wrap coords to same image as atom ID stored in "other" column
|
||||
# if dynamic extra lines or triangles defined, owrap them as well
|
||||
|
||||
|
||||
def owrap(self,other):
|
||||
print "Wrapping to other ..."
|
||||
|
||||
|
||||
id = self.names["id"]
|
||||
x = self.names["x"]
|
||||
y = self.names["y"]
|
||||
@ -641,10 +641,10 @@ class dump:
|
||||
# should bonds also be owrapped ?
|
||||
if self.lineflag == 2 or self.triflag == 2:
|
||||
self.objextra.owrap(snap.time,xprd,yprd,zprd,ids,atoms,iother,ix,iy,iz)
|
||||
|
||||
|
||||
# --------------------------------------------------------------------
|
||||
# convert column names assignment to a string, in column order
|
||||
|
||||
|
||||
def names2str(self):
|
||||
pairs = self.names.items()
|
||||
values = self.names.values()
|
||||
@ -697,7 +697,7 @@ class dump:
|
||||
else: id = -1
|
||||
if "type" in self.names: type = self.names["type"]
|
||||
else: type = -1
|
||||
|
||||
|
||||
for snap in self.snaps:
|
||||
if not snap.tselect: continue
|
||||
print snap.time,
|
||||
@ -719,7 +719,7 @@ class dump:
|
||||
print >>f,snap.ylo,snap.yhi
|
||||
print >>f,snap.zlo,snap.zhi
|
||||
print >>f,"ITEM: ATOMS",namestr
|
||||
|
||||
|
||||
atoms = snap.atoms
|
||||
nvalues = len(atoms[0])
|
||||
for i in xrange(snap.natoms):
|
||||
@ -743,7 +743,7 @@ class dump:
|
||||
if not snap.tselect: continue
|
||||
print snap.time,
|
||||
sys.stdout.flush()
|
||||
|
||||
|
||||
file = root + "." + str(snap.time)
|
||||
f = open(file,"w")
|
||||
print >>f,"ITEM: TIMESTEP"
|
||||
@ -761,7 +761,7 @@ class dump:
|
||||
print >>f,snap.ylo,snap.yhi
|
||||
print >>f,snap.zlo,snap.zhi
|
||||
print >>f,"ITEM: ATOMS",namestr
|
||||
|
||||
|
||||
atoms = snap.atoms
|
||||
nvalues = len(atoms[0])
|
||||
for i in xrange(snap.natoms):
|
||||
@ -803,7 +803,7 @@ class dump:
|
||||
lhs = list[0][1:]
|
||||
if not self.names.has_key(lhs):
|
||||
self.newcolumn(lhs)
|
||||
|
||||
|
||||
for item in list:
|
||||
name = item[1:]
|
||||
column = self.names[name]
|
||||
@ -815,7 +815,7 @@ class dump:
|
||||
if not snap.tselect: continue
|
||||
for i in xrange(snap.natoms):
|
||||
if snap.aselect[i]: exec ceq
|
||||
|
||||
|
||||
# --------------------------------------------------------------------
|
||||
# set a column value via an input vec for all selected snapshots/atoms
|
||||
|
||||
@ -835,7 +835,7 @@ class dump:
|
||||
if snap.aselect[i]:
|
||||
atoms[i][icol] = vec[m]
|
||||
m += 1
|
||||
|
||||
|
||||
# --------------------------------------------------------------------
|
||||
# clone value in col across selected timesteps for atoms with same ID
|
||||
|
||||
@ -901,7 +901,7 @@ class dump:
|
||||
columns.append(self.names[name])
|
||||
values.append(self.nselect * [0])
|
||||
ncol = len(columns)
|
||||
|
||||
|
||||
id = self.names["id"]
|
||||
m = 0
|
||||
for snap in self.snaps:
|
||||
@ -917,13 +917,13 @@ class dump:
|
||||
|
||||
if len(list) == 1: return values[0]
|
||||
else: return values
|
||||
|
||||
|
||||
# --------------------------------------------------------------------
|
||||
# extract vector(s) of values for selected atoms at chosen timestep
|
||||
|
||||
def vecs(self,n,*list):
|
||||
snap = self.snaps[self.findtime(n)]
|
||||
|
||||
|
||||
if len(list) == 0:
|
||||
raise StandardError, "no columns specified"
|
||||
columns = []
|
||||
@ -978,7 +978,7 @@ class dump:
|
||||
del self.snaps[i]
|
||||
else:
|
||||
i += 1
|
||||
|
||||
|
||||
# --------------------------------------------------------------------
|
||||
# iterate over selected snapshots
|
||||
|
||||
@ -990,12 +990,12 @@ class dump:
|
||||
self.iterate = i
|
||||
return i,self.snaps[i].time,1
|
||||
return 0,0,-1
|
||||
|
||||
|
||||
# --------------------------------------------------------------------
|
||||
# return list of atoms to viz for snapshot isnap
|
||||
# if called with flag, then index is timestep, so convert to snapshot index
|
||||
# augment with bonds, tris, lines if extra() was invoked
|
||||
|
||||
|
||||
def viz(self,index,flag=0):
|
||||
if not flag: isnap = index
|
||||
else:
|
||||
@ -1019,7 +1019,7 @@ class dump:
|
||||
|
||||
# create atom list needed by viz from id,type,x,y,z
|
||||
# need Numeric/Numpy mode here
|
||||
|
||||
|
||||
atoms = []
|
||||
for i in xrange(snap.natoms):
|
||||
if not snap.aselect[i]: continue
|
||||
@ -1059,7 +1059,7 @@ class dump:
|
||||
if self.triflag == 1: tris = self.trilist
|
||||
elif self.triflag == 2:
|
||||
tmp1,tmp2,tmp3,tmp4,tris,tmp5 = self.objextra.viz(time,1)
|
||||
|
||||
|
||||
# create list of lines from static or dynamic tri list
|
||||
# if dynamic, could eliminate lines for unselected atoms
|
||||
|
||||
@ -1070,7 +1070,7 @@ class dump:
|
||||
tmp1,tmp2,tmp3,tmp4,tmp5,lines = self.objextra.viz(time,1)
|
||||
|
||||
return time,box,atoms,bonds,tris,lines
|
||||
|
||||
|
||||
# --------------------------------------------------------------------
|
||||
|
||||
def findtime(self,n):
|
||||
@ -1115,7 +1115,7 @@ class dump:
|
||||
def extra(self,arg):
|
||||
|
||||
# data object, grab bonds statically
|
||||
|
||||
|
||||
if type(arg) is types.InstanceType and ".data" in str(arg.__class__):
|
||||
self.bondflag = 0
|
||||
try:
|
||||
@ -1132,7 +1132,7 @@ class dump:
|
||||
raise StandardError,"could not extract bonds from data object"
|
||||
|
||||
# cdata object, grab tris and lines statically
|
||||
|
||||
|
||||
elif type(arg) is types.InstanceType and ".cdata" in str(arg.__class__):
|
||||
self.triflag = self.lineflag = 0
|
||||
try:
|
||||
@ -1147,32 +1147,32 @@ class dump:
|
||||
raise StandardError,"could not extract tris/lines from cdata object"
|
||||
|
||||
# mdump object, grab tris dynamically
|
||||
|
||||
|
||||
elif type(arg) is types.InstanceType and ".mdump" in str(arg.__class__):
|
||||
self.triflag = 2
|
||||
self.objextra = arg
|
||||
|
||||
# bdump object, grab bonds dynamically
|
||||
|
||||
|
||||
elif type(arg) is types.InstanceType and ".bdump" in str(arg.__class__):
|
||||
self.bondflag = 2
|
||||
self.objextra = arg
|
||||
|
||||
# ldump object, grab lines dynamically
|
||||
|
||||
|
||||
elif type(arg) is types.InstanceType and ".ldump" in str(arg.__class__):
|
||||
self.lineflag = 2
|
||||
self.objextra = arg
|
||||
|
||||
# tdump object, grab tris dynamically
|
||||
|
||||
|
||||
elif type(arg) is types.InstanceType and ".tdump" in str(arg.__class__):
|
||||
self.triflag = 2
|
||||
self.objextra = arg
|
||||
|
||||
else:
|
||||
raise StandardError,"unrecognized argument to dump.extra()"
|
||||
|
||||
|
||||
# --------------------------------------------------------------------
|
||||
|
||||
def compare_atom(self,a,b):
|
||||
@ -1181,7 +1181,7 @@ class dump:
|
||||
elif a[0] > b[0]:
|
||||
return 1
|
||||
else:
|
||||
return 0
|
||||
return 0
|
||||
|
||||
# --------------------------------------------------------------------
|
||||
# one snapshot
|
||||
@ -1196,7 +1196,7 @@ class tselect:
|
||||
|
||||
def __init__(self,data):
|
||||
self.data = data
|
||||
|
||||
|
||||
# --------------------------------------------------------------------
|
||||
|
||||
def all(self):
|
||||
@ -1243,7 +1243,7 @@ class tselect:
|
||||
data.nselect -= 1
|
||||
data.aselect.all()
|
||||
print "%d snapshots selected out of %d" % (data.nselect,data.nsnaps)
|
||||
|
||||
|
||||
# --------------------------------------------------------------------
|
||||
|
||||
def test(self,teststr):
|
||||
@ -1289,7 +1289,7 @@ class aselect:
|
||||
data = self.data
|
||||
|
||||
# replace all $var with snap.atoms references and compile test string
|
||||
|
||||
|
||||
pattern = "\$\w*"
|
||||
list = re.findall(pattern,teststr)
|
||||
for item in list:
|
||||
|
||||
@ -3,7 +3,7 @@
|
||||
#
|
||||
# Copyright (2005) Sandia Corporation. Under the terms of Contract
|
||||
# DE-AC04-94AL85000 with Sandia Corporation, the U.S. Government retains
|
||||
# certain rights in this software. This software is distributed under
|
||||
# certain rights in this software. This software is distributed under
|
||||
# the GNU General Public License.
|
||||
|
||||
# gnu tool
|
||||
@ -11,12 +11,12 @@
|
||||
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
|
||||
@ -29,21 +29,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:
|
||||
|
||||
@ -94,7 +94,7 @@ except: PIZZA_GNUTERM = "x11"
|
||||
# Class definition
|
||||
|
||||
class gnu:
|
||||
|
||||
|
||||
# --------------------------------------------------------------------
|
||||
|
||||
def __init__(self):
|
||||
@ -102,7 +102,7 @@ class gnu:
|
||||
self.file = "tmp.gnu"
|
||||
self.figures = []
|
||||
self.select(1)
|
||||
|
||||
|
||||
# --------------------------------------------------------------------
|
||||
|
||||
def stop(self):
|
||||
@ -114,7 +114,7 @@ class gnu:
|
||||
def __call__(self,command):
|
||||
self.GNUPLOT.write(command + '\n')
|
||||
self.GNUPLOT.flush()
|
||||
|
||||
|
||||
# --------------------------------------------------------------------
|
||||
|
||||
def enter(self):
|
||||
@ -152,7 +152,7 @@ class gnu:
|
||||
if i: partial_vecs.append(vec[:i])
|
||||
else: partial_vecs.append([0])
|
||||
self.plot(*partial_vecs)
|
||||
|
||||
|
||||
if n < 10: newfile = file + "000" + str(n)
|
||||
elif n < 100: newfile = file + "00" + str(n)
|
||||
elif n < 1000: newfile = file + "0" + str(n)
|
||||
@ -160,7 +160,7 @@ class gnu:
|
||||
|
||||
self.save(newfile)
|
||||
n += 1
|
||||
|
||||
|
||||
# --------------------------------------------------------------------
|
||||
# write list of equal-length vectors to filename
|
||||
|
||||
@ -201,7 +201,7 @@ class gnu:
|
||||
# do not continue until plot file is written out
|
||||
# else script could go forward and change data file
|
||||
# use tmp.done as semaphore to indicate plot is finished
|
||||
|
||||
|
||||
def save(self,file):
|
||||
self.__call__("set terminal postscript enhanced solid lw 2 color portrait")
|
||||
cmd = "set output '%s.eps'" % file
|
||||
@ -212,7 +212,7 @@ class gnu:
|
||||
while not os.path.exists("tmp.done"): continue
|
||||
self.__call__("set output")
|
||||
self.select(self.current)
|
||||
|
||||
|
||||
# --------------------------------------------------------------------
|
||||
# restore default attributes by creating a new fig object
|
||||
|
||||
@ -221,7 +221,7 @@ class gnu:
|
||||
fig.ncurves = self.figures[self.current-1].ncurves
|
||||
self.figures[self.current-1] = fig
|
||||
self.draw()
|
||||
|
||||
|
||||
# --------------------------------------------------------------------
|
||||
|
||||
def aspect(self,value):
|
||||
@ -245,12 +245,12 @@ class gnu:
|
||||
else:
|
||||
self.figures[self.current-1].ylimit = (values[0],values[1])
|
||||
self.draw()
|
||||
|
||||
|
||||
# --------------------------------------------------------------------
|
||||
|
||||
def label(self,x,y,text):
|
||||
self.figures[self.current-1].labels.append((x,y,text))
|
||||
self.figures[self.current-1].nlabels += 1
|
||||
self.figures[self.current-1].nlabels += 1
|
||||
self.draw()
|
||||
|
||||
# --------------------------------------------------------------------
|
||||
@ -259,7 +259,7 @@ class gnu:
|
||||
self.figures[self.current-1].nlabel = 0
|
||||
self.figures[self.current-1].labels = []
|
||||
self.draw()
|
||||
|
||||
|
||||
# --------------------------------------------------------------------
|
||||
|
||||
def title(self,*strings):
|
||||
@ -276,13 +276,13 @@ class gnu:
|
||||
def xtitle(self,label):
|
||||
self.figures[self.current-1].xtitle = label
|
||||
self.draw()
|
||||
|
||||
|
||||
# --------------------------------------------------------------------
|
||||
|
||||
def ytitle(self,label):
|
||||
self.figures[self.current-1].ytitle = label
|
||||
self.draw()
|
||||
|
||||
|
||||
# --------------------------------------------------------------------
|
||||
|
||||
def xlog(self):
|
||||
@ -291,7 +291,7 @@ class gnu:
|
||||
else:
|
||||
self.figures[self.current-1].xlog = 1
|
||||
self.draw()
|
||||
|
||||
|
||||
# --------------------------------------------------------------------
|
||||
|
||||
def ylog(self):
|
||||
@ -300,7 +300,7 @@ class gnu:
|
||||
else:
|
||||
self.figures[self.current-1].ylog = 1
|
||||
self.draw()
|
||||
|
||||
|
||||
# --------------------------------------------------------------------
|
||||
|
||||
def curve(self,num,color):
|
||||
@ -316,10 +316,10 @@ class gnu:
|
||||
def draw(self):
|
||||
fig = self.figures[self.current-1]
|
||||
if not fig.ncurves: return
|
||||
|
||||
|
||||
cmd = 'set size ratio ' + str(1.0/float(fig.aspect))
|
||||
self.__call__(cmd)
|
||||
|
||||
|
||||
cmd = 'set title ' + '"' + fig.title + '"'
|
||||
self.__call__(cmd)
|
||||
cmd = 'set xlabel ' + '"' + fig.xtitle + '"'
|
||||
@ -331,11 +331,11 @@ class gnu:
|
||||
else: self.__call__("unset logscale x")
|
||||
if fig.ylog: self.__call__("set logscale y")
|
||||
else: self.__call__("unset logscale y")
|
||||
if fig.xlimit:
|
||||
if fig.xlimit:
|
||||
cmd = 'set xr [' + str(fig.xlimit[0]) + ':' + str(fig.xlimit[1]) + ']'
|
||||
self.__call__(cmd)
|
||||
else: self.__call__("set xr [*:*]")
|
||||
if fig.ylimit:
|
||||
if fig.ylimit:
|
||||
cmd = 'set yr [' + str(fig.ylimit[0]) + ':' + str(fig.ylimit[1]) + ']'
|
||||
self.__call__(cmd)
|
||||
else: self.__call__("set yr [*:*]")
|
||||
@ -365,7 +365,7 @@ class figure:
|
||||
|
||||
def __init__(self):
|
||||
self.ncurves = 0
|
||||
self.colors = []
|
||||
self.colors = []
|
||||
self.title = ""
|
||||
self.xtitle = ""
|
||||
self.ytitle = ""
|
||||
|
||||
@ -3,7 +3,7 @@
|
||||
#
|
||||
# Copyright (2005) Sandia Corporation. Under the terms of Contract
|
||||
# DE-AC04-94AL85000 with Sandia Corporation, the U.S. Government retains
|
||||
# certain rights in this software. This software is distributed under
|
||||
# certain rights in this software. This software is distributed under
|
||||
# the GNU General Public License.
|
||||
|
||||
# log tool
|
||||
@ -28,7 +28,7 @@ nvec = l.nvec # of vectors of thermo info
|
||||
nlen = l.nlen length of each vectors
|
||||
names = l.names list of vector names
|
||||
t,pe,... = l.get("Time","KE",...) return one or more vectors of values
|
||||
l.write("file.txt") write all vectors to a file
|
||||
l.write("file.txt") write all vectors to a file
|
||||
l.write("file.txt","Time","PE",...) write listed vectors to a file
|
||||
|
||||
get and write allow abbreviated (uniquely) vector names
|
||||
@ -89,7 +89,7 @@ class log:
|
||||
|
||||
# --------------------------------------------------------------------
|
||||
# read all thermo from all files
|
||||
|
||||
|
||||
def read_all(self):
|
||||
self.read_header(self.flist[0])
|
||||
if self.nvec == 0: raise StandardError,"log file has no values"
|
||||
@ -100,7 +100,7 @@ class log:
|
||||
print
|
||||
|
||||
# sort entries by timestep, cull duplicates
|
||||
|
||||
|
||||
self.data.sort(self.compare)
|
||||
self.cull()
|
||||
self.nlen = len(self.data)
|
||||
@ -133,9 +133,9 @@ class log:
|
||||
else:
|
||||
count = 0
|
||||
for i in range(self.nvec):
|
||||
if self.names[i].find(key) == 0:
|
||||
count += 1
|
||||
index = i
|
||||
if self.names[i].find(key) == 0:
|
||||
count += 1
|
||||
index = i
|
||||
if count == 1:
|
||||
map.append(index)
|
||||
else:
|
||||
@ -161,9 +161,9 @@ class log:
|
||||
else:
|
||||
count = 0
|
||||
for i in range(self.nvec):
|
||||
if self.names[i].find(key) == 0:
|
||||
count += 1
|
||||
index = i
|
||||
if self.names[i].find(key) == 0:
|
||||
count += 1
|
||||
index = i
|
||||
if count == 1:
|
||||
map.append(index)
|
||||
else:
|
||||
@ -226,7 +226,7 @@ class log:
|
||||
keywords.insert(0,"Step")
|
||||
i = 0
|
||||
for keyword in keywords:
|
||||
self.names.append(keyword)
|
||||
self.names.append(keyword)
|
||||
self.ptr[keyword] = i
|
||||
i += 1
|
||||
|
||||
@ -236,7 +236,7 @@ class log:
|
||||
line = txt[s1:s2]
|
||||
words = line.split()
|
||||
for i in range(len(words)):
|
||||
self.names.append(words[i])
|
||||
self.names.append(words[i])
|
||||
self.ptr[words[i]] = i
|
||||
|
||||
self.nvec = len(self.names)
|
||||
@ -275,43 +275,43 @@ class log:
|
||||
|
||||
if s1 >= 0 and s2 >= 0 and s1 < s2: # found s1,s2 with s1 before s2
|
||||
if self.style == 2:
|
||||
s1 = txt.find("\n",s1) + 1
|
||||
s1 = txt.find("\n",s1) + 1
|
||||
elif s1 >= 0 and s2 >= 0 and s2 < s1: # found s1,s2 with s2 before s1
|
||||
s1 = 0
|
||||
elif s1 == -1 and s2 >= 0: # found s2, but no s1
|
||||
last = 1
|
||||
last = 1
|
||||
s1 = 0
|
||||
elif s1 >= 0 and s2 == -1: # found s1, but no s2
|
||||
last = 1
|
||||
if self.style == 1:
|
||||
s2 = txt.rfind("\n--",s1) + 1
|
||||
else:
|
||||
s1 = txt.find("\n",s1) + 1
|
||||
s1 = txt.find("\n",s1) + 1
|
||||
s2 = txt.rfind("\n",s1) + 1
|
||||
eof -= len(txt) - s2
|
||||
eof -= len(txt) - s2
|
||||
elif s1 == -1 and s2 == -1: # found neither
|
||||
# could be end-of-file section
|
||||
# or entire read was one chunk
|
||||
# or entire read was one chunk
|
||||
|
||||
if txt.find("Loop time of",start) == start: # end of file, so exit
|
||||
eof -= len(txt) - start # reset eof to "Loop"
|
||||
break
|
||||
eof -= len(txt) - start # reset eof to "Loop"
|
||||
break
|
||||
|
||||
last = 1 # entire read is a chunk
|
||||
last = 1 # entire read is a chunk
|
||||
s1 = 0
|
||||
if self.style == 1:
|
||||
s2 = txt.rfind("\n--",s1) + 1
|
||||
else:
|
||||
s2 = txt.rfind("\n",s1) + 1
|
||||
eof -= len(txt) - s2
|
||||
if s1 == s2: break
|
||||
eof -= len(txt) - s2
|
||||
if s1 == s2: break
|
||||
|
||||
chunk = txt[s1:s2-1]
|
||||
start = s2
|
||||
|
||||
# split chunk into entries
|
||||
# parse each entry for numeric fields, append to data
|
||||
|
||||
|
||||
if self.style == 1:
|
||||
sections = chunk.split("\n--")
|
||||
pat1 = re.compile("Step\s*(\S*)\s")
|
||||
|
||||
@ -3,7 +3,7 @@
|
||||
#
|
||||
# Copyright (2005) Sandia Corporation. Under the terms of Contract
|
||||
# DE-AC04-94AL85000 with Sandia Corporation, the U.S. Government retains
|
||||
# certain rights in this software. This software is distributed under
|
||||
# certain rights in this software. This software is distributed under
|
||||
# the GNU General Public License.
|
||||
|
||||
# pdb tool
|
||||
@ -22,7 +22,7 @@ p = pdbfile("3CRO",d) read in single PDB file with snapshot data
|
||||
if only one 4-char file specified and it is not found,
|
||||
it will be downloaded from http://www.rcsb.org as 3CRO.pdb
|
||||
d arg is object with atom coordinates (dump, data)
|
||||
|
||||
|
||||
p.one() write all output as one big PDB file to tmp.pdb
|
||||
p.one("mine") write to mine.pdb
|
||||
p.many() write one PDB file per snapshot: tmp0000.pdb, ...
|
||||
@ -36,7 +36,7 @@ p.single(N,"new") write as new.pdb
|
||||
if one file in str arg and d: one new PDB file per snapshot
|
||||
using input PDB file as template
|
||||
multiple input PDB files with a d is not allowed
|
||||
|
||||
|
||||
index,time,flag = p.iterator(0)
|
||||
index,time,flag = p.iterator(1)
|
||||
|
||||
@ -87,7 +87,7 @@ class pdbfile:
|
||||
|
||||
# flist = full list of all PDB input file names
|
||||
# append .pdb if needed
|
||||
|
||||
|
||||
if filestr:
|
||||
list = filestr.split()
|
||||
flist = []
|
||||
@ -107,7 +107,7 @@ class pdbfile:
|
||||
raise StandardError, "no input PDB file(s)"
|
||||
|
||||
# grab PDB file from http://rcsb.org if not a local file
|
||||
|
||||
|
||||
if len(self.files) == 1 and len(self.files[0]) == 8:
|
||||
try:
|
||||
open(self.files[0],'r').close()
|
||||
@ -117,7 +117,7 @@ class pdbfile:
|
||||
urllib.urlretrieve(fetchstr,self.files[0])
|
||||
|
||||
if self.data and len(self.files): self.read_template(self.files[0])
|
||||
|
||||
|
||||
# --------------------------------------------------------------------
|
||||
# write a single large PDB file for concatenating all input data or files
|
||||
# if data exists:
|
||||
@ -135,7 +135,7 @@ class pdbfile:
|
||||
f = open(file,'w')
|
||||
|
||||
# use template PDB file with each snapshot
|
||||
|
||||
|
||||
if self.data:
|
||||
n = flag = 0
|
||||
while 1:
|
||||
@ -153,7 +153,7 @@ class pdbfile:
|
||||
print >>f,"END"
|
||||
print file,
|
||||
sys.stdout.flush()
|
||||
|
||||
|
||||
f.close()
|
||||
print "\nwrote %d datasets to %s in PDB format" % (n,file)
|
||||
|
||||
@ -189,7 +189,7 @@ class pdbfile:
|
||||
f = open(file,'w')
|
||||
self.convert(f,which)
|
||||
f.close()
|
||||
|
||||
|
||||
print time,
|
||||
sys.stdout.flush()
|
||||
n += 1
|
||||
@ -206,13 +206,13 @@ class pdbfile:
|
||||
else:
|
||||
file = root + str(n)
|
||||
file += ".pdb"
|
||||
|
||||
|
||||
f = open(file,'w')
|
||||
f.write(open(infile,'r').read())
|
||||
f.close()
|
||||
print file,
|
||||
sys.stdout.flush()
|
||||
|
||||
|
||||
n += 1
|
||||
|
||||
print "\nwrote %d datasets to %s*.pdb in PDB format" % (n,root)
|
||||
@ -239,7 +239,7 @@ class pdbfile:
|
||||
self.convert(f,which)
|
||||
else:
|
||||
f.write(open(self.files[time],'r').read())
|
||||
|
||||
|
||||
f.close()
|
||||
|
||||
# --------------------------------------------------------------------
|
||||
@ -258,8 +258,8 @@ class pdbfile:
|
||||
|
||||
# --------------------------------------------------------------------
|
||||
# read a PDB file and store ATOM lines
|
||||
|
||||
def read_template(self,file):
|
||||
|
||||
def read_template(self,file):
|
||||
lines = open(file,'r').readlines()
|
||||
self.atomlines = {}
|
||||
for line in lines:
|
||||
|
||||
@ -3,7 +3,7 @@
|
||||
#
|
||||
# Copyright (2005) Sandia Corporation. Under the terms of Contract
|
||||
# DE-AC04-94AL85000 with Sandia Corporation, the U.S. Government retains
|
||||
# certain rights in this software. This software is distributed under
|
||||
# certain rights in this software. This software is distributed under
|
||||
# the GNU General Public License.
|
||||
|
||||
# xyz tool
|
||||
@ -11,14 +11,14 @@
|
||||
oneline = "Convert LAMMPS snapshots to XYZ format"
|
||||
|
||||
docstr = """
|
||||
x = xyz(d) d = object containing atom coords (dump, data)
|
||||
x = xyz(d) d = object containing atom coords (dump, data)
|
||||
|
||||
x.one() write all snapshots to tmp.xyz
|
||||
x.one("new") write all snapshots to new.xyz
|
||||
x.many() write snapshots to tmp0000.xyz, tmp0001.xyz, etc
|
||||
x.many("new") write snapshots to new0000.xyz, new0001.xyz, etc
|
||||
x.single(N) write snapshot for timestep N to tmp.xyz
|
||||
x.single(N,"file") write snapshot for timestep N to file.xyz
|
||||
x.single(N) write snapshot for timestep N to tmp.xyz
|
||||
x.single(N,"file") write snapshot for timestep N to file.xyz
|
||||
"""
|
||||
|
||||
# History
|
||||
@ -41,7 +41,7 @@ class xyz:
|
||||
|
||||
def __init__(self,data):
|
||||
self.data = data
|
||||
|
||||
|
||||
# --------------------------------------------------------------------
|
||||
|
||||
def one(self,*args):
|
||||
@ -61,14 +61,14 @@ class xyz:
|
||||
for atom in atoms:
|
||||
itype = int(atom[1])
|
||||
print >>f,itype,atom[2],atom[3],atom[4]
|
||||
|
||||
|
||||
print time,
|
||||
sys.stdout.flush()
|
||||
n += 1
|
||||
|
||||
|
||||
f.close()
|
||||
print "\nwrote %d snapshots to %s in XYZ format" % (n,file)
|
||||
|
||||
|
||||
# --------------------------------------------------------------------
|
||||
|
||||
def many(self,*args):
|
||||
@ -80,7 +80,7 @@ class xyz:
|
||||
which,time,flag = self.data.iterator(flag)
|
||||
if flag == -1: break
|
||||
time,box,atoms,bonds,tris,lines = self.data.viz(which)
|
||||
|
||||
|
||||
if n < 10:
|
||||
file = root + "000" + str(n)
|
||||
elif n < 100:
|
||||
@ -88,7 +88,7 @@ class xyz:
|
||||
elif n < 1000:
|
||||
file = root + "0" + str(n)
|
||||
else:
|
||||
file = root + str(n)
|
||||
file = root + str(n)
|
||||
file += ".xyz"
|
||||
f = open(file,"w")
|
||||
print >>f,len(atoms)
|
||||
@ -100,9 +100,9 @@ class xyz:
|
||||
sys.stdout.flush()
|
||||
f.close()
|
||||
n += 1
|
||||
|
||||
|
||||
print "\nwrote %s snapshots in XYZ format" % n
|
||||
|
||||
|
||||
# --------------------------------------------------------------------
|
||||
|
||||
def single(self,time,*args):
|
||||
|
||||
Reference in New Issue
Block a user