#### import the simple module from the paraview
from paraview.simple import *
import os
import time


t_start = time.time()

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

d = '/home/lehmann/Dokumente/GITS/simulation_elmer/simBig/generated_data12/'
folders = [os.path.join(d, o) for o in os.listdir(d) if os.path.isdir(os.path.join(d, o))]

s_dataconf = '{}/s_dataconf.txt'.format(d)
datac = open(s_dataconf, 'w+')
datac.write('speed\n')
datac.close()

counter = 0

for f in folders:
    print(counter)
    print(f)

    counter = counter +1	
    # create a new 'XML Partitioned Unstructured Grid Reader'
    case_t0 = XMLPartitionedUnstructuredGridReader(registrationName='case_t0*',
                                        FileName=['{}/case_t0001.pvtu'.format(f), '{}/case_t0002.pvtu'.format(f),
                                                  '{}/case_t0003.pvtu'.format(f), '{}/case_t0004.pvtu'.format(f),
                                                  '{}/case_t0005.pvtu'.format(f), '{}/case_t0006.pvtu'.format(f),
                                                  '{}/case_t0007.pvtu'.format(f), '{}/case_t0008.pvtu'.format(f),
                                                  '{}/case_t0009.pvtu'.format(f), '{}/case_t0010.pvtu'.format(f),
                                                  '{}/case_t0011.pvtu'.format(f), '{}/case_t0012.pvtu'.format(f),
                                                  '{}/case_t0013.pvtu'.format(f), '{}/case_t0014.pvtu'.format(f),
                                                  '{}/case_t0015.pvtu'.format(f), '{}/case_t0016.pvtu'.format(f),
                                                  '{}/case_t0017.pvtu'.format(f), '{}/case_t0018.pvtu'.format(f),
                                                  '{}/case_t0019.pvtu'.format(f), '{}/case_t0020.pvtu'.format(f),
                                                  '{}/case_t0021.pvtu'.format(f), '{}/case_t0022.pvtu'.format(f),
                                                  '{}/case_t0023.pvtu'.format(f), '{}/case_t0024.pvtu'.format(f),
                                                  '{}/case_t0025.pvtu'.format(f), '{}/case_t0026.pvtu'.format(f),
                                                  '{}/case_t0027.pvtu'.format(f), '{}/case_t0028.pvtu'.format(f),
                                                  '{}/case_t0029.pvtu'.format(f), '{}/case_t0030.pvtu'.format(f),
                                                  '{}/case_t0031.pvtu'.format(f), '{}/case_t0032.pvtu'.format(f),
                                                  '{}/case_t0033.pvtu'.format(f), '{}/case_t0034.pvtu'.format(f),
                                                  '{}/case_t0035.pvtu'.format(f), '{}/case_t0036.pvtu'.format(f),
                                                  '{}/case_t0037.pvtu'.format(f), '{}/case_t0038.pvtu'.format(f),
                                                  '{}/case_t0039.pvtu'.format(f), '{}/case_t0040.pvtu'.format(f),
                                                  '{}/case_t0041.pvtu'.format(f), '{}/case_t0042.pvtu'.format(f),
                                                  '{}/case_t0043.pvtu'.format(f), '{}/case_t0044.pvtu'.format(f),
                                                  '{}/case_t0045.pvtu'.format(f), '{}/case_t0046.pvtu'.format(f),
                                                  '{}/case_t0047.pvtu'.format(f), '{}/case_t0048.pvtu'.format(f),
                                                  '{}/case_t0049.pvtu'.format(f), '{}/case_t0050.pvtu'.format(f),
                                                  '{}/case_t0051.pvtu'.format(f), '{}/case_t0052.pvtu'.format(f),
                                                  '{}/case_t0053.pvtu'.format(f), '{}/case_t0054.pvtu'.format(f),
                                                  '{}/case_t0055.pvtu'.format(f), '{}/case_t0056.pvtu'.format(f),
                                                  '{}/case_t0057.pvtu'.format(f), '{}/case_t0058.pvtu'.format(f),
                                                  '{}/case_t0059.pvtu'.format(f), '{}/case_t0060.pvtu'.format(f),
                                                  '{}/case_t0061.pvtu'.format(f), '{}/case_t0062.pvtu'.format(f),
                                                  '{}/case_t0063.pvtu'.format(f), '{}/case_t0064.pvtu'.format(f),
                                                  '{}/case_t0065.pvtu'.format(f), '{}/case_t0066.pvtu'.format(f),
                                                  '{}/case_t0067.pvtu'.format(f), '{}/case_t0068.pvtu'.format(f),
                                                  '{}/case_t0069.pvtu'.format(f), '{}/case_t0070.pvtu'.format(f),
                                                  '{}/case_t0071.pvtu'.format(f), '{}/case_t0072.pvtu'.format(f),
                                                  '{}/case_t0073.pvtu'.format(f), '{}/case_t0074.pvtu'.format(f),
                                                  '{}/case_t0075.pvtu'.format(f), '{}/case_t0076.pvtu'.format(f),
                                                  '{}/case_t0077.pvtu'.format(f), '{}/case_t0078.pvtu'.format(f),
                                                  '{}/case_t0079.pvtu'.format(f), '{}/case_t0080.pvtu'.format(f),
                                                  '{}/case_t0081.pvtu'.format(f), '{}/case_t0082.pvtu'.format(f),
                                                  '{}/case_t0083.pvtu'.format(f), '{}/case_t0084.pvtu'.format(f),
                                                  '{}/case_t0085.pvtu'.format(f), '{}/case_t0086.pvtu'.format(f),
                                                  '{}/case_t0087.pvtu'.format(f), '{}/case_t0088.pvtu'.format(f),
                                                  '{}/case_t0089.pvtu'.format(f), '{}/case_t0090.pvtu'.format(f),
                                                  '{}/case_t0091.pvtu'.format(f), '{}/case_t0092.pvtu'.format(f),
                                                  '{}/case_t0093.pvtu'.format(f), '{}/case_t0094.pvtu'.format(f),
                                                  '{}/case_t0095.pvtu'.format(f), '{}/case_t0096.pvtu'.format(f),
                                                  '{}/case_t0097.pvtu'.format(f), '{}/case_t0098.pvtu'.format(f),
                                                  '{}/case_t0099.pvtu'.format(f), '{}/case_t0100.pvtu'.format(f),
                                                  '{}/case_t0101.pvtu'.format(f), '{}/case_t0102.pvtu'.format(f),
                                                  '{}/case_t0103.pvtu'.format(f), '{}/case_t0104.pvtu'.format(f),
                                                  '{}/case_t0105.pvtu'.format(f), '{}/case_t0106.pvtu'.format(f),
                                                  '{}/case_t0107.pvtu'.format(f), '{}/case_t0108.pvtu'.format(f),
                                                  '{}/case_t0109.pvtu'.format(f), '{}/case_t0110.pvtu'.format(f),
                                                  '{}/case_t0111.pvtu'.format(f), '{}/case_t0112.pvtu'.format(f),
                                                  '{}/case_t0113.pvtu'.format(f), '{}/case_t0114.pvtu'.format(f),
                                                  '{}/case_t0115.pvtu'.format(f), '{}/case_t0116.pvtu'.format(f),
                                                  '{}/case_t0117.pvtu'.format(f), '{}/case_t0118.pvtu'.format(f),
                                                  '{}/case_t0119.pvtu'.format(f), '{}/case_t0120.pvtu'.format(f),
                                                  '{}/case_t0121.pvtu'.format(f), '{}/case_t0122.pvtu'.format(f),
                                                  '{}/case_t0123.pvtu'.format(f), '{}/case_t0124.pvtu'.format(f),
                                                  '{}/case_t0125.pvtu'.format(f), '{}/case_t0126.pvtu'.format(f),
                                                  '{}/case_t0127.pvtu'.format(f), '{}/case_t0128.pvtu'.format(f),
                                                  '{}/case_t0129.pvtu'.format(f), '{}/case_t0130.pvtu'.format(f),
                                                  '{}/case_t0131.pvtu'.format(f), '{}/case_t0132.pvtu'.format(f),
                                                  '{}/case_t0133.pvtu'.format(f), '{}/case_t0134.pvtu'.format(f),
                                                  '{}/case_t0135.pvtu'.format(f), '{}/case_t0136.pvtu'.format(f),
                                                  '{}/case_t0137.pvtu'.format(f), '{}/case_t0138.pvtu'.format(f),
                                                  '{}/case_t0139.pvtu'.format(f), '{}/case_t0140.pvtu'.format(f),
                                                  '{}/case_t0141.pvtu'.format(f), '{}/case_t0142.pvtu'.format(f),
                                                  '{}/case_t0143.pvtu'.format(f), '{}/case_t0144.pvtu'.format(f),
                                                  '{}/case_t0145.pvtu'.format(f), '{}/case_t0146.pvtu'.format(f),
                                                  '{}/case_t0147.pvtu'.format(f), '{}/case_t0148.pvtu'.format(f),
                                                  '{}/case_t0149.pvtu'.format(f), '{}/case_t0150.pvtu'.format(f),
                                                  '{}/case_t0151.pvtu'.format(f), '{}/case_t0152.pvtu'.format(f),
                                                  '{}/case_t0153.pvtu'.format(f), '{}/case_t0154.pvtu'.format(f),
                                                  '{}/case_t0155.pvtu'.format(f), '{}/case_t0156.pvtu'.format(f),
                                                  '{}/case_t0157.pvtu'.format(f), '{}/case_t0158.pvtu'.format(f),
                                                  '{}/case_t0159.pvtu'.format(f), '{}/case_t0160.pvtu'.format(f),
                                                  '{}/case_t0161.pvtu'.format(f), '{}/case_t0162.pvtu'.format(f),
                                                  '{}/case_t0163.pvtu'.format(f), '{}/case_t0164.pvtu'.format(f),
                                                  '{}/case_t0165.pvtu'.format(f), '{}/case_t0166.pvtu'.format(f),
                                                  '{}/case_t0167.pvtu'.format(f), '{}/case_t0168.pvtu'.format(f),
                                                  '{}/case_t0169.pvtu'.format(f), '{}/case_t0170.pvtu'.format(f),
                                                  '{}/case_t0171.pvtu'.format(f), '{}/case_t0172.pvtu'.format(f),
                                                  '{}/case_t0173.pvtu'.format(f), '{}/case_t0174.pvtu'.format(f),
                                                  '{}/case_t0175.pvtu'.format(f), '{}/case_t0176.pvtu'.format(f),
                                                  '{}/case_t0177.pvtu'.format(f), '{}/case_t0178.pvtu'.format(f),
                                                  '{}/case_t0179.pvtu'.format(f), '{}/case_t0180.pvtu'.format(f),
                                                  '{}/case_t0181.pvtu'.format(f), '{}/case_t0182.pvtu'.format(f),
                                                  '{}/case_t0183.pvtu'.format(f), '{}/case_t0184.pvtu'.format(f),
                                                  '{}/case_t0185.pvtu'.format(f), '{}/case_t0186.pvtu'.format(f),
                                                  '{}/case_t0187.pvtu'.format(f), '{}/case_t0188.pvtu'.format(f),
                                                  '{}/case_t0189.pvtu'.format(f), '{}/case_t0190.pvtu'.format(f),
                                                  '{}/case_t0191.pvtu'.format(f), '{}/case_t0192.pvtu'.format(f),
                                                  '{}/case_t0193.pvtu'.format(f), '{}/case_t0194.pvtu'.format(f),
                                                  '{}/case_t0195.pvtu'.format(f), '{}/case_t0196.pvtu'.format(f),
                                                  '{}/case_t0197.pvtu'.format(f), '{}/case_t0198.pvtu'.format(f),
                                                  '{}/case_t0199.pvtu'.format(f), '{}/case_t0200.pvtu'.format(f),
                                                  '{}/case_t0201.pvtu'.format(f), '{}/case_t0202.pvtu'.format(f),
                                                  '{}/case_t0203.pvtu'.format(f), '{}/case_t0204.pvtu'.format(f),
                                                  '{}/case_t0205.pvtu'.format(f), '{}/case_t0206.pvtu'.format(f),
                                                  '{}/case_t0207.pvtu'.format(f), '{}/case_t0208.pvtu'.format(f),
                                                  '{}/case_t0209.pvtu'.format(f), '{}/case_t0210.pvtu'.format(f),
                                                  '{}/case_t0211.pvtu'.format(f), '{}/case_t0212.pvtu'.format(f),
                                                  '{}/case_t0213.pvtu'.format(f), '{}/case_t0214.pvtu'.format(f),
                                                  '{}/case_t0215.pvtu'.format(f), '{}/case_t0216.pvtu'.format(f),
                                                  '{}/case_t0217.pvtu'.format(f), '{}/case_t0218.pvtu'.format(f),
                                                  '{}/case_t0219.pvtu'.format(f), '{}/case_t0220.pvtu'.format(f),
                                                  '{}/case_t0221.pvtu'.format(f), '{}/case_t0222.pvtu'.format(f),
                                                  '{}/case_t0223.pvtu'.format(f), '{}/case_t0224.pvtu'.format(f),
                                                  '{}/case_t0225.pvtu'.format(f), '{}/case_t0226.pvtu'.format(f),
                                                  '{}/case_t0227.pvtu'.format(f), '{}/case_t0228.pvtu'.format(f),
                                                  '{}/case_t0229.pvtu'.format(f), '{}/case_t0230.pvtu'.format(f),
                                                  '{}/case_t0231.pvtu'.format(f), '{}/case_t0232.pvtu'.format(f),
                                                  '{}/case_t0233.pvtu'.format(f), '{}/case_t0234.pvtu'.format(f),
                                                  '{}/case_t0235.pvtu'.format(f), '{}/case_t0236.pvtu'.format(f),
                                                  '{}/case_t0237.pvtu'.format(f), '{}/case_t0238.pvtu'.format(f),
                                                  '{}/case_t0239.pvtu'.format(f), '{}/case_t0240.pvtu'.format(f),
                                                  '{}/case_t0241.pvtu'.format(f), '{}/case_t0242.pvtu'.format(f),
                                                  '{}/case_t0243.pvtu'.format(f), '{}/case_t0244.pvtu'.format(f),
                                                  '{}/case_t0245.pvtu'.format(f), '{}/case_t0246.pvtu'.format(f),
                                                  '{}/case_t0247.pvtu'.format(f), '{}/case_t0248.pvtu'.format(f),
                                                  '{}/case_t0249.pvtu'.format(f), '{}/case_t0250.pvtu'.format(f),
                                                  '{}/case_t0251.pvtu'.format(f), '{}/case_t0252.pvtu'.format(f),
                                                  '{}/case_t0253.pvtu'.format(f), '{}/case_t0254.pvtu'.format(f),
                                                  '{}/case_t0255.pvtu'.format(f), '{}/case_t0256.pvtu'.format(f),
                                                  '{}/case_t0257.pvtu'.format(f), '{}/case_t0258.pvtu'.format(f),
                                                  '{}/case_t0259.pvtu'.format(f), '{}/case_t0260.pvtu'.format(f),
                                                  '{}/case_t0261.pvtu'.format(f), '{}/case_t0262.pvtu'.format(f),
                                                  '{}/case_t0263.pvtu'.format(f), '{}/case_t0264.pvtu'.format(f),
                                                  '{}/case_t0265.pvtu'.format(f), '{}/case_t0266.pvtu'.format(f),
                                                  '{}/case_t0267.pvtu'.format(f), '{}/case_t0268.pvtu'.format(f),
                                                  '{}/case_t0269.pvtu'.format(f), '{}/case_t0270.pvtu'.format(f),
                                                  '{}/case_t0271.pvtu'.format(f), '{}/case_t0272.pvtu'.format(f),
                                                  '{}/case_t0273.pvtu'.format(f), '{}/case_t0274.pvtu'.format(f),
                                                  '{}/case_t0275.pvtu'.format(f), '{}/case_t0276.pvtu'.format(f),
                                                  '{}/case_t0277.pvtu'.format(f), '{}/case_t0278.pvtu'.format(f),
                                                  '{}/case_t0279.pvtu'.format(f), '{}/case_t0280.pvtu'.format(f),
                                                  '{}/case_t0281.pvtu'.format(f), '{}/case_t0282.pvtu'.format(f),
                                                  '{}/case_t0283.pvtu'.format(f), '{}/case_t0284.pvtu'.format(f),
                                                  '{}/case_t0285.pvtu'.format(f), '{}/case_t0286.pvtu'.format(f),
                                                  '{}/case_t0287.pvtu'.format(f), '{}/case_t0288.pvtu'.format(f),
                                                  '{}/case_t0289.pvtu'.format(f), '{}/case_t0290.pvtu'.format(f),
                                                  '{}/case_t0291.pvtu'.format(f), '{}/case_t0292.pvtu'.format(f),
                                                  '{}/case_t0293.pvtu'.format(f), '{}/case_t0294.pvtu'.format(f),
                                                  '{}/case_t0295.pvtu'.format(f), '{}/case_t0296.pvtu'.format(f),
                                                  '{}/case_t0297.pvtu'.format(f), '{}/case_t0298.pvtu'.format(f),
                                                  '{}/case_t0299.pvtu'.format(f), '{}/case_t0300.pvtu'.format(f),
                                                  '{}/case_t0301.pvtu'.format(f), '{}/case_t0302.pvtu'.format(f),
                                                  '{}/case_t0303.pvtu'.format(f), '{}/case_t0304.pvtu'.format(f),
                                                  '{}/case_t0305.pvtu'.format(f), '{}/case_t0306.pvtu'.format(f),
                                                  '{}/case_t0307.pvtu'.format(f), '{}/case_t0308.pvtu'.format(f),
                                                  '{}/case_t0309.pvtu'.format(f), '{}/case_t0310.pvtu'.format(f),
                                                  '{}/case_t0311.pvtu'.format(f), '{}/case_t0312.pvtu'.format(f),
                                                  '{}/case_t0313.pvtu'.format(f), '{}/case_t0314.pvtu'.format(f),
                                                  '{}/case_t0315.pvtu'.format(f), '{}/case_t0316.pvtu'.format(f),
                                                  '{}/case_t0317.pvtu'.format(f), '{}/case_t0318.pvtu'.format(f),
                                                  '{}/case_t0319.pvtu'.format(f), '{}/case_t0320.pvtu'.format(f),
                                                  '{}/case_t0321.pvtu'.format(f), '{}/case_t0322.pvtu'.format(f),
                                                  '{}/case_t0323.pvtu'.format(f), '{}/case_t0324.pvtu'.format(f),
                                                  '{}/case_t0325.pvtu'.format(f), '{}/case_t0326.pvtu'.format(f),
                                                  '{}/case_t0327.pvtu'.format(f), '{}/case_t0328.pvtu'.format(f),
                                                  '{}/case_t0329.pvtu'.format(f), '{}/case_t0330.pvtu'.format(f),
                                                  '{}/case_t0331.pvtu'.format(f), '{}/case_t0332.pvtu'.format(f),
                                                  '{}/case_t0333.pvtu'.format(f), '{}/case_t0334.pvtu'.format(f),
                                                  '{}/case_t0335.pvtu'.format(f)])
    case_t0.CellArrayStatus = ['GeometryIds']
    case_t0.PointArrayStatus = ['pressure', 'velocity']

    animationScene1 = GetAnimationScene()

    animationScene1.UpdateAnimationUsingDataTimeSteps()

    renderView1 = GetActiveView()

    if not renderView1:
        # When using the ParaView UI, the View will be present, not otherwise.
        renderView1 = CreateRenderView()

    # show data in view
    case_t0Display = Show(case_t0, renderView1)

    # trace defaults for the display properties.
    case_t0Display.Representation = 'Surface'
    case_t0Display.ColorArrayName = [None, '']
    case_t0Display.OSPRayScaleArray = 'pressure'
    case_t0Display.OSPRayScaleFunction = 'PiecewiseFunction'
    case_t0Display.ScaleFactor = 1.06
    case_t0Display.GlyphType = 'Arrow'
    case_t0Display.GaussianRadius = 0.053
    case_t0Display.SetScaleArray = ['POINTS', 'pressure']
    case_t0Display.ScaleTransferFunction = 'PiecewiseFunction'
    case_t0Display.OpacityArray = ['POINTS', 'pressure']
    case_t0Display.OpacityTransferFunction = 'PiecewiseFunction'
    case_t0Display.DataAxesGrid = 'GridAxesRepresentation'
    case_t0Display.PolarAxes = 'PolarAxesRepresentation'
    case_t0Display.ScalarOpacityUnitDistance = 0.5683734564645577

    # init the 'PiecewiseFunction' selected for 'ScaleTransferFunction'
    case_t0Display.ScaleTransferFunction.Points = [4.3925555865654745e-05, 0.0, 0.5, 0.0, 89.73824620136891, 1.0,
                                                   0.5, 0.0]

    # init the 'PiecewiseFunction' selected for 'OpacityTransferFunction'
    case_t0Display.OpacityTransferFunction.Points = [4.3925555865654745e-05, 0.0, 0.5, 0.0, 89.73824620136891, 1.0,
                                                     0.5, 0.0]

    # reset view to fit data
    renderView1.ResetCamera()

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

    # get the material library
    materialLibrary1 = GetMaterialLibrary()

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

    # set scalar coloring
    ColorBy(case_t0Display, ('POINTS', 'velocity', 'Magnitude'))

    # rescale color and/or opacity maps used to include current data range
    case_t0Display.RescaleTransferFunctionToDataRange(True, False)

    # show color bar/color legend
    case_t0Display.SetScalarBarVisibility(renderView1, False)

    # get color transfer function/color map for 'velocity'
    velocityLUT = GetColorTransferFunction('velocity')

    # get opacity transfer function/opacity map for 'velocity'
    velocityPWF = GetOpacityTransferFunction('velocity')

    # set scalar coloring
    ColorBy(case_t0Display, ('POINTS', 'velocity', 'X'))

    # rescale color and/or opacity maps used to exactly fit the current data range
    case_t0Display.RescaleTransferFunctionToDataRange(False, True)

    # Update a scalar bar component title.
    UpdateScalarBarsComponentTitle(velocityLUT, case_t0Display)

    # Apply a preset using its name. Note this may not work as expected when presets have duplicate names.
    velocityLUT.ApplyPreset('Grayscale', True)

    # Hide orientation axes
    renderView1.OrientationAxesVisibility = 0

    # reset view to fit data bounds
    renderView1.ResetCamera(0.0, 2.2, 0.0, 0.41, 0.0, 0.0)

    # current camera placement for renderView1
    renderView1.CameraPosition = [1.1, 0.205, 2.016827658506227]
    renderView1.CameraFocalPoint = [1.1, 0.205, 0.0]
    renderView1.CameraParallelScale = 0.8189392298065164

    # ---------------Saving of the animation in 3 Dimensions --------------------------

    px = '{}/images_x'.format(f)
    if not os.path.exists(px):
        os.makedirs(px)

    # save animation
    SaveAnimation('{}/flow.png'.format(px), renderView1, ImageResolution=[1113, 552],
                  TransparentBackground=1,
                  FrameWindow=[0, 334])

    print("X-Velocity \t \t \t --> Done!")

    py = '{}/images_y'.format(f)
    if not os.path.exists(py):
        os.makedirs(py)

    # set scalar coloring
    ColorBy(case_t0Display, ('POINTS', 'velocity', 'Y'))

    # rescale color and/or opacity maps used to exactly fit the current data range
    case_t0Display.RescaleTransferFunctionToDataRange(False, True)

    # save animation
    SaveAnimation('{}/flow.png'.format(py), renderView1, ImageResolution=[1113, 552],
                  TransparentBackground=1,
                  FrameWindow=[0, 334])

    print("Y-Velocity \t \t \t --> Done!")

    pp = '{}/images_p'.format(f)
    if not os.path.exists(pp):
        os.makedirs(pp)

    # set scalar coloring
    ColorBy(case_t0Display, ('POINTS', 'pressure'))

    # show color bar/color legend
    case_t0Display.SetScalarBarVisibility(renderView1, False)

    # get color transfer function/color map for 'pressure'
    pressureLUT = GetColorTransferFunction('pressure')

    # get opacity transfer function/opacity map for 'pressure'
    pressurePWF = GetOpacityTransferFunction('pressure')

    # Apply a preset using its name. Note this may not work as expected when presets have duplicate names.
    pressureLUT.ApplyPreset('Grayscale', True)

    # rescale color and/or opacity maps used to exactly fit the current data range
    case_t0Display.RescaleTransferFunctionToDataRange(False, True)

    # ======================ALTERNATIVE TO RESCALE TO DATA RANGE=====================
    # pressureLUT.RescaleTransferFunction(-2.0, 3.0)

    SaveAnimation('{}/flow.png'.format(pp), renderView1, ImageResolution=[1113, 552],
                  TransparentBackground=1,
                  FrameWindow=[0, 334])

    print("Pressure \t \t \t --> Done!")

    # should work, lol
    folderSpeed = 'speed File incomplete'
    sim = 's_-1'
    with open(os.path.join(d, 'speed.txt'), 'r') as speeds:
        for line in speeds:
            (mesh, name, speed) = line.split(';')
            if name in f:
                folderSpeed = speed.replace('\n', '')
                sim = name
                break

    fAX = os.listdir(px)
    fAY = os.listdir(py)
    fAP = os.listdir(pp)
    datac = open(s_dataconf, 'w+')
    i = 0
    while i < len(fAX):
        xPath = '{}/images_x/{}'.format(sim, fAX[i])
        yPath = '{}/images_y/{}'.format(sim, fAY[i])
        pPath = '{}/images_p/{}'.format(sim, fAP[i])
        datac.write('{}, {}, {}, {}\n'.format(xPath, yPath, pPath, speed))
        i += 1

    # current camera placement for renderView1
    renderView1.InteractionMode = '2D'
    renderView1.CameraPosition = [5.3, 1.35, 10000.0]
    renderView1.CameraFocalPoint = [5.3, 1.35, 0.0]
    renderView1.CameraParallelScale = 5.469232121605372

print("--- %s seconds ---" % (time.time() - t_start))
with open('speeds.txt','w') as file:
    file.write("--- %s seconds ---" % (time.time() - t_start))

