Skip to content

[BUG] Notebook examples - AttributeError: 'StratigraphicColumn' object has no attribute 'keys' #261

Description

@gpirot

Describe your issue

Working with LoopStructural v1.6.16, I get the AttributeError: 'StratigraphicColumn' object has no attribute 'keys' when running the provided example notebooks (1b. Implicit surface modelling, 1c. Visualising models, 1d. Using Stratigraphic Columns, 1j. Exporting models)

Minimal reproducing code example

https://loop3d.org/LoopStructural/_auto_examples/1_basic/plot_2_surface_modelling.htmlhttps://loop3d.org/LoopStructural/_auto_examples/1_basic/plot_3_model_visualisation.htmlhttps://loop3d.org/LoopStructural/_auto_examples/1_basic/plot_4_using_stratigraphic_column.htmlhttps://loop3d.org/LoopStructural/_auto_examples/1_basic/plot_7_exporting.html

Error message

ERROR FOR 1b.
---------------------------------------------------------------------------
AttributeError Traceback (most recent call last)
Cell In[8], line 2
1 viewer = Loop3DView(model)
----> 2 viewer.plot_block_model(cmap="tab20")
3 viewer.display()
File ~\Anaconda3\envs\loop2025\lib\site-packages\loopstructuralvisualisation\_3d_viewer.py:293, in Loop3DView.plot_block_model(self, cmap, model, pyvista_kwargs, scalar_bar, slicer, threshold, name)
291 name = 'block_model'
292 name = self.increment_name(name) # , 'block_model')
--> 293 block, codes = model.get_block_model()
294 block = block.vtk()
295 block.set_active_scalars('stratigraphy')
File ~\Anaconda3\envs\loop2025\lib\site-packages\LoopStructural\modelling\core\geological_model.py:1755, in GeologicalModel.get_block_model(self, name)
1752 def get_block_model(self, name='block model'):
1753 grid = self.bounding_box.structured_grid(name=name)
-> 1755 grid.cell_properties['stratigraphy'] = self.evaluate_model(
1756 self.rescale(self.bounding_box.cell_centres())
1757 )
1758 return grid, self.stratigraphic_ids()
File ~\Anaconda3\envs\loop2025\lib\site-packages\LoopStructural\modelling\core\geological_model.py:1497, in GeologicalModel.evaluate_model(self, xyz, scale)
1495 logger.warning("No stratigraphic column defined")
1496 return strat_id
-> 1497 forgroupinreversed(self.stratigraphic_column.keys()):
1498 if group == "faults":
1499 continue
AttributeError: 'StratigraphicColumn' object has no attribute 'keys'
ERROR FOR 1c.
---------------------------------------------------------------------------
AttributeError Traceback (most recent call last)
Cell In[3], line 10
6 viewer.plot_surface(strati, value=vals, cmap="prism", paint_with=strati)
9 viewer.plot_scalar_field(strati, cmap="prism")
---> 10 print(viewer._build_stratigraphic_cmap(model))
11 viewer.plot_block_model()
12 # Add the data addgrad/addvalue arguments are optional
File ~\Anaconda3\envs\loop2025\lib\site-packages\loopstructuralvisualisation\_3d_viewer.py:371, in Loop3DView._build_stratigraphic_cmap(self, model)
369 boundaries = []
370 data = []
--> 371 forginmodel.stratigraphic_column.keys():
372 if g == "faults":
373 continue
AttributeError: 'StratigraphicColumn' object has no attribute 'keys'
ERROR FOR 1d.
---------------------------------------------------------------------------
AttributeError Traceback (most recent call last)
Cell In[3], line 4
1 model.set_stratigraphic_column(stratigraphic_column)
3 viewer = Loop3DView(model)
----> 4 viewer.plot_block_model()
5 viewer.display()
File ~\Anaconda3\envs\loop2025\lib\site-packages\loopstructuralvisualisation\_3d_viewer.py:293, in Loop3DView.plot_block_model(self, cmap, model, pyvista_kwargs, scalar_bar, slicer, threshold, name)
291 name = 'block_model'
292 name = self.increment_name(name) # , 'block_model')
--> 293 block, codes = model.get_block_model()
294 block = block.vtk()
295 block.set_active_scalars('stratigraphy')
File ~\Anaconda3\envs\loop2025\lib\site-packages\LoopStructural\modelling\core\geological_model.py:1755, in GeologicalModel.get_block_model(self, name)
1752 def get_block_model(self, name='block model'):
1753 grid = self.bounding_box.structured_grid(name=name)
-> 1755 grid.cell_properties['stratigraphy'] = self.evaluate_model(
1756 self.rescale(self.bounding_box.cell_centres())
1757 )
1758 return grid, self.stratigraphic_ids()
File ~\Anaconda3\envs\loop2025\lib\site-packages\LoopStructural\modelling\core\geological_model.py:1497, in GeologicalModel.evaluate_model(self, xyz, scale)
1495 logger.warning("No stratigraphic column defined")
1496 return strat_id
-> 1497 forgroupinreversed(self.stratigraphic_column.keys()):
1498 if group == "faults":
1499 continue
AttributeError: 'StratigraphicColumn' object has no attribute 'keys'
ERROR FOR 1j.
---------------------------------------------------------------------------
AttributeError Traceback (most recent call last)
Cell In[7], line 1
----> 1 model.save('model.geoh5')
File ~\Anaconda3\envs\loop2025\lib\site-packages\LoopStructural\modelling\core\geological_model.py:1788, in GeologicalModel.save(self, filename, block_model, stratigraphic_surfaces, fault_surfaces, stratigraphic_data, fault_data)
1786 s.save(f'{parent}/{name}_{s.name}{extension}')
1787 if block_model:
-> 1788 grid, ids = self.get_block_model()
1789 if extension == ".geoh5" or extension == '.omf':
1790 grid.save(filename)
File ~\Anaconda3\envs\loop2025\lib\site-packages\LoopStructural\modelling\core\geological_model.py:1755, in GeologicalModel.get_block_model(self, name)
1752 def get_block_model(self, name='block model'):
1753 grid = self.bounding_box.structured_grid(name=name)
-> 1755 grid.cell_properties['stratigraphy'] = self.evaluate_model(
1756 self.rescale(self.bounding_box.cell_centres())
1757 )
1758 return grid, self.stratigraphic_ids()
File ~\Anaconda3\envs\loop2025\lib\site-packages\LoopStructural\modelling\core\geological_model.py:1497, in GeologicalModel.evaluate_model(self, xyz, scale)
1495 logger.warning("No stratigraphic column defined")
1496 return strat_id
-> 1497 forgroupinreversed(self.stratigraphic_column.keys()):
1498 if group == "faults":
1499 continue
AttributeError: 'StratigraphicColumn' object has no attribute 'keys'

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions