Skip to content

Commit

Permalink
updating notebooks
Browse files Browse the repository at this point in the history
  • Loading branch information
jgostick committed Jun 21, 2024
1 parent e9894d2 commit 56e0480
Show file tree
Hide file tree
Showing 3 changed files with 652 additions and 169 deletions.
12 changes: 9 additions & 3 deletions examples/simulations/reference/tortuosity_gdd.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
"import numpy as np\n",
"import porespy as ps\n",
"from porespy import beta\n",
"\n",
"ps.visualization.set_mpl_style()"
]
},
Expand All @@ -29,7 +30,7 @@
{
"data": {
"text/plain": [
"<Signature (im, scale_factor=3, use_dask=True)>"
"<Signature (im, block_size=None, use_dask=True)>"
]
},
"execution_count": 2,
Expand All @@ -39,7 +40,7 @@
],
"source": [
"import inspect\n",
"inspect.signature(beta.tortuosity_gdd)"
"inspect.signature(beta.tortuosity_bt)"
]
},
{
Expand All @@ -49,6 +50,11 @@
"# im\n",
"Can be a 3D image:"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": []
}
],
"metadata": {
Expand All @@ -67,7 +73,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.10.12"
"version": "3.11.5"
}
},
"nbformat": 4,
Expand Down
790 changes: 632 additions & 158 deletions examples/simulations/tutorials/using_tortuosity_gdd.ipynb

Large diffs are not rendered by default.

19 changes: 11 additions & 8 deletions src/porespy/beta/_tortuosity_bt_funcs.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,18 @@
import openpnm as op
import pandas as pd
import dask
import edt
try:
from pyedt import edt
except:
from edt import edt


__all__ = [
'tortuosity_bt',
'get_block_sizes',
'df_to_tortuosity',
'rev_tortuosity',
'analyze_blocks',
]


Expand Down Expand Up @@ -81,7 +85,7 @@ def get_block_sizes(shape, block_size_range=[10, 100]):
Notes
-----
This is called by `rev_tortuosity` so it know what size blocks to use.
This is called by `rev_tortuosity` to determine what size blocks to use.
"""
Lmin, Lmax = block_size_range
a = np.ceil(min(shape)/Lmax).astype(int)
Expand Down Expand Up @@ -109,7 +113,7 @@ def rev_tortuosity(im, block_sizes=None, use_dask=True):
A `pandas` data frame with the properties for each block on a given row
"""
if block_sizes is None:
block_sizes = get_block_sizes(im.shape)
block_sizes = get_block_sizes(im.shape)
block_sizes = np.array(block_sizes, dtype=int)
tau = []
for s in block_sizes:
Expand Down Expand Up @@ -142,21 +146,19 @@ def block_size_to_divs(shape, block_size):
return divs


def analyze_blocks(im, block_size , use_dask=True):
def analyze_blocks(im, block_size, use_dask=True):
r'''
Computes structural and transport properties of each block
Parameters
----------
im : np.ndarray
The binary image to analyze with ``True`` indicating phase of interest
block_size : int
The size of the blocks to use. Only cubic blocks are supported so an integer
must be given, or an exception is raised. If the image is not evenly
divisible by the given `block_size` any extra voxels are removed from the
end of each axis before all processing occcurs.
use_dask : bool
A boolean determining the usage of `dask`.
Expand All @@ -166,9 +168,10 @@ def analyze_blocks(im, block_size , use_dask=True):
A `pandas` data frame with the properties for each block on a given row.
'''

if not block_size:
if block_size is None:
scale_factor = 3
dt = edt.edt(im)
dt = edt(im)
# TODO: Is the following supposed to be over 2 or over im.ndim?
x = min(dt.max() * scale_factor, min(np.array(im.shape)/2))
block_shape = np.ones(im.ndim) * x
else:
Expand Down

0 comments on commit 56e0480

Please sign in to comment.