-
Notifications
You must be signed in to change notification settings - Fork 247
Add gallery example "Cross-section along a transect" #2515
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 2 commits
Commits
Show all changes
59 commits
Select commit
Hold shift + click to select a range
679ccf9
Add basic code
yvonnefroehlich 588eec8
Add introduction
yvonnefroehlich 86ee2fb
Add first comments to code
yvonnefroehlich 8807d26
Replace tabs by four spaces
yvonnefroehlich 02e3a44
Rename 'track.py' -> 'cross_section.py'
yvonnefroehlich 50fdb76
[format-command] fixes
actions-bot 9f82ebc
Add more comments to code
yvonnefroehlich 9ca69d2
Replace tabs by four spaces
yvonnefroehlich 1ec8745
Fix typo
yvonnefroehlich a7573af
Improve formulation
yvonnefroehlich 554f750
Merge branch 'main' into rewrite-ex026-to-pygmt
yvonnefroehlich b884167
Improve formulation of reference to GMT/China docs
yvonnefroehlich 68ec873
Remove trailing white space
yvonnefroehlich 209cfb7
Reduce resolution temporarly
dbf4e82
Remove 'r' at the beginning of the docstrings
yvonnefroehlich f2f8429
Improve comments
yvonnefroehlich 1a2dc75
Adjust comments temporaly
yvonnefroehlich 321ca29
Improve comments
yvonnefroehlich 4f5e6e7
Merge branch 'main' into rewrite-ex026-to-pygmt
yvonnefroehlich 387eb87
Improve comment for track labels
yvonnefroehlich 03aacf2
Improve comment for track labels
yvonnefroehlich 84a766c
Fix line length - shorten comment
yvonnefroehlich ad23ec9
Fix line length - shorten comment
yvonnefroehlich 8ed29b6
Merge branch 'main' into rewrite-ex026-to-pygmt
yvonnefroehlich 87077fa
Merge branch 'main' into rewrite-ex026-to-pygmt
yvonnefroehlich f9bccb8
Expand introduction and comments
yvonnefroehlich 9c294b5
Merge branch 'main' into rewrite-ex026-to-pygmt
yvonnefroehlich d102f7d
Improve comment
yvonnefroehlich 6e88c97
Merge branch 'main' into rewrite-ex026-to-pygmt
yvonnefroehlich 51f6373
Fix typo
yvonnefroehlich c535ac9
Merge branch 'main' into rewrite-ex026-to-pygmt
yvonnefroehlich f909f19
Fix typo introduction (code review)
yvonnefroehlich 1f40002
Shorten comment (code review)
yvonnefroehlich c40401b
Remove not required word (code review)
yvonnefroehlich e6f716d
Add missing word (code review)
yvonnefroehlich 70727e5
Remove not required word (code review)
yvonnefroehlich b0735ae
Remove colorbar (code review)
yvonnefroehlich 992bd0c
Add colorbar immediately after grdimage (code review)
yvonnefroehlich 116171b
Download grid only once (code review)
yvonnefroehlich 5e4a497
Improve formulation for comment for colorbar argument
yvonnefroehlich 98709d9
Merge branch 'main' into rewrite-ex026-to-pygmt
yvonnefroehlich f791a08
Reduce step size of survey line
yvonnefroehlich b142510
Update als comment to larger step size along survey line
yvonnefroehlich 0cc6b9e
Comment code parts related to 'pygmt.grdtrack' out
yvonnefroehlich 68bc2fd
Fix code style for comments
yvonnefroehlich a467834
Revert step size increase for survey line
yvonnefroehlich 8bda00e
Merge branch 'main' into rewrite-ex026-to-pygmt
yvonnefroehlich 5021879
Merge branch 'main' into rewrite-ex026-to-pygmt
yvonnefroehlich 63b71ab
Un-comment only calculation of 'track_df' via 'grdtrack'
yvonnefroehlich a9f2e5d
Un-comment plotting 'track_df' via 'data' and 'incols'
yvonnefroehlich c25a778
Test plotting 'track_df' via 'x' and 'y'
yvonnefroehlich a5ce14f
Merge branch 'main' into rewrite-ex026-to-pygmt
yvonnefroehlich 355831e
Merge branch 'main' into rewrite-ex026-to-pygmt
yvonnefroehlich ab5d52b
Test using 'int' with 'data' and 'incols'
yvonnefroehlich 5fb3e49
Test using 'float' with 'data' and 'incols'
yvonnefroehlich b666712
Redo test changes and use 'x' and 'y'
yvonnefroehlich e18b6b2
Merge branch 'main' into rewrite-ex026-to-pygmt
yvonnefroehlich 129c3fa
Merge branch 'main' into rewrite-ex026-to-pygmt
yvonnefroehlich 765f2fd
Use '+u°' instead of '+u@.' following PR #2584
yvonnefroehlich 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,108 @@ | ||
| r""" | ||
| Cross-section along a transect | ||
| ============================== | ||
| :func:`pygmt.project` and :func:`pygmt.grdtrack` can be used to estimate | ||
| a quantity along a track. | ||
| In this example, the elevation is extracted from a gird provided via | ||
| :func:`pygmt.datasets.load_earth_relief`. | ||
|
|
||
| *The example is orientated on | ||
| https://docs.gmt-china.org/latest/examples/ex026/.* | ||
| TODO | ||
| """ | ||
|
|
||
| import pygmt | ||
|
|
||
| region_map = [122, 149, 30, 49] | ||
|
|
||
| fig = pygmt.Figure() | ||
|
|
||
| # ---------------------------------------------------------------------------- | ||
| # Bottom: Map | ||
|
|
||
| fig.basemap( | ||
| region=region_map, | ||
| projection="M12c", | ||
| frame="af", | ||
| ) | ||
|
|
||
| grid_map = pygmt.datasets.load_earth_relief( | ||
| resolution="10m", | ||
| region=region_map, | ||
| ) | ||
|
|
||
| fig.grdimage(grid=grid_map, cmap="oleron") | ||
|
|
||
| fig.plot( | ||
| x=[126, 146], | ||
| y=[42, 40], | ||
| pen="2p,red,--", | ||
| ) | ||
|
|
||
| fig.text( | ||
| x=[126, 146], | ||
| y=[42, 40], | ||
| text=["A", "B"], | ||
| offset="0c/0.2c", | ||
| font="15p", | ||
| ) | ||
|
|
||
| fig.colorbar( | ||
| position="jBR+o0.7c/0.8c+h+w5c/0.3c+ml", | ||
| box="+gwhite@30+p0.8p,black", | ||
| frame=["x+lElevation", "y+lm"], | ||
| ) | ||
|
|
||
| # ---------------------------------------------------------------------------- | ||
| # Top: Profil | ||
|
|
||
| fig.shift_origin(yshift="12.5c") | ||
|
|
||
| fig.basemap( | ||
| region=[0, 15, -8000, 6000], | ||
| projection="X12/3c", | ||
| frame=["WSrt", "xa2f1+lDistance+u@.", "ya4000+lElevation / m"], | ||
| ) | ||
|
|
||
| fig.text( | ||
| x=[0, 15], | ||
| y=[7000, 7000], | ||
| text=["A", "B"], | ||
| no_clip=True, | ||
| font="10p", | ||
| ) | ||
|
|
||
| track_df = pygmt.project( | ||
| center="126/42", | ||
| endpoint="146/40", | ||
| generate="0.1", | ||
| ) | ||
|
|
||
| grid_track = pygmt.datasets.load_earth_relief( | ||
| resolution="04m", | ||
| region=region_map, | ||
| ) | ||
|
|
||
| track_df = pygmt.grdtrack( | ||
| grid=grid_track, | ||
| points=track_df, | ||
| newcolname="elevation", | ||
| ) | ||
|
|
||
| fig.plot( | ||
| x=[0, 15], | ||
| y=[0, 0], | ||
| fill="lightblue", | ||
| pen="0.25p,black,solid", | ||
| close="+y-8000", | ||
| ) | ||
|
|
||
| fig.plot( | ||
| data=track_df, | ||
| fill="gray", | ||
| pen="1p,black,solid", | ||
| close="+y-8000", | ||
| incols=[2, 3], | ||
| ) | ||
|
|
||
| fig.show() | ||
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.
Uh oh!
There was an error while loading. Please reload this page.