Mondaic

salvus.project.domain.dim2

salvus.project.domain.dim2 salvus project domain dim2

2-D cartesian and spherical domains.

Classes

BoxDomain

class BoxDomain(salvus.project.domain.Domain):
    def __init__(
        self,
        x0: salvus._core.types.float_,
        x1: salvus._core.types.float_,
        y0: salvus._core.types.float_,
        y1: salvus._core.types.float_,
    ) -> None: ...

A base class to handle all variants of 2-D box-like domains.

A box is a 2-D object defined by its x and y extents. All extents do not need to be the same, i.e. a box is not necessarily a cube.

Construct a simple 2-D box domain.

Any of the coordinate axes can by +/- np.inf to signify that the domain is unbounded in that direction.

Parameters
  • x0 salvus._core.types.float_ — Minimum x-coordinate.
  • x1 salvus._core.types.float_ — Maximum x-coordinate.
  • y0 salvus._core.types.float_ — Minimum y-coordinate.
  • y1 salvus._core.types.float_ — Maximum y-coordinate.
Attributes
bounding_box np.ndarray

Domain bounding box.

bounds DomainBounds

Get the 2-D domain bounds.

coordinate_system CoordinateSystem

Coordinate system of the domain.

dim int

Get the dimension of this domain.

Returns: 2.

Methods
from_2d_line()
def from_2d_line(
    topo: SurfaceTopography,
    depth_in_meters: salvus._core.types.float_,
    shrink_domain_x: salvus._core.types.float_ = 0.0,
) -> BoxDomain: ...

Generate a domain from a 2-D line.

Parameters
  • topo SurfaceTopography — 2-D surface topography.
  • depth_in_meters salvus._core.types.float_ — Depth in the domain - measured from the maximum value of the given topography.
  • shrink_domain_x salvus._core.types.float_ — Shrink the domain along the x-axis.
Returns BoxDomain
from_bounds()
def from_bounds() -> BoxDomain: ...

Construct a domain from its bounds.

The bounds can be specified in a number of ways:

  • As a DomainBounds object.
  • As x and y coordinates. If either coordinate is a single value, it will be assumed to be the extent of the domain in that dimension, and the minimum coordinate value will be set to 0.
# Create a box domain with a width of 1.0 and a height of 2.0.
d = sn.domain.dim2.BoxDomain.from_bounds(1.0, 2.0)
# Create a box domain from -1 to 2 in x and 3 to 4 in y.
d = sn.domain.dim2.BoxDomain.from_bounds(x=(-1.0, 2.0), y=(3.0, 4.0))
Returns BoxDomain
from_json_data()
def from_json_data(d: dict) -> Domain: ...

Load the domain from a file.

Parameters
  • d dict — Dictionary with the JSON data.
Returns Domain
from_material()
def from_material(m: typing.Any) -> Domain: ...

Create a new domain from the extents of a material model.

Parameters
  • m typing.Any — The material model.
Returns Domain — Domain: A new domain.
from_salvus_xy()
def from_salvus_xy(
    model: Path | str | xr.Dataset,
    shrink_domain: salvus._core.types.float_ = 0.0,
) -> BoxDomain: ...

Construct a Box domain from a 2-D Salvus model.

The model can either be stored as an xarray.Dataset object, or in a NetCDF file on disk conforming to the Salvus XY file format.

Parameters
  • model Path | str | xr.Dataset — Model file, either stored in memory (as an xarray.Dataset) or on disk (as a NetCDF file).
  • shrink_domain salvus._core.types.float_ — Reduce the size of the domain w.r.t. the size as defined in the Salvus model.
Returns BoxDomain — A constructed 2-D BoxDomain object.
from_volume_model()
def from_volume_model(model: volume._VolumeBase) -> Domain: ...

Create a new domain from the extents of a volumetric model.

Parameters
  • model volume._VolumeBase — The volumetric model from which to create the domain.
Returns Domain — A new domain object with the proper extents.
from_xarray()
def from_xarray(
    d: xr.Dataset | xr.DataArray,
) -> dim2.BoxDomain | dim3.BoxDomain: ...

Create a new domain from the extents of an xarray object.

Parameters
  • d xr.Dataset | xr.DataArray — The xarray Dataset or DataArray.
Returns dim2.BoxDomain | dim3.BoxDomain — Domain: A new domain.
load()
def load(filename: pathlib.Path) -> Domain: ...

Load the domain from a file.

Parameters
  • filename pathlib.Path — File from which to load.
Returns Domain
unit()
def unit() -> BoxDomain: ...

Construct a 2D unit domain on [0, 1] x [0, 1].

Returns BoxDomain
dim_enum()
def dim_enum(self) -> Dim: ...

The dimension as a typed enum.

Returns Dim
estimate_max_travel_distance_in_m()
def estimate_max_travel_distance_in_m(self) -> float: ...

Estimate the maximum distance waves travel to fully cross the domain.

For Cartesian domains it will return the distance between two opposing corners. Dimensions that are unbounded are not considered in that computation.

Returns float
is_point_inside_domain()
def is_point_inside_domain(
    self,
    x: salvus._core.types.float_,
    y: salvus._core.types.float_ | None = None,
) -> bool: ...

Determine whether or not p point is within the box.

Parameters
  • x salvus._core.types.float_ — x-coordinate to test.
  • y salvus._core.types.float_ | None — y-coordinate to test. If None test will only be done for the x-coordinate. Defaults to None.
Returns bool — True or False whether or not the point is in the box.
plot()
def plot(
    self,
    events: Event | list[Event] | None = None,
    return_figure: bool = False,
) -> Figure | None: ...

Plot the domain.

Parameters
  • events Event | list[Event] | None — Optionally pass events for a domain.
  • return_figure bool — This method will by default just show the plot, if this argument is set to True it will instead return the Figure object.
Returns Figure | None
write()
def write(self, filename: pathlib.Path) -> None: ...

Write the domain to a file.

Parameters
  • filename pathlib.Path — Filename to write it to.
Returns None

CircularDomain

class CircularDomain(salvus.project.domain.Domain):
    def __init__(
        self,
        radius_in_meter: salvus._core.types.float_,
        maximum_colatitude: salvus._core.types.float_ = 180.0,
        minimum_radius_in_meter: salvus._core.types.float_ | None = None,
    ): ...

A 2-D circular seismological domain.

The coordinates for this domain are longitude and radius/depth. A Longitude of 0 degrees points to the right and it is then counted counterclockwise. Thus a longitude of 90 degrees points straight up.

Parameters
  • radius_in_meter salvus._core.types.float_ — Outer radius of the circle.
  • maximum_colatitude salvus._core.types.float_ — Maximum colatitude of the domain, counted both sides from the top. Thus a value of 180 degrees will be the full circle.
  • minimum_radius_in_meter salvus._core.types.float_ | None — The minimum radius of the domain. If not set, defaults to 0 (representing a full circle).
Attributes
bounding_box np.ndarray

Domain bounding box.

bounds DomainBounds

Get the 2-D domain bounds.

coordinate_system CoordinateSystem

Coordinate system of the domain.

dim int

Get the dimension of this domain.

Returns: 2.

Methods
from_bounds()
def from_bounds() -> CircularDomain: ...

Construct a circular domain from its bounds.

The bounds can be specified in a number of ways:

  • As a DomainBounds object.
  • As longitude (maximum_colatitude) and radius values. Longitude may be a single value or a tuple, but if a tuple is given it must be symmetric around 0 (i.e. (-l, +l)). Radius may be a single value (in which case the minimum radius is assumed to be 0) or a tuple (in which case the first value is the minimum radius and the second value the maximum radius).
  • If a tuple is provided for longitude, a ValueError is raised.
# Full disk with a radius of 6371 km.
d = sn.domain.dim2.CircularDomain.from_bounds(180.0, 6371e3)
# Same using keyword arguments.
d = sn.domain.dim2.CircularDomain.from_bounds(
    longitude=180.0, radius=6371e3
)
# Annulus limited to +/-45 degrees.
d = sn.domain.dim2.CircularDomain.from_bounds(45.0, (3000e3, 6371e3))
Returns CircularDomain — A constructed CircularDomain object.
from_json_data()
def from_json_data(d: dict) -> Domain: ...

Load the domain from a file.

Parameters
  • d dict — Dictionary with the JSON data.
Returns Domain
from_material()
def from_material(m: typing.Any) -> Domain: ...

Create a new domain from the extents of a material model.

Parameters
  • m typing.Any — The material model.
Returns Domain — Domain: A new domain.
from_volume_model()
def from_volume_model(model: volume._VolumeBase) -> Domain: ...

Create a new domain from the extents of a volumetric model.

Parameters
  • model volume._VolumeBase — The volumetric model from which to create the domain.
Returns Domain — A new domain object with the proper extents.
from_xarray()
def from_xarray(
    d: xr.Dataset | xr.DataArray,
) -> dim2.BoxDomain | dim3.BoxDomain: ...

Create a new domain from the extents of an xarray object.

Parameters
  • d xr.Dataset | xr.DataArray — The xarray Dataset or DataArray.
Returns dim2.BoxDomain | dim3.BoxDomain — Domain: A new domain.
like_earth()
def like_earth() -> CircularDomain: ...

Get a full circular domain with a radius of 6371e3 meters.

Returns CircularDomain — A circular domain with the nominal radius of Earth.
load()
def load(filename: pathlib.Path) -> Domain: ...

Load the domain from a file.

Parameters
  • filename pathlib.Path — File from which to load.
Returns Domain
unit_circle()
def unit_circle() -> CircularDomain: ...

Get a circular domain with a unit radius (1 meter).

Returns CircularDomain — A circular domain with a radius of 1 meter.
dim_enum()
def dim_enum(self) -> Dim: ...

The dimension as a typed enum.

Returns Dim
estimate_max_travel_distance_in_m()
def estimate_max_travel_distance_in_m(self) -> float: ...

Estimate the maximum distance waves travel to fully cross the domain.

Will return either half the circumference of the circle (if the domain is a full circle) or the great-circle distance between the edges of the domain.

Returns float
is_point_inside_domain()
def is_point_inside_domain(
    self, longitude: salvus._core.types.float_
) -> bool: ...

Tests if a given longitude is in the domain.

Parameters
  • longitude salvus._core.types.float_ — The longitude to test.
Returns bool
plot()
def plot(
    self,
    events: Event | list[Event] | None = None,
    return_figure: bool = False,
) -> Figure | None: ...

Create a matplotlib plot of the domain.

Parameters
  • events Event | list[Event] | None — Optionally pass events to plot.
  • return_figure bool — This method will by default just show the plot, if this argument is set to True it will instead return the Figure object.
Returns Figure | None
write()
def write(self, filename: pathlib.Path) -> None: ...

Write the domain to a file.

Parameters
  • filename pathlib.Path — Filename to write it to.
Returns None

Used in tutorials