-
Notifications
You must be signed in to change notification settings - Fork 6
add new methods for geulen #556
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: dev
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -274,6 +274,64 @@ def data_array(da, ds=None, ax=None, rotated=False, edgecolor=None, **kwargs): | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| return ax.pcolormesh(x, y, da, shading=shading, edgecolor=edgecolor, **kwargs) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| def geotop_strat_in_cross_section( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| line, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| gt=None, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| ax=None, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| legend=True, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| legend_loc=None, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| strat_props=None, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| alpha=None, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| **kwargs, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| ): | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| """PLot the stratigraphic-data of GeoTOP in a cross-section. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| """PLot the stratigraphic-data of GeoTOP in a cross-section. | |
| """Plot the stratigraphic-data of GeoTOP in a cross-section. |
Copilot
AI
Mar 28, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The docstring for geotop_var_in_cross_section still says it's for "lithoclass-data", but the function is now generic and also supports plotting stratigraphy. Update the summary line and parameter descriptions accordingly (e.g., describe that it plots any categorical GeoTOP variable with a properties table).
| """PLot the lithoclass-data of GeoTOP in a cross-section. | |
| Parameters | |
| ---------- | |
| line : shapely.LineString | |
| The line along which the GeoTOP data is plotted | |
| var : str | |
| The variable in the GeoTOP dataset to plot in the cross-section. Can be | |
| 'lithok' or 'strat' | |
| gt : xr.Dataset, optional | |
| The voxel-dataset from GeoTOP. It is downloaded with the method | |
| `nlmod.read.geotop.get_geotop()` if None. The default is None. | |
| ax : matplotlib.Axes, optional | |
| The axes in which the cross-section is plotted. Will default to the current axes | |
| if None. The default is None. | |
| legend : bool, optional | |
| When True, add a legend to the plot with the lithology-classes. The default is | |
| True. | |
| legend_loc : None or str, optional | |
| The location of the legend. See matplotlib documentation. The default is None. | |
| var_props : pd.DataFrame, optional | |
| A DataFrame containing the properties of the variable (lithoclasses or | |
| stratigraphy). Will call nlmod.read.geotop.get_{var}_props() when None. | |
| The default is None. | |
| alpha : float, optional | |
| Opacity for plot_array function, The default is None. | |
| label_col : str, optional | |
| column in the var_props dataframe to use a a label. The default is 'name'. | |
| **kwargs : dict | |
| kwargs are passed onto DatasetCrossSection. | |
| """Plot a categorical GeoTOP variable (e.g. lithology or stratigraphy) in a cross-section. | |
| Parameters | |
| ---------- | |
| line : shapely.LineString | |
| The line along which the GeoTOP data is plotted. | |
| var : str | |
| Name of the categorical variable in the GeoTOP dataset to plot in the | |
| cross-section, typically 'lithok' (lithoclass) or 'strat' (stratigraphy). | |
| gt : xr.Dataset, optional | |
| The GeoTOP voxel dataset. It is downloaded with the method | |
| `nlmod.read.geotop.get_geotop()` if None. The default is None. | |
| ax : matplotlib.Axes, optional | |
| The axes in which the cross-section is plotted. Will default to the current axes | |
| if None. The default is None. | |
| legend : bool, optional | |
| When True, add a legend to the plot with the classes of the selected variable. | |
| The default is True. | |
| legend_loc : None or str, optional | |
| The location of the legend. See matplotlib documentation. The default is None. | |
| var_props : pd.DataFrame, optional | |
| A DataFrame containing the properties of the categorical variable (e.g. | |
| lithoclasses or stratigraphic units), including at least an integer code and | |
| label information. Will call `nlmod.read.geotop.get_{var}_props()` when None. | |
| The default is None. | |
| alpha : float, optional | |
| Opacity for the plot_array function. The default is None. | |
| label_col : str, optional | |
| Column in the var_props DataFrame to use as a label in the legend. The default | |
| is 'name'. | |
| **kwargs : dict | |
| Additional keyword arguments are passed on to DatasetCrossSection. |
Copilot
AI
Mar 28, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
_add_geotop_var_legend uses var_props.at[index, "color"] but index comes from np.unique(var) and will typically be a float (e.g., 1.0). If var_props.index is an integer index, this can raise a KeyError depending on pandas index dtype/coercion. Cast consistently (e.g., idx = int(index)) for both color and label, and consider skipping indices not present in var_props with a warning.
| color = var_props.at[index, "color"] | |
| label = var_props.at[int(index), label_col] | |
| # Normalize index type: values from np.unique are often float (e.g. 1.0) | |
| # while var_props.index may be integer-based (e.g. 1). Cast numeric values | |
| # to int to avoid KeyError, and skip indices not present in var_props. | |
| if isinstance(index, (int, float, np.integer, np.floating)): | |
| idx = int(index) | |
| else: | |
| idx = index | |
| if idx not in var_props.index: | |
| warnings.warn( | |
| f"Value {index!r} (normalized to {idx!r}) not found in var_props index; " | |
| "skipping legend entry.", | |
| UserWarning, | |
| ) | |
| continue | |
| color = var_props.at[idx, "color"] | |
| label = var_props.at[idx, label_col] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This notebook calls the new helper via
nlmod.plot.plot.geotop_strat_in_cross_section(...), but the PR also exports it in the publicnlmod.plotnamespace (seenlmod/plot/__init__.py). To avoid relying on the internal module attribute, prefernlmod.plot.geotop_strat_in_cross_section(...)here.