added surface2VTK
This commit is contained in:
parent
5d378f9f0f
commit
c28e2bda2a
@ -619,9 +619,54 @@ class SeisArray(object):
|
||||
sys.stdout.write("%d%% done \r" % (progress) )
|
||||
sys.stdout.flush()
|
||||
|
||||
def surface2VTK(self, surface, filename = 'surface.vtk'):
|
||||
'''
|
||||
Generates a vtk file from all points of a surface as generated by interpolateTopography.
|
||||
'''
|
||||
outfile = open(filename, 'w')
|
||||
|
||||
nPoints = len(surface)
|
||||
|
||||
# write header
|
||||
print("Writing header for VTK file...")
|
||||
outfile.writelines('# vtk DataFile Version 3.1\n')
|
||||
outfile.writelines('Surface Points\n')
|
||||
outfile.writelines('ASCII\n')
|
||||
outfile.writelines('DATASET POLYDATA\n')
|
||||
outfile.writelines('POINTS %15d float\n' %(nPoints))
|
||||
|
||||
# write coordinates
|
||||
print("Writing coordinates to VTK file...")
|
||||
for point in surface:
|
||||
x = point[0]
|
||||
y = point[1]
|
||||
z = point[2]
|
||||
|
||||
outfile.writelines('%10f %10f %10f \n' %(x, y, z))
|
||||
|
||||
outfile.writelines('VERTICES %15d %15d\n' %(nPoints, 2 * nPoints))
|
||||
|
||||
# write indices
|
||||
print("Writing indices to VTK file...")
|
||||
for index in range(nPoints):
|
||||
outfile.writelines('%10d %10d\n' %(1, index))
|
||||
|
||||
# outfile.writelines('POINT_DATA %15d\n' %(nPoints))
|
||||
# outfile.writelines('SCALARS traceIDs int %d\n' %(1))
|
||||
# outfile.writelines('LOOKUP_TABLE default\n')
|
||||
|
||||
# # write traceIDs
|
||||
# print("Writing traceIDs to VTK file...")
|
||||
# for traceID in traceIDs:
|
||||
# outfile.writelines('%10d\n' %traceID)
|
||||
|
||||
outfile.close()
|
||||
print("Wrote %d points to file: %s" %(nPoints, filename))
|
||||
return
|
||||
|
||||
def receivers2VTK(self, filename = 'receivers.vtk'):
|
||||
'''
|
||||
Generates vtk files from all receivers of the SeisArray object.
|
||||
Generates a vtk file from all receivers of the SeisArray object.
|
||||
'''
|
||||
outfile = open(filename, 'w')
|
||||
traceIDs = []
|
||||
@ -670,7 +715,7 @@ class SeisArray(object):
|
||||
|
||||
def sources2VTK(self, filename = 'sources.vtk'):
|
||||
'''
|
||||
Generates vtk-files for all source locations in the SeisArray object.
|
||||
Generates a vtk-file for all source locations in the SeisArray object.
|
||||
'''
|
||||
outfile = open(filename, 'w')
|
||||
shotnumbers = []
|
||||
|
Loading…
Reference in New Issue
Block a user