Updated for new visualisation of PML region and source/receiver positions.

这个提交包含在:
Craig Warren
2016-03-22 18:21:13 +00:00
父节点 e6015fd0d1
当前提交 f9c6ca4c9f

查看文件

@@ -25,9 +25,6 @@ paraview.simple._DisableFirstRenderCameraReset()
# Get whatever source is loaded (should be model) # Get whatever source is loaded (should be model)
model = GetActiveSource() model = GetActiveSource()
# Get display properties
dp = GetDisplayProperties(model)
# Get active view # Get active view
renderview = GetActiveView() renderview = GetActiveView()
@@ -37,25 +34,24 @@ Show(model, renderview)
# Reset view to fit data # Reset view to fit data
renderview.ResetCamera() renderview.ResetCamera()
# Lists to hold material and sources/receiver identifiers written in VTK file in tags <gprMax3D> <Material> and <gprMax3D> <Sources_Receivers> # Lists to hold material and sources/receiver identifiers written in VTK file in tags <gprMax3D> <Material> and <gprMax3D> <Sources/Receivers>
materials = [] materials = []
srcsrxs = [] srcs_rxs_pml = []
with open(model.FileName[0], 'r') as f: with open(model.FileName[0], 'r') as f:
for line in f: for line in f:
if line.startswith('<Material'): if line.startswith('<Material'):
line.rstrip('\n') line.rstrip('\n')
tmp = (int(ET.fromstring(line).text), ET.fromstring(line).attrib.get('name')) tmp = (int(ET.fromstring(line).text), ET.fromstring(line).attrib.get('name'))
materials.append(tmp) materials.append(tmp)
elif line.startswith('<Sources'): elif line.startswith('<Sources') or line.startswith('<PML'):
line.rstrip('\n') line.rstrip('\n')
tmp = (int(ET.fromstring(line).text), ET.fromstring(line).attrib.get('name')) tmp = (int(ET.fromstring(line).text), ET.fromstring(line).attrib.get('name'))
srcsrxs.append(tmp) srcs_rxs_pml.append(tmp)
# Get ranges of data
matdatarange = model.CellData.GetArray(0).GetRange()
srcrxdatarange = model.CellData.GetArray(1).GetRange()
if materials: if materials:
# Get range of data
matdatarange = model.CellData.GetArray(0).GetRange()
# Create threshold for materials (name and numeric value) # Create threshold for materials (name and numeric value)
for x in range(0, int(matdatarange[1]) + 1): for x in range(0, int(matdatarange[1]) + 1):
for y in range(len(materials)): for y in range(len(materials)):
@@ -71,21 +67,28 @@ if materials:
thresholddisplay = Show(threshold, renderview) thresholddisplay = Show(threshold, renderview)
thresholddisplay.ColorArrayName = 'Material' thresholddisplay.ColorArrayName = 'Material'
if srcsrxs: if srcs_rxs_pml:
# Get ranges of data
srcs_rxs_pml_datarange = model.CellData.GetArray(1).GetRange()
# Create threshold for sources/receivers (name and numeric value) # Create threshold for sources/receivers (name and numeric value)
for x in range(0, int(srcrxdatarange[1]) + 1): for x in range(0, int(srcs_rxs_pml_datarange[1]) + 1):
for y in range(len(srcsrxs)): for y in range(len(srcs_rxs_pml)):
if srcsrxs[y][0] == x: if srcs_rxs_pml[y][0] == x:
threshold = Threshold(Input=model) threshold = Threshold(Input=model)
threshold.Scalars = 'Sources_Receivers' threshold.Scalars = 'Sources_Receivers_PML'
threshold.ThresholdRange = [srcsrxs[y][0], srcsrxs[y][0]] threshold.ThresholdRange = [srcs_rxs_pml[y][0], srcs_rxs_pml[y][0]]
RenameSource(srcsrxs[y][1], threshold) RenameSource(srcs_rxs_pml[y][1], threshold)
# Show data in view # Show data in view
thresholddisplay = Show(threshold, renderview) thresholddisplay = Show(threshold, renderview)
thresholddisplay.ColorArrayName = 'Sources_Receivers' thresholddisplay.ColorArrayName = 'Sources_Receivers_PML'
Render() if srcs_rxs_pml[y][0] == 1:
thresholddisplay.Opacity = 0.5
renderview.CameraParallelProjection = 1
RenderAllViews()
# Show color bar/color legend # Show color bar/color legend
#thresholdDisplay.SetScalarBarVisibility(renderview, False) #thresholdDisplay.SetScalarBarVisibility(renderview, False)