-
Notifications
You must be signed in to change notification settings - Fork 0
Fix:add downhole plot #13
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
Merged
Merged
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
4f96b60
fix: adding downhole plots for drillhole/dbs
lachlangrose 1dbb223
fix: enhance downhole plotting with additional categorical legend opt…
lachlangrose 7c20765
Apply suggestions from code review
lachlangrose ded74b4
Apply suggestions from code review
lachlangrose 86782fc
tests: add dh test
lachlangrose 368bfcb
fix: updating legend location
lachlangrose File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,85 @@ | ||
| """ | ||
| Downhole plotting | ||
| ================ | ||
|
|
||
| Example showing downhole line, categorical, and image plots. | ||
| """ | ||
|
|
||
| import matplotlib.pyplot as plt | ||
| import pandas as pd | ||
|
|
||
| from loopresources.drillhole.dhconfig import DhConfig | ||
| from loopresources.drillhole.drillhole_database import DrillholeDatabase | ||
|
|
||
| collar = pd.DataFrame( | ||
| { | ||
| DhConfig.holeid: ["DH001", "DH002", "DH003"], | ||
| DhConfig.x: [100.0, 200.0, 300.0], | ||
| DhConfig.y: [1000.0, 2000.0, 3000.0], | ||
| DhConfig.z: [50.0, 60.0, 70.0], | ||
| DhConfig.total_depth: [150.0, 200.0, 180.0], | ||
| } | ||
| ) | ||
|
|
||
| survey = pd.DataFrame( | ||
| { | ||
| DhConfig.holeid: ["DH001", "DH001", "DH002", "DH002", "DH003"], | ||
| DhConfig.depth: [0.0, 100.0, 0.0, 120.0, 0.0], | ||
| DhConfig.azimuth: [0.0, 0.0, 45.0, 45.0, 90.0], | ||
| DhConfig.dip: [-90.0, -90.0, -85.0, -80.0, -90.0], | ||
| } | ||
| ) | ||
|
|
||
| db = DrillholeDatabase(collar, survey) | ||
|
|
||
| lithology = pd.DataFrame( | ||
| { | ||
| DhConfig.holeid: ["DH001", "DH001", "DH002", "DH002", "DH003"], | ||
| DhConfig.sample_from: [0.0, 50.0, 0.0, 80.0, 0.0], | ||
| DhConfig.sample_to: [50.0, 150.0, 80.0, 200.0, 180.0], | ||
| "LITHO": ["Granite", "Schist", "Sandstone", "Shale", "Limestone"], | ||
| } | ||
| ) | ||
|
|
||
| assays = pd.DataFrame( | ||
| { | ||
| DhConfig.holeid: ["DH001", "DH001", "DH002", "DH002", "DH003"], | ||
| DhConfig.sample_from: [0.0, 75.0, 0.0, 100.0, 0.0], | ||
| DhConfig.sample_to: [75.0, 150.0, 100.0, 200.0, 180.0], | ||
| "AU_ppm": [0.1, 2.5, 0.05, 1.2, 0.4], | ||
| } | ||
| ) | ||
|
|
||
| db.add_interval_table("lithology", lithology) | ||
| db.add_interval_table("assays", assays) | ||
|
|
||
| # Line plot (numeric values) | ||
| db.plot_downhole("assays", "AU_ppm", kind="line", layout="grid", ncols=2) | ||
| plt.tight_layout() | ||
| plt.show() | ||
|
|
||
| # Categorical plot with shared legend on the right | ||
| db.plot_downhole("lithology", "LITHO", kind="categorical", step=2.0, layout="grid", ncols=2) | ||
| plt.tight_layout() | ||
| plt.show() | ||
|
|
||
| # Categorical plot with legend at bottom | ||
| db.plot_downhole("lithology", "LITHO", kind="categorical", step=2.0, layout="grid", ncols=2, legend_loc="bottom") | ||
| plt.tight_layout() | ||
| plt.show() | ||
|
|
||
| # Categorical plot without legend | ||
| db.plot_downhole("lithology", "LITHO", kind="categorical", step=2.0, layout="grid", ncols=2, show_legend=False) | ||
| plt.tight_layout() | ||
| plt.show() | ||
|
|
||
| # Create standalone legend | ||
| categories = lithology["LITHO"].unique() | ||
| DrillholeDatabase.create_categorical_legend(categories, cmap="tab20", title="Lithology") | ||
| plt.tight_layout() | ||
| plt.show() | ||
|
|
||
| # Image plot (numeric heatmap) | ||
| db.plot_downhole("assays", "AU_ppm", kind="image", step=2.0, layout="grid", ncols=2) | ||
| plt.tight_layout() | ||
| plt.show() |
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
Oops, something went wrong.
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.
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.
These new sampling helpers are core logic that the plotting APIs depend on, but there are no unit tests exercising their outputs for interval vs point tables (and categorical vs numeric data). Consider adding tests that assert the generated depth grid and sampled values (plus error cases like unknown tables / missing columns) to avoid relying on Matplotlib rendering in tests.