-
Notifications
You must be signed in to change notification settings - Fork 235
Add a gallery example showing how to use advanced grdgradient via the "azimuth" & "normalize" parameters #2354
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
60 commits
Select commit
Hold shift + click to select a range
9007170
alias surface.py T=tensor
jhtong33 4b62f0e
surface.py add tension documnets
jhtong33 803a278
surface add -L -M -C:
jhtong33 fc0ba08
Apply suggestions from code review
jhtong33 fbe59e2
surface add document: limit upper & lower
jhtong33 6cf98c8
Apply suggestions from code review
jhtong33 f917d9d
Apply suggestions from code review
jhtong33 add6d0a
/format
5c77c5f
format
ae90cc3
format bold and space
jhtong33 9d19405
Apply suggestions from code review
jhtong33 38e80c0
Apply suggestions from code review
jhtong33 68f7fbf
add Unit links
jhtong33 78f721c
add Unit links with :
jhtong33 15680a7
add Unit links
jhtong33 d05a7a5
Merge branch 'GenericMappingTools:main' into main
jhtong33 c6fcf49
adding grdgradient_shading
jhtong33 bffc4c2
[format-command] fixes
actions-bot 8c9505a
Apply suggestions from code review
jhtong33 e5f5c54
code finish
jhtong33 1fdc625
Merge branch 'GenericMappingTools:main' into mini_branch
jhtong33 2897d2f
Merge branch 'main' into main
weiji14 3256f2b
Apply suggestions from code review
jhtong33 2d433b0
add tension more infomation
jhtong33 1492de9
Merge branch 'main' of github.com:JingHuiTong/pygmt into main
jhtong33 3c8fd2c
mini_branch/ surface.py T=tension more information
jhtong33 968bda3
Fix conflicts
jhtong33 6136b8a
Merge remote-tracking branch 'origin/main' into main
jhtong33 5653ef1
[format-command] fixes
actions-bot 8da18ee
Apply suggestions from code review
jhtong33 5de7419
Merge branch 'GenericMappingTools:main' into main
jhtong33 7f0d144
add gallery example: grdgradient_shading.py
jhtong33 a0573d8
Merge branch 'GenericMappingTools:main' into grdgradient
jhtong33 b20ea8f
Add documents to explain azimuth and normalize
jhtong33 e2a1219
[format-command] fixes
actions-bot d0e25a9
add some space
jhtong33 856ccb3
change the pygmt.config and pygmt.makecpt order
jhtong33 b3373ea
Apply suggestions from code review
jhtong33 fc6ac58
Revise colormap series and add grdgradient doc.
jhtong33 0200fc2
Merge branch 'GenericMappingTools:main' into grdgradient
jhtong33 5c40093
[format-command] fixes
actions-bot 51fce43
whitespace solve
jhtong33 6189e32
Apply suggestions from code review
jhtong33 d54f946
Revise subplot panel and improve amp parameter docu.
04822ce
[format-command] fixes
actions-bot acb8061
Apply suggestions from code review
jhtong33 692f2db
low resolution topo
6fc00a7
Merge branch 'GenericMappingTools:main' into grdgradient
jhtong33 dd538a9
typo
6977cb7
[format-command] fixes
actions-bot 8640f72
Apply suggestions from code review
jhtong33 384fba6
Update examples/gallery/images/grdgradient_shading.py
jhtong33 fd750d7
Apply suggestions from code review
jhtong33 bf4de7b
Add colorbar and change the light direction
jhtong33 ad689a7
Apply suggestions from code review
jhtong33 7d420ad
projection size
4cb2dbe
Apply suggestions from code review
jhtong33 f89a0c9
[format-command] fixes
actions-bot 3a82b44
colorbar position -> middle
635512f
Merge branch 'main' into grdgradient
michaelgrund 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,62 @@ | ||
| """ | ||
| Calculating grid gradient with custom ``azimuth`` and ``normalize`` parameters | ||
| ------------------------------------------------------------------------------ | ||
| The :func:`pygmt.grdgradient` function calculates the gradient of a grid file. | ||
| As input, :func:`pygmt.grdgradient` gets a :class:`xarray.DataArray` object or | ||
| a path string to a grid file. It then calculates the respective gradient and | ||
| returns an :class:`xarray.DataArray` object. The example below sets two main | ||
| parameters: | ||
|
|
||
| - ``azimuth``: to set the illumination light source direction (0° is North, | ||
| 90° is East, 180° is South, 270° is West). | ||
| - ``normalize`` to enhance the three-dimensional sense of the topography. | ||
|
|
||
| The ``normalize`` parameter calculates the azimuthal gradient of each point | ||
| along a certain azimuth angle, then adjusts the brightness value of the color | ||
| according to the positive/negative of the azimuthal gradient and the amplitude | ||
| of each point. | ||
| """ | ||
|
|
||
| import pygmt | ||
|
|
||
| # Load the 3 arc-minutes global relief grid in the target area around Caucasus | ||
| grid = pygmt.datasets.load_earth_relief(resolution="03m", region=[35, 50, 35, 45]) | ||
|
|
||
| fig = pygmt.Figure() | ||
|
|
||
| # Define a colormap to be used for topography | ||
| pygmt.makecpt(cmap="terra", series=[-7000, 7000]) | ||
|
|
||
| # Define figure configuration | ||
| pygmt.config(FONT_TITLE="10p,5", MAP_TITLE_OFFSET="1p", MAP_FRAME_TYPE="plain") | ||
|
|
||
| # Setup subplot panels with three rows and four columns | ||
| with fig.subplot( | ||
| nrows=3, | ||
| ncols=4, | ||
| figsize=("28c", "21c"), | ||
| sharex="b", | ||
| sharey="l", | ||
| ): | ||
| # E.g. "0/90" illuminates light source from the North (top) and East | ||
| # (right), and so on | ||
| for azi in ["0/90", "0/300", "180/225"]: | ||
| # "e" and "t" are cumulative Laplace distribution and cumulative | ||
| # Cauchy distribution, respectively | ||
| # "amp" (e.g. 1 or 10) controls the brightness value of the color | ||
| for nor in ["t1", "e1", "t10", "e10"]: | ||
| # Making an intensity DataArray using azimuth and normalize | ||
| # parameters | ||
| shade = pygmt.grdgradient(grid=grid, azimuth=azi, normalize=nor) | ||
| fig.grdimage( | ||
| grid=grid, | ||
| shading=shade, | ||
| projection="M?", | ||
| frame=["a4f2", f"+tazimuth={azi}, normalize={nor}"], | ||
| cmap=True, | ||
| panel=True, | ||
| ) | ||
|
|
||
| fig.colorbar(position="x9.0c/-1.1c+w10c/0.25c+h", frame="a2000f500+lElevation (m)") | ||
|
|
||
| fig.show() | ||
jhtong33 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
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.