API Reference
This page contains the API reference for the poromics
package.
Main (poromics
)
The main module of the poromics
package provides the core functionality for calculating tortuosity and other transport properties.
tortuosity_fd(im, *, axis, rtol=1e-05, gpu=False)
Performs a tortuosity simulation on the given image along the specified axis.
The function removes non-percolating paths from the image before performing the tortuosity calculation.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
im
|
ndarray
|
The input image. |
required |
axis
|
int
|
The axis along which to compute tortuosity (0=x, 1=y, 2=z). |
required |
rtol
|
float
|
Relative tolerance for the solver. |
1e-05
|
gpu
|
bool
|
If True, use GPU for computation. |
False
|
Returns:
Name | Type | Description |
---|---|---|
result |
Result
|
An object containing the boolean image, axis, tortuosity, and concentration. |
Raises:
Type | Description |
---|---|
RuntimeError
|
If no percolating paths are found along the specified axis. |
Source code in src/poromics/_metrics.py
Julia helpers (poromics.julia_helpers
)
The poromics.julia_helpers
module provides helper functions for interacting with Julia and the Tortuosity.jl
package. These functions are used internally by the main module to perform calculations. Feel free to explore them if you're interested in the implementation details.
ensure_julia_deps_ready(quiet=False, retry=True)
Ensures Julia and Tortuosity.jl are installed.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
quiet
|
bool
|
If True, suppresses output during installation. Default is False. |
False
|
retry
|
bool
|
If True, retries the installation if it fails. Default is True. |
True
|
Raises:
Type | Description |
---|---|
ImportError
|
If Julia or Tortuosity.jl cannot be installed. |
Source code in src/poromics/julia_helpers.py
import_backend(Main=None)
Imports Tortuosity.jl package from Julia.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
Main
|
ModuleValue
|
Julia Main module. Default is None. If None, the Main module will be initialized. |
None
|
Returns:
Name | Type | Description |
---|---|---|
backend |
ModuleValue
|
Handle to the Tortuosity.jl package. |
Raises:
Type | Description |
---|---|
ImportError
|
If Julia is not installed or the package is not found. |
Source code in src/poromics/julia_helpers.py
import_package(package_name, Main, error=False)
Imports a package in Julia and returns the module.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
package_name
|
str
|
Name of the Julia package to import. |
required |
Main
|
ModuleValue
|
Julia Main module. |
required |
error
|
bool
|
If True, raises an error if the package is not found. Default is False. |
False
|
Returns:
Name | Type | Description |
---|---|---|
package |
ModuleValue
|
Handle to the imported package. |
Raises:
Type | Description |
---|---|
ImportError
|
If the package is not found and error is True. |
Source code in src/poromics/julia_helpers.py
init_julia(quiet=False)
Initializes Julia and returns the Main module.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
quiet
|
bool
|
If True, suppresses the output of Julia initialization. Default is False. |
False
|
Returns:
Name | Type | Description |
---|---|---|
Main |
ModuleValue
|
The Julia Main module. |
Raises:
Type | Description |
---|---|
ImportError
|
If Julia is not installed. |
Source code in src/poromics/julia_helpers.py
install_backend(quiet=False)
Installs Julia dependencies for Poromics.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
quiet
|
bool
|
If True, suppresses output during installation. Default is False. |
False
|
Raises:
Type | Description |
---|---|
ImportError
|
If Julia is not installed. |
Source code in src/poromics/julia_helpers.py
install_julia(quiet=False)
Installs Julia using juliapkg.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
quiet
|
bool
|
If True, suppresses output during installation. Default is False. |
False
|
Source code in src/poromics/julia_helpers.py
is_backend_installed(Main=None, error=False)
Checks if Tortuosity.jl is installed.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
Main
|
ModuleValue
|
Julia Main module. Default is None. If None, it will be initialized. |
None
|
error
|
bool
|
If True, raises an error if backend is not found. Default is False. |
False
|
Returns:
Name | Type | Description |
---|---|---|
flag |
bool
|
True if the package is installed, False otherwise. |
Raises:
Type | Description |
---|---|
ImportError
|
If Julia is not installed or backend is not found and error is True. |
Source code in src/poromics/julia_helpers.py
is_julia_installed(error=False)
Checks that Julia is installed.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
error
|
bool
|
If True, raises an error if Julia is not found. Default is False. |
False
|
Returns:
Name | Type | Description |
---|---|---|
flag |
bool
|
True if Julia is installed, False otherwise. |
Raises:
Type | Description |
---|---|
ImportError
|
If Julia is not installed and error is True. |
Source code in src/poromics/julia_helpers.py
remove_julia_env()
Removes the active Julia environment directory.
When Julia or its dependencies are corrupted, this is a possible fix.