Point incorrectly considered outside domain
Opened this issue · 2 comments
Describe the bug
Hello, I just encountered a bug in mikeio-1.7.1 when trying to extract data in specific points. All the points work fine except one of them, for which data.sel() raises OutsideDomainError. I checked on a plot, and this point is in the middle of the domain, not especially close to a boundary or anything.
I tried to uninstall and reinstall mikeio, without any change.
To Reproduce
Below is an example with two points : for the first one the extraction is successful, the second one raises OutsideDomaineError. However, mesh.contains(pt) returns True.
pts = [(439166.047, 6921703.975), (439297.166, 6921728.645)]
output_file= "SW.dfsu"
data = mikeio.read(output_file, items=['Sign. Wave Height', 'Mean Wave Direction', 'Peak Wave Period', 'Surface elevation'])
mesh = mikeio.Mesh(output_file)
for pt in pts :
print(mesh.contains(pt))
data_pt = data.sel(x=pt[0], y=pt[1])
Link to SW data file : https://creocean.fromsmash.com/vZre2O85U0-ct
Expected behavior
I would have expected both points to be corrrectly extracted from data file.
Screenshots
Position of the two points tested above :
System information:
- Python version : '3.11.5 | packaged by Anaconda, Inc. | (main, Sep 11 2023, 13:26:23) [MSC v.1916 64 bit (AMD64)]'
- MIKE IO version: 1.7.1
Thank you very much,
Coline
Our current strategy to find the correct element (trying to be as fast as possible) is not correct in areas with such a mixed element sizes.
The failing point is not inside the any of the 10 closest elements and then wrongly categorized as outside the domain.
mikeio/mikeio/spatial/_FM_geometry.py
Line 688 in 08f52ac
You can tell from the comment, that I was a bit unsure on how to handle this, but this example indicates that 10 is not enough😳
Thanks @coline-mathias for reporting.
Attaching a smaller file of the AOI to make it easer to reproduce.
subset.zip