import os
import paraview
from paraview.simple import *


class sim_data:
#creates a class that takes in directories of a VTU and either a .csv file or a directory that contains one or more of them
    
    def __init__(self, vtu_direc = None, csv_direc = None):
        #everytime one of these objects is created it sets the vtu and csv directories

        
        #if there's no VTU directory input when the function is called, ask for one
        if vtu_direc == None:
            vtu_direc = input(str("Input the path to your VTU: "))

        #if there's no CSV directory input when the function is called, ask for one
        if csv_direc == None:
            csv_direc = input(str("Input the the path to your CSV or the path to the directory that contains them: "))
            
        self.vtu_direc = vtu_direc
        self.csv_direc = csv_direc


    def mach_contour(self):
    #mach_contour either runs the ParaView code once or loops through every .csv file in a folder
    #outputs are saved as a .jpg image next to the .csv file or in a folder called "outputs" within the directory that contains the .csv files

        #assigning variable names for ease of life
        vtu_direc = self.vtu_direc
        csv_direc = self.csv_direc
        
        #code that checks if the input for CSV(s) is a directory or an actual file
        direc_check = os.path.isdir(self.csv_direc)
        file_check = os.path.isfile(self.csv_direc)

        #if it's a lone csv just run it
        if file_check == True:
            self.output_direc = os.path.splitext(csv_direc)[0] + '.png'
            self.paraview_mach_contour()

            
        #if it's a directory
        if direc_check == True:
            
            #makes a path with a new folder called Screenshots
            output_folder_direc = self.csv_direc + '/Outputs'
            #check if there is already a screenshots folder in the directory
            ExistCheck = os.path.exists(output_folder_direc)
            if ExistCheck == False:
                os.mkdir(output_folder_direc)    
           
            #for loop that goes through every csv file in the directory and runs the macro
            for filename in os.listdir(csv_direc):
                #if it's a csv file, run in through the macro
                if filename.endswith('.csv'):
                    #set data and screenshot paths
                    self.csv_direc = csv_direc + '/{0}'.format(filename)
                    self.output_direc = os.path.splitext(output_folder_direc + '/{0}'.format(filename))[0] + '.jpg'
                    #run your macro given these paths
                    self.paraview_mach_contour()
   

    def paraview_mach_contour(self):
        #this is the paraview specific code for mach_ contour that: updates the file, colors it by mach number, applies contour lines, and takes a screenshot

        #### disable automatic camera reset on 'Show'
        paraview.simple._DisableFirstRenderCameraReset()

        # create a new 'XML Unstructured Grid Reader'
        flowvtu = XMLUnstructuredGridReader(registrationName='flow.vtu', FileName=[self.vtu_direc])
        flowvtu.PointArrayStatus = ['Density_0', 'Density_1', 'Density_2', 'Density_3', 'Density_4', 'Momentum', 'Energy', 'Energy_ve', 'MassFrac_0', 'MassFrac_1', 'MassFrac_2', 'MassFrac_3', 'MassFrac_4', 'Pressure', 'Temperature_tr', 'Temperature_ve', 'Mach', 'Pressure_Coefficient', 'Laminar_Viscosity', 'Skin_Friction_Coefficient', 'Heat_Flux', 'Y_Plus']

        # Properties modified on flowvtu
        flowvtu.TimeArray = 'None'

        # get active view
        renderView1 = GetActiveViewOrCreate('RenderView')

        # show data in view
        flowvtuDisplay = Show(flowvtu, renderView1, 'UnstructuredGridRepresentation')

        # trace defaults for the display properties.
        flowvtuDisplay.Representation = 'Surface'
        flowvtuDisplay.ColorArrayName = [None, '']
        flowvtuDisplay.SelectTCoordArray = 'None'
        flowvtuDisplay.SelectNormalArray = 'None'
        flowvtuDisplay.SelectTangentArray = 'None'
        flowvtuDisplay.OSPRayScaleArray = 'Density_0'
        flowvtuDisplay.OSPRayScaleFunction = 'PiecewiseFunction'
        flowvtuDisplay.SelectOrientationVectors = 'Momentum'
        flowvtuDisplay.ScaleFactor = 0.018500570952892304
        flowvtuDisplay.SelectScaleArray = 'Density_0'
        flowvtuDisplay.GlyphType = 'Arrow'
        flowvtuDisplay.GlyphTableIndexArray = 'Density_0'
        flowvtuDisplay.GaussianRadius = 0.0009250285476446151
        flowvtuDisplay.SetScaleArray = ['POINTS', 'Density_0']
        flowvtuDisplay.ScaleTransferFunction = 'PiecewiseFunction'
        flowvtuDisplay.OpacityArray = ['POINTS', 'Density_0']
        flowvtuDisplay.OpacityTransferFunction = 'PiecewiseFunction'
        flowvtuDisplay.DataAxesGrid = 'GridAxesRepresentation'
        flowvtuDisplay.PolarAxes = 'PolarAxesRepresentation'
        flowvtuDisplay.ScalarOpacityUnitDistance = 0.004357030660741584
        flowvtuDisplay.OpacityArrayName = ['POINTS', 'Density_0']

        # init the 'PiecewiseFunction' selected for 'ScaleTransferFunction'
        flowvtuDisplay.ScaleTransferFunction.Points = [1.8854900688596942e-34, 0.0, 0.5, 0.0, 1.4016611022628e-20, 1.0, 0.5, 0.0]

        # init the 'PiecewiseFunction' selected for 'OpacityTransferFunction'
        flowvtuDisplay.OpacityTransferFunction.Points = [1.8854900688596942e-34, 0.0, 0.5, 0.0, 1.4016611022628e-20, 1.0, 0.5, 0.0]

        #changing interaction mode based on data extents
        renderView1.InteractionMode = '3D'

        # get the material library
        materialLibrary1 = GetMaterialLibrary()

        # create a new 'CSV Reader'
        soln_volume_1csv = CSVReader(registrationName='soln_volume_1.csv', FileName=[self.csv_direc])


        # get layout
        layout1 = GetLayoutByName("Layout #1")


        # set active view
        SetActiveView(renderView1)

        # create a new 'Table To Points'
        tableToPoints1 = TableToPoints(registrationName='TableToPoints1', Input=soln_volume_1csv)
        tableToPoints1.XColumn = 'Density_0'
        tableToPoints1.YColumn = 'Density_0'
        tableToPoints1.ZColumn = 'Density_0'

        # Properties modified on tableToPoints1
        tableToPoints1.XColumn = 'x'
        tableToPoints1.YColumn = 'y'
        tableToPoints1.a2DPoints = 1

        # show data in view
        tableToPoints1Display = Show(tableToPoints1, renderView1, 'GeometryRepresentation')

        # trace defaults for the display properties.
        tableToPoints1Display.Representation = 'Surface'
        tableToPoints1Display.ColorArrayName = [None, '']
        tableToPoints1Display.SelectTCoordArray = 'None'
        tableToPoints1Display.SelectNormalArray = 'None'
        tableToPoints1Display.SelectTangentArray = 'None'
        tableToPoints1Display.OSPRayScaleArray = 'Density_1'
        tableToPoints1Display.OSPRayScaleFunction = 'PiecewiseFunction'
        tableToPoints1Display.SelectOrientationVectors = 'None'
        tableToPoints1Display.ScaleFactor = 0.011015886848306108
        tableToPoints1Display.SelectScaleArray = 'Density_1'
        tableToPoints1Display.GlyphType = 'Arrow'
        tableToPoints1Display.GlyphTableIndexArray = 'Density_1'
        tableToPoints1Display.GaussianRadius = 0.0005507943424153055
        tableToPoints1Display.SetScaleArray = ['POINTS', 'Density_1']
        tableToPoints1Display.ScaleTransferFunction = 'PiecewiseFunction'
        tableToPoints1Display.OpacityArray = ['POINTS', 'Density_1']
        tableToPoints1Display.OpacityTransferFunction = 'PiecewiseFunction'
        tableToPoints1Display.DataAxesGrid = 'GridAxesRepresentation'
        tableToPoints1Display.PolarAxes = 'PolarAxesRepresentation'

        # init the 'PiecewiseFunction' selected for 'ScaleTransferFunction'
        tableToPoints1Display.ScaleTransferFunction.Points = [1.241998014818178e-44, 0.0, 0.5, 0.0, 0.002270008363428088, 1.0, 0.5, 0.0]

        # init the 'PiecewiseFunction' selected for 'OpacityTransferFunction'
        tableToPoints1Display.OpacityTransferFunction.Points = [1.241998014818178e-44, 0.0, 0.5, 0.0, 0.002270008363428088, 1.0, 0.5, 0.0]

        # create a new 'Delaunay 2D'
        delaunay2D1 = Delaunay2D(registrationName='Delaunay2D1', Input=tableToPoints1)

        # show data in view
        delaunay2D1Display = Show(delaunay2D1, renderView1, 'GeometryRepresentation')

        # trace defaults for the display properties.
        delaunay2D1Display.Representation = 'Surface'
        delaunay2D1Display.ColorArrayName = [None, '']
        delaunay2D1Display.SelectTCoordArray = 'None'
        delaunay2D1Display.SelectNormalArray = 'None'
        delaunay2D1Display.SelectTangentArray = 'None'
        delaunay2D1Display.OSPRayScaleArray = 'Density_1'
        delaunay2D1Display.OSPRayScaleFunction = 'PiecewiseFunction'
        delaunay2D1Display.SelectOrientationVectors = 'None'
        delaunay2D1Display.ScaleFactor = 0.011015886848306108
        delaunay2D1Display.SelectScaleArray = 'Density_1'
        delaunay2D1Display.GlyphType = 'Arrow'
        delaunay2D1Display.GlyphTableIndexArray = 'Density_1'
        delaunay2D1Display.GaussianRadius = 0.0005507943424153055
        delaunay2D1Display.SetScaleArray = ['POINTS', 'Density_1']
        delaunay2D1Display.ScaleTransferFunction = 'PiecewiseFunction'
        delaunay2D1Display.OpacityArray = ['POINTS', 'Density_1']
        delaunay2D1Display.OpacityTransferFunction = 'PiecewiseFunction'
        delaunay2D1Display.DataAxesGrid = 'GridAxesRepresentation'
        delaunay2D1Display.PolarAxes = 'PolarAxesRepresentation'

        # init the 'PiecewiseFunction' selected for 'ScaleTransferFunction'
        delaunay2D1Display.ScaleTransferFunction.Points = [1.241998014818178e-44, 0.0, 0.5, 0.0, 0.002270008363428088, 1.0, 0.5, 0.0]

        # init the 'PiecewiseFunction' selected for 'OpacityTransferFunction'
        delaunay2D1Display.OpacityTransferFunction.Points = [1.241998014818178e-44, 0.0, 0.5, 0.0, 0.002270008363428088, 1.0, 0.5, 0.0]

        # hide data in view
        Hide(tableToPoints1, renderView1)

        # create a new 'Transform'
        transform1 = Transform(registrationName='Transform1', Input=delaunay2D1)
        transform1.Transform = 'Transform'

        # Properties modified on transform1.Transform
        transform1.Transform.Scale = [1.0001, 1.0001, 1.0001]

        # show data in view
        transform1Display = Show(transform1, renderView1, 'GeometryRepresentation')

        # trace defaults for the display properties.
        transform1Display.Representation = 'Surface'
        transform1Display.ColorArrayName = [None, '']
        transform1Display.SelectTCoordArray = 'None'
        transform1Display.SelectNormalArray = 'None'
        transform1Display.SelectTangentArray = 'None'
        transform1Display.OSPRayScaleArray = 'Density_1'
        transform1Display.OSPRayScaleFunction = 'PiecewiseFunction'
        transform1Display.SelectOrientationVectors = 'None'
        transform1Display.ScaleFactor = 0.01101698843699094
        transform1Display.SelectScaleArray = 'Density_1'
        transform1Display.GlyphType = 'Arrow'
        transform1Display.GlyphTableIndexArray = 'Density_1'
        transform1Display.GaussianRadius = 0.000550849421849547
        transform1Display.SetScaleArray = ['POINTS', 'Density_1']
        transform1Display.ScaleTransferFunction = 'PiecewiseFunction'
        transform1Display.OpacityArray = ['POINTS', 'Density_1']
        transform1Display.OpacityTransferFunction = 'PiecewiseFunction'
        transform1Display.DataAxesGrid = 'GridAxesRepresentation'
        transform1Display.PolarAxes = 'PolarAxesRepresentation'

        # init the 'PiecewiseFunction' selected for 'ScaleTransferFunction'
        transform1Display.ScaleTransferFunction.Points = [1.241998014818178e-44, 0.0, 0.5, 0.0, 0.002270008363428088, 1.0, 0.5, 0.0]

        # init the 'PiecewiseFunction' selected for 'OpacityTransferFunction'
        transform1Display.OpacityTransferFunction.Points = [1.241998014818178e-44, 0.0, 0.5, 0.0, 0.002270008363428088, 1.0, 0.5, 0.0]

        # hide data in view
        Hide(delaunay2D1, renderView1)

        # create a new 'Resample With Dataset'
        resampleWithDataset1 = ResampleWithDataset(registrationName='ResampleWithDataset1', SourceDataArrays=transform1,
            DestinationMesh=flowvtu)
        resampleWithDataset1.CellLocator = 'Static Cell Locator'

        # show data in view
        resampleWithDataset1Display = Show(resampleWithDataset1, renderView1, 'UnstructuredGridRepresentation')

        # trace defaults for the display properties.
        resampleWithDataset1Display.Representation = 'Surface'
        resampleWithDataset1Display.ColorArrayName = [None, '']
        resampleWithDataset1Display.SelectTCoordArray = 'None'
        resampleWithDataset1Display.SelectNormalArray = 'None'
        resampleWithDataset1Display.SelectTangentArray = 'None'
        resampleWithDataset1Display.OSPRayScaleArray = 'Density_1'
        resampleWithDataset1Display.OSPRayScaleFunction = 'PiecewiseFunction'
        resampleWithDataset1Display.SelectOrientationVectors = 'None'
        resampleWithDataset1Display.ScaleFactor = 0.018500570952892304
        resampleWithDataset1Display.SelectScaleArray = 'Density_1'
        resampleWithDataset1Display.GlyphType = 'Arrow'
        resampleWithDataset1Display.GlyphTableIndexArray = 'Density_1'
        resampleWithDataset1Display.GaussianRadius = 0.0009250285476446151
        resampleWithDataset1Display.SetScaleArray = ['POINTS', 'Density_1']
        resampleWithDataset1Display.ScaleTransferFunction = 'PiecewiseFunction'
        resampleWithDataset1Display.OpacityArray = ['POINTS', 'Density_1']
        resampleWithDataset1Display.OpacityTransferFunction = 'PiecewiseFunction'
        resampleWithDataset1Display.DataAxesGrid = 'GridAxesRepresentation'
        resampleWithDataset1Display.PolarAxes = 'PolarAxesRepresentation'
        resampleWithDataset1Display.ScalarOpacityUnitDistance = 0.004357030660741584
        resampleWithDataset1Display.OpacityArrayName = ['POINTS', 'Density_1']

        # init the 'PiecewiseFunction' selected for 'ScaleTransferFunction'
        resampleWithDataset1Display.ScaleTransferFunction.Points = [0.0, 0.0, 0.5, 0.0, 0.00226973790246123, 1.0, 0.5, 0.0]

        # init the 'PiecewiseFunction' selected for 'OpacityTransferFunction'
        resampleWithDataset1Display.OpacityTransferFunction.Points = [0.0, 0.0, 0.5, 0.0, 0.00226973790246123, 1.0, 0.5, 0.0]

        # hide data in view
        Hide(flowvtu, renderView1)

        # hide data in view
        Hide(transform1, renderView1)

        # create a new 'Slice'
        slice1 = Slice(registrationName='Slice1', Input=resampleWithDataset1)
        slice1.SliceType = 'Plane'
        slice1.HyperTreeGridSlicer = 'Plane'
        slice1.SliceOffsetValues = [0.0]

        # init the 'Plane' selected for 'SliceType'
        slice1.SliceType.Origin = [0.03492056764662266, 0.0, 0.0]

        # init the 'Plane' selected for 'HyperTreeGridSlicer'
        slice1.HyperTreeGridSlicer.Origin = [0.03492056764662266, 0.0, 0.0]

        # Properties modified on slice1.SliceType
        slice1.SliceType.Normal = [0.0, 0.0, 1.0]

        # show data in view
        slice1Display = Show(slice1, renderView1, 'GeometryRepresentation')
      
        # trace defaults for the display properties.
        slice1Display.Representation = 'Surface'
        slice1Display.ColorArrayName = [None, '']
        slice1Display.SelectTCoordArray = 'None'
        slice1Display.SelectNormalArray = 'None'
        slice1Display.SelectTangentArray = 'None'
        slice1Display.OSPRayScaleArray = 'Density_1'
        slice1Display.OSPRayScaleFunction = 'PiecewiseFunction'
        slice1Display.SelectOrientationVectors = 'None'
        slice1Display.ScaleFactor = 0.018500570952892304
        slice1Display.SelectScaleArray = 'Density_1'
        slice1Display.GlyphType = 'Arrow'
        slice1Display.GlyphTableIndexArray = 'Density_1'
        slice1Display.GaussianRadius = 0.0009250285476446151
        slice1Display.SetScaleArray = ['POINTS', 'Density_1']
        slice1Display.ScaleTransferFunction = 'PiecewiseFunction'
        slice1Display.OpacityArray = ['POINTS', 'Density_1']
        slice1Display.OpacityTransferFunction = 'PiecewiseFunction'
        slice1Display.DataAxesGrid = 'GridAxesRepresentation'
        slice1Display.PolarAxes = 'PolarAxesRepresentation'

        # init the 'PiecewiseFunction' selected for 'ScaleTransferFunction'
        slice1Display.ScaleTransferFunction.Points = [0.0, 0.0, 0.5, 0.0, 0.00226973790246123, 1.0, 0.5, 0.0]

        # init the 'PiecewiseFunction' selected for 'OpacityTransferFunction'
        slice1Display.OpacityTransferFunction.Points = [0.0, 0.0, 0.5, 0.0, 0.00226973790246123, 1.0, 0.5, 0.0]

        # hide data in view
        Hide(resampleWithDataset1, renderView1)


        # create a new 'Slice'
        slice2 = Slice(registrationName='Slice2', Input=slice1)
        slice2.SliceType = 'Plane'
        slice2.HyperTreeGridSlicer = 'Plane'
        slice2.SliceOffsetValues = [0.0]

        # init the 'Plane' selected for 'SliceType'
        slice2.SliceType.Origin = [0.03492056764662266, 0.0, 0.0]

        # init the 'Plane' selected for 'HyperTreeGridSlicer'
        slice2.HyperTreeGridSlicer.Origin = [0.03492056764662266, 0.0, 0.0]

        # set active source
        SetActiveSource(slice1)

        # toggle 3D widget visibility (only when running from the GUI)
        Hide3DWidgets(proxy=slice2.SliceType)

        # destroy slice2
        Delete(slice2)
        del slice2

        # create a new 'Clip'
        clip1 = Clip(registrationName='Clip1', Input=slice1)
        clip1.ClipType = 'Plane'
        clip1.HyperTreeGridClipper = 'Plane'
        clip1.Scalars = ['POINTS', 'Density_1']
        clip1.Value = 0.001134868951230615

        # init the 'Plane' selected for 'ClipType'
        clip1.ClipType.Origin = [0.03492056764662266, 0.0, 0.0]

        # init the 'Plane' selected for 'HyperTreeGridClipper'
        clip1.HyperTreeGridClipper.Origin = [0.03492056764662266, 0.0, 0.0]

        # Properties modified on clip1.ClipType
        clip1.ClipType.Normal = [0.0, -1.0, 0.0]

        # show data in view
        clip1Display = Show(clip1, renderView1, 'UnstructuredGridRepresentation')

        # trace defaults for the display properties.
        clip1Display.Representation = 'Surface'
        clip1Display.ColorArrayName = [None, '']
        clip1Display.SelectTCoordArray = 'None'
        clip1Display.SelectNormalArray = 'None'
        clip1Display.SelectTangentArray = 'None'
        clip1Display.OSPRayScaleArray = 'Density_1'
        clip1Display.OSPRayScaleFunction = 'PiecewiseFunction'
        clip1Display.SelectOrientationVectors = 'None'
        clip1Display.ScaleFactor = 0.011015887185931206
        clip1Display.SelectScaleArray = 'Density_1'
        clip1Display.GlyphType = 'Arrow'
        clip1Display.GlyphTableIndexArray = 'Density_1'
        clip1Display.GaussianRadius = 0.0005507943592965603
        clip1Display.SetScaleArray = ['POINTS', 'Density_1']
        clip1Display.ScaleTransferFunction = 'PiecewiseFunction'
        clip1Display.OpacityArray = ['POINTS', 'Density_1']
        clip1Display.OpacityTransferFunction = 'PiecewiseFunction'
        clip1Display.DataAxesGrid = 'GridAxesRepresentation'
        clip1Display.PolarAxes = 'PolarAxesRepresentation'
        clip1Display.ScalarOpacityUnitDistance = 0.006460926023525854
        clip1Display.OpacityArrayName = ['POINTS', 'Density_1']

        # init the 'PiecewiseFunction' selected for 'ScaleTransferFunction'
        clip1Display.ScaleTransferFunction.Points = [0.0, 0.0, 0.5, 0.0, 0.00226973790246123, 1.0, 0.5, 0.0]

        # init the 'PiecewiseFunction' selected for 'OpacityTransferFunction'
        clip1Display.OpacityTransferFunction.Points = [0.0, 0.0, 0.5, 0.0, 0.00226973790246123, 1.0, 0.5, 0.0]

        # hide data in view
        Hide(slice1, renderView1)

        # update the view to ensure updated data information
        renderView1.Update()

        # set scalar coloring
        ColorBy(clip1Display, ('POINTS', 'Mach'))
        
        # rescale color and/or opacity maps used to include current data range
        clip1Display.RescaleTransferFunctionToDataRange(True, False)

        # show color bar/color legend
        clip1Display.SetScalarBarVisibility(renderView1, True)

        # get color transfer function/color map for 'Mach'
        machLUT = GetColorTransferFunction('Mach')

        # get opacity transfer function/opacity map for 'Mach'
        machPWF = GetOpacityTransferFunction('Mach')

        # create a new 'Contour'
        contour1 = Contour(registrationName='Contour1', Input=clip1)
        contour1.ContourBy = ['POINTS', 'Mach']
        contour1.Isosurfaces = [0.001134868951230615]
        contour1.PointMergeMethod = 'Uniform Binning'

        # Properties modified on contour1
        contour1.Isosurfaces = [0.0, 0.5263157894736842, 1.0526315789473684, 1.5789473684210527, 2.1052631578947367, 2.631578947368421, 3.1578947368421053, 3.6842105263157894, 4.2105263157894735, 4.7368421052631575, 5.263157894736842, 5.789473684210526, 6.315789473684211, 6.842105263157895, 7.368421052631579, 7.894736842105263, 8.421052631578947, 8.947368421052632, 9.473684210526315, 10.0]

        # show data in view
        contour1Display = Show(contour1, renderView1, 'GeometryRepresentation')

        # trace defaults for the display properties.
        contour1Display.Representation = 'Surface'
        contour1Display.ColorArrayName = [None, '']
        contour1Display.SelectTCoordArray = 'None'
        contour1Display.SelectNormalArray = 'None'
        contour1Display.SelectTangentArray = 'None'
        contour1Display.OSPRayScaleFunction = 'PiecewiseFunction'
        contour1Display.SelectOrientationVectors = 'None'
        contour1Display.ScaleFactor = -0.2
        contour1Display.SelectScaleArray = 'None'
        contour1Display.GlyphType = 'Arrow'
        contour1Display.GlyphTableIndexArray = 'None'
        contour1Display.GaussianRadius = -0.01
        contour1Display.SetScaleArray = [None, '']
        contour1Display.ScaleTransferFunction = 'PiecewiseFunction'
        contour1Display.OpacityArray = [None, '']
        contour1Display.OpacityTransferFunction = 'PiecewiseFunction'
        contour1Display.DataAxesGrid = 'GridAxesRepresentation'
        contour1Display.PolarAxes = 'PolarAxesRepresentation'

        # hide data in view
        Hide(clip1, renderView1)

        # update the view to ensure updated data information
        renderView1.Update()

        # hide data in view
        Hide(contour1, renderView1)

        # set active source
        SetActiveSource(contour1)

        # show data in view
        contour1Display = Show(contour1, renderView1, 'GeometryRepresentation')

        # hide data in view
        Hide(contour1, renderView1)
        
        # set active source
        SetActiveSource(clip1)

        # show data in view
        clip1Display = Show(clip1, renderView1, 'UnstructuredGridRepresentation')

        # show color bar/color legend
        clip1Display.SetScalarBarVisibility(renderView1, True)

        #changing interaction mode based on data extents
        renderView1.InteractionMode = '2D'
        renderView1.CameraPosition = [0.03492056764662266, 0.04625142738223076, 10000.0]
        renderView1.CameraFocalPoint = [0.03492056764662266, 0.04625142738223076, 0.0]

        # set active source
        SetActiveSource(clip1)

        # set active source
        SetActiveSource(contour1)

        # toggle 3D widget visibility (only when running from the GUI)
        Hide3DWidgets(proxy=clip1.ClipType)

        # show data in view
        contour1Display = Show(contour1, renderView1, 'GeometryRepresentation')

        # set active source
        SetActiveSource(contour1)

        # update the view to ensure updated data information
        renderView1.Update()

        # reset view to fit data
        #renderView1.ResetCamera(False)

        # hide data in view
        Hide(clip1, renderView1)
        
        # set active source
        SetActiveSource(clip1)

        # toggle 3D widget visibility (only when running from the GUI)
        Show3DWidgets(proxy=clip1.ClipType)

        # show data in view
        clip1Display = Show(clip1, renderView1, 'UnstructuredGridRepresentation')

        # show color bar/color legend
        clip1Display.SetScalarBarVisibility(renderView1, True)

        # set active source
        SetActiveSource(contour1)

        # toggle 3D widget visibility (only when running from the GUI)
        Hide3DWidgets(proxy=clip1.ClipType)


        # current camera placement for renderView1
        renderView1.InteractionMode = '2D'
        renderView1.CameraPosition = [0.03492056764662266, 0.04625142738223076, 0.2778896933366181]
        renderView1.CameraFocalPoint = [0.03492056764662266, 0.04625142738223076, 0.0]
        renderView1.CameraParallelScale = 0.07192314507321582
       
        # save screenshot
        
        SaveScreenshot(self.output_direc, renderView1, ImageResolution=[1354, 1354])

        #================================================================
        # addendum: following script captures some of the application
        # state to faithfully reproduce the visualization during playback
        #================================================================

        ResetSession()



#below is an example of potential ways to run the simulation:
#   create an object and input the required .vtu and .csv paths
#   run the script by entering the following command in the terminal: "/pathToPvpython/pvpython /pathToScript/Script"

#s1 = sim_data('/Users/johndoe/Downloads/flow.vtu', '/Users/johndoe/Downloads/CSV_Files')
#s2 = sim_data('/Users/johndoe/Downloads/flow.vtu', '/Users/johndoe/Downloads/CSV_Files/soln_volume_1')

s1 = sim_data()

s1.mach_contour()

