Mondaic
This API reference is not for the latest stable Salvus version.

salvus.project.domain.dim2

2-D cartesian and spherical domains.

Classes

BoxDomain

class BoxDomain(salvus.project.domain.Domain):
    def __init__(
        self,
        x0: Union[
            int, numpy.int32, numpy.int64, float, numpy.float32, numpy.float64
        ],
        x1: Union[
            int, numpy.int32, numpy.int64, float, numpy.float32, numpy.float64
        ],
        y0: Union[
            int, numpy.int32, numpy.int64, float, numpy.float32, numpy.float64
        ],
        y1: Union[
            int, numpy.int32, numpy.int64, float, numpy.float32, numpy.float64
        ],
    ) -> 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.infty to signify that the domain is unbounded in that direction.

Parameters
  • x0 Union[int, numpy.int32, numpy.int64, float, numpy.float32, numpy.float64] — Minimum x-coordinate.
  • x1 Union[int, numpy.int32, numpy.int64, float, numpy.float32, numpy.float64] — Maximum x-coordinate.
  • y0 Union[int, numpy.int32, numpy.int64, float, numpy.float32, numpy.float64] — Minimum y-coordinate.
  • y1 Union[int, numpy.int32, numpy.int64, float, numpy.float32, numpy.float64] — Maximum y-coordinate.
Attributes
bounding_box numpy.ndarray

Domain bounding box.

bounds salvus.project.domain.DomainBounds

Get the 2-D domain bounds.

coordinate_system str

Coordinate system of the domain.

dim int

Get the dimension of this domain.

Returns: 2.

Methods
from_2d_line()
def from_2d_line(
    topo: salvus.project.configuration.topography.cartesian.SurfaceTopography,
    depth_in_meters: Union[
        int, numpy.int32, numpy.int64, float, numpy.float32, numpy.float64
    ],
    shrink_domain_x: Union[
        int, numpy.int32, numpy.int64, float, numpy.float32, numpy.float64
    ] = 0.0,
) -> BoxDomain:
    ...

Generate a domain from a 2-D line.

Parameters
  • topo salvus.project.configuration.topography.cartesian.SurfaceTopography — 2-D surface topography.
  • depth_in_meters Union[int, numpy.int32, numpy.int64, float, numpy.float32, numpy.float64] — Depth in the domain - measured from the maximum value of the given topography.
  • shrink_domain_x Union[int, numpy.int32, numpy.int64, float, numpy.float32, numpy.float64] — Shrink the domain along the x-axis.
Returns BoxDomain
from_bounds()
def from_bounds(bounds: salvus.project.domain.DomainBounds) -> BoxDomain:
    ...

Construct from a domain bounds object.

Parameters
  • bounds salvus.project.domain.DomainBounds — The domain bounds.
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: Any) -> Domain:
    ...

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

Parameters
  • m Any — The material model.
Returns Domain — Domain: A new domain.
from_salvus_xy()
def from_salvus_xy(
    model: Union[pathlib.Path, str, xarray.core.dataset.Dataset],
    shrink_domain: Union[
        int, numpy.int32, numpy.int64, float, numpy.float32, numpy.float64
    ] = 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 Union[pathlib.Path, str, xarray.core.dataset.Dataset] — Model file, either stored in memory (as an xarray.Dataset) or on disk (as a NetCDF file).
  • shrink_domain Union[int, numpy.int32, numpy.int64, float, numpy.float32, numpy.float64] — 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: salvus.project.configuration.model.volume._VolumeBase,
) -> Domain:
    ...

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

Parameters
  • model salvus.project.configuration.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: Union[xarray.core.dataset.Dataset, xarray.core.dataarray.DataArray]
) -> Domain:
    ...

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

Parameters
  • d Union[xarray.core.dataset.Dataset, xarray.core.dataarray.DataArray] — The xarray Dataset or DataArray.
Returns Domain — 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
dim_enum()
def dim_enum(self) -> salvus.project.components.types.Dim:
    ...

The dimension as a typed enum.

Returns salvus.project.components.types.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: Union[
        int, numpy.int32, numpy.int64, float, numpy.float32, numpy.float64
    ],
    y: Optional[
        int, numpy.int32, numpy.int64, float, numpy.float32, numpy.float64
    ] = None,
) -> bool:
    ...

Determine whether or not p point is within the box.

Parameters
  • x Union[int, numpy.int32, numpy.int64, float, numpy.float32, numpy.float64] — x-coordinate to test.
  • y Optional[int, numpy.int32, numpy.int64, float, numpy.float32, numpy.float64] — 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: Optional[
        salvus.flow.collections.event.Event,
        List[salvus.flow.collections.event.Event],
    ] = None,
    return_figure: bool = False,
) -> Optional[matplotlib.figure.Figure]:
    ...

Plot the domain.

Parameters
  • events Optional[salvus.flow.collections.event.Event, List[salvus.flow.collections.event.Event]] — 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 Optional[matplotlib.figure.Figure]
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: Union[
            int, numpy.int32, numpy.int64, float, numpy.float32, numpy.float64
        ],
        maximum_colatitude: Union[
            int, numpy.int32, numpy.int64, float, numpy.float32, numpy.float64
        ] = 180.0,
        minimum_radius_in_meter: Optional[
            int, numpy.int32, numpy.int64, float, numpy.float32, numpy.float64
        ] = 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 Union[int, numpy.int32, numpy.int64, float, numpy.float32, numpy.float64] — Outer radius of the circle.
  • maximum_colatitude Union[int, numpy.int32, numpy.int64, float, numpy.float32, numpy.float64] — Maximum colatitude of the domain, counted both side from the top. Thus a value of 180 degress will be the full circle.
  • minimum_radius_in_meter Optional[int, numpy.int32, numpy.int64, float, numpy.float32, numpy.float64] — The minimum radius of the domain. If not set, defaults to 0 (representing a full circle).
Attributes
bounding_box numpy.ndarray

Domain bounding box.

bounds salvus.project.domain.DomainBounds

Get the 2-D domain bounds.

coordinate_system str

Coordinate system of the domain.

dim int

Get the dimension of this domain.

Returns: 2.

Methods
from_bounds()
def from_bounds(bounds: salvus.project.domain.DomainBounds) -> CircularDomain:
    ...

Construct from a domain bounds object.

Parameters
  • bounds salvus.project.domain.DomainBounds — The domain bounds.
Returns CircularDomain
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: Any) -> Domain:
    ...

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

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

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

Parameters
  • model salvus.project.configuration.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: Union[xarray.core.dataset.Dataset, xarray.core.dataarray.DataArray]
) -> Domain:
    ...

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

Parameters
  • d Union[xarray.core.dataset.Dataset, xarray.core.dataarray.DataArray] — The xarray Dataset or DataArray.
Returns Domain — 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) -> salvus.project.components.types.Dim:
    ...

The dimension as a typed enum.

Returns salvus.project.components.types.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: Union[
        int, numpy.int32, numpy.int64, float, numpy.float32, numpy.float64
    ],
) -> bool:
    ...

Tests if a given longitude is in the domain

Parameters
  • longitude Union[int, numpy.int32, numpy.int64, float, numpy.float32, numpy.float64] — The longitude to test.
Returns bool
plot()
def plot(
    self,
    events: Optional[
        salvus.flow.collections.event.Event,
        List[salvus.flow.collections.event.Event],
    ] = None,
    return_figure: bool = False,
) -> Optional[matplotlib.figure.Figure]:
    ...

Create a matplotlib plot of the domain.

Parameters
  • events Optional[salvus.flow.collections.event.Event, List[salvus.flow.collections.event.Event]] — 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 Optional[matplotlib.figure.Figure]
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