API

Main functions

class meshslice.meshslice_sph.MeshPlotSph(mesh, lat: Optional[float] = None, lon: Optional[float] = None, rotangle: float = 0.0, depth: Optional[float] = None, rotlat: Optional[float] = None, rotlon: Optional[float] = None, get_mean: bool = True, opacity: bool = False, meshname: str = 'RF', cmapname: str = 'seismic', cmapsym: bool = True, clim: Optional[List[float]] = None, debug: bool = True, outputdir: str = '.', use_ipyvtk: bool = False, figures_only: bool = False, test: bool = False, fmt: str = 'pdf')[source]
meshslice.read_mesh.read_mesh(filename: str)[source]

Utilities

meshslice.utils.cart2geo.cart2geo(x: float, y: float, z: float) -> (<class 'float'>, <class 'float'>, <class 'float'>)[source]

Computes Cartesian coordinates from geographical coordinates.

Parameters
xfloat or numpy.ndarray or list

Radius

yfloat or numpy.ndarray or list

Latitude (-90, 90)

zfloat or numpy.ndarray or list

Longitude (-180, 180)

Returns
float or np.ndarray or list, float or np.ndarray or list, float or np.ndarray or list

(r, theta, phi)

meshslice.utils.cart2pol.cart2pol(x, y)[source]
meshslice.utils.cart2sph.cart2sph(x: float, y: float, z: float) -> (<class 'float'>, <class 'float'>, <class 'float'>)[source]

Computes Cartesian coordinates from geographical coordinates.

Parameters
xfloat or numpy.ndarray or list

Radius

yfloat or numpy.ndarray or list

Latitude (-90, 90)

zfloat or numpy.ndarray or list

Longitude (-180, 180)

Returns
float or np.ndarray or list, float or np.ndarray or list, float or np.ndarray or list

(r, theta, phi)

meshslice.utils.geo2cart.geo2cart(r: float, theta: float, phi: float) -> (<class 'float'>, <class 'float'>, <class 'float'>)[source]

Computes Cartesian coordinates from geographical coordinates.

Parameters
rfloat or numpy.ndarray or list

Radius

thetafloat or numpy.ndarray or list

Latitude (-90, 90)

phifloat or numpy.ndarray or list

Longitude (-180, 180)

Returns
float or np.ndarray or list, float or np.ndarray or list, float or np.ndarray or list

(x, y, z)

meshslice.utils.map_axes.map_axes(proj: str = 'moll', central_longitude=0.0) → matplotlib.axes._axes.Axes[source]

Creates matplotlib axes with map projection taken from cartopy.

Parameters
proj: str, optional

shortname for mapprojection ‘moll’, ‘carr’, by default “moll”

Returns
plt.Axes

Matplotlib axes with projection

Raises
ValueError

If non supported shortname for axes is given

Notes

Author

Lucas Sawade (lsawade@princeton.edu)

Last Modified

2021.01.13 20.30

Examples

>>> from lwsspy import map_axes
>>> map_axes()
meshslice.utils.plot_map.plot_map(fill=True, zorder=None, labelstopright: bool = True, labelsbottomleft: bool = True, borders: bool = True, rivers: bool = False, lakes: bool = False)[source]

Plots map into existing axes.

Parameters
fillbool, optional

fills the continents in light gray, by default True

zorderint, optional

zorder of the map, by default -10

projectioncartopy.crs.projection, optional

projection to be used for the map.

labelstoprightbool, optional

flag to turn on or off the ticks

labelsbottomleftbool, optional

flag to turn on or off the ticks

bordersbool

plot borders. Default True

riversbool

plot rivers. Default False

lakesbool

plot lakes. Default True

Returns
matplotlib.pyplot.Axes

Axes in which the map was plotted

Notes

Author

Lucas Sawade (lsawade@princeton.edu)

Last Modified

2020.01.07 16.30

meshslice.utils.pol2cart.pol2cart(rho, phi)[source]
meshslice.utils.rotation_matrix.rotation_matrix(axis, theta)[source]

Return the rotation matrix associated with counterclockwise rotation about the given axis by theta radians.

meshslice.utils.sph2cart.sph2cart(r: float, theta: float, phi: float) -> (<class 'float'>, <class 'float'>, <class 'float'>)[source]

Computes Cartesian coordinates from geographical coordinates.

Parameters
rfloat or numpy.ndarray or list

Radius

thetafloat or numpy.ndarray or list

Theta (0, pi)

phifloat or numpy.ndarray or list

phi (0, 2*pi)

Returns
float or np.ndarray or list, float or np.ndarray or list, float or np.ndarray or list

(x, y, z)

class meshslice.utils.SphericalNN.SphericalNN(lat, lon)[source]

Spherical nearest neighbour queries using scipy’s fast kd-tree implementation.

Notes

Authors

Lucas Sawade (lsawade@princeton.edu)

Last Modified

2020.01.07 19.00

Attributes
datanumpy.ndarray

cartesian point data array [x,y,z]

kd_treescipy.spatial.cKDTree

a KDTree used to query data

Methods

query(qlat, qlon)

Query a set of latitudes and longitudes

query_pairs(maximum_distance)

Find pairs of points that are within a certain distance of each other

interp(data, qlat, qlon)

Use the kdtree to interpolate data corresponding to the points of the Kdtree onto a new set of points using nearest neighbor interpolation or weighted nearest neighbor interpolation (default).

meshslice.utils.updaterc.updaterc(rebuild=False)[source]

Updates the rcParams to something generic that looks ok good out of the box.

Args:

rebuild (bool):

Rebuilds fontcache incase it needs it.

Last modified: Lucas Sawade, 2020.09.15 01.00 (lsawade@princeton.edu)

meshslice.utils.visibility_callback.SetVisibilityCallback(actors)[source]

Helper callback to keep a reference to the actor being modified.

meshslice.utils.vtksphere.generate_sphere(radius, origin)[source]

Return a _vtk.vtkSphere.