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, ax=fig)
fig = op.topotools.plot_coordinates(pn, c='w', s=100, ax=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 0x2773b4eda30>