Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
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