gempy-project / gempy

GemPy is an open-source, Python-based 3-D structural geological modeling software, which allows the implicit (i.e. automatic) creation of complex geological models from interface and orientation data. It also offers support for stochastic modeling to address parameter and model uncertainties.
https://gempy.org
European Union Public License 1.2
965 stars 232 forks source link

`get_element_bt_name("basement")` -> ValueError: Element with name "basement" not found in the structural frame. #870

Closed JoostGevaert-Arup closed 6 months ago

JoostGevaert-Arup commented 6 months ago

Describe the bug I saw Florian Wellman's comment on someone's LinkedIn post, saying that GemPy v3 is underway, and that there is a Google Colab.

When trying out the Google Colab, after Step 5, I tried to get some structural elements by name:

print(geo_model.structural_frame.elements_names)
print(geo_model.structural_frame.get_element_by_name("basement"))

But then got the error:

['surface2', 'surface1', 'basement']
---------------------------------------------------------------------------
ValueError                                Traceback (most recent call last)
[<ipython-input-35-1168d3e7cf55>](https://localhost:8080/#) in <cell line: 2>()
      1 print(geo_model.structural_frame.elements_names)
----> 2 print(geo_model.structural_frame.get_element_by_name("basement"))

[/usr/local/lib/python3.10/dist-packages/gempy/core/data/structural_frame.py](https://localhost:8080/#) in get_element_by_name(self, element_name)
     35         element = next(valid_elements, None)
     36         if element is None:
---> 37             raise ValueError(f"Element with name {element_name} not found in the structural frame.")
     38         return element
     39 

ValueError: Element with name basement not found in the structural frame.

Which I find curious, because "basement" is listed when running print(geo_model.structural_frame.elements_names)

To Reproduce Run GemPy v3 Google Colab ...

Expected behavior I expected geo_model.structural_frame.get_element_by_name("basement") to return the "basement" <class 'gempy.core.data.structural_element.StructuralElement'>.

Screenshots image

Desktop (please complete the following information): N/A

JoostGevaert-Arup commented 6 months ago

I can obtain "surface1" and "surface2", I guess because they're in a <class 'gempy.core.data.structural_group.StructuralGroup'? However, I do find it somewhat confusing that "basement" is listed when I do print(geo_model.structural_frame.elements_names), but then cannot obtain it.

flohorovicic commented 6 months ago

Hi @JoostGevaert-Arup,

Happy to see that you are giving the online GemPy version a try!

The reason that you can not get more information about the basement is that it is - by default- the base of the stratigraphic pile - i.e.: everything below the first structural element that you define ("surface1", in this case). As such, it does not have any data associated with it (no interface points, orientations, etc.).

Can you explain a bit more what exactly you try to achieve and what you need it for? Maybe we can solve the issue from there?

JoostGevaert-Arup commented 6 months ago

Hi Florian,

Great to hear from you! I'm a big fan of open-source software and have always been looking for ways to use GemPy in my work in geotechnical engineering, so I was very happy to see it'll now become easier to get my colleagues introduced to GemPy with the Google Colab :)

I was not really trying to achieve anything specific. I was just exploring GemPy in that Colab and then stumbled upon the error mentioned above.

Rather than returning a ValueError when trying to retrieve the "basement", it might make more sense to return a message similar to what you just explained above?

flohorovicic commented 6 months ago

Yes, good idea! I'll add this as a development note. Just as an information: we are also working on more notebooks for Google Colab with additional examples and use cases. Hope this helps you and your colleagues in getting forward with GemPy!