Skip to content

Commit

Permalink
Merge pull request #696 from MiraGeoscience/GEOPY-1484
Browse files Browse the repository at this point in the history
GEOPY-1484: Replace geoapps-edge detection code for curve-apps.edge_detection
  • Loading branch information
domfournier authored Jun 3, 2024
2 parents 3299642 + 9dab8da commit 7a51e16
Show file tree
Hide file tree
Showing 7 changed files with 90 additions and 88 deletions.
6 changes: 3 additions & 3 deletions environments/py-3.10-linux-64-dev.conda.lock.yml
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ dependencies:
- colorama=0.4.6=pyhd8ed1ab_0
- comm=0.2.2=pyhd8ed1ab_0
- contourpy=1.2.1=py310hd41b1e2_0
- coverage=7.5.2=py310hc51659f_0
- coverage=7.5.3=py310hc51659f_0
- cycler=0.12.1=pyhd8ed1ab_0
- cytoolz=0.12.3=py310h2372a71_0
- dash=2.12.1=pyhd8ed1ab_0
Expand Down Expand Up @@ -288,7 +288,7 @@ dependencies:
- pycparser=2.22=pyhd8ed1ab_0
- pydantic=2.5.3=pyhd8ed1ab_0
- pydantic-core=2.14.6=py310hcb5633a_1
- pydata-sphinx-theme=0.15.2=pyhd8ed1ab_0
- pydata-sphinx-theme=0.15.3=pyhd8ed1ab_0
- pydiso=0.0.3=py310h1dd1467_4
- pygments=2.18.0=pyhd8ed1ab_0
- pylint=3.2.2=pyhd8ed1ab_0
Expand Down Expand Up @@ -318,7 +318,7 @@ dependencies:
- readline=8.2=h8228510_1
- readthedocs-sphinx-ext=2.2.5=pyhd8ed1ab_0
- referencing=0.35.1=pyhd8ed1ab_0
- requests=2.32.2=pyhd8ed1ab_0
- requests=2.32.3=pyhd8ed1ab_0
- retrying=1.3.3=py_2
- rpds-py=0.18.1=py310he421c4c_0
- scikit-image=0.20.0=py310h9b08913_1
Expand Down
2 changes: 1 addition & 1 deletion environments/py-3.10-linux-64.conda.lock.yml
Original file line number Diff line number Diff line change
Expand Up @@ -285,7 +285,7 @@ dependencies:
- re2=2023.09.01=h7f4b329_1
- readline=8.2=h8228510_1
- referencing=0.35.1=pyhd8ed1ab_0
- requests=2.32.2=pyhd8ed1ab_0
- requests=2.32.3=pyhd8ed1ab_0
- retrying=1.3.3=py_2
- rpds-py=0.18.1=py310he421c4c_0
- scikit-image=0.20.0=py310h9b08913_1
Expand Down
6 changes: 3 additions & 3 deletions environments/py-3.10-win-64-dev.conda.lock.yml
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ dependencies:
- colorama=0.4.6=pyhd8ed1ab_0
- comm=0.2.2=pyhd8ed1ab_0
- contourpy=1.2.1=py310h232114e_0
- coverage=7.5.2=py310ha8f682b_0
- coverage=7.5.3=py310ha8f682b_0
- cycler=0.12.1=pyhd8ed1ab_0
- cytoolz=0.12.3=py310h8d17308_0
- dash=2.12.1=pyhd8ed1ab_0
Expand Down Expand Up @@ -252,7 +252,7 @@ dependencies:
- pycparser=2.22=pyhd8ed1ab_0
- pydantic=2.5.3=pyhd8ed1ab_0
- pydantic-core=2.14.6=py310h87d50f1_1
- pydata-sphinx-theme=0.15.2=pyhd8ed1ab_0
- pydata-sphinx-theme=0.15.3=pyhd8ed1ab_0
- pydiso=0.0.3=py310h847dae0_4
- pygments=2.18.0=pyhd8ed1ab_0
- pylint=3.2.2=pyhd8ed1ab_0
Expand Down Expand Up @@ -283,7 +283,7 @@ dependencies:
- re2=2023.09.01=hd3b24a8_1
- readthedocs-sphinx-ext=2.2.5=pyhd8ed1ab_0
- referencing=0.35.1=pyhd8ed1ab_0
- requests=2.32.2=pyhd8ed1ab_0
- requests=2.32.3=pyhd8ed1ab_0
- retrying=1.3.3=py_2
- rpds-py=0.18.1=py310hc226416_0
- scikit-image=0.20.0=py310h1c4a608_1
Expand Down
2 changes: 1 addition & 1 deletion environments/py-3.10-win-64.conda.lock.yml
Original file line number Diff line number Diff line change
Expand Up @@ -250,7 +250,7 @@ dependencies:
- rav1e=0.6.6=h975169c_2
- re2=2023.09.01=hd3b24a8_1
- referencing=0.35.1=pyhd8ed1ab_0
- requests=2.32.2=pyhd8ed1ab_0
- requests=2.32.3=pyhd8ed1ab_0
- retrying=1.3.3=py_2
- rpds-py=0.18.1=py310hc226416_0
- scikit-image=0.20.0=py310h1c4a608_1
Expand Down
3 changes: 2 additions & 1 deletion geoapps/base/application.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,11 @@
dict_mapper,
entity2uuid,
fetch_active_workspace,
list2str,
str2uuid,
)
from geoh5py.ui_json import InputFile
from geoh5py.ui_json.utils import list2str, monitored_directory_copy
from geoh5py.ui_json.utils import monitored_directory_copy
from geoh5py.workspace import Workspace
from traitlets import TraitError

Expand Down
55 changes: 27 additions & 28 deletions geoapps/edge_detection/application.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@
from time import time
from uuid import UUID

from curve_apps.edge_detection.driver import EdgeDetectionDriver
from curve_apps.edge_detection.params import Parameters
from curve_apps.edges.driver import EdgesDriver
from curve_apps.edges.params import EdgeParameters
from geoh5py.objects import Grid2D, ObjectBase
from geoh5py.shared.utils import fetch_active_workspace
from geoh5py.ui_json import InputFile
Expand Down Expand Up @@ -76,7 +76,7 @@ class EdgeDetectionApp(PlotSelection2D):
"""

_object_types = (Grid2D,)
_param_class = Parameters
_param_class = EdgeParameters

def __init__(self, ui_json=None, plot_result=True, geoh5: str | None = None):

Expand Down Expand Up @@ -166,7 +166,7 @@ def params(self):

@params.setter
def params(self, val):
if not isinstance(val, Parameters):
if not isinstance(val, EdgeParameters):
raise TypeError("Input parameters must be of type Parameters.")
self._params = val

Expand Down Expand Up @@ -241,7 +241,8 @@ def window_size(self):
def is_computational(self, attr):
"""True if app attribute is required for the driver (belongs in params)."""
out = isinstance(getattr(self, attr), Widget)
fields = list(self._param_class.model_construct().input_file.data)
ifile = InputFile.read_ui_json(EdgeParameters.default_ui_json, validate=False)
fields = list(ifile.data)
return out & (attr.lstrip("_") in fields)

def trigger_click(self, _):
Expand All @@ -263,11 +264,11 @@ def trigger_click(self, _):
if self.live_link.value:
param_dict["monitoring_directory"] = self.monitoring_directory

new_params = Parameters.build(param_dict)
new_params = EdgeParameters.build(param_dict)
new_params.input_file.write_ui_json(
name=temp_geoh5.replace(".geoh5", ".ui.json")
)
driver = EdgeDetectionDriver(new_params)
driver = EdgesDriver(new_params)
driver.run()

if self.live_link.value:
Expand All @@ -284,24 +285,22 @@ def compute_trigger(self, _):
if param_dict.get("objects", None) is None:
return

param_dict["geoh5"] = self.workspace
new_params = Parameters.build(param_dict)
self.refresh.value = False
canny_grid = EdgeDetectionDriver.get_canny_edges(
new_params.source.objects,
new_params.source.data,
new_params.detection,
)
(
vertices,
cells,
) = EdgeDetectionDriver.get_edges(
new_params.source.objects,
canny_grid,
new_params.detection,
)
segments = [vertices[c, :2] for c in cells]
self.collections = [
collections.LineCollection(segments, colors="k", linewidths=2)
]
self.refresh.value = True
with fetch_active_workspace(self.workspace, mode="r+") as ws:
param_dict["geoh5"] = ws
new_params = EdgeParameters.build(param_dict)
self.refresh.value = False
canny_grid = EdgesDriver.get_canny_edges(
new_params.source.objects,
new_params.source.data,
new_params.detection,
)
vertices, cells = EdgesDriver.get_edges(
new_params.source.objects,
canny_grid,
new_params.detection,
)
segments = [vertices[c, :2] for c in cells]
self.collections = [
collections.LineCollection(segments, colors="k", linewidths=2)
]
self.refresh.value = True
Loading

0 comments on commit 7a51e16

Please sign in to comment.