Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
24 commits
Select commit Hold shift + click to select a range
9c237c6
use balance for all diverging colormaps, update cpt limits and colorb…
mdtanker Nov 19, 2025
15c844a
use pygmt instead of matplotlib for documentation
mdtanker Nov 19, 2025
bf00da8
wrap returns in print in .rst file
mdtanker Nov 19, 2025
38afc87
add hidden pygmt import to igrf.rst
mdtanker Nov 19, 2025
e6d05c8
remove quotes from and update and standardize figure titles and labels
mdtanker Nov 19, 2025
725169b
standardize forward calculation example colorbars
mdtanker Nov 19, 2025
1694600
add labels to point masses in plot
mdtanker Nov 19, 2025
0bfeb31
make nans transparent in plot
mdtanker Nov 19, 2025
1cf6580
format fix
mdtanker Nov 19, 2025
a1ac93d
Merge branch 'main' into colormaps
mdtanker Nov 19, 2025
891c745
Merge branch 'main' into colormaps
santisoler Nov 20, 2025
246e8d3
Merge branch 'main' into colormaps
mdtanker Nov 25, 2025
b839ef1
remove print statement to keep html rendering of dataframe
mdtanker Nov 28, 2025
83c5678
Merge branch 'main' into colormaps
mdtanker Nov 28, 2025
7681df3
Merge branch 'main' into colormaps
mdtanker Apr 25, 2026
db2ad9e
use single colorbar in eqs gallery
mdtanker Apr 30, 2026
78f8976
remove dublicate boule from environment.yml
mdtanker Apr 30, 2026
4811cc1
update listed dependencies in install docs
mdtanker Apr 30, 2026
bbf586d
plot tesseroid boundaries in forward modeling gallery
mdtanker Apr 30, 2026
d13339b
use verde percentiles in other gallery docs
mdtanker Apr 30, 2026
6f4567a
combine colorbars for compare RTP and up continued grids
mdtanker Apr 30, 2026
1cbf976
add min version for verde for docs
mdtanker Apr 30, 2026
bada65a
formatting
mdtanker Apr 30, 2026
7fb9924
update colorbars and plots and revert some back to xarray
mdtanker Apr 30, 2026
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
24 changes: 12 additions & 12 deletions doc/gallery_src/equivalent_sources/block_averaged_sources.py
Original file line number Diff line number Diff line change
Expand Up @@ -106,17 +106,15 @@

title = "Observed magnetic anomaly data"

# Make colormap of data
# Get the 95 percentile of the maximum absolute value between the original and
# gridded data so we can use the same color scale for both plots and have 0
# centered at the white color.
maxabs = vd.maxabs(data.total_field_anomaly_nt, grid.magnetic_anomaly.values) * 0.95
pygmt.makecpt(
cmap="vik",
series=(-maxabs, maxabs),
background=True,
# Get the 99th percentile of the absolute value to use as color scale limits
maxabs = vd.maxabs(
data.total_field_anomaly_nt,
percentile=99,
)

# Make colormap of data
pygmt.makecpt(cmap="balance+h0", series=[-maxabs, maxabs], background=True)

with pygmt.config(FONT_TITLE="12p"):
fig.plot(
projection=fig_proj,
Expand All @@ -129,8 +127,6 @@
cmap=True,
)

fig.colorbar(cmap=True, frame=["a400f100", "x+lnT"])

fig.shift_origin(xshift=fig_width + 1)

title = "Gridded and upward-continued"
Expand All @@ -142,6 +138,10 @@
cmap=True,
)

fig.colorbar(cmap=True, frame=["a400f100", "x+lnT"])
fig.colorbar(
cmap=True,
frame=["a400f100", "x+lnT"],
position="n0/0+jTC+w8c/0.25c+h+o-0.5c/0.8c",
)

fig.show()
24 changes: 12 additions & 12 deletions doc/gallery_src/equivalent_sources/cartesian.py
Original file line number Diff line number Diff line change
Expand Up @@ -95,17 +95,15 @@

title = "Observed magnetic anomaly data"

# Make colormap of data
# Get the 95 percentile of the maximum absolute value between the original and
# gridded data so we can use the same color scale for both plots and have 0
# centered at the white color.
maxabs = vd.maxabs(data.total_field_anomaly_nt, grid.magnetic_anomaly.values) * 0.95
pygmt.makecpt(
cmap="vik",
series=(-maxabs, maxabs),
background=True,
# Get the 99th percentile of the absolute value to use as color scale limits
maxabs = vd.maxabs(
data.total_field_anomaly_nt,
percentile=99,
)

# Make colormap of data
pygmt.makecpt(cmap="balance+h0", series=[-maxabs, maxabs], background=True)

with pygmt.config(FONT_TITLE="12p"):
fig.plot(
projection=fig_proj,
Expand All @@ -118,8 +116,6 @@
cmap=True,
)

fig.colorbar(cmap=True, frame=["a400f100", "x+lnT"])

fig.shift_origin(xshift=fig_width + 1)

title = "Gridded and upward-continued"
Expand All @@ -131,6 +127,10 @@
cmap=True,
)

fig.colorbar(cmap=True, frame=["a400f100", "x+lnT"])
fig.colorbar(
cmap=True,
frame=["a400f100", "x+lnT"],
position="n0/0+jTC+w8c/0.25c+h+o-0.5c/0.8c",
)

fig.show()
23 changes: 12 additions & 11 deletions doc/gallery_src/equivalent_sources/gradient_boosted.py
Original file line number Diff line number Diff line change
Expand Up @@ -115,16 +115,15 @@

title = "Observed gravity disturbance data"

# Make colormap of data
pygmt.makecpt(
cmap="vik",
series=(
-data.gravity_disturbance.quantile(0.99),
data.gravity_disturbance.quantile(0.99),
),
background=True,
# Get the 99th percentile of the absolute value to use as color scale limits
maxabs = vd.maxabs(
data.gravity_disturbance,
percentile=99,
)

# Make colormap of data
pygmt.makecpt(cmap="balance+h0", series=[-maxabs, maxabs], background=True)

with pygmt.config(FONT_TITLE="14p"):
fig.plot(
projection=fig_proj,
Expand All @@ -137,8 +136,6 @@
cmap=True,
)

fig.colorbar(cmap=True, frame=["a50f25", "x+lmGal"])

fig.shift_origin(xshift=fig_width + 1)

title = "Gridded with gradient-boosted equivalent sources"
Expand All @@ -150,6 +147,10 @@
cmap=True,
)

fig.colorbar(cmap=True, frame=["a50f25", "x+lmGal"])
fig.colorbar(
cmap=True,
frame=["x+lmGal"],
position="n0/0+jTC+w10c/0.5c+h+o-0.5c/0.9c",
)

fig.show()
33 changes: 18 additions & 15 deletions doc/gallery_src/equivalent_sources/spherical.py
Original file line number Diff line number Diff line change
Expand Up @@ -80,38 +80,41 @@
# Plot observed and gridded gravity disturbance
fig = pygmt.Figure()

# Get the 99th percentile of the absolute value to use as color scale limits
maxabs = vd.maxabs(gravity_disturbance, percentile=99)

# Make colormap of data
# Get the 90% of the maximum absolute value between the original and gridded
# data so we can use the same color scale for both plots and have 0 centered
# at the white color.
maxabs = vd.maxabs(gravity_disturbance, grid.gravity_disturbance.values) * 0.90
pygmt.makecpt(
cmap="vik",
series=(-maxabs, maxabs),
background=True,
)
pygmt.makecpt(cmap="balance+h0", series=[-maxabs, maxabs], background=True)


title = "Observed gravity disturbance data"

fig.plot(
projection="M10c",
projection="M12c",
region=region,
frame=["WSne", "xa5", "ya4"],
frame=[f"WSne+t{title}", "xa5", "ya4"],
x=longitude,
y=latitude,
fill=gravity_disturbance,
style="c0.1c",
cmap=True,
)

fig.colorbar(cmap=True, frame=["a100f50", "x+lmGal"])
fig.shift_origin(xshift="w+1c")

fig.shift_origin(xshift="w+3c")
title = "Gridded and upward-continued"

fig.grdimage(
frame=["ESnw", "xa5", "ya4"],
frame=[f"ESnw+t{title}", "xa5", "ya4"],
grid=grid.gravity_disturbance,
cmap=True,
nan_transparent=True,
)

fig.colorbar(cmap=True, frame=["a100f50", "x+lmGal"])
fig.colorbar(
cmap=True,
frame=["x+lmGal"],
position="n0/0+jTC+w10c/0.5c+h+o-0.5c/0.9c",
)

fig.show()
16 changes: 12 additions & 4 deletions doc/gallery_src/forward/point_gravity.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,9 +54,9 @@

title = "Gravitational acceleration (downward)"

maxabs = vd.maxabs(gravity) * 0.80
maxabs = vd.maxabs(gravity, percentile=100)

pygmt.makecpt(cmap="vik", series=(-maxabs, maxabs, 0.3))
pygmt.makecpt(cmap="vik", series=[-maxabs, maxabs, 0.3], background=True)

with pygmt.config(FONT_TITLE="16p"):
fig.grdimage(
Expand All @@ -68,8 +68,16 @@
cmap=True,
)

fig.plot(x=easting, y=northing, style="c0.2c", fill="grey")
fig.plot(
x=easting,
y=northing,
style="t0.15c",
fill="magenta",
label="Point masses",
)

fig.colorbar(cmap=True, position="JMR+e", frame=["x+lmGal"])

fig.colorbar(cmap=True, position="JMR", frame=["a.6f.2", "x+lmGal"])
fig.legend()

fig.show()
6 changes: 3 additions & 3 deletions doc/gallery_src/forward/prism_layer.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,17 +51,17 @@
# Plot gravity field
fig = pygmt.Figure()

title = "Gravitational acceleration of a layer of prisms"
title = "Gravitational acceleration of topography with prisms"

with pygmt.config(FONT_TITLE="14p"):
fig.grdimage(
region=region,
projection="X10c/10c",
grid=grid.gravity,
frame=["a", f"+t{title}", 'x+l"easting (m)"', 'y+l"northing (m)"'],
frame=["a", f"+t{title}", "x+leasting (m)", "y+lnorthing (m)"],
cmap="viridis",
)

fig.colorbar(cmap=True, position="JMR", frame=["a2f1", "x+lmGal"])
fig.colorbar(cmap=True, position="JMR", frame=["x+lmGal"])

fig.show()
10 changes: 8 additions & 2 deletions doc/gallery_src/forward/prisms_topo_gravity.py
Original file line number Diff line number Diff line change
Expand Up @@ -87,15 +87,21 @@

title = "Gravitational acceleration of the topography"

# Get the max absolute value to use as color scale limits
cpt_lims = vd.maxabs(grid.gravity)

# Make colormap of data
pygmt.makecpt(cmap="balance+h0", series=[-cpt_lims, cpt_lims])

with pygmt.config(FONT_TITLE="14p"):
fig.grdimage(
region=xy_region,
projection=fig_proj,
grid=grid.gravity,
frame=["ag", f"+t{title}"],
cmap="vik",
cmap=True,
)

fig.colorbar(cmap=True, frame=["a100f50", "x+lmGal"])
fig.colorbar(cmap=True, position="JMR", frame=["a100f50", "x+lmGal"])

fig.show()
14 changes: 12 additions & 2 deletions doc/gallery_src/forward/tesseroid.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@
# Plot the gravitational field
fig = pygmt.Figure()

title = "Downward component of gravitational acceleration"
title = "Gravitational acceleration of a tesseroid"

with pygmt.config(FONT_TITLE="16p"):
fig.grdimage(
Expand All @@ -61,7 +61,17 @@
cmap="viridis",
)

fig.colorbar(cmap=True, frame=["a200f50", "x+lmGal"])
# Plot edges of tesseroid
fig.plot(
x=[tesseroid[0], tesseroid[1], tesseroid[1], tesseroid[0], tesseroid[0]],
y=[tesseroid[2], tesseroid[2], tesseroid[3], tesseroid[3], tesseroid[2]],
pen="1p,red",
label="Tesseroid boundaries",
)

fig.legend()

fig.colorbar(cmap=True, position="JMR", frame=["a200f50", "x+lmGal"])

fig.coast(shorelines="1p,black")

Expand Down
4 changes: 3 additions & 1 deletion doc/gallery_src/forward/tesseroid_layer.py
Original file line number Diff line number Diff line change
Expand Up @@ -86,9 +86,11 @@
gravity.g_z,
projection="M15c",
nan_transparent=True,
cmap=True,
frame="+tForward gravity",
)

fig.basemap(frame=True)
fig.colorbar(frame="af+lGravity (mGal)")
fig.colorbar(frame="af+lgravity (mGal)")
fig.coast(shorelines="0.5p,black", borders=["1/0.5p,black"])
fig.show()
15 changes: 13 additions & 2 deletions doc/gallery_src/forward/tesseroid_variable_density.py
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ def density(radius):
# Plot the gravitational field
fig = pygmt.Figure()

title = "Downward component of gravitational acceleration"
title = "Gravitational acceleration of variable density tesseroids"

with pygmt.config(FONT_TITLE="16p"):
fig.grdimage(
Expand All @@ -89,7 +89,18 @@ def density(radius):
cmap="viridis",
)

fig.colorbar(cmap=True, frame=["a200f50", "x+lmGal"])
# Plot edges of tesseroids
for i, tesseroid in enumerate(tesseroids):
label = "Tesseroid boundaries" if i == 0 else None
fig.plot(
x=[tesseroid[0], tesseroid[1], tesseroid[1], tesseroid[0], tesseroid[0]],
y=[tesseroid[2], tesseroid[2], tesseroid[3], tesseroid[3], tesseroid[2]],
pen="1p,red",
label=label,
)
fig.legend()

fig.colorbar(cmap=True, position="JMR", frame=["a200f50", "x+lmGal"])

fig.coast(shorelines="1p,black")

Expand Down
9 changes: 7 additions & 2 deletions doc/gallery_src/gravity_disturbance.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
import boule as bl
import ensaio
import pygmt
import verde as vd
import xarray as xr

# Load the global gravity grid
Expand All @@ -36,7 +37,11 @@
# Make a plot of data using PyGMT
fig = pygmt.Figure()

pygmt.grd2cpt(grid=disturbance, cmap="polar", continuous=True)
# Get the 99.9th percentile of the absolute value to use as color scale limits
maxabs = vd.maxabs(disturbance, percentile=99.9)

# Make colormap of data
pygmt.makecpt(cmap="balance+h0", series=[-maxabs, maxabs], background=True)

title = "Gravity disturbance of the Earth"

Expand All @@ -50,6 +55,6 @@

fig.coast(shorelines="0.5p,black", resolution="crude")

fig.colorbar(cmap=True, frame=["a100f50", "x+lmGal"])
fig.colorbar(cmap=True, frame=["x+lmGal"], position="+e")

fig.show()
9 changes: 7 additions & 2 deletions doc/gallery_src/gravity_disturbance_topofree.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
import boule as bl
import ensaio
import pygmt
import verde as vd
import xarray as xr

import harmonica as hm
Expand Down Expand Up @@ -62,7 +63,11 @@
# Make a plot of data using PyGMT
fig = pygmt.Figure()

pygmt.grd2cpt(grid=disturbance_topofree, cmap="vik+h0", continuous=True)
# Get the 99th percentile of the absolute value to use as color scale limits
maxabs = vd.maxabs(disturbance_topofree, percentile=99)

# Make colormap of data
pygmt.makecpt(cmap="balance+h0", series=[-maxabs, maxabs], background=True)

title = "Topography-free (Bouguer) gravity disturbance of the Earth"

Expand All @@ -77,6 +82,6 @@

fig.coast(shorelines="0.5p,black", resolution="crude")

fig.colorbar(cmap=True, frame=["a200f50", "x+lmGal"])
fig.colorbar(cmap=True, frame=["x+lmGal"], position="+e")

fig.show()
Loading
Loading