size_to_seq#

Converts values of invasion size into sequence numbers.

import numpy as np
import porespy as ps
import matplotlib.pyplot as plt
from edt import edt
ps.visualization.set_mpl_style()
/opt/hostedtoolcache/Python/3.8.16/x64/lib/python3.8/site-packages/openpnm/algorithms/_invasion_percolation.py:358: NumbaDeprecationWarning: The 'nopython' keyword argument was not supplied to the 'numba.jit' decorator. The implicit default value for this argument is currently False, but it will be changed to True in Numba 0.59.0. See https://numba.readthedocs.io/en/stable/reference/deprecation.html#deprecation-of-object-mode-fall-back-behaviour-when-using-jit for details.
  def _find_trapped_pores(inv_seq, indices, indptr, outlets):  # pragma: no cover

The arguments and default values for this function are:

import inspect
inspect.signature(ps.filters.size_to_seq)
<Signature (size, im=None, bins=None, mode='drainage')>

Generate an image containing invasion sizes using the porosimetry function:

np.random.seed(0)
im = ps.generators.blobs([200, 200], porosity=0.5)
inv = ps.filters.porosimetry(im)

size#

The sizes are produced by porosimetry for instance:

seq = ps.filters.size_to_seq(size=inv)
fig, ax = plt.subplots(1, 2, figsize=[12, 6])
ax[0].imshow(inv, origin='lower', interpolation='none')
ax[0].set_title('Invasion map by size')
ax[0].axis(False)
ax[1].imshow(seq, origin='lower', interpolation='none')
ax[1].set_title('Invasion map by sequence')
ax[1].axis(False);
../../../_images/a971bfca3607a0dbc0ef8787d887f5a7d8903915bab0745a934476fd44826345.png

im#

The boolean image can be optionally passed into so that uninvaded regions can be differentiated from solid (if both are labelled 0).

seq = ps.filters.size_to_seq(size=inv, im=im)
fig, ax = plt.subplots(1, 2, figsize=[12, 6])
ax[0].imshow(inv, origin='lower', interpolation='none')
ax[0].set_title('Invasion map by size')
ax[0].axis(False)
ax[1].imshow(seq, origin='lower', interpolation='none')
ax[1].set_title('Invasion map by sequence')
ax[1].axis(False);
../../../_images/d12ea57c462b0eb4e50f2ab77640878d5eee2bee713a4a3c1cfa1d8386533edb.png

In the right image above, there can be seen several regions that are isolated by the void space. They are colored yellow indicating they are filled last. This is caused by the fact that these regions were uninvaded so were set to 0, which makes them the last regions invaded. This may or may not be desired.

bins#

The number of sequence values to when converting sizes. The default is 25.

fig, ax = plt.subplots(1, 2, figsize=[12, 6])

bins = 5
seq = ps.filters.size_to_seq(size=inv, bins=bins)
ax[0].imshow(seq, origin='lower', interpolation='none')
ax[0].set_title(f'bins = {bins}')
ax[0].axis(False)

bins = 25
seq = ps.filters.size_to_seq(size=inv, bins=bins)
ax[1].imshow(seq, origin='lower', interpolation='none')
ax[1].set_title(f'bins = {bins}')
ax[1].axis(False);
../../../_images/5bd659542883412f934b85ea12adf6ff9f16f61b2e938ac19553a266c957e718.png