Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rename prisms_layer for prism_layer #223

Merged
merged 1 commit into from
Apr 13, 2021
Merged
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
4 changes: 2 additions & 2 deletions doc/api/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,8 @@ Forward modelling
point_mass_gravity
prism_gravity
tesseroid_gravity
prisms_layer
DatasetAccessorPrismsLayer
prism_layer
DatasetAccessorPrismLayer

Isostasy
--------
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@

One way to model three dimensional structures is to create a set of prisms that
approximates their geometry and its physical properties (density,
susceptibility, etc.). The :func:`harmonica.prisms_layer` offers a simple way
susceptibility, etc.). The :func:`harmonica.prism_layer` offers a simple way
to create a layer of prisms: a regular grid of prisms of equal size on the
horizontal directions with variable top and bottom boundaries. It returns
a :class:`xarray.Dataset` with the coordinates of the centers of the prisms and
Expand All @@ -33,7 +33,7 @@
(easting, northing) = vd.grid_coordinates(region=region, spacing=spacing)
surface = 100 * np.exp(-((easting - 50e3) ** 2 + northing ** 2) / 1e9)
density = 2670.0 * np.ones_like(surface)
prisms = hm.prisms_layer(
prisms = hm.prism_layer(
coordinates=(easting[0, :], northing[:, 0]),
surface=surface,
reference=0,
Expand All @@ -42,7 +42,7 @@

# Compute gravity field of prisms on a regular grid of observation points
coordinates = vd.grid_coordinates(region, spacing=spacing, extra_coords=1e3)
gravity = prisms.prisms_layer.gravity(coordinates, field="g_z")
gravity = prisms.prism_layer.gravity(coordinates, field="g_z")

# Plot gravity field
plt.pcolormesh(*coordinates[:2], gravity)
Expand Down
6 changes: 3 additions & 3 deletions examples/forward/prisms_topo_gravity.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
Gravitational effect of topography
==================================

One possible application of the :func:`harmonica.prisms_layer` function is to
One possible application of the :func:`harmonica.prism_layer` function is to
create a model of the terrain and compute its gravity effect. Here we will use
a regular grid of topographic and bathymetric heights for South Africa to
create a prisms layer that model the terrain with a density of 2670 kg/m^3 and
Expand Down Expand Up @@ -43,7 +43,7 @@
density = density.where(south_africa_topo >= 0, 1000 - 2900)

# Create layer of prisms
prisms = hm.prisms_layer(
prisms = hm.prism_layer(
(south_africa_topo.easting, south_africa_topo.northing),
surface=south_africa_topo.values,
reference=0,
Expand All @@ -56,7 +56,7 @@
)
easting, northing = projection(*coordinates[:2])
coordinates_projected = (easting, northing, coordinates[-1])
prisms_gravity = prisms.prisms_layer.gravity(coordinates_projected, field="g_z")
prisms_gravity = prisms.prism_layer.gravity(coordinates_projected, field="g_z")

# Make a plot of the computed gravity
plt.figure(figsize=(8, 8))
Expand Down
2 changes: 1 addition & 1 deletion harmonica/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
from .forward.point_mass import point_mass_gravity
from .forward.tesseroid import tesseroid_gravity
from .forward.prism import prism_gravity
from .forward.prisms_layer import prisms_layer, DatasetAccessorPrismsLayer
from .forward.prism_layer import prism_layer, DatasetAccessorPrismLayer
from .equivalent_layer.harmonic import EQLHarmonic
from .equivalent_layer.harmonic_spherical import EQLHarmonicSpherical

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
from .prism import prism_gravity


def prisms_layer(
def prism_layer(
coordinates,
surface,
reference,
Expand All @@ -32,7 +32,7 @@ def prisms_layer(
``northing`` coordinates correspond to the location of the center of each
prism.

The ``prisms_layer`` dataset accessor can be used to access special methods
The ``prism_layer`` dataset accessor can be used to access special methods
and attributes for the layer of prisms, like the horizontal dimensions of
the prisms, getting the boundaries of each prisms, etc.
See :class:`XarrayAcessorPrismLayer` for the definition of these methods
Expand Down Expand Up @@ -85,7 +85,7 @@ def prisms_layer(
>>> surface = np.arange(20, dtype=float).reshape((4, 5))
>>> density = 2670.0 * np.ones_like(surface)
>>> # Define a layer of prisms
>>> prisms = prisms_layer(
>>> prisms = prism_layer(
... (easting, northing),
... surface,
... reference=0,
Expand All @@ -105,10 +105,10 @@ def prisms_layer(
coords_units: meters
properties_units: SI
>>> # Get the boundaries of the layer (will exceed the region)
>>> print(prisms.prisms_layer.boundaries)
>>> print(prisms.prism_layer.boundaries)
(-1.25, 11.25, 1.0, 9.0)
>>> # Get the boundaries of one of the prisms
>>> print(prisms.prisms_layer.get_prism((0, 2)))
>>> print(prisms.prism_layer.get_prism((0, 2)))
(3.75, 6.25, 1.0, 3.0, 0.0, 2.0)
""" # noqa: W505
dims = ("northing", "easting")
Expand All @@ -128,7 +128,7 @@ def prisms_layer(
attrs = {"coords_units": "meters", "properties_units": "SI"}
prisms.attrs = attrs
# Create the top and bottom coordinates of the prisms
prisms.prisms_layer.update_top_bottom(surface, reference)
prisms.prism_layer.update_top_bottom(surface, reference)
return prisms


Expand All @@ -146,20 +146,20 @@ def _check_regular_grid(easting, northing):
raise ValueError("Passed northing coordiantes are not evenly spaced.")


@xr.register_dataset_accessor("prisms_layer")
class DatasetAccessorPrismsLayer:
@xr.register_dataset_accessor("prism_layer")
class DatasetAccessorPrismLayer:
"""
Defines dataset accessor for layer of prisms

.. warning::

This class is not intended to be initialized.
Use the `prisms_layer` accessor for accessing the methods and
Use the `prism_layer` accessor for accessing the methods and
attributes of this class.

See also
--------
harmonica.prisms_layer
harmonica.prism_layer
"""

def __init__(self, xarray_obj):
Expand Down
Loading