map_to_regions maps

Import packages

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

ws = op.Workspace()
ws.settings['loglevel'] = 50

Create image and extract network

im = ps.generators.blobs(shape=[400, 400], porosity=0.6)
snow_output = ps.networks.snow2(im, boundary_width=10)

Plot the pore network:

pn, geo =
fig = plt.figure(figsize=[4, 4])
fig = op.topotools.plot_connections(pn, c='w', linewidth=2, fig=fig)
fig = op.topotools.plot_coordinates(pn, c='w', s=100, fig=fig)
plt.imshow(snow_output.regions.T, origin='lower')

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, values=pn['pore.values'])
<matplotlib.image.AxesImage at 0x29b8cd74640>