.. DO NOT EDIT. .. THIS FILE WAS AUTOMATICALLY GENERATED BY SPHINX-GALLERY. .. TO MAKE CHANGES, EDIT THE SOURCE PYTHON FILE: .. "gallery/forward/point_gravity.py" .. LINE NUMBERS ARE GIVEN BELOW. .. only:: html .. note:: :class: sphx-glr-download-link-note Click :ref:`here ` to download the full example code .. rst-class:: sphx-glr-example-title .. _sphx_glr_gallery_forward_point_gravity.py: Point Masses 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 useful for other purposes: creating synthetic models, solving inverse problems, generating equivalent sources for interpolation, 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 gravitational acceleration generated by a set of point masses on a computation grid given in Cartesian coordinates using the :func:`harmonica.point_gravity` function. .. GENERATED FROM PYTHON SOURCE LINES 21-75 .. image-sg:: /gallery/forward/images/sphx_glr_point_gravity_001.png :alt: point gravity :srcset: /gallery/forward/images/sphx_glr_point_gravity_001.png :class: sphx-glr-single-img .. rst-class:: sphx-glr-script-out Out: .. code-block:: none [[ 0.00181314 0.00190983 0.00200888 ... -0.00328218 -0.0032428 -0.00320183] [ 0.00196785 0.00207626 0.00218766 ... -0.0034324 -0.00338955 -0.00334507] [ 0.0021343 0.00225579 0.00238107 ... -0.00359128 -0.00354465 -0.00349633] ... [-0.0014489 -0.00151296 -0.0015806 ... -0.01802268 -0.01727698 -0.01655213] [-0.00144777 -0.00151078 -0.00157723 ... -0.01697132 -0.0162955 -0.01563681] [-0.00144484 -0.00150675 -0.00157197 ... -0.01599028 -0.01537726 -0.01477824]] | .. code-block:: default import pygmt import verde as vd import harmonica as hm # Define the coordinates for two point masses easting = [5e3, 15e3] northing = [7e3, 13e3] # The vertical coordinate is positive upward so negative numbers represent # depth upward = [-0.5e3, -1e3] points = [easting, northing, upward] # We're using "negative" masses to represent a "mass deficit" since we assume # measurements are gravity disturbances, not actual gravity values. masses = [3e11, -10e11] # Define computation points on a grid at 500m above the ground coordinates = vd.grid_coordinates( region=[0, 20e3, 0, 20e3], shape=(100, 100), extra_coords=500 ) # Compute the downward component of the gravitational acceleration gravity = hm.point_gravity( coordinates, points, masses, field="g_z", coordinate_system="cartesian" ) print(gravity) grid = vd.make_xarray_grid( coordinates, gravity, data_names="gravity", extra_coords_names="extra" ) # Plot the results on a map fig = pygmt.Figure() title = "Gravitational acceleration (downward)" maxabs = vd.maxabs(gravity) * 0.80 pygmt.makecpt(cmap="vik", series=(-maxabs, maxabs, 0.3)) with pygmt.config(FONT_TITLE="16p"): fig.grdimage( region=[0, 20e3, 0, 20e3], projection="X10c", grid=grid.gravity, dpi=1000, frame=["a", f"+t{title}", "x+lm", "y+lm"], cmap=True, ) fig.plot(x=easting, y=northing, style="c0.2c", color="grey") fig.colorbar(cmap=True, position="JMR", frame=["a.6f.2", "x+lmGal"]) fig.show() .. rst-class:: sphx-glr-timing **Total running time of the script:** ( 0 minutes 4.259 seconds) .. _sphx_glr_download_gallery_forward_point_gravity.py: .. only :: html .. container:: sphx-glr-footer :class: sphx-glr-footer-example .. container:: sphx-glr-download sphx-glr-download-python :download:`Download Python source code: point_gravity.py ` .. container:: sphx-glr-download sphx-glr-download-jupyter :download:`Download Jupyter notebook: point_gravity.ipynb ` .. only:: html .. rst-class:: sphx-glr-signature `Gallery generated by Sphinx-Gallery `_