Skip to content

Rename and recolor basement structural element #1082

@MattiaBressanelli

Description

@MattiaBressanelli

Hi

Describe the bug
When renaming and recoloring structural elements, the basement element can't be edited.

To Reproduce
Create a simple model:

# Define the path
data_path = "your_data_path"

# Create a GeoModel instance with the given project name, extent, and refinement level.
data = gp.create_geomodel(
    project_name='horizontal',
    extent=[0, 1000, 0, 1000, 0, 1000],
    refinement=5,
    importer_helper=gp.data.ImporterHelper(
        path_to_orientations=data_path + "orientations.csv",
        path_to_surface_points=data_path + "surface_points.csv"
    )
)

# Map a geological series to the corresponding surfaces.
# Here, the "Strat_Series" is associated with two formations ('rock2' and 'rock1'),
# which defines the stacking order of horizontal layers.
gp.map_stack_to_surfaces(
    gempy_model=data,
    mapping_object={"Strat_Series": ('rock2', 'rock1')}
)

# Compute the geological model using the provided data and mappings.
gp.compute_model(data)
geo_data = data

Fyi the orientations are:

X,Y,Z,azimuth,dip,polarity,formation
500,500,600,60,0,1,rock2
500,500,400,90,0,1,rock1

and the surface points are:

X,Y,Z,formation
100,200,600,rock2
500,200,600,rock2
900,200,600,rock2
100,800,600,rock2
500,800,600,rock2
900,800,600,rock2
100,200,400,rock1
500,200,400,rock1
900,200,400,rock1
100,800,400,rock1
500,800,400,rock1
900,800,400,rock1

Print the structural elements:
print(geo_data.structural_frame.structural_elements)

returns:

[Element(
	name=rock2,
	color=#9f0052,
	is_active=True
), Element(
	name=rock1,
	color=#015482,
	is_active=True
), Element(
	name=basement,
	color=#ffbe00,
	is_active=True
)]

Rename and recolor with:

geo_data.structural_frame.structural_elements[0].color = "#ff0000"
geo_data.structural_frame.structural_elements[0].name = "Level 2"

geo_data.structural_frame.structural_elements[1].color = "#00ff00"
geo_data.structural_frame.structural_elements[1].name = "Level 1"

geo_data.structural_frame.structural_elements[2].color = "#0000ff"
geo_data.structural_frame.structural_elements[2].name = "Level 0"

Reprint structural elements:

[Element(
	name=Level 2,
	color=#ff0000,
	is_active=True
), Element(
	name=Level 1,
	color=#00ff00,
	is_active=True
), Element(
	name=basement,
	color=#ffbe00,
	is_active=True
)]

The basement element ins't changed, and no error/warning is displayed.

Expected behavior
I would expect the basement element to behave like any other with respect to name and color.

Desktop (please complete the following information):

  • OS: Windows 10
  • GemPy Version: 2025.2.0
  • Python Version: 3.13.9

Thanks

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions