source: util/src/FindInnerPointsinBB.py.in@ 086db0

Last change on this file since 086db0 was e1a46d, checked in by Frederik Heber <heber@…>, 16 years ago

All of my python script put into ESPACK and adapted with @PYTHON@ and so on.

  • Property mode set to 100755
File size: 1.6 KB
Line 
1#! @PYTHON@
2#
3# determines all points which are a given distance away from the boundary
4
5import sys, string, re, math
6wrerr = sys.stderr.write
7wrout = sys.stdout.write
8
9# check for parameters
10if len(sys.argv) < 3:
11 wrerr("Usage: "+sys.argv[0]+" <datafile> <distance>\n")
12 sys.exit(1)
13
14#Get box boundaries (open parameter file)
15input = open(sys.argv[1], "r")
16distance = float(sys.argv[2])
17CELLLENGTH=distance/4
18filetype=sys.argv[1].split(".")
19if (filetype[-1]=="data"):
20 while 1:
21 line=input.readline() # skip header (starting with #)
22 if not re.compile("^#").match(line):
23 break
24elif (filetype[-1]=="xyz"):
25 line=input.readline()
26 line=input.readline()
27
28line=input.readline()
29atoms=line.split()
30max=[float(atoms[1]), float(atoms[2]), float(atoms[3])]
31min=[float(atoms[1]), float(atoms[2]), float(atoms[3])]
32for line in input:
33 atom=line.split()
34 for i in range(3):
35 if float(atom[i+1]) < min[i]:
36 min[i] = float(atom[i+1])
37 if float(atom[i+1]) > max[i]:
38 max[i] = float(atom[i+1])
39#print "Found Box bounds [%f,%f]x[%f,%f]x[%f,%f]." % (min[0],max[0],min[1],max[1],min[2],max[2])
40input.close()
41
42# open files
43input = open(sys.argv[1], "r")
44
45# parse every atom
46n=0
47line=input.readline()
48line=input.readline()
49for line in input:
50 # atom=[]
51 fields=line.split()
52
53 x=float(fields[1]) # shift coordinates by box minimum
54 y=float(fields[2])
55 z=float(fields[3])
56 if (x > (min[0]+distance)) and (x < (max[0]-distance)):
57 if (y > (min[1]+distance)) and (y < (max[1]-distance)):
58 if (z > (min[2]+distance)) and (z < (max[2]-distance)):
59 print "%lg" % (n)
60 n=n+1
61
62
Note: See TracBrowser for help on using the repository browser.