AttributeError

13 views
Skip to first unread message

Michael Wenz

unread,
Jan 19, 2023, 4:06:14 AM1/19/23
to SimPEG
its not liking this line when I run it

ind_polygon = model_builder.get_indices_polygon(mesh, xyz_pts)

Can anyone help?

thanks,

Michael

```
mesh = make_example_mesh()

background_value = 100.0
dyke_value = 40.0
sphere_value = 70.0

# Define surface topography
[xx, yy] = np.meshgrid(mesh.nodes_x, mesh.nodes_y)
zz = -3 * np.exp((xx ** 2 + yy ** 2) / 75 ** 2) + 40.0
topo = np.c_[mkvc(xx), mkvc(yy), mkvc(zz)]

# Set active cells and define unit values
air_value = 0.0
ind_active = surface2ind_topo(mesh, topo, "N")
model_map = maps.InjectActiveCells(mesh, ind_active, air_value)

# Define model for cells under the surface topography
model = background_value * np.ones(ind_active.sum())

# Add a sphere
ind_sphere = model_builder.getIndicesSphere(np.r_[-25.0, 0.0, -15.0], 20.0, mesh.gridCC)
ind_sphere = ind_sphere[ind_active]  # So it's same size and order as model
model[ind_sphere] = sphere_value

# Add dyke defined by a set of points
xp = np.kron(np.ones((2)), [-10.0, 10.0, 45.0, 25.0])
yp = np.kron([-1000.0, 1000.0], np.ones((4)))
zp = np.kron(np.ones((2)), [-120.0, -120.0, 35.0, 35.0])
xyz_pts = np.c_[mkvc(xp), mkvc(yp), mkvc(zp)]
ind_polygon = model_builder.get_indices_polygon(mesh, xyz_pts)
ind_polygon = ind_polygon[ind_active]  # So same size and order as model
model[ind_polygon] = dyke_value

# Plot
fig = plt.figure(figsize=(5, 5))
ax = fig.add_subplot(111)
ind_slice = int(mesh.shape_cells[1] / 2)
mesh.plot_slice(model_map * model, normal="Y", ax=ax, ind=ind_slice, grid=True)
ax.set_title("Model slice at y = {} m".format(mesh.cell_centers_y[ind_slice]))
plt.show()
```

--------------------------------------------------------------------------- AttributeError Traceback (most recent call last) ~\AppData\Local\Temp\ipykernel_2248\2730624236.py in <module> 28 zp = np.kron(np.ones((2)), [-120.0, -120.0, 35.0, 35.0]) 29 xyz_pts = np.c_[mkvc(xp), mkvc(yp), mkvc(zp)] ---> 30 ind_polygon = model_builder.get_indices_polygon(mesh, xyz_pts) 31 ind_polygon = ind_polygon[ind_active] # So same size and order as model 32 model[ind_polygon] = dyke_value AttributeError: module 'SimPEG.utils.model_builder' has no attribute 'get_indices_polygon'


Reply all
Reply to author
Forward
0 new messages