map_to_regions#

Maps pore values from a network onto the image from which it was extracted

import matplotlib.pyplot as plt
import numpy as np
import openpnm as op

import porespy as ps

ws = op.Workspace()
ws.settings["loglevel"] = 50
np.random.seed(10)
ps.visualization.set_mpl_style()
[00:39:22] ERROR    PARDISO solver not installed, run `pip install pypardiso`. Otherwise,          _workspace.py:56
                    simulations will be slow. Apple M chips not supported.                                         

Create image and extract network#

im = ps.generators.blobs(shape=[400, 400], porosity=0.6)
ps.imshow(im)
snow_output = ps.networks.snow2(im, voxel_size=1)
pn = op.io.network_from_porespy(snow_output.network)
../../../_images/ea9bf3598888801573e212f05e845be0c2be608ec6577451b82af97dd377937a.png

Plot the pore network#

fig, ax = plt.subplots()
op.visualization.plot_connections(pn, c="w", linewidth=2, ax=ax)
op.visualization.plot_coordinates(pn, c="w", s=100, ax=ax)
plt.imshow(snow_output.regions.T, origin="lower")
plt.axis("off");
../../../_images/296ae29bc442f96f2eb0f78d09a29c80384c25b9a10219f64a7553f3ad0355f3.png

Now assign some values to the network:

pn["pore.values"] = np.random.rand(pn.Np)

And now assign these values to the image regions:

reg = ps.networks.map_to_regions(regions=snow_output.regions.T, values=pn["pore.values"])
plt.imshow(reg, origin="lower");
../../../_images/04f9cde890599f79b031a3f531605567ad9d2ea3fa1b083e774e235524a3d504.png