Version:

salvus.project.domain.dim2

salvus.project.domain.dim2 salvus project domain dim2
2-D cartesian and spherical domains.

Classes

BoxDomain

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.
SIGNATURE
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: ...
ARGUMENTS
Required
x0
Type:salvus._core.types.float_
Description:
Minimum x-coordinate.
Required
x1
Type:salvus._core.types.float_
Description:
Maximum x-coordinate.
Required
y0
Type:salvus._core.types.float_
Description:
Minimum y-coordinate.
Required
y1
Type:salvus._core.types.float_
Description:
Maximum y-coordinate.

Properties

  • 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.

Class Methods

BoxDomain.from_2d_line()
Generate a domain from a 2-D line.
SIGNATURE
def from_2d_line(
    topo: SurfaceTopography,
    depth_in_meters: salvus._core.types.float_,
    shrink_domain_x: salvus._core.types.float_ = 0.0,
) -> BoxDomain: ...
ARGUMENTS
Required
topo
Type:SurfaceTopography
Description:
2-D surface topography.
Required
depth_in_meters
Type:salvus._core.types.float_
Description:
Depth in the domain - measured from the maximum value of the given topography.
Optional
shrink_domain_x
Type:salvus._core.types.float_
Default value:0.0
Description:
Shrink the domain along the x-axis.
BoxDomain.from_bounds()
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))
SIGNATURE
def from_bounds() -> BoxDomain: ...
BoxDomain.from_json_data()
Load the domain from a file.
SIGNATURE
def from_json_data(d: dict) -> Domain: ...
ARGUMENTS
Required
d
Type:dict
Description:
Dictionary with the JSON data.
BoxDomain.from_material()
Create a new domain from the extents of a material model.
SIGNATURE
def from_material(m: typing.Any) -> Domain: ...
ARGUMENTS
Required
m
Type:typing.Any
Description:
The material model.
BoxDomain.from_salvus_xy()
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.
SIGNATURE
def from_salvus_xy(
    model: Path | str | xr.Dataset,
    shrink_domain: salvus._core.types.float_ = 0.0,
) -> BoxDomain: ...
ARGUMENTS
Required
model
Type:Path | str | xr.Dataset
Description:
Model file, either stored in memory (as an xarray.Dataset) or on disk (as a NetCDF file).
Optional
shrink_domain
Type:salvus._core.types.float_
Default value:0.0
Description:
Reduce the size of the domain w.r.t. the size as defined in the Salvus model.
BoxDomain.from_volume_model()
Create a new domain from the extents of a volumetric model.
SIGNATURE
def from_volume_model(model: volume._VolumeBase) -> Domain: ...
ARGUMENTS
Required
model
Type:volume._VolumeBase
Description:
The volumetric model from which to create the domain.
BoxDomain.from_xarray()
Create a new domain from the extents of an xarray object.
SIGNATURE
def from_xarray(
    d: xr.Dataset | xr.DataArray,
) -> dim2.BoxDomain | dim3.BoxDomain: ...
ARGUMENTS
Required
d
Type:xr.Dataset | xr.DataArray
Description:
The xarray Dataset or DataArray.
BoxDomain.load()
Load the domain from a file.
SIGNATURE
def load(filename: pathlib.Path) -> Domain: ...
ARGUMENTS
Required
filename
Type:pathlib.Path
Description:
File from which to load.
BoxDomain.unit()
Construct a 2D unit domain on [0, 1] x [0, 1].
SIGNATURE
def unit() -> BoxDomain: ...

Methods

BoxDomain.dim_enum()
The dimension as a typed enum.
SIGNATURE
def dim_enum(self) -> Dim: ...
BoxDomain.estimate_max_travel_distance_in_m()
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.
SIGNATURE
def estimate_max_travel_distance_in_m(self) -> float: ...
BoxDomain.is_point_inside_domain()
Determine whether or not p point is within the box.
SIGNATURE
def is_point_inside_domain(
    self,
    x: salvus._core.types.float_,
    y: salvus._core.types.float_ | None = None,
) -> bool: ...
ARGUMENTS
Required
x
Type:salvus._core.types.float_
Description:
x-coordinate to test.
Optional
y
Type:salvus._core.types.float_ | None
Default value:None
Description:
y-coordinate to test. If None test will only be done for the x-coordinate. Defaults to None.
BoxDomain.plot()
Plot the domain.
SIGNATURE
def plot(
    self,
    events: Event | list[Event] | None = None,
    return_figure: bool = False,
) -> Figure | None: ...
ARGUMENTS
Optional
events
Type:Event | list[Event] | None
Default value:None
Description:
Optionally pass events for a domain.
Optional
return_figure
Type:bool
Default value:False
Description:
This method will by default just show the plot, if this argument is set to True it will instead return the Figure object.
BoxDomain.write()
Write the domain to a file.
SIGNATURE
def write(self, filename: pathlib.Path) -> None: ...
ARGUMENTS
Required
filename
Type:pathlib.Path
Description:
Filename to write it to.

CircularDomain

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.
SIGNATURE
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,
    ): ...
ARGUMENTS
Required
radius_in_meter
Type:salvus._core.types.float_
Description:
Outer radius of the circle.
Optional
maximum_colatitude
Type:salvus._core.types.float_
Default value:180.0
Description:
Maximum colatitude of the domain, counted both sides from the top. Thus a value of 180 degrees will be the full circle.
Optional
minimum_radius_in_meter
Type:salvus._core.types.float_ | None
Default value:None
Description:
The minimum radius of the domain. If not set, defaults to 0 (representing a full circle).

Properties

  • 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.

Class Methods

CircularDomain.from_bounds()
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))
SIGNATURE
def from_bounds() -> CircularDomain: ...
CircularDomain.from_json_data()
Load the domain from a file.
SIGNATURE
def from_json_data(d: dict) -> Domain: ...
ARGUMENTS
Required
d
Type:dict
Description:
Dictionary with the JSON data.
CircularDomain.from_material()
Create a new domain from the extents of a material model.
SIGNATURE
def from_material(m: typing.Any) -> Domain: ...
ARGUMENTS
Required
m
Type:typing.Any
Description:
The material model.
CircularDomain.from_volume_model()
Create a new domain from the extents of a volumetric model.
SIGNATURE
def from_volume_model(model: volume._VolumeBase) -> Domain: ...
ARGUMENTS
Required
model
Type:volume._VolumeBase
Description:
The volumetric model from which to create the domain.
CircularDomain.from_xarray()
Create a new domain from the extents of an xarray object.
SIGNATURE
def from_xarray(
    d: xr.Dataset | xr.DataArray,
) -> dim2.BoxDomain | dim3.BoxDomain: ...
ARGUMENTS
Required
d
Type:xr.Dataset | xr.DataArray
Description:
The xarray Dataset or DataArray.
CircularDomain.like_earth()
Get a full circular domain with a radius of 6371e3 meters.
SIGNATURE
def like_earth() -> CircularDomain: ...
CircularDomain.load()
Load the domain from a file.
SIGNATURE
def load(filename: pathlib.Path) -> Domain: ...
ARGUMENTS
Required
filename
Type:pathlib.Path
Description:
File from which to load.
CircularDomain.unit_circle()
Get a circular domain with a unit radius (1 meter).
SIGNATURE
def unit_circle() -> CircularDomain: ...

Methods

CircularDomain.dim_enum()
The dimension as a typed enum.
SIGNATURE
def dim_enum(self) -> Dim: ...
CircularDomain.estimate_max_travel_distance_in_m()
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.
SIGNATURE
def estimate_max_travel_distance_in_m(self) -> float: ...
CircularDomain.is_point_inside_domain()
Tests if a given longitude is in the domain.
SIGNATURE
def is_point_inside_domain(
    self, longitude: salvus._core.types.float_
) -> bool: ...
ARGUMENTS
Required
longitude
Type:salvus._core.types.float_
Description:
The longitude to test.
CircularDomain.plot()
Create a matplotlib plot of the domain.
SIGNATURE
def plot(
    self,
    events: Event | list[Event] | None = None,
    return_figure: bool = False,
) -> Figure | None: ...
ARGUMENTS
Optional
events
Type:Event | list[Event] | None
Default value:None
Description:
Optionally pass events to plot.
Optional
return_figure
Type:bool
Default value:False
Description:
This method will by default just show the plot, if this argument is set to True it will instead return the Figure object.
CircularDomain.write()
Write the domain to a file.
SIGNATURE
def write(self, filename: pathlib.Path) -> None: ...
ARGUMENTS
Required
filename
Type:pathlib.Path
Description:
Filename to write it to.

Used in tutorials

Functionality from this module is used in the following tutorials.
PAGE CONTENTS