Skip to content

Commit 1d602dd

Browse files
authored
feat: choose the number of elements from the data (phase 6.4) (#141)
* feat: choose the number of interpolation elements from the data Add suggest_nelements and summarise_data, an Automatic setting, and one model manager method for the interpolator arguments that reads the saved settings instead of the class defaults. The feature panel shows the number and keeps a number that the user sets. * fix: element count from the extent, and the Automatic check box - Calculate the element count from the model extent as well as from the number of data rows: the volume of the model divided by the cube of the median spacing of the data points. Use the larger number. - When the user selects Automatic again, show the number of the settings, not the last number of the user. - The check box follows the global Automatic setting. Without it, the box uses the fixed number of the settings. - Correct the sign of the normal in _normals_from_strike_dip. - Add tests for interpolator_arguments and for the save and load of the overrides. * fix: limit the extent factor of the automatic element count volume / spacing^3 gave the maximum (250 000) for most map data: contacts are sampled densely along lines, so the spacing is small. The solve was then slow. The extent factor is now the map area of the model divided by the map area of the data, limited to 1 .. 2.
1 parent 44aaab3 commit 1d602dd

11 files changed

Lines changed: 671 additions & 39 deletions

File tree

‎docs/development/usability-plan.md‎

Lines changed: 88 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -529,12 +529,12 @@ Design:
529529

530530
Tasks:
531531

532-
- [ ] `main/interpolation_size.py` with `summarise_data` and `suggest_nelements`.
533-
- [ ] Setting, settings page and preference test.
534-
- [ ] Model manager: one method for the interpolator arguments, used in all
532+
- [x] `main/interpolation_size.py` with `summarise_data` and `suggest_nelements`.
533+
- [x] Setting, settings page and preference test.
534+
- [x] Model manager: one method for the interpolator arguments, used in all
535535
build paths. Fix the use of the class defaults.
536-
- [ ] Feature panel: show the number, and an "Automatic" check box.
537-
- [ ] Docs: say how the number is chosen, and what the user can change.
536+
- [x] Feature panel: show the number, and an "Automatic" check box.
537+
- [x] Docs: say how the number is chosen, and what the user can change.
538538

539539
Acceptance: a model with 20 contact points and a model with 5 000 points get
540540
different numbers of elements, both inside the limits. A saved fixed number is
@@ -638,13 +638,34 @@ user can select any combination that is in the table below.
638638
frame). This adds the axial surface constraint (`fold_orientation`).
639639
2. **Fold axis.** The user selects the source of the fold axis:
640640
- constant: plunge and azimuth (as now);
641-
- average intersection lineation of the folded feature and the axial
642-
surface (`av_fold_axis`, as now);
643-
- lineation data: a layer of fold axis or intersection lineation
644-
measurements. The plugin fits the fold axis rotation angle to
645-
coordinate 1 (the axis S-plot).
641+
- lineations. The user selects one of two lineation sources:
642+
1. **Lineation layer**: a point layer (for example a shapefile) with
643+
measured fold axes or intersection lineations. The user selects the
644+
plunge field and the trend (plunge direction) field.
645+
2. **Calculated intersection lineations**: the plugin calculates a
646+
lineation at each orientation point of the folded feature. The
647+
lineation is the intersection of the folded foliation and the axial
648+
foliation (coordinate 0 of the fold frame) at that point
649+
(`FoldFrame.calculate_intersection_lineation`). This source needs an
650+
axial surface.
651+
652+
Then the user selects how the plugin uses the lineations:
653+
- **average**: the fold axis is the mean of the lineations, and it is
654+
constant in the model (`av_fold_axis` for the calculated lineations,
655+
as now);
656+
- **fit**: the plugin fits the fold axis rotation angle of the
657+
lineations to coordinate 1 (the axis S-plot), so that the fold axis
658+
can change in the model. This needs an axial surface.
646659

647660
This adds the fold axis constraint (`fold_axis_w`).
661+
662+
| Lineation source | Average | Fit (axis S-plot) | Needs an axial surface |
663+
|---|---|---|---|
664+
| Lineation layer | yes | yes | only for "fit" |
665+
| Calculated intersection lineations | yes | yes | yes |
666+
667+
The UI shows the lineations of the selected source in the 3D view and in
668+
the axis S-plot, so that the user can compare the two sources.
648669
3. **S-plot.** The user controls the rotation angle profiles: the profile
649670
type (Fourier series, trigonometric), the wavelength, and fixed values for
650671
the profile parameters. Without this control, the plugin fits the
@@ -654,11 +675,11 @@ user can select any combination that is in the table below.
654675
| Axial surface | Fold axis | S-plot | Result |
655676
|---|---|---|---|
656677
| - | - | - | A standard foliation. No fold constraint. |
657-
| x | - | - | Fold frame and DFI. Axial surface constraint on. The fold axis is the average intersection lineation, but the fold axis constraint is off (`fold_axis_w = None`). Automatic profiles. |
658-
| - | x | - | No fold frame. The plugin adds the fold axis as tangent constraints on a regular grid in the bounding box (gradient . axis = 0). The interpolator of the feature does not change. Only a constant fold axis is possible. |
678+
| x | - | - | Fold frame and DFI. Axial surface constraint on. The fold axis is the average of the calculated intersection lineations, but the fold axis constraint is off (`fold_axis_w = None`). Automatic profiles. |
679+
| - | x | - | No fold frame. The plugin adds the fold axis as tangent constraints on a regular grid in the bounding box (gradient . axis = 0). The interpolator of the feature does not change. Only a constant fold axis is possible: plunge and azimuth, or the average of a lineation layer. |
659680
| x | x | - | Fold frame and DFI. Both constraints on. Automatic profiles. |
660681
| x | - | x | As "axial surface only", but with the limb profile of the user. |
661-
| x | x | x | All constraints on. The limb profile of the user. With "lineation data", also the axis profile of the user. |
682+
| x | x | x | All constraints on. The limb profile of the user. With lineations and "fit", also the axis profile of the user. |
662683
| - | - | x, or - x x | Not possible. An S-plot needs a fold frame coordinate. The S-plot check box is disabled until the user selects an axial surface. The tooltip says why. |
663684

664685
Rules:
@@ -721,8 +742,11 @@ with orientations: `s2`, `s1` and `s0`.
721742
stratigraphic group:
722743
- `fold_event`: the name of the fold event, or `None`;
723744
- `axial_surface`: on or off, and `fold_orientation` weight;
724-
- `fold_axis`: off, `constant` (plunge, azimuth), `average`, or `data`
725-
(layer dicts), and `fold_axis_w` weight;
745+
- `fold_axis`: `source` (off, `constant` or `lineations`), the plunge and
746+
azimuth for `constant`, the `fold_axis_w` weight, and for `lineations`:
747+
- `lineation_source`: `layer` (layer dict with the plunge and trend
748+
fields) or `intersection` (calculated);
749+
- `use`: `average` or `fit`;
726750
- `splot`: off or on; for the limb and for the axis profile: the type, the
727751
wavelength (or "automatic"), and the fixed parameters;
728752
- `fold_normalisation`, `fold_norm`, `fold_regularisation`.
@@ -743,7 +767,8 @@ with orientations: `s2`, `s1` and `s0`.
743767
The S-plot needs the fold frame before the folded feature is built. Thus:
744768

745769
- "Calculate rotation angles" builds the fold frame (and the fold events that
746-
fold it) if it is not current. Then it calculates the rotation angles of the
770+
fold it) if it is not current. Then it calculates the lineations (for the
771+
"calculated intersection lineations" source) and the rotation angles of the
747772
data of the feature. It does not build the folded feature. Run it in a
748773
background task with progress.
749774
- The S-plot panel shows the data points, the fitted curve, the S-variogram
@@ -793,8 +818,15 @@ Do the parts in this order. Each part is a separate pull request.
793818
the three controls with their check boxes and "Advanced" weights.
794819
- [ ] Apply the rules of the combination table. Disable the S-plot control
795820
when there is no axial surface.
796-
- [ ] Fold axis "lineation data": a layer picker with the trend and plunge
797-
fields.
821+
- [ ] Fold axis "lineations": a choice of the two lineation sources. For
822+
"lineation layer", a point layer picker with the plunge and trend
823+
fields. For "calculated intersection lineations", no input (disabled
824+
without an axial surface).
825+
- [ ] Fold axis "average" or "fit" for the lineations. Disable "fit" without
826+
an axial surface.
827+
- [ ] Convert the plunge and trend of the layer to vectors, and give them
828+
with their points (N x 6) to the fold axis calculation
829+
(`main/fold_spec.py`).
798830
- [ ] Fold axis without axial surface: make the tangent constraints on a grid
799831
(`main/fold_spec.py`). The grid step comes from the bounding box and
800832
the number of elements.
@@ -829,6 +861,11 @@ Tests:
829861
F2 -> F1 -> S0; a cycle is an error; each row of the combination table gives
830862
the correct arguments (a control that is off gives `None`); the S-plot is
831863
refused without an axial surface; old specs with `folded_feature_name` load.
864+
- Unit tests for the two lineation sources: the plunge and trend of a layer
865+
give the correct vectors; the calculated intersection lineation of a known
866+
folded foliation and a known axial foliation is their cross product; the
867+
"average" of both sources gives the same axis for the same data; "fit" and
868+
the calculated source are refused without an axial surface.
832869
- A QGIS test that builds the refolded fold from the test layers and compares
833870
the S0 scalar field on a coarse grid with the result of the LoopStructural
834871
calls of the example (same data, same arguments).
@@ -839,6 +876,22 @@ depend on 7.1. 7.4 depends on 7.3 (the S-plot control). 7.5 comes last. Phase 7
839876
depends on 6.1 (the workflow mode), 6.3 (`SectionStack`) and 6.4 (the number of
840877
elements of each feature, which is also used for the fold frames).
841878

879+
### Phase 8: Advanced 3D viewer
880+
881+
A second 3D viewer for hard 3D problems. It is a standalone application
882+
(Rust, Bevy) with a live link to QGIS. The PyVista viewer stays as the default
883+
viewer. The new viewer shows geological data objects that are similar to
884+
those of Geoscience ANALYST (`geoh5` types): points, curves, surfaces,
885+
sections, block models, drillholes and orientations.
886+
887+
This phase is large, and most of the work is in a separate repository. The
888+
tasks, the protocol, the risks and the open questions are in the
889+
[viewer plan](viewer-plan.md).
890+
891+
Acceptance: from step 5, a user opens the advanced viewer. The viewer shows
892+
the model and its input data, and updates after each build. A pick in the
893+
viewer selects the feature in the dock and shows the point on the map.
894+
842895
## Risks
843896

844897
- **Large UI change.** Users of the current version must learn the new layout.
@@ -899,3 +952,20 @@ elements of each feature, which is also used for the fold frames).
899952
Does a fault need a different rule from a foliation?
900953
8. (6.1) Must a manual unconformity or fold in the "constraints" mode use the
901954
column? Recommendation: no. It uses only the features of that mode.
955+
9. (7) How does the plugin give the lineations of a layer to LoopStructural?
956+
`FoldFrame.calculate_fold_axis_rotation` has a `fold_axis` argument (an
957+
N x 6 array of points and lineations), but
958+
`FoldedFeatureBuilder.set_fold_axis` does not use it, and there is no build
959+
argument for it. "Average" of a lineation layer is easy: the plugin
960+
calculates the mean and gives it as `fold_axis`. For "fit", either the
961+
plugin calls `calculate_fold_axis_rotation` itself and sets
962+
`fold.fold_axis_rotation`, or LoopStructural gets a build argument for the
963+
lineations. Recommendation: add the build argument to LoopStructural, and
964+
use the plugin call until that version is released.
965+
10. (7) Is "fold axis without axial surface" (tangent constraints on a grid)
966+
good enough, or must the plugin make a simple fold frame from the fold
967+
axis? Recommendation: tangent constraints first. Compare the two on the
968+
single fold example (`load_noddy_single_fold`).
969+
11. (7) Must a fault that cuts a fold frame also cut the folded features?
970+
LoopStructural calculates the rotation angles in the restored space.
971+
Recommendation: yes, use the same faults. Test it before 7.5.

‎docs/usage/interface.md‎

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -115,4 +115,11 @@ Units that don't match the stratigraphic column will have null values, helping y
115115
Once the layers have been selected, stratigraphic column defined and the fault topology relationships set, the LoopStructural model can be initialised.
116116

117117
Initialise model will create a LoopStructural model with all of the geological features in the model. For each feature in the model the number of interpolation elements (degrees of freedom), the weighting of the regularisation, contact points and orientation weight can be changed.
118+
119+
#### Number of interpolation elements
120+
121+
By default the number of elements is "Automatic". The plugin chooses it for each feature from the data of the feature: more constraints, more surfaces and a wider spread of orientations give more elements. The number is rounded to 1 000 and kept between 5 000 and 250 000. The panel of the feature shows the number that was used.
122+
123+
- To keep a number for one feature, clear the "Automatic" check box in the panel of the feature and enter the number. The feature keeps it, and the project file saves it, until you select "Automatic" again.
124+
- To use one fixed number for all features, clear "Automatic" in the plugin settings and enter the number. Features that you set by hand keep their own number.
118125
![Model Parameters](../static/model-setup.png)

‎loopstructural/gui/dlg_settings.py‎

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,10 @@ def __init__(self, parent):
8181
if hasattr(self, "btn_open_debug_directory"):
8282
self.btn_open_debug_directory.pressed.connect(self._open_debug_directory)
8383

84+
self.n_elements_auto_check_box.toggled.connect(
85+
lambda checked: self.n_elements_spin_box.setEnabled(not checked)
86+
)
87+
8488
# load previously saved settings
8589
self.load_settings()
8690

@@ -92,6 +96,7 @@ def apply(self):
9296
settings.debug_mode = self.opt_debug.isChecked()
9397
settings.separate_dock_widgets = self.opt_separate_dock_widgets.isChecked()
9498
settings.interpolator_nelements = self.n_elements_spin_box.value()
99+
settings.interpolator_nelements_auto = self.n_elements_auto_check_box.isChecked()
95100
settings.interpolator_npw = self.npw_spin_box.value()
96101
settings.interpolator_cpw = self.cpw_spin_box.value()
97102
settings.interpolator_regularisation = self.regularisation_spin_box.value()
@@ -121,6 +126,8 @@ def load_settings(self):
121126
self.lbl_version_saved_value.setText(settings.version)
122127
# self.interpolator_type_combo.setCurrentText(settings.interpolator_type)
123128
self.n_elements_spin_box.setValue(settings.interpolator_nelements)
129+
self.n_elements_auto_check_box.setChecked(settings.interpolator_nelements_auto)
130+
self.n_elements_spin_box.setEnabled(not settings.interpolator_nelements_auto)
124131
self.regularisation_spin_box.setValue(settings.interpolator_regularisation)
125132
self.cpw_spin_box.setValue(settings.interpolator_cpw)
126133
self.npw_spin_box.setValue(settings.interpolator_npw)

‎loopstructural/gui/dlg_settings.ui‎

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -280,6 +280,16 @@
280280
</property>
281281
</widget>
282282
</item>
283+
<item row="4" column="1">
284+
<widget class="QCheckBox" name="n_elements_auto_check_box">
285+
<property name="toolTip">
286+
<string>Choose the number of elements of each feature from its data. If this is off, every feature uses the fixed number.</string>
287+
</property>
288+
<property name="text">
289+
<string>Automatic</string>
290+
</property>
291+
</widget>
292+
</item>
283293
</layout>
284294
</widget>
285295
</item>

0 commit comments

Comments
 (0)