<SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
 Extracting a pore network using PoreSpy and loading into OpenPNM
Step1:  Let's check out the porosity of the generated image!
Step2:  Let's visualize the image using porespy's 3D visualizer
<ASSISTANT_TASK:>
Python Code:
import warnings
import scipy as sp
import numpy as np
import porespy as ps
import openpnm as op
import matplotlib.pyplot as plt
ws = op.Workspace()
ws.settings["loglevel"] = 40
warnings.filterwarnings('ignore')
%matplotlib inline
np.random.seed(10)
#NBVAL_IGNORE_OUTPUT
im = ps.generators.overlapping_spheres(shape=[300, 300, 300], radius=10, porosity=0.5, iter_max=0)
plt.imshow(im[:, :, 50]);
Explanation: Extracting a pore network using PoreSpy and loading into OpenPNM
End of explanation
eps = ps.metrics.porosity(im)
print(f"Porosity: {eps*100:.1f}%")
Explanation: Let's check out the porosity of the generated image!
End of explanation
#NBVAL_IGNORE_OUTPUT
im_3d = ps.visualization.show_3D(im)
plt.imshow(im_3d, cmap=plt.cm.magma);
#NBVAL_IGNORE_OUTPUT
snow = ps.networks.snow(im=im, boundary_faces=['right'])
net = op.network.GenericNetwork()
net.update(snow)
print(net)
#NBVAL_IGNORE_OUTPUT
fig = op.topotools.plot_connections(network=net, alpha=0.8)
fig = op.topotools.plot_coordinates(network=net, fig=fig, color='r')
fig.set_size_inches(8, 8)
fig.tight_layout()
geo = op.geometry.Imported(net)
m = np.meshgrid(range(50, 250, 10), range(50, 295, 10))
m = np.vstack([-10*np.ones_like(m[1].flatten()), m[0].flatten(), m[1].flatten()]).T
op.topotools.find_surface_pores(network=net, markers=m, label='left')
op.topotools.clone_pores(network=net, pores=net.pores('left'), labels='left_boundary')
net['pore.coords'][net.pores('left_boundary')] *= [0, 1, 1]
#NBVAL_IGNORE_OUTPUT
Ps = net.pores('boundary')
net.set_label('right_boundary', pores=Ps)
Ts = net.find_neighbor_throats(pores=net.pores('right_boundary'))
net.set_label('right_boundary', throats=Ts)
fig = op.topotools.plot_connections(network=net,
                                    throats=net.throats(['left_boundary', 'right_boundary']))
fig.set_size_inches(8, 8)
proj = net.project
for geo in proj.geometries().values():
    proj.purge_object(geo)
Ps = net.pores('left_boundary')
Ts = net.find_neighbor_throats(pores=Ps)
geo_bnd = op.geometry.StickAndBall(network=net, pores=Ps, throats=Ts)
#NBVAL_IGNORE_OUTPUT
geo_bnd.show_hist('pore.diameter')
Explanation: Let's visualize the image using porespy's 3D visualizer: (this might take several seconds)
End of explanation
<END_TASK>