allow selecting a list of timesteps. avoid redundant code
This commit is contained in:
@ -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,21 @@ 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.one(N1,N2,N3) select only timestep N1,N2,N3
|
||||
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 +61,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 +90,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 +112,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 +122,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
|
||||
@ -1117,24 +1118,23 @@ class tselect:
|
||||
|
||||
# --------------------------------------------------------------------
|
||||
|
||||
def one(self,n):
|
||||
def one(self,*steps):
|
||||
data = self.data
|
||||
data.nselect = 0
|
||||
for snap in data.snaps:
|
||||
snap.tselect = 0
|
||||
i = data.findtime(n)
|
||||
data.snaps[i].tselect = 1
|
||||
data.nselect = 1
|
||||
data.aselect.all()
|
||||
|
||||
for n in steps:
|
||||
i = data.findtime(n)
|
||||
data.snaps[i].tselect = 1
|
||||
data.nselect += 1
|
||||
data.aselect.all()
|
||||
print("%d snapshots selected out of %d" % (data.nselect,data.nsnaps))
|
||||
|
||||
# --------------------------------------------------------------------
|
||||
|
||||
def none(self):
|
||||
data = self.data
|
||||
for snap in data.snaps:
|
||||
snap.tselect = 0
|
||||
data.nselect = 0
|
||||
print("%d snapshots selected out of %d" % (data.nselect,data.nsnaps))
|
||||
self.one()
|
||||
|
||||
# --------------------------------------------------------------------
|
||||
|
||||
|
||||
Reference in New Issue
Block a user