<jupyter_start><jupyter_text>`size_to_satn`Converts values of invasion size into a saturation map<jupyter_code>import numpy as np
import porespy as ps
import matplotlib.pyplot as plt
from edt import edt<jupyter_output><empty_output><jupyter_text>The arguments and default values for this function are:<jupyter_code>import inspect
inspect.signature(ps.filters.size_to_satn)<jupyter_output><empty_output><jupyter_text>Generate an image containing invasion sizes using the ``porosimetry`` function:<jupyter_code>np.random.seed(0)
im = ps.generators.blobs([200, 200], porosity=0.5)
inv = ps.filters.porosimetry(im)<jupyter_output><empty_output><jupyter_text>`size`The sizes are produced by ``porosimetry`` for instance:<jupyter_code>satn = ps.filters.size_to_satn(size=inv)
fig, ax = plt.subplots(1, 2, figsize=[12, 6])
ax[0].imshow(inv/im, origin='lower', interpolation='none')
ax[0].set_title('Invasion map by size')
ax[0].axis(False)
ax[1].imshow(satn/im, origin='lower', interpolation='none')
ax[1].set_title('Invasion map by saturation')
ax[1].axis(False);<jupyter_output><empty_output><jupyter_text>The saturation map makes it very easy to obtain a desired fluid configuration just by applying a threhold:<jupyter_code>fig, ax = plt.subplots(1, 2, figsize=[12, 6])

s = 0.3
ax[0].imshow((satn < s)*(satn > 0)/im, origin='lower', interpolation='none')
ax[0].set_title(f'saturation = {s}')
ax[0].axis(False)

s = 0.6
ax[1].imshow((satn < s)*(satn > 0)/im, origin='lower', interpolation='none')
ax[1].set_title(f'saturation = {s}')
ax[1].axis(False);<jupyter_output><empty_output><jupyter_text>`im`The boolean image can be optionally passed into so that uninvaded regions can be differentiated from solid (if both are labelled 0).<jupyter_code>fig, ax = plt.subplots(1, 2, figsize=[12, 6])

satn = ps.filters.size_to_satn(size=inv)
ax[0].imshow(satn, origin='lower', interpolation='none')
ax[0].set_title('Invasion map by size')
ax[0].axis(False)

satn = ps.filters.size_to_satn(size=inv, im=im)
ax[1].imshow(satn, origin='lower', interpolation='none')
ax[1].set_title('Invasion map by saturation')
ax[1].axis(False);<jupyter_output><empty_output><jupyter_text>The different between the two images above is that when ``im`` is not supplied, then uninvaded regions are given a lable of 0, matching solid.  When ``im`` *is* supplied, the uninvaded regions are labelled -1.  `bins`The number of sequence values to when converting sizes. The default is 25.<jupyter_code>fig, ax = plt.subplots(1, 2, figsize=[12, 6])

bins = 5
seq = ps.filters.size_to_satn(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_satn(size=inv, bins=bins)
ax[1].imshow(seq, origin='lower', interpolation='none')
ax[1].set_title(f'bins = {bins}')
ax[1].axis(False);<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.1545138888888889, 'fraction_numerical': 0.02326388888888889, 'mean_word_length': 7.625748502994012, 'pattern_counts': {'":': 0, '<': 31, '<?xml version=': 0, '>': 31, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '7', 'dir': 'jupyter-structured-clean-dedup', 'id': '468076', 'license': 'MIT', 'n_tokens_mistral': 1117, 'n_tokens_neox': 1049, 'n_words': 242, 'path': 'examples/filters/reference/size_to_satn.ipynb', 'repo_name': 'xu-kai-xu/porespy', 'size': '2880'}