Skip to content

Commit b3de1e4

Browse files
committed
Use Bordado instead of Verde to make coordinates in docs
The new package took over the coordinate generation functions from Verde. So best to use it in our docs. Don't rely on the magic Verde function for creating DataArray and make it manually instead.
1 parent 82cad7b commit b3de1e4

4 files changed

Lines changed: 33 additions & 23 deletions

File tree

doc/conf.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,9 +37,10 @@
3737
"python": ("https://docs.python.org/3/", None),
3838
"numpy": ("https://numpy.org/doc/stable/", None),
3939
"xarray": ("https://docs.xarray.dev/en/stable/", None),
40+
"pandas": ("https://pandas.pydata.org/docs/", None),
4041
"pygmt": ("https://www.pygmt.org/latest/", None),
4142
"ensaio": ("https://www.fatiando.org/ensaio/latest/", None),
42-
"verde": ("https://www.fatiando.org/verde/latest/", None),
43+
"bordado": ("https://www.fatiando.org/bordado/latest/", None),
4344
}
4445

4546
# Autosummary pages will be generated by sphinx-autogen instead of sphinx-build

doc/user_guide/normal_gravity.rst

Lines changed: 29 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,8 @@ It can operate on single values:
2323
gamma = bl.WGS84.normal_gravity(coordinates=(0, 45, 500))
2424
print(f"{gamma:.2f} mGal")
2525

26-
Or on numpy array-like data (including ``pandas.DataFrame`` and
27-
``xarray.DataArray``):
26+
Or on numpy array-like data (including :class:`pandas.DataFrame` and
27+
:class:`xarray.DataArray`):
2828

2929
.. jupyter-execute::
3030

@@ -34,25 +34,30 @@ Or on numpy array-like data (including ``pandas.DataFrame`` and
3434
gamma = bl.WGS84.normal_gravity(coordinates=(0, 45, height))
3535
print(gamma)
3636

37-
The arrays can be multi-dimensional so we can use :mod:`verde` to generate a
38-
grid of normal gravity:
37+
The arrays can be multi-dimensional so we can use :mod:`bordado` to generate a
38+
grid of normal gravity (the non-dimensional coordinate is the geometric height,
39+
which is constant):
3940

4041
.. jupyter-execute::
4142

42-
import verde as vd
43+
import bordado as bd
4344

44-
coordinates = vd.grid_coordinates(
45-
region=[0, 360, -90, 90], spacing=0.5, extra_coords=10_000,
45+
coordinates = bd.grid_coordinates(
46+
region=[0, 360, -90, 90], spacing=0.5, non_dimensional_coords=10_000,
4647
)
4748
gamma = bl.WGS84.normal_gravity(coordinates)
4849
print(gamma)
4950

50-
Which can be put in a :class:`xarray.Dataset`:
51+
Which can be put in a :class:`xarray.DataArray` for convenience:
5152

5253
.. jupyter-execute::
5354

54-
grid = vd.make_xarray_grid(
55-
coordinates[:2], gamma, data_names="normal_gravity",
55+
import xarray as xr
56+
57+
grid = xr.DataArray(
58+
gamma,
59+
coords={"longitude": coordinates[0][0, :], "latitude": coordinates[1][:, 0]},
60+
dims=("latitude", "longitude"),
5661
)
5762
grid
5863

@@ -73,7 +78,7 @@ And plotted with :mod:`pygmt`:
7378
import pygmt
7479

7580
fig = pygmt.Figure()
76-
fig.grdimage(grid.normal_gravity, projection="W20c", cmap="viridis")
81+
fig.grdimage(grid, projection="W20c", cmap="viridis")
7782
fig.basemap(frame=["af", "WEsn"])
7883
fig.colorbar(position="JCB+w10c", frame=["af", 'y+l"mGal"', 'x+l"WGS84"'])
7984
fig.show()
@@ -98,12 +103,14 @@ These calculations can be performed for any oblate ellipsoid (see
98103

99104
gamma_mars = bl.Mars2009.normal_gravity(coordinates)
100105

101-
grid_mars = vd.make_xarray_grid(
102-
coordinates[:2], gamma_mars, data_names="normal_gravity",
106+
grid_mars = xr.DataArray(
107+
gamma_mars,
108+
coords={"longitude": coordinates[0][0, :], "latitude": coordinates[1][:, 0]},
109+
dims=("latitude", "longitude"),
103110
)
104111

105112
fig = pygmt.Figure()
106-
fig.grdimage(grid_mars.normal_gravity, projection="W20c", cmap="lajolla")
113+
fig.grdimage(grid_mars, projection="W20c", cmap="lajolla")
107114
fig.basemap(frame=["af", "WEsn"])
108115
fig.colorbar(position="JCB+w10c", frame=["af", 'y+l"mGal"', 'x+l"Mars"'])
109116
fig.show()
@@ -147,17 +154,19 @@ This is what the normal gravity of Moon looks like on a map:
147154

148155
.. jupyter-execute::
149156

150-
coordinates = vd.grid_coordinates(
151-
region=[0, 360, -90, 90], spacing=0.5, extra_coords=10_000,
157+
coordinates = bd.grid_coordinates(
158+
region=[0, 360, -90, 90], spacing=0.5, non_dimensional_coords=10_000,
152159
)
153-
gamma = bl.Moon2015.normal_gravity(coordinates)
160+
gamma_moon = bl.Moon2015.normal_gravity(coordinates)
154161

155-
grid = vd.make_xarray_grid(
156-
coordinates[:2], gamma, data_names="normal_gravity",
162+
grid_moon = xr.DataArray(
163+
gamma_moon,
164+
coords={"longitude": coordinates[0][0, :], "latitude": coordinates[1][:, 0]},
165+
dims=("latitude", "longitude"),
157166
)
158167

159168
fig = pygmt.Figure()
160-
fig.grdimage(grid.normal_gravity, projection="W20c", cmap="lapaz")
169+
fig.grdimage(grid_moon, projection="W20c", cmap="lapaz")
161170
fig.basemap(frame=["af", "WEsn"])
162171
fig.colorbar(position="JCB+w10c", frame=["af", 'y+l"mGal"', 'x+l"Moon"'])
163172
fig.show()

env/requirements-docs.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ sphinx-copybutton==0.5.*
66
sphinx-design==0.5.*
77
jupyter-sphinx==0.5.*
88
ensaio
9-
verde
9+
bordado
1010
pandas
1111
matplotlib
1212
xarray

environment.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ dependencies:
2626
- sphinx-design==0.5.*
2727
- jupyter-sphinx==0.5.*
2828
- ensaio
29-
- verde
29+
- bordado
3030
- pandas
3131
- matplotlib
3232
- xarray

0 commit comments

Comments
 (0)