From 5ecef73c01cd251941132838411d3f143092f63f Mon Sep 17 00:00:00 2001 From: Thomas Fetzer <thomas.fetzer@iws.uni-stuttgart.de> Date: Tue, 9 Aug 2016 08:47:42 +0200 Subject: [PATCH] [postprocessing][pvpython] Fix use of input and output directory. --- .../{extractLineData.py => extractlinedata.py} | 13 +++++++------ ...ataOverTime.py => extractpointdataovertime.py} | 15 ++++++++------- 2 files changed, 15 insertions(+), 13 deletions(-) rename bin/postprocessing/{extractLineData.py => extractlinedata.py} (86%) rename bin/postprocessing/{extractPointDataOverTime.py => extractpointdataovertime.py} (88%) diff --git a/bin/postprocessing/extractLineData.py b/bin/postprocessing/extractlinedata.py similarity index 86% rename from bin/postprocessing/extractLineData.py rename to bin/postprocessing/extractlinedata.py index 57f6fc4f8c..b571704f01 100644 --- a/bin/postprocessing/extractLineData.py +++ b/bin/postprocessing/extractlinedata.py @@ -9,9 +9,8 @@ parser = argparse.ArgumentParser( description='Extract data from the paraview plotOverLine filter.' ) parser = argparse.ArgumentParser() -parser.add_argument('-i', '--inputDirectory', help="Directory in which the .vtu are located") parser.add_argument('-f', '--files', nargs='+', required=True, help="vtu files to be processed") -parser.add_argument('-o', '--outputDirectory', help="Directory to which the data files are written") +parser.add_argument('-o', '--outputDirectory', default='', help="Directory to which the data files are written") parser.add_argument('-p1', '--point1', type=float, nargs=3, required=True, help='Coordinates of the first point (in 3D)') parser.add_argument('-p2', '--point2', type=float, nargs=3, required=True, help='Coordinates of the second point (in 3D)') parser.add_argument('-r', '--resolution', type=int, default=1000, help='Resolution of the line (number of data points written to data file)') @@ -21,12 +20,11 @@ args = vars(parser.parse_args()) from paraview.simple import * # import locations -inDirectory = args['inputDirectory'] +commonOutDirectory = False outDirectory = args['outputDirectory'] -if not inDirectory == '': - inDirectory += '/' if not outDirectory == '': outDirectory += '/' + commonOutDirectory = True if not os.path.exists(outDirectory): os.makedirs(outDirectory) @@ -35,13 +33,16 @@ counter = 1 for curFile in args['files']: # 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: print("Processing file ({}/{}): {}".format(counter, len(args['files']), fileWithoutPath)) counter += 1 # load vtk file - vtkFile = XMLUnstructuredGridReader(FileName=inDirectory+curFile) + vtkFile = XMLUnstructuredGridReader(FileName=curFile) SetActiveSource(vtkFile) # apply and configure PlotOverLine filter diff --git a/bin/postprocessing/extractPointDataOverTime.py b/bin/postprocessing/extractpointdataovertime.py similarity index 88% rename from bin/postprocessing/extractPointDataOverTime.py rename to bin/postprocessing/extractpointdataovertime.py index 1acd1043d0..80edab9c04 100644 --- a/bin/postprocessing/extractPointDataOverTime.py +++ b/bin/postprocessing/extractpointdataovertime.py @@ -9,9 +9,8 @@ parser = argparse.ArgumentParser( prog='pvpython ' + sys.argv[0], description='Extract data from the paraview probeLocation and plotOverTime filters.' ) -parser.add_argument('-i', '--inputDirectory', help="Directory in which the pvd file is located") parser.add_argument('-f', '--files', nargs='+', required=True, help="pvd files to be processed") -parser.add_argument('-o', '--outputDirectory', help="Directory to which the .csv files are written") +parser.add_argument('-o', '--outputDirectory', default='', help="Directory to which the .csv files are written") parser.add_argument('-p', '--point', type=float, nargs=3, required=True, help='Coordinates of the probed point (in 3D)') parser.add_argument('-v', '--verbosity', type=int, default=2, help='Verbosity of the output. 1 = print progress. 2 = print data columns') args = vars(parser.parse_args()) @@ -19,12 +18,11 @@ args = vars(parser.parse_args()) from paraview.simple import * # import locations -inDirectory = args['inputDirectory'] +commonOutDirectory = False outDirectory = args['outputDirectory'] -if not inDirectory == '': - inDirectory += '/' if not outDirectory == '': outDirectory += '/' + commonOutDirectory = True if not os.path.exists(outDirectory): os.makedirs(outDirectory) @@ -33,13 +31,16 @@ counter = 1 for curFile in args['files']: # 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: - print("Processing file ({}/{}): {}".format(counter, len(args['files']), inDirectory+curFile)) + print("Processing file ({}/{}): {}".format(counter, len(args['files']), curFile)) counter += 1 # load pvd file - pvdFile = PVDReader(FileName=inDirectory+curFile) + pvdFile = PVDReader(FileName=curFile) # Extract Point and Probe at a location selectionSource = IDSelectionSource( ContainingCells=0, InsideOut=False, FieldType='POINT', IDs=0 ) -- GitLab