Skip to content

Commit a5ddef9

Browse files
committed
v2.7.2
1 parent 90c0fc4 commit a5ddef9

File tree

27 files changed

+834
-139
lines changed

27 files changed

+834
-139
lines changed

src/ltrace/ltrace/algorithms/microporosity/modelling.py

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,10 @@ class DataVar:
8686
color: tuple = (0, 0, 0)
8787

8888

89+
class ModelDataTypeError(Exception):
90+
pass
91+
92+
8993
class SampleModel:
9094
def __init__(self, pcrRange=(0.0, 1.0)):
9195
self.variables: typing.Dict[str, DataVar] = {}
@@ -95,16 +99,19 @@ def __init__(self, pcrRange=(0.0, 1.0)):
9599
self.limits = None
96100

97101
def addData(self, image: np.ndarray, mask: np.ndarray, label: int = 0, color: tuple = (0, 0, 0)):
102+
if not np.issubdtype(image.dtype, np.integer):
103+
raise ValueError("Input Image must be of integer type")
104+
98105
self.image = image
99106
self.addSubGroup("Data", mask, label, color, markers=[0.0001, 0.99])
100107
self.limits = [int(np.round(v)) for v in self.variables["Data"].threshold]
101108

102109
def addSubGroup(self, name: str, mask: np.ndarray, label: int, color: tuple, markers: typing.List[float] = None):
103110
if self.image is None:
104-
raise ValueError("Image is missing")
111+
raise ModelDataTypeError("Image is missing")
105112

106113
if np.any(mask.shape != self.image.shape):
107-
raise ValueError("Mask and image must have the same shape")
114+
raise ModelDataTypeError("Mask and image must have the same shape")
108115

109116
counts = fast1DBinCountUInt64(self.image[mask])
110117
counts[0] = 0 # exclude background 0

src/ltrace/ltrace/pore_networks/functions_extract.py

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -346,14 +346,17 @@ def general_pn_extract(
346346
# Convert from adimensional voxel size to node scale
347347
# TODO: Deal with anisotropic data PL-1370
348348
scale = inputNode.GetSpacing()[::-1]
349-
pn_properties = _porespy_extract(
350-
input_multiphase,
351-
input_watershed,
352-
scale,
353-
porosity_map=porosity_map,
354-
watershed_blur=watershed_blur,
355-
force_cpu=force_cpu,
356-
)
349+
try:
350+
pn_properties = _porespy_extract(
351+
input_multiphase,
352+
input_watershed,
353+
scale,
354+
porosity_map=porosity_map,
355+
watershed_blur=watershed_blur,
356+
force_cpu=force_cpu,
357+
)
358+
except TypeError:
359+
raise RuntimeError("Empty network extracted from porespy.")
357360
if pn_properties is False:
358361
return False
359362
elif method == "PNExtract":

src/ltrace/ltrace/pore_networks/pnflow_parameter_defs.py

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -204,13 +204,21 @@
204204
"default_value": False,
205205
},
206206
"max_subprocesses": {
207-
"display_name": "Max subprocesses",
207+
"display_name": "Max subprocesses (Local)",
208208
"layout": "options",
209209
"dtype": "integerspinbox",
210210
"minimum_value": 1,
211211
"maximum_value": 256,
212212
"default_value": 8,
213213
},
214+
"n_jobs": {
215+
"display_name": "Number of jobs (Remote)",
216+
"layout": "options",
217+
"dtype": "integerspinbox",
218+
"minimum_value": 1,
219+
"maximum_value": 8,
220+
"default_value": 2,
221+
},
214222
"timeout_enabled": {
215223
"display_name": "Enable timeout",
216224
"layout": "options",

src/ltrace/ltrace/pore_networks/subres_models.py

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -91,8 +91,8 @@ def get_capillary_radius_function(cls, params, pore_network, volume):
9191
pore_network["throat.phases"][:, 1],
9292
)
9393
resolved_radii = radii[resolved_throats]
94-
smallest_raddi = resolved_radii.min()
95-
highest_pc = estimate_pressure(smallest_raddi)
94+
smallest_radii = resolved_radii.min()
95+
highest_pc = estimate_pressure(smallest_radii)
9696
highest_pc_index = Pc >= highest_pc
9797
if highest_pc_index.sum() == 0:
9898
return lambda _: highest_pc
@@ -154,8 +154,8 @@ def get_capillary_radius_function(cls, params, pore_network, volume):
154154
pore_network["throat.phases"][:, 1],
155155
)
156156
resolved_radii = radii[resolved_throats]
157-
smallest_raddi = resolved_radii.min()
158-
highest_pc = estimate_pressure(smallest_raddi)
157+
smallest_radii = resolved_radii.min()
158+
highest_pc = estimate_pressure(smallest_radii)
159159
highest_pc_index = Pc >= highest_pc
160160
if highest_pc_index.sum() == 0:
161161
return lambda _: highest_pc
@@ -197,7 +197,7 @@ def _get_cumulative_dist_points(cls, points):
197197

198198

199199
class PressureCurveLogic:
200-
required_params = ("throat radii", "capillary pressure", "dsn", "smallest_raddi_multiplier")
200+
required_params = ("throat radii", "capillary pressure", "dsn", "smallest_radii_multiplier")
201201

202202
def __init__(self):
203203
pass
@@ -216,15 +216,15 @@ def get_capillary_radius_function(cls, params, pore_network, volume):
216216
if resolved_radii.size == 0:
217217
return lambda _: None
218218

219-
smallest_resolved_raddi = resolved_radii.min()
219+
smallest_resolved_radii = resolved_radii.min()
220220

221221
if params["throat radii"] is not None:
222222
subresolution_radii_bool_index = np.logical_and(
223223
params["throat radii"] > 1e-8,
224-
params["throat radii"] <= params["smallest_raddi_multiplier"] * smallest_resolved_raddi,
224+
params["throat radii"] <= params["smallest_radii_multiplier"] * smallest_resolved_radii,
225225
)
226226
if subresolution_radii_bool_index.sum() == 0:
227-
return lambda _: smallest_resolved_raddi / 2
227+
return lambda _: smallest_resolved_radii / 2
228228
elif subresolution_radii_bool_index.sum() == 1:
229229
return lambda _: params["throat radii"][subresolution_radii_bool_index][0]
230230

0 commit comments

Comments
 (0)