-
Notifications
You must be signed in to change notification settings - Fork 69
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Forward modelling for point masses in Cartesian coordiantes (#71)
Extend existing point mass forward modelling to Cartesian coordinates. Improve docstring of point_mass_gravity function by adding mathematical definitions and references. Add tests and a gallery example for the extended feature.
- Loading branch information
1 parent
12a1d95
commit 16c58fe
Showing
5 changed files
with
361 additions
and
49 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
""" | ||
Point Mass in Cartesian Coordinates | ||
=================================== | ||
The simplest geometry used to compute gravitational fields are point masses. | ||
Although modelling geologic structures with point masses can be challenging, they are | ||
very usefull for other purposes: creating synthetic models, solving inverse problems | ||
very quickly, generating equivalent sources for interpolation or gridding, etc. | ||
The gravitational fields generated by point masses can be quickly computed | ||
either in Cartesian or in geocentric spherical coordinate systems. | ||
We will compute the downward component of the gravitational acceleration generated by | ||
a set of point masses on a computation grid given in Cartesian coordinates. We will do | ||
it throught the :func:`harmonica.point_mass_gravity` function. | ||
""" | ||
import harmonica as hm | ||
import verde as vd | ||
import matplotlib.pyplot as plt | ||
import matplotlib.ticker | ||
|
||
|
||
# Define two point masses with oposite mass values of 10000000 kg | ||
easting = [5e3, 15e3] | ||
northing = [5e3, 15e3] | ||
down = [7e3, 2.5e3] | ||
points = [easting, northing, down] | ||
# We're using "negative" masses to represent a "mass deficit" | ||
masses = [10e6, -10e6] | ||
|
||
# Define computation points on a grid at 500m above the ground | ||
coordinates = vd.grid_coordinates( | ||
region=[0, 20e3, 0, 20e3], shape=(80, 80), extra_coords=-500 | ||
) | ||
|
||
# Compute the downward component of the acceleration | ||
gravity = hm.point_mass_gravity( | ||
coordinates, points, masses, field="g_z", coordinate_system="cartesian" | ||
) | ||
print(gravity) | ||
|
||
# Plot the gravitational field | ||
fig, ax = plt.subplots(figsize=(8, 9)) | ||
ax.set_aspect("equal") | ||
img = plt.pcolormesh(*coordinates[:2], gravity) | ||
# Add colorbar | ||
fmt = matplotlib.ticker.ScalarFormatter(useMathText=True) | ||
fmt.set_powerlimits((0, 0)) | ||
plt.colorbar(img, ax=ax, format=fmt, pad=0.04, shrink=0.73, label="mGal") | ||
ax.set_title("Downward component of gravitational acceleration") | ||
# Convert axes units to km | ||
ax.set_xticklabels(ax.get_xticks() * 1e-3) | ||
ax.set_yticklabels(ax.get_yticks() * 1e-3) | ||
ax.set_xlabel("km") | ||
ax.set_ylabel("km") | ||
plt.show() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.