Possible bug in `simplify_polygons`
mferrera opened this issue · comments
Matthew Ferrera commented
From an RMS script:
Traceback (most recent call last):
Python script, line 89
Python script, line 65, in main
Python script, line 34, in _get_polygons
File "xx/xtgeo/surface/regular_surface.py", line 2802, in get_boundary_polygons
return _regsurf_boundary.create_boundary(self, alpha_factor, convex, simplify)
File "xx/xtgeo/surface/_regsurf_boundary.py", line 22, in create_boundary
pol.simplify(tolerance=0.1)
File "xx/xyz/polygons.py", line 707, in simplify
return _polygons_oper.simplify_polygons(self, tolerance, preserve_topology)
File "xx/xtgeo/xyz/_polygons_oper.py", line 231, in simplify_polygons
idgroups = self.get_dataframe(copy=False).groupby(self.pname)
File "xx/13.1.2/linux-amd64-gcc_4_8-release/lib/python3.8/site-packages/pandas/core/frame.py";, line 6511, in groupby
return DataFrameGroupBy(
File "xx/13.1.2/linux-amd64-gcc_4_8-release/lib/python3.8/site-packages/pandas/core/groupby/groupby.py", line 525, in __init__
grouper, exclusions, obj = get_grouper(
File "xx/13.1.2/linux-amd64-gcc_4_8-release/lib/python3.8/site-packages/pandas/core/groupby/grouper.py", line 781, in get_grouper
raise KeyError(gpr)
KeyError: 'POLY_ID'
With calling context
surface = xtgeo.surface_from_roxar(
PRJ, STRUCTURAL_HORIZON_NAME, STRUCTURAL_CATEGORY_NAME
)
contact = xtgeo.surface_from_roxar(
PRJ, "GOC", CONTACTS_FOLDER_NAME, stype="clipboard"
)
tmpsurf = surface.copy()
usecontact = surface.copy()
usecontact.resample(contact)
# set surface undefined where below contact
tmpsurf.values = np.ma.masked_where(
usecontact.values <= tmpsurf.values, tmpsurf.values
)
tmpsurf.to_roxar(PRJ, f"_surface--{contact_name}", CLIPBOARD_FOLDER_NAME, stype="clipboard")
tmpsurf.unrotate()
poly = tmpsurf.get_boundary_polygons(alpha_factor=ALPHA_FACTOR)
Could relate to 749b73e, but maybe not. @jcrivenaes
Jan C. Rivenæs commented
Could you look at this, @tnatt ?
Therese Natterøy commented
This should fix the issue 🙂 #1163
I've done quite some testing, and it is much more robust now.
Matthew Ferrera commented
Closing as presumed fixed in #1163