你已经派生过 gprMax
镜像自地址
https://gitee.com/sunhf/gprMax.git
已同步 2025-08-07 15:10:13 +08:00
Updated for new visualisation of PML region and source/receiver positions.
这个提交包含在:
@@ -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)
|
在新工单中引用
屏蔽一个用户