Skip to content

Commit 1671459

Browse files
committed
fix: add debug info and warning for bad calculations
1 parent 0605cdf commit 1671459

File tree

1 file changed

+32
-3
lines changed

1 file changed

+32
-3
lines changed

map2loop/thickness_calculator.py

Lines changed: 32 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -176,6 +176,16 @@ def compute(
176176
val = min(distance, thicknesses.at[idx, "ThicknessMean"])
177177
thicknesses.loc[idx, "ThicknessMean"] = val
178178

179+
# add check more than 75% of the unit thicknesses are -1
180+
units_with_no_thickness = len(thicknesses[thicknesses['ThicknessMedian'] == -1])
181+
182+
if units_with_no_thickness / len(thicknesses) >= 0.75:
183+
logger.warning(
184+
f"More than 75% of units ({units_with_no_thickness}/{len(thicknesses)}) have a calculated thickness of -1. "
185+
f"This may indicate that {self.thickness_calculator_label} is not suitable for this dataset."
186+
)
187+
188+
179189
return thicknesses
180190

181191

@@ -299,6 +309,7 @@ def compute(
299309
].copy()
300310

301311
_lines = []
312+
_dips = []
302313
for i in range(0, len(stratigraphic_order) - 1):
303314
if (
304315
stratigraphic_order[i] in basal_unit_list
@@ -346,6 +357,7 @@ def compute(
346357
# get the dip of the points that are within
347358
# 10% of the length of the shortest line
348359
_dip = numpy.deg2rad(dip[indices])
360+
_dips.append(_dip)
349361
# get the end points of the shortest line
350362
# calculate the true thickness t = L . sin dip
351363
thickness = line_length * numpy.sin(_dip)
@@ -374,9 +386,18 @@ def compute(
374386
f"Thickness Calculator InterpolatedStructure: Cannot calculate thickness between {stratigraphic_order[i]} and {stratigraphic_order[i + 1]}\n"
375387
)
376388

377-
print("lines", geopandas.GeoDataFrame(geometry = _lines))
378-
# self.lines = geopandas.GeoDataFrame(geometry= _lines, crs=basal_contacts.crs)
379-
# self.lines["DIP"] = dip
389+
self.lines = geopandas.GeoDataFrame(geometry=[line[0] for line in _lines], crs = basal_contacts.crs)
390+
self.lines['dip'] = _dips
391+
392+
# add check more than 75% of the unit thicknesses are -1
393+
units_with_no_thickness = len(thicknesses[thicknesses['ThicknessMedian'] == -1])
394+
395+
if units_with_no_thickness / len(thicknesses) >= 0.75:
396+
logger.warning(
397+
f"More than 75% of units ({units_with_no_thickness}/{len(thicknesses)}) have a calculated thickness of -1. "
398+
f"This may indicate that {self.thickness_calculator_label} is not suitable for this dataset."
399+
)
400+
380401
return thicknesses
381402

382403

@@ -655,4 +676,12 @@ def compute(
655676
output_units.loc[output_units["name"] == unit, "ThicknessMean"] = -1
656677
output_units.loc[output_units["name"] == unit, "ThicknessStdDev"] = -1
657678

679+
# check if more than 75% of the unit thicknesses are -1
680+
units_with_no_thickness = len(output_units[output_units['ThicknessMedian'] == -1])
681+
682+
if units_with_no_thickness / len(output_units) >= 0.75:
683+
logger.warning(
684+
f"More than 75% of units ({units_with_no_thickness}/{len(output_units)}) have a calculated thickness of -1. "
685+
f"This may indicate that {self.thickness_calculator_label} is not suitable for this dataset."
686+
)
658687
return output_units

0 commit comments

Comments
 (0)