Skip to content
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 Jan 11, 2023
4b62f0e
surface.py add tension documnets
jhtong33 Jan 13, 2023
803a278
surface add -L -M -C:
jhtong33 Jan 13, 2023
fc0ba08
Apply suggestions from code review
jhtong33 Jan 14, 2023
fbe59e2
surface add document: limit upper & lower
jhtong33 Jan 14, 2023
6cf98c8
Apply suggestions from code review
jhtong33 Jan 14, 2023
f917d9d
Apply suggestions from code review
jhtong33 Jan 15, 2023
add6d0a
/format
Jan 15, 2023
5c77c5f
format
Jan 15, 2023
ae90cc3
format bold and space
jhtong33 Jan 16, 2023
9d19405
Apply suggestions from code review
jhtong33 Jan 21, 2023
38e80c0
Apply suggestions from code review
jhtong33 Jan 21, 2023
68f7fbf
add Unit links
jhtong33 Jan 21, 2023
78f721c
add Unit links with :
jhtong33 Jan 21, 2023
15680a7
add Unit links
jhtong33 Jan 21, 2023
d05a7a5
Merge branch 'GenericMappingTools:main' into main
jhtong33 Jan 21, 2023
c6fcf49
adding grdgradient_shading
jhtong33 Jan 21, 2023
bffc4c2
[format-command] fixes
actions-bot Jan 23, 2023
8c9505a
Apply suggestions from code review
jhtong33 Jan 27, 2023
e5f5c54
code finish
jhtong33 Jan 27, 2023
1fdc625
Merge branch 'GenericMappingTools:main' into mini_branch
jhtong33 Jan 27, 2023
2897d2f
Merge branch 'main' into main
weiji14 Feb 6, 2023
3256f2b
Apply suggestions from code review
jhtong33 Feb 6, 2023
2d433b0
add tension more infomation
jhtong33 Feb 6, 2023
1492de9
Merge branch 'main' of github.com:JingHuiTong/pygmt into main
jhtong33 Feb 6, 2023
3c8fd2c
mini_branch/ surface.py T=tension more information
jhtong33 Feb 6, 2023
968bda3
Fix conflicts
jhtong33 Feb 6, 2023
6136b8a
Merge remote-tracking branch 'origin/main' into main
jhtong33 Feb 6, 2023
5653ef1
[format-command] fixes
actions-bot Feb 6, 2023
8da18ee
Apply suggestions from code review
jhtong33 Feb 7, 2023
5de7419
Merge branch 'GenericMappingTools:main' into main
jhtong33 Feb 8, 2023
7f0d144
add gallery example: grdgradient_shading.py
jhtong33 Feb 8, 2023
a0573d8
Merge branch 'GenericMappingTools:main' into grdgradient
jhtong33 Feb 9, 2023
b20ea8f
Add documents to explain azimuth and normalize
jhtong33 Feb 9, 2023
e2a1219
[format-command] fixes
actions-bot Feb 9, 2023
d0e25a9
add some space
jhtong33 Feb 9, 2023
856ccb3
change the pygmt.config and pygmt.makecpt order
jhtong33 Feb 9, 2023
b3373ea
Apply suggestions from code review
jhtong33 Feb 10, 2023
fc6ac58
Revise colormap series and add grdgradient doc.
jhtong33 Feb 10, 2023
0200fc2
Merge branch 'GenericMappingTools:main' into grdgradient
jhtong33 Feb 10, 2023
5c40093
[format-command] fixes
actions-bot Feb 10, 2023
51fce43
whitespace solve
jhtong33 Feb 10, 2023
6189e32
Apply suggestions from code review
jhtong33 Feb 20, 2023
d54f946
Revise subplot panel and improve amp parameter docu.
Feb 20, 2023
04822ce
[format-command] fixes
actions-bot Feb 20, 2023
acb8061
Apply suggestions from code review
jhtong33 Feb 22, 2023
692f2db
low resolution topo
Feb 22, 2023
6fc00a7
Merge branch 'GenericMappingTools:main' into grdgradient
jhtong33 Feb 22, 2023
dd538a9
typo
Feb 22, 2023
6977cb7
[format-command] fixes
actions-bot Feb 26, 2023
8640f72
Apply suggestions from code review
jhtong33 Mar 1, 2023
384fba6
Update examples/gallery/images/grdgradient_shading.py
jhtong33 Mar 3, 2023
fd750d7
Apply suggestions from code review
jhtong33 Mar 14, 2023
bf4de7b
Add colorbar and change the light direction
jhtong33 Mar 14, 2023
ad689a7
Apply suggestions from code review
jhtong33 Mar 14, 2023
7d420ad
projection size
Mar 15, 2023
4cb2dbe
Apply suggestions from code review
jhtong33 Mar 15, 2023
f89a0c9
[format-command] fixes
actions-bot Mar 15, 2023
3a82b44
colorbar position -> middle
Mar 15, 2023
635512f
Merge branch 'main' into grdgradient
michaelgrund Mar 15, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
62 changes: 62 additions & 0 deletions examples/gallery/images/grdgradient_shading.py
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()