<html>
<head>
<style><!--
.hmmessage P
{
margin:0px;
padding:0px
}
body.hmmessage
{
font-size: 12pt;
font-family:Calibri
}
--></style></head>
<body class='hmmessage'><div dir='ltr'>I have the following Python script to plot the radial porosity profile for a single slice extracted from a VTK file:<div><br></div><div><div><font face="Courier New, sans-serif" size="2">import paraview.simple as pv</font></div><div><font face="Courier New, sans-serif" size="2">import numpy as np</font></div><div><font face="Courier New, sans-serif" size="2">import matplotlib.pyplot as plt</font></div><div><font face="Courier New, sans-serif" size="2">from paraview import numpy_support as ns</font></div><div><font face="Courier New, sans-serif" size="2">import sys</font></div><div><font face="Courier New, sans-serif" size="2"><br></font></div><div><span style="font-family: 'Courier New', sans-serif; font-size: 10pt;">fileName = r'porosity.vtk'</span></div><div><font face="Courier New, sans-serif" size="2"><br></font></div><div><font face="Courier New, sans-serif" size="2"># Bulk velocity and sphere diameter</font></div><div><font face="Courier New, sans-serif" size="2">U0 = 0.0033</font></div><div><font face="Courier New, sans-serif" size="2">D0 = 0.003</font></div><div><font face="Courier New, sans-serif" size="2"><br></font></div><div><font face="Courier New, sans-serif" size="2"># Slice location in streamwise direction</font></div><div><font face="Courier New, sans-serif" size="2">x0 = 0.01</font></div><div><font face="Courier New, sans-serif" size="2"><br></font></div><div><font face="Courier New, sans-serif" size="2"># Translate in y and z direction to get the origin in the middle of the pipe</font></div><div><font face="Courier New, sans-serif" size="2">l0 = -0.00015-0.0214/2</font></div><div><font face="Courier New, sans-serif" size="2"><br></font></div><div><font face="Courier New, sans-serif" size="2"><br></font></div><div><font face="Courier New, sans-serif" size="2">U = []</font></div><div><font face="Courier New, sans-serif" size="2">R = []</font></div><div><font face="Courier New, sans-serif" size="2"><br></font></div><div><font face="Courier New, sans-serif" size="2"># Pipeline</font></div><div><font face="Courier New, sans-serif" size="2">reader = pv.OpenDataFile(fileName)</font></div><div><font face="Courier New, sans-serif" size="2">transform=pv.Transform(reader)</font></div><div><font face="Courier New, sans-serif" size="2">transform.Transform.Translate = [0,l0,l0]</font></div><div><font face="Courier New, sans-serif" size="2">slice = pv.Slice(transform,SliceType='Plane')</font></div><div><font face="Courier New, sans-serif" size="2">slice.SliceType.Origin = [x0,0,0]</font></div><div><font face="Courier New, sans-serif" size="2">slice.SliceType.Normal = [1,0,0]</font></div><div><font face="Courier New, sans-serif" size="2">calc = pv.Calculator(slice, ResultArrayName = 'radius', Function = 'sqrt(coordsY^2+coordsZ^2)')</font></div><div><font face="Courier New, sans-serif" size="2">contour = pv.Contour(calc,ContourBy = ['POINTS','radius'],Isosurfaces = [0])</font></div><div><font face="Courier New, sans-serif" size="2">int = pv.IntegrateVariables(contour)</font></div><div><font face="Courier New, sans-serif" size="2"><br></font></div><div><font face="Courier New, sans-serif" size="2"># Loop over radial distances</font></div><div><font face="Courier New, sans-serif" size="2">for r in np.linspace(0.00015,0.01065,200):</font></div><div><font face="Courier New, sans-serif" size="2"> contour.Isosurfaces = [r]</font></div><div><font face="Courier New, sans-serif" size="2"> intData = pv.servermanager.Fetch(int)</font></div><div><font face="Courier New, sans-serif" size="2"> L = ns.vtk_to_numpy(intData.GetCellData().GetArray('Length'))[0]</font></div><div><font face="Courier New, sans-serif" size="2"> U.append(ns.vtk_to_numpy(intData.GetPointData().GetArray('Porosity'))[0]/L)</font></div><div><font face="Courier New, sans-serif" size="2"> R.append(0.01065-r)</font></div><div><font face="Courier New, sans-serif" size="2"><br></font></div><div><font face="Courier New, sans-serif" size="2"># Plot the results</font></div><div><font face="Courier New, sans-serif" size="2">plt.plot(np.array(R)/D0,np.array(U), 'b-')</font></div><div><font face="Courier New, sans-serif" size="2">plt.xlabel('Distance from the wall in particle diameters')</font></div><div><font face="Courier New, sans-serif" size="2">plt.ylabel('Porosity')</font></div><div><font face="Courier New, sans-serif" size="2">plt.ylim(0,1)</font></div><div><font face="Courier New, sans-serif" size="2">plt.show()</font></div></div><div><font face="Courier New, sans-serif" size="2"><br></font></div><div><span style="font-size: 12pt;">How could I modify this Python script to average the radial porosity profiles also along the streamwise (axial) direction (x coordinate)?</span></div> </div></body>
</html>