[e1a46d] | 1 | #! @PYTHON@
|
---|
| 2 | #
|
---|
| 3 | # determines all points which are a given distance away from the boundary
|
---|
| 4 |
|
---|
| 5 | import sys, string, re, math
|
---|
| 6 | wrerr = sys.stderr.write
|
---|
| 7 | wrout = sys.stdout.write
|
---|
| 8 |
|
---|
| 9 | # check for parameters
|
---|
| 10 | if 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)
|
---|
| 15 | input = open(sys.argv[1], "r")
|
---|
| 16 | distance = float(sys.argv[2])
|
---|
| 17 | CELLLENGTH=distance/4
|
---|
| 18 | filetype=sys.argv[1].split(".")
|
---|
| 19 | if (filetype[-1]=="data"):
|
---|
| 20 | while 1:
|
---|
| 21 | line=input.readline() # skip header (starting with #)
|
---|
| 22 | if not re.compile("^#").match(line):
|
---|
| 23 | break
|
---|
| 24 | elif (filetype[-1]=="xyz"):
|
---|
| 25 | line=input.readline()
|
---|
| 26 | line=input.readline()
|
---|
| 27 |
|
---|
| 28 | line=input.readline()
|
---|
| 29 | atoms=line.split()
|
---|
| 30 | max=[float(atoms[1]), float(atoms[2]), float(atoms[3])]
|
---|
| 31 | min=[float(atoms[1]), float(atoms[2]), float(atoms[3])]
|
---|
| 32 | for 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])
|
---|
| 40 | input.close()
|
---|
| 41 |
|
---|
| 42 | # open files
|
---|
| 43 | input = open(sys.argv[1], "r")
|
---|
| 44 |
|
---|
| 45 | # parse every atom
|
---|
| 46 | n=0
|
---|
| 47 | line=input.readline()
|
---|
| 48 | line=input.readline()
|
---|
| 49 | for 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 |
|
---|