Skip to content
Open
Show file tree
Hide file tree
Changes from 12 commits
Commits
Show all changes
27 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
c8aaa7f
Merge branch 'main' into colormaps
mdtanker May 4, 2026
667977c
fix issues from merge
mdtanker May 4, 2026
7fa5f4e
remove print statements to show grid previews
mdtanker May 4, 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
18 changes: 9 additions & 9 deletions doc/gallery_src/equivalent_sources/block_averaged_sources.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@
"""

import ensaio
import numpy as np
import pandas as pd
import pygmt
import pyproj
Expand Down Expand Up @@ -106,14 +107,14 @@

title = "Observed magnetic anomaly data"

# Get the 99.9th percentile of the absolute value of the point data to use as color
# scale limits
cpt_lim = np.quantile(np.abs(data.total_field_anomaly_nt), 0.999)

# 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),
cmap="balance+h0",
series=[-cpt_lim, cpt_lim],
background=True,
)

Expand All @@ -129,8 +130,7 @@
cmap=True,
)

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

fig.colorbar(cmap=True, frame=["x+lnT"], position="+e")
fig.shift_origin(xshift=fig_width + 1)

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

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

fig.show()
17 changes: 9 additions & 8 deletions doc/gallery_src/equivalent_sources/cartesian.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
"""

import ensaio
import numpy as np
import pandas as pd
import pygmt
import pyproj
Expand Down Expand Up @@ -95,14 +96,14 @@

title = "Observed magnetic anomaly data"

# Get the 99.9th percentile of the absolute value of the point data to use as color
# scale limits
cpt_lim = np.quantile(np.abs(data.total_field_anomaly_nt), 0.999)

# 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),
cmap="balance+h0",
series=[-cpt_lim, cpt_lim],
background=True,
)

Expand All @@ -118,7 +119,7 @@
cmap=True,
)

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

fig.shift_origin(xshift=fig_width + 1)

Expand All @@ -131,6 +132,6 @@
cmap=True,
)

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

fig.show()
16 changes: 9 additions & 7 deletions doc/gallery_src/equivalent_sources/gradient_boosted.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@

import boule as bl
import ensaio
import numpy as np
import pandas as pd
import pygmt
import pyproj
Expand Down Expand Up @@ -115,13 +116,14 @@

title = "Observed gravity disturbance data"

# Get the 99.9th percentile of the absolute value of the point data to use as color
# scale limits
cpt_lim = np.quantile(np.abs(data.gravity_disturbance), 0.999)

# Make colormap of data
pygmt.makecpt(
cmap="vik",
series=(
-data.gravity_disturbance.quantile(0.99),
data.gravity_disturbance.quantile(0.99),
),
cmap="balance+h0",
series=[-cpt_lim, cpt_lim],
background=True,
)

Expand All @@ -137,7 +139,7 @@
cmap=True,
)

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

fig.shift_origin(xshift=fig_width + 1)

Expand All @@ -150,6 +152,6 @@
cmap=True,
)

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

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

# Get the 99.9th percentile of the absolute value of the point data to use as color
# scale limits
cpt_lim = np.quantile(np.abs(gravity_disturbance), 0.999)

# 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),
cmap="balance+h0",
series=[-cpt_lim, cpt_lim],
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.colorbar(cmap=True, frame=["x+lmGal"], position="+e")

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="+e")

fig.show()
15 changes: 12 additions & 3 deletions doc/gallery_src/forward/point_gravity.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@

maxabs = vd.maxabs(gravity) * 0.80

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,17 @@
cmap=True,
)

fig.plot(x=easting, y=northing, style="c0.2c", fill="grey")
fig.plot(
x=easting,
y=northing,
style="c0.15c",
fill="white",
pen="1p,black",
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()
4 changes: 2 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,7 @@
cmap="viridis",
)

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

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

Expand Down
16 changes: 13 additions & 3 deletions doc/gallery_src/forward/tesseroid_layer.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,14 +55,24 @@

# Plot gravity field
fig = pygmt.Figure()
maxabs = vd.maxabs(gravity.g_z)
pygmt.makecpt(cmap="polar", series=(-maxabs, maxabs))

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

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

title = "Gravitational acceleration of topography with tesseroids"

fig.grdimage(
gravity.g_z,
frame=f"+t{title}",
projection="M15c",
nan_transparent=True,
cmap=True,
)

fig.basemap(frame=True)
fig.colorbar(frame='af+l"Gravity [mGal]"', position="JCR")
fig.colorbar(frame="af+lmGal", position="JCR")
fig.coast(shorelines="0.5p,black", borders=["1/0.5p,black"])
fig.show()
4 changes: 2 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,7 @@ def density(radius):
cmap="viridis",
)

fig.colorbar(cmap=True, frame=["a200f50", "x+lmGal"])
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 @@ -18,6 +18,7 @@

import boule as bl
import ensaio
import numpy as np
import pygmt
import xarray as xr

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
cpt_lims = np.quantile(np.abs(disturbance), 0.999)

# Make colormap of data
pygmt.makecpt(cmap="balance+h0", series=[-cpt_lims, cpt_lims], 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 @@ -28,6 +28,7 @@

import boule as bl
import ensaio
import numpy as np
import pygmt
import xarray as xr

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
cpt_lims = np.quantile(np.abs(disturbance_topofree), 0.99)

# Make colormap of data
pygmt.makecpt(cmap="balance+h0", series=[-cpt_lims, cpt_lims], 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