Skip to content
Snippets Groups Projects
Commit f3084a31 authored by Dennis Gläser's avatar Dennis Gläser
Browse files

[bin][extractlinedata] simplify and add docu

parent b2302ce8
No related branches found
No related tags found
1 merge request!2207Feature/improve extract line data
...@@ -23,25 +23,28 @@ except ImportError: ...@@ -23,25 +23,28 @@ except ImportError:
print("`paraview.simple` not found. Make sure using pvpython instead of python.") print("`paraview.simple` not found. Make sure using pvpython instead of python.")
# import locations # import locations
commonOutDirectory = False
outDirectory = args['outputDirectory'] outDirectory = args['outputDirectory']
if not outDirectory == '': if not outDirectory == '' and not os.path.exists(outDirectory):
outDirectory += '/' os.makedirs(outDirectory)
commonOutDirectory = True
if not os.path.exists(outDirectory):
os.makedirs(outDirectory)
# loop over all vtk files # loop over all vtk files
counter = 1 counter = 1
for curFile in args['files']: for curFile in args['files']:
# if no output directory was specified, use the directory of the given file
curOutDirectory = outDirectory
if curOutDirectory == '':
curOutDirectory = os.path.dirname( os.path.abspath(curFile) )
# if no basename was specified, reuse the file name for the .csv file
if args['outFile'] == '':
csvFileName = os.path.join(curOutDirectory, os.path.splitext(os.path.basename(curFile))[0] + ".csv")
else:
csvFileName = os.path.join(curOutDirectory, args['outFile'] + ".csv")
# print progress to command line # print progress to command line
fileWithoutPath = os.path.basename(curFile)
if not commonOutDirectory:
abspath = os.path.abspath(curFile)
outDirectory = os.path.dirname(abspath) + '/'
basename = os.path.splitext(fileWithoutPath)[0]
if args['verbosity'] == 1: if args['verbosity'] == 1:
print("Processing file ({}/{}): {}".format(counter, len(args['files']), fileWithoutPath)) print("Processing file ({}/{}): {}".format(counter, len(args['files']), os.path.basename(curFile)))
counter += 1 counter += 1
# load vtk file # load vtk file
...@@ -58,16 +61,13 @@ for curFile in args['files']: ...@@ -58,16 +61,13 @@ for curFile in args['files']:
plotOverLine.Source.Point2 = args['point2'] plotOverLine.Source.Point2 = args['point2']
# write output to csv writer # write output to csv writer
if not args['outFile'] == '': writer = CreateWriter(csvFileName, plotOverLine)
basename = args['outFile']
csvFile = outDirectory + basename + '.csv'
writer = CreateWriter(csvFile, plotOverLine)
writer.UpdatePipeline() writer.UpdatePipeline()
# print the parameters and the column numbers # print the parameters and the column numbers
if args['verbosity'] == 2: if args['verbosity'] == 2:
with open(csvFile) as f: with open(csvFileName) as f:
print(csvFile) print(csvFileName)
reader = csv.reader(f) reader = csv.reader(f)
paramList = list(reader) paramList = list(reader)
paramCounter=1 paramCounter=1
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment