Repository navigation
fix(modelling): correct unit ranges from stratigraphic column dicts and return unit ids from evaluate_model - #412
Merged
Merged
Conversation
… column dict set_stratigraphic_column made the unit ranges again from the thicknesses, starting at 0. The basal unit from ProcessInputData has min=-inf and max=0, so its thickness was inf and all units above it got (inf, inf). Now the units keep the min and max values from the dict, and get_isovalues uses these values. The group names used the dict order (oldest group first), but get_groups counts the groups from the top of the column. With two or more groups, each unit got the name, and so the scalar field, of a different group. Now the names follow the position of each group in the column. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
evaluate_model gave a running counter (bottom group first, top unit first) in place of unit.id. Thus the values did not agree with stratigraphic_ids(). Now each point gets the id of its unit. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The first fix set the unit ranges once, but update_unit_values made them again on each add_unit or thickness change. The basal unit with an infinite thickness then gave (inf, inf) to all units above it again. Now update_unit_values gives an infinite basal unit of a group the range (-inf, 0), and the units above it start at 0. set_stratigraphic_column does not set the ranges itself any more. get_isovalues makes the values again and reads the unit ranges, so a column from from_dict also gives correct values. The Basement range changes from (0, inf) to (-inf, 0). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
cmap() gave the colours with the top unit first. evaluate_model now gives unit.id, which increases from the bottom, and the viewers map each value to a colour in order. Thus the block model and map colours were in the reverse order. Now cmap() gives the colours in the order of the unit ids. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
evaluate_model is a stable method. Its values are now unit ids, and the cmap colours and the basal unit range also changed. Add a COMPAT.md row for these changes and say in the docstring that the values are unit ids. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes two problems found in a repo audit. Together they gave every model built with
from_processor(ProcessInputData or map2loop) a wrong block model and missing surfaces.Unit ranges and group names
update_unit_valuesstacked thicknesses from 0, so every unit above it got (inf, inf). On the shippedload_geological_map_dataexample, every point above 0 was labelled as the basal unit, andget_stratigraphic_surfacesgave only one surface.update_unit_values: an infinite first unit of a group gets (-inf, 0), and the stack above it starts at 0. This survives a lateradd_unit, a thickness change, andfrom_dict.get_isovaluesrecomputes before it reads.group_mappingwas built in dict order butget_groups()counts from the top, so each unit was evaluated against the other group's field. Groups are now mapped by their position in the built column.evaluate_modelidsunit.id, so ids disagreed withstratigraphic_ids()andcmap(). It now returnsunit.id, or -1 where no unit is assigned.cmap()now orders its colours by unit id, so the block model and map views keep each unit's colour.Behaviour changes (recorded in COMPAT.md):
evaluate_modelvalues are unit ids (evaluate_modelis public API, stable tier). The default Basement range is now (-inf, 0). A hand-written column dict whose units have gaps, or do not start at 0, is rebuilt from the thicknesses rather than taking its literal min and max values.Overlap: #297 adds a test in the same file (a textual conflict). #375, #376 and #380 edit
from_dict, COMPAT.md andgeological_model.py, so a rebase may need small merges.Tests: 202 passed and 7 skipped in tests/unit/input, test_exporters, test_fault_topology, test_geological_model, test_stratigraphic_column, test_world_location_consumers and the public API tests. The whole tests/unit/modelling folder and the visualisation package tests were not run, because they took too long locally. Reviewed by a second agent; the review's findings are fixed in 5485ee6, 64d3ba8 and 2de0f07.
🤖 Generated with Claude Code