harmonica.Ellipsoid#

class harmonica.Ellipsoid(a, b, c, yaw=0.0, pitch=0.0, roll=0.0, center=(0.0, 0.0, 0.0), *, density=None, susceptibility=None, remanent_mag=None)[source]#

Ellipsoidal body with arbitrary rotation.

Parameters:
a, b, cfloat

Semi-axis lengths of the ellipsoid in meters.

yawfloat, optional

Rotation angle about the upward axis, in degrees.

pitchfloat, optional

Rotation angle about the northing axis (after yaw rotation), in degrees. A positive pitch angle lifts the side of the ellipsoid pointing in easting direction.

rollfloat, optional

Rotation angle about the easting axis (after yaw and pitch rotation), in degrees.

centertuple of float, optional

Coordinates of the center of the ellipsoid in the following order: easting, northing, upward, in meters.

densityfloat or None, optional

Density of the ellipsoid in \(kg/m^3\).

susceptibilityfloat, (3, 3) array or None, optional

Magnetic susceptibility of the ellipsoid in SI units. A single float represents isotropic susceptibility in the body. A (3, 3) array represents the susceptibility tensor to account for anisotropy (defined in the local coordinate system of the ellipsoid). If None, zero susceptibility will be assigned to the ellipsoid.

remanent_mag(3,) array or None, optional

Remanent magnetization vector of the ellipsoid in A/m units. Its components are defined in the easting-northing-upward coordinate system and should be passed in that order. If None, no remanent magnetization will be assigned to the ellipsoid.

Notes

The three semi-axes a, b, and c are defined parallel to the easting, northing and upward directions, respectively, before applying any rotation.

Rotations directed by yaw and roll are applied using the right-hand rule across their respective axes. Pitch rotations are carried out in the opposite direction, so a positive pitch lifts the side of the ellipsoid pointing in the easting direction.

Figure showing an ellipsoid with arbitrary rotation given by the yaw, pitch and roll angles.
Attributes:
a

Length of the first semiaxis in meters.

b

Length of the second semiaxis in meters.

c

Length of the third semiaxis in meters.

density

Density of the ellipsoid in \(kg/m^3\).

remanent_mag

Remanent magnetization of the ellipsoid in A/m.

rotation_matrix

Create a rotation matrix for the ellipsoid.

susceptibility

Magnetic susceptibility of the ellipsoid in SI units.

Methods

get_surface(*[, lon_size, lat_size])

Return three arrays with a discrete representation of the ellipsoid's surface.

to_pyvista(**kwargs)

Export ellipsoid to a pyvista.PolyData object.

Ellipsoid.get_surface(*, lon_size=361, lat_size=181)[source]#

Return three arrays with a discrete representation of the ellipsoid’s surface.

Tip

Use this method to plot the ellipsoid in Matplotlib 3D plots.

Parameters:
lon_sizeint, optional

Number of points used in the latitudinal discretization.

lat_sizeint, optional

Number of points used in the longitudinal discretization.

Returns:
easting, northing, upwardarray

Arrays containing the coordinates of points in the surface of the ellipsoid.

Examples

Use this method to plot the ellipsoid in matplotlib 3D plots:

>>> import matplotlib.pyplot as plt
>>>
>>> ellipsoid = Ellipsoid(a=3, b=2, c=1, yaw=60, pitch=45, roll=70)
>>>
>>> fig = plt.figure()
>>> ax = fig.add_subplot(projection="3d")
>>> ax.plot_surface(*ellipsoid.get_surface()) 
>>> ax.set_aspect("equal")
>>> ax.set_xlabel("x") 
>>> ax.set_ylabel("y") 
>>> ax.set_zlabel("z") 
>>> plt.show()   
Ellipsoid.to_pyvista(**kwargs)[source]#

Export ellipsoid to a pyvista.PolyData object.

Important

The pyvista optional dependency must be installed to use this method.

Parameters:
kwargsdict

Keyword arguments passed to pyvista.ParametricEllipsoid.

Returns:
ellipsoidpyvista.PolyData

A PyVista’s parametric ellipsoid.

Attributes#

Ellipsoid.a#

Length of the first semiaxis in meters.

Ellipsoid.b#

Length of the second semiaxis in meters.

Ellipsoid.c#

Length of the third semiaxis in meters.

Ellipsoid.density#

Density of the ellipsoid in \(kg/m^3\).

Ellipsoid.remanent_mag#

Remanent magnetization of the ellipsoid in A/m.

Ellipsoid.rotation_matrix#

Create a rotation matrix for the ellipsoid.

Use this matrix to rotate from the local coordinate system (centered in the ellipsoid center) in to the global coordinate system (easting, northing, upward).

Returns:
rotation_matrix(3, 3) array

Rotation matrix that transforms coordinates from the local ellipsoid-aligned coordinate system to the global coordinate system.

Notes

Generate the rotation matrix from Tait-Bryan intrinsic angles: yaw, pitch, and roll. The rotations are applied in the following order: (ZŶX). Yaw (Z) and roll (X) rotations are done using the right-hand rule. Rotations for the pitch (Ŷ) are carried out in the opposite direction, so positive pitch lifts the easting axis.

Ellipsoid.susceptibility#

Magnetic susceptibility of the ellipsoid in SI units.