sync
This commit is contained in:
@ -38,6 +38,7 @@ d.map(1,"id",3,"x") assign names to atom columns (1-N)
|
||||
|
||||
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
|
||||
@ -299,9 +300,9 @@ class dump:
|
||||
|
||||
# if snapshots are scaled, unscale them
|
||||
|
||||
if (not "x" in self.names) or \
|
||||
(not "y" in self.names) or \
|
||||
(not "z" in self.names):
|
||||
if ("x" not in self.names) or \
|
||||
("y" not in self.names) or \
|
||||
("z" not in self.names):
|
||||
print("no unscaling could be performed")
|
||||
elif self.nsnaps > 0:
|
||||
if self.scaled(self.nsnaps-1): self.unscale()
|
||||
@ -582,8 +583,8 @@ class dump:
|
||||
pairs = self.names.items()
|
||||
str = ""
|
||||
for i in range(ncol):
|
||||
for p in pairs:
|
||||
if p[1] == i: str += p[0] + ' '
|
||||
for k,v in pairs:
|
||||
if v == i: str += k + ' '
|
||||
return str
|
||||
|
||||
# --------------------------------------------------------------------
|
||||
@ -723,7 +724,7 @@ class dump:
|
||||
column = self.names[name]
|
||||
insert = "snap.atoms[i][%d]" % (column)
|
||||
eq = eq.replace(item,insert)
|
||||
ceq = compile(eq,'','single')
|
||||
ceq = compile(eq,'<string>','single')
|
||||
|
||||
for snap in self.snaps:
|
||||
if not snap.tselect: continue
|
||||
@ -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
|
||||
|
||||
for n in steps:
|
||||
i = data.findtime(n)
|
||||
data.snaps[i].tselect = 1
|
||||
data.nselect = 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()
|
||||
|
||||
# --------------------------------------------------------------------
|
||||
|
||||
@ -1157,11 +1157,11 @@ class tselect:
|
||||
def test(self,teststr):
|
||||
data = self.data
|
||||
snaps = data.snaps
|
||||
cmd = "flag = " + teststr.replace("$t","snaps[i].time")
|
||||
ccmd = compile(cmd,'','single')
|
||||
cmd = teststr.replace("$t","snaps[i].time")
|
||||
ccmd = compile(cmd,'<string>','eval')
|
||||
for i in range(data.nsnaps):
|
||||
if not snaps[i].tselect: continue
|
||||
exec(ccmd)
|
||||
flag = eval(ccmd)
|
||||
if not flag:
|
||||
snaps[i].tselect = 0
|
||||
data.nselect -= 1
|
||||
@ -1199,21 +1199,20 @@ class aselect:
|
||||
# replace all $var with snap.atoms references and compile test string
|
||||
|
||||
pattern = "\$\w*"
|
||||
list = re.findall(pattern,teststr)
|
||||
for item in list:
|
||||
matches = re.findall(pattern,teststr)
|
||||
for item in matches:
|
||||
name = item[1:]
|
||||
column = data.names[name]
|
||||
insert = "snap.atoms[i][%d]" % column
|
||||
teststr = teststr.replace(item,insert)
|
||||
cmd = "flag = " + teststr
|
||||
ccmd = compile(cmd,'','single')
|
||||
ccmd = compile(teststr,'<string>','eval')
|
||||
|
||||
if len(args) == 0: # all selected timesteps
|
||||
for snap in data.snaps:
|
||||
if not snap.tselect: continue
|
||||
for i in range(snap.natoms):
|
||||
if not snap.aselect[i]: continue
|
||||
exec(ccmd)
|
||||
flag = eval(ccmd)
|
||||
if not flag:
|
||||
snap.aselect[i] = 0
|
||||
snap.nselect -= 1
|
||||
|
||||
Reference in New Issue
Block a user