Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
20 commits
Select commit Hold shift + click to select a range
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
2 changes: 1 addition & 1 deletion .github/environment.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ dependencies:
- xrft>=1.0
- choclo>=0.1
- boule>=0.6.0
- bordado>=0.4.0
# Build
- python-build
- twine
Expand All @@ -30,7 +31,6 @@ dependencies:
- ipykernel
- boule
- pyproj
- bordado>=0.4.0
- ensaio>=0.5.*
- netcdf4
- matplotlib
Expand Down
1 change: 1 addition & 0 deletions doc/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@
"pooch": ("https://www.fatiando.org/pooch/latest/", None),
"ensaio": ("https://www.fatiando.org/ensaio/latest/", None),
"verde": ("https://www.fatiando.org/verde/latest/", None),
"bordado": ("https://www.fatiando.org/bordado/latest/", None),
"boule": ("https://www.fatiando.org/boule/latest/", None),
"matplotlib": ("https://matplotlib.org/", None),
"pyproj": ("https://pyproj4.github.io/pyproj/stable/", None),
Expand Down
3 changes: 2 additions & 1 deletion doc/install.rst
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,8 @@ Required:
* `scikit-learn <https://scikit-learn.org>`__
* `pooch <http://www.fatiando.org/pooch/>`__
* `verde <http://www.fatiando.org/verde/>`__
* `bordado <http://www.fatiando.org/bordado/>`__
* `boule <http://www.fatiando.org/boule/>`__
* `xrft <https://xrft.readthedocs.io/>`__

Optional:
Expand All @@ -92,7 +94,6 @@ Optional:

The examples in the :ref:`gallery` also use:

* `boule <http://www.fatiando.org/boule/>`__
* `ensaio <http://www.fatiando.org/ensaio/>`__ for downloading sample datasets
* `pygmt <https://www.pygmt.org/>`__ for plotting maps
* `pyproj <https://jswhit.github.io/pyproj/>`__ for cartographic projections
16 changes: 8 additions & 8 deletions doc/user_guide/coordinate_systems.rst
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ height:

.. jupyter-execute::

import verde as vd
import bordado as bd

# Define boundaries of the rectangular prism (in meters)
west, east, south, north = -20, 20, -20, 20
Expand All @@ -45,8 +45,8 @@ Or a regular grid of points at 100 meters above the zeroth plane:
.. jupyter-execute::

# Define a regular grid of observation points (coordinates in meters)
coordinates = vd.grid_coordinates(
region=(-40, 40, -40, 40), shape=(5, 5), extra_coords=100
coordinates = bd.grid_coordinates(
region=(-40, 40, -40, 40), shape=(5, 5), non_dimensional_coords=100
)
easting, northing, upward = coordinates[:]

Expand Down Expand Up @@ -103,12 +103,12 @@ Spatial data are usually given in geodetic coordinates, along with the
reference ellipsoid on which they are defined.

For example, let's define a regular grid of points (separated by equal
angles) at 2km above the ellipsoid using :mod:`verde`.
angles) at 2km above the ellipsoid using :mod:`bordado`.

.. jupyter-execute::

coordinates = vd.grid_coordinates(
region=(-70, -65, -35, -30), shape=(6, 6), extra_coords=2e3
coordinates = bd.grid_coordinates(
region=(-70, -65, -35, -30), shape=(6, 6), non_dimensional_coords=2e3
)
longitude, latitude, height = coordinates[:]
print("longitude:", longitude)
Expand Down Expand Up @@ -199,10 +199,10 @@ the same radius equal to the *mean radius of the Earth*.

.. jupyter-execute::

coordinates = vd.grid_coordinates(
coordinates = bd.grid_coordinates(
region=(-70, -65, -35, -30),
shape=(6, 6),
extra_coords=ellipsoid.mean_radius,
non_dimensional_coords=ellipsoid.mean_radius,
)
longitude, sph_latitude, radius = coordinates[:]
print("longitude:", longitude)
Expand Down
15 changes: 8 additions & 7 deletions doc/user_guide/equivalent_sources/block-averaged-eqs.rst
Original file line number Diff line number Diff line change
Expand Up @@ -44,10 +44,10 @@ the data:

.. jupyter-execute::

import verde as vd
import bordado as bd

region = (-5.5, -4.7, 57.8, 58.5)
inside = vd.inside((data.longitude, data.latitude), region)
inside = bd.inside((data.longitude, data.latitude), region)
data = data[inside]
data

Expand All @@ -60,7 +60,7 @@ And project the geographic coordinates to plain Cartesian ones:
projection = pyproj.Proj(proj="merc", lat_ts=data.latitude.mean())
easting, northing = projection(data.longitude.values, data.latitude.values)
coordinates = (easting, northing, data.height_m)
xy_region=vd.get_region(coordinates)
xy_region = bd.get_region((easting, northing))


.. jupyter-execute::
Expand All @@ -77,9 +77,10 @@ And project the geographic coordinates to plain Cartesian ones:

.. jupyter-execute::

import verde as vd
import pygmt

maxabs = vd.maxabs(data.total_field_anomaly_nt)*.8
maxabs = vd.maxabs(data.total_field_anomaly_nt) * .8

# Set figure properties
w, e, s, n = xy_region
Expand Down Expand Up @@ -167,10 +168,10 @@ we are efectivelly upward continuing the data.

.. jupyter-execute::

grid_coords = vd.grid_coordinates(
region=vd.get_region(coordinates),
grid_coords = bd.grid_coordinates(
region=bd.get_region((easting, northing)),
spacing=500,
extra_coords=1500,
non_dimensional_coords=1500,
)
grid = eqs.grid(grid_coords, data_names=["magnetic_anomaly"])
grid
Expand Down
8 changes: 5 additions & 3 deletions doc/user_guide/equivalent_sources/eq-sources-spherical.rst
Original file line number Diff line number Diff line change
Expand Up @@ -98,15 +98,17 @@ of 6 arcminutes.

.. jupyter-execute::

import bordado as bd

# Get the bounding region of the data in geodetic coordinates
region = vd.get_region((data.longitude, data.latitude))
region = bd.get_region((data.longitude, data.latitude))

# Get the maximum height of the data coordinates
max_height = data.height_sea_level_m.max()

# Define a regular grid of points in geodetic coordinates
grid_coords = vd.grid_coordinates(
region=region, spacing=6 / 60, extra_coords=max_height
grid_coords = bd.grid_coordinates(
region=region, spacing=6 / 60, non_dimensional_coords=max_height
)

But before we can tell the equivalent sources to predict the
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -175,12 +175,14 @@ And grid the data using the two equivalent sources:

.. jupyter-execute::

import bordado as bd

# Define grid coordinates
region = vd.get_region(coordinates)
grid_coords = vd.grid_coordinates(
region = bd.get_region((easting, northing))
Comment thread
leouieda marked this conversation as resolved.
grid_coords = bd.grid_coordinates(
region=region,
spacing=2e3,
extra_coords=2.5e3,
non_dimensional_coords=2.5e3,
)

grid_first_guess = eqs_first_guess.grid(grid_coords)
Expand Down
11 changes: 7 additions & 4 deletions doc/user_guide/equivalent_sources/gradient-boosted-eqs.rst
Original file line number Diff line number Diff line change
Expand Up @@ -125,12 +125,13 @@ And then predict the field on a regular grid of computation points:

.. jupyter-execute::

import verde as vd
region = vd.get_region(coordinates)
grid_coords = vd.grid_coordinates(
import bordado as bd

region = bd.get_region((easting, northing))
grid_coords = bd.grid_coordinates(
region=region,
spacing=5e3,
extra_coords=2.5e3,
non_dimensional_coords=2.5e3,
)
grid = eqs.grid(grid_coords, data_names=["gravity_disturbance"])
grid
Expand All @@ -141,6 +142,8 @@ point. We can do so through the :func:`verde.distance_mask` function.

.. jupyter-execute::

import verde as vd

grid_masked = vd.distance_mask(coordinates, maxdist=50e3, grid=grid)

And plot it:
Expand Down
11 changes: 7 additions & 4 deletions doc/user_guide/equivalent_sources/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -59,11 +59,11 @@ coordinates, so we need to project these gravity observations:
.. jupyter-execute::

import pyproj
import verde as vd
import bordado as bd

projection = pyproj.Proj(proj="merc", lat_ts=data.latitude.values.mean())
easting, northing = projection(data.longitude.values, data.latitude.values)
region = vd.get_region((easting, northing))
region = bd.get_region((easting, northing))

Now we can initialize the :class:`harmonica.EquivalentSources` class.

Expand Down Expand Up @@ -131,6 +131,7 @@ And plot it:
.. jupyter-execute::

import pygmt
import verde as vd

# Get max absolute value for the observed gravity disturbance
maxabs = vd.maxabs(data.gravity_disturbance_mgal)
Expand Down Expand Up @@ -176,7 +177,7 @@ And plot it:

We can also *grid* and *upper continue* the field by predicting its values on
a regular grid at a constant height higher than the observations. To do so we
can use the :func:`verde.grid_coordinates` function to create the coordinates
can use the :func:`bordado.grid_coordinates` function to create the coordinates
of the grid and then use the :meth:`harmonica.EquivalentSources.grid` method.

First, lets get the maximum height of the observations:
Expand All @@ -191,7 +192,9 @@ and use the equivalent sources to generate a gravity disturbance grid.
.. jupyter-execute::

# Build the grid coordinates
grid_coords = vd.grid_coordinates(region=region, spacing=2e3, extra_coords=2.2e3)
grid_coords = bd.grid_coordinates(
region=region, spacing=2e3, non_dimensional_coords=2.2e3
)

# Grid the gravity disturbances
grid = equivalent_sources.grid(grid_coords, data_names=["gravity_disturbance"])
Expand Down
6 changes: 3 additions & 3 deletions doc/user_guide/forward_modelling/dipole.rst
Original file line number Diff line number Diff line change
Expand Up @@ -60,13 +60,13 @@ Let's define a regular grid of observation points:

.. jupyter-execute::

import verde as vd
import bordado as bd

region = (-100, 100, -100, 100)
spacing = 1
height = 0
coordinates = vd.grid_coordinates(
region=region, spacing=spacing, extra_coords=height
coordinates = bd.grid_coordinates(
region=region, spacing=spacing, non_dimensional_coords=height
)

And a set of dipoles with their magnetic moments:
Expand Down
11 changes: 6 additions & 5 deletions doc/user_guide/forward_modelling/point.rst
Original file line number Diff line number Diff line change
Expand Up @@ -70,10 +70,10 @@ height:

.. jupyter-execute::

import verde as vd
import bordado as bd

coordinates = vd.grid_coordinates(
region=(-250, 1250, -250, 1250), shape=(40, 40), extra_coords=0
coordinates = bd.grid_coordinates(
region=(-250, 1250, -250, 1250), shape=(40, 40), non_dimensional_coords=0
)

And finally calculate the vertical component of the gravitational acceleration
Expand Down Expand Up @@ -106,6 +106,7 @@ Lets plot this gravitational field:
.. jupyter-execute::

import pygmt
import verde as vd

grid = vd.make_xarray_grid(
coordinates, g_z, data_names="g_z", extra_coords_names="extra")
Expand Down Expand Up @@ -200,10 +201,10 @@ coordinates and located at 1km above the ellipsoid:

.. jupyter-execute::

coordinates = vd.grid_coordinates(
coordinates = bd.grid_coordinates(
region=(-72, -68, -46, -42),
shape=(101, 101),
extra_coords=20e3,
non_dimensional_coords=20e3,
)

Before we can start forward modelling these sources, we need to convert them to
Expand Down
26 changes: 16 additions & 10 deletions doc/user_guide/forward_modelling/prism.rst
Original file line number Diff line number Diff line change
Expand Up @@ -61,12 +61,14 @@ Build a regular grid of computation points located 10m above the zero height:

.. jupyter-execute::

import verde as vd
import bordado as bd

region = (-10e3, 10e3, -10e3, 10e3)
shape = (51, 51)
height = 10
coordinates = vd.grid_coordinates(region, shape=shape, extra_coords=height)
coordinates = bd.grid_coordinates(
region, shape=shape, non_dimensional_coords=height
)

Define a single prism:

Expand Down Expand Up @@ -164,10 +166,10 @@ height:

.. jupyter-execute::

import verde as vd
import bordado as bd

coordinates = vd.grid_coordinates(
region=(0, 10e3, 0, 10e3), shape=(40, 40), extra_coords=0
coordinates = bd.grid_coordinates(
region=(0, 10e3, 0, 10e3), shape=(40, 40), non_dimensional_coords=0
)

And finally calculate the vertical component of the gravitational acceleration
Expand Down Expand Up @@ -200,6 +202,8 @@ Lets plot this gravitational field:
.. jupyter-execute::

import pygmt
import verde as vd

grid = vd.make_xarray_grid(
coordinates, g_z, data_names="g_z", extra_coords_names="extra")
fig = pygmt.Figure()
Expand Down Expand Up @@ -253,7 +257,9 @@ points by choosing ``field="b"``:
region = (-10e3, 10e3, -10e3, 10e3)
shape = (51, 51)
height = 10
coordinates = vd.grid_coordinates(region, shape=shape, extra_coords=height)
coordinates = bd.grid_coordinates(
region, shape=shape, non_dimensional_coords=height
)

.. jupyter-execute::

Expand Down Expand Up @@ -364,7 +370,7 @@ Then we can define a regular grid where the centers of the prisms will fall:

.. jupyter-execute::

easting, northing = vd.grid_coordinates(region=region, spacing=spacing)
easting, northing = bd.grid_coordinates(region=region, spacing=spacing)

We need to define a 2D array for the uppermost *surface* of the layer. We will
sample a trigonometric function for this simple example:
Expand Down Expand Up @@ -396,9 +402,9 @@ Let's define a grid of observation points at 1 km above the zeroth height:

.. jupyter-execute::

region_pad = vd.pad_region(region, 10e3)
coordinates = vd.grid_coordinates(
region_pad, spacing=spacing, extra_coords=1e3
region_pad = bd.pad_region(region, 10e3)
coordinates = bd.grid_coordinates(
region_pad, spacing=spacing, non_dimensional_coords=1e3
)


Expand Down
Loading
Loading