salvus.project.domain.dim2
salvus.project.domain.dim2 salvus project domain dim2 2-D cartesian and spherical domains.
Classes
BoxDomain
BoxDomainclass 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.
x0salvus._core.types.float_ — Minimum x-coordinate.x1salvus._core.types.float_ — Maximum x-coordinate.y0salvus._core.types.float_ — Minimum y-coordinate.y1salvus._core.types.float_ — Maximum y-coordinate.
bounding_box np.ndarray
bounding_box np.ndarrayDomain bounding box.
bounds DomainBounds
bounds DomainBoundsGet the 2-D domain bounds.
coordinate_system CoordinateSystem
coordinate_system CoordinateSystemCoordinate system of the domain.
dim int
dim intGet the dimension of this domain.
Returns: 2.
from_2d_line()
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.
topoSurfaceTopography — 2-D surface topography.depth_in_meterssalvus._core.types.float_ — Depth in the domain - measured from the maximum value of the given topography.shrink_domain_xsalvus._core.types.float_ — Shrink the domain along the x-axis.
from_bounds()
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))from_json_data()
from_json_data()def from_json_data(d: dict) -> Domain: ...Load the domain from a file.
ddict — Dictionary with the JSON data.
from_material()
from_material()def from_material(m: typing.Any) -> Domain: ...Create a new domain from the extents of a material model.
mtyping.Any — The material model.
from_salvus_xy()
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.
modelPath | str | xr.Dataset — Model file, either stored in memory (as anxarray.Dataset) or on disk (as a NetCDF file).shrink_domainsalvus._core.types.float_ — Reduce the size of the domain w.r.t. the size as defined in the Salvus model.
from_volume_model()
from_volume_model()def from_volume_model(model: volume._VolumeBase) -> Domain: ...Create a new domain from the extents of a volumetric model.
modelvolume._VolumeBase — The volumetric model from which to create the domain.
from_xarray()
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.
dxr.Dataset | xr.DataArray — The xarray Dataset or DataArray.
load()
load()def load(filename: pathlib.Path) -> Domain: ...Load the domain from a file.
filenamepathlib.Path — File from which to load.
unit()
unit()def unit() -> BoxDomain: ...Construct a 2D unit domain on [0, 1] x [0, 1].
dim_enum()
dim_enum()def dim_enum(self) -> Dim: ...The dimension as a typed enum.
estimate_max_travel_distance_in_m()
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.
is_point_inside_domain()
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.
xsalvus._core.types.float_ — x-coordinate to test.ysalvus._core.types.float_ | None — y-coordinate to test. If None test will only be done for the x-coordinate. Defaults to None.
plot()
plot()def plot(
self,
events: Event | list[Event] | None = None,
return_figure: bool = False,
) -> Figure | None: ...Plot the domain.
eventsEvent | list[Event] | None — Optionally pass events for a domain.return_figurebool — This method will by default just show the plot, if this argument is set toTrueit will instead return the Figure object.
write()
write()def write(self, filename: pathlib.Path) -> None: ...Write the domain to a file.
filenamepathlib.Path — Filename to write it to.
CircularDomain
CircularDomainclass 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.
radius_in_metersalvus._core.types.float_ — Outer radius of the circle.maximum_colatitudesalvus._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_metersalvus._core.types.float_ | None — The minimum radius of the domain. If not set, defaults to 0 (representing a full circle).
bounding_box np.ndarray
bounding_box np.ndarrayDomain bounding box.
bounds DomainBounds
bounds DomainBoundsGet the 2-D domain bounds.
coordinate_system CoordinateSystem
coordinate_system CoordinateSystemCoordinate system of the domain.
dim int
dim intGet the dimension of this domain.
Returns: 2.
from_bounds()
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))from_json_data()
from_json_data()def from_json_data(d: dict) -> Domain: ...Load the domain from a file.
ddict — Dictionary with the JSON data.
from_material()
from_material()def from_material(m: typing.Any) -> Domain: ...Create a new domain from the extents of a material model.
mtyping.Any — The material model.
from_volume_model()
from_volume_model()def from_volume_model(model: volume._VolumeBase) -> Domain: ...Create a new domain from the extents of a volumetric model.
modelvolume._VolumeBase — The volumetric model from which to create the domain.
from_xarray()
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.
dxr.Dataset | xr.DataArray — The xarray Dataset or DataArray.
like_earth()
like_earth()def like_earth() -> CircularDomain: ...Get a full circular domain with a radius of 6371e3 meters.
load()
load()def load(filename: pathlib.Path) -> Domain: ...Load the domain from a file.
filenamepathlib.Path — File from which to load.
unit_circle()
unit_circle()def unit_circle() -> CircularDomain: ...Get a circular domain with a unit radius (1 meter).
dim_enum()
dim_enum()def dim_enum(self) -> Dim: ...The dimension as a typed enum.
estimate_max_travel_distance_in_m()
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.
is_point_inside_domain()
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.
longitudesalvus._core.types.float_ — The longitude to test.
plot()
plot()def plot(
self,
events: Event | list[Event] | None = None,
return_figure: bool = False,
) -> Figure | None: ...Create a matplotlib plot of the domain.
eventsEvent | list[Event] | None — Optionally pass events to plot.return_figurebool — This method will by default just show the plot, if this argument is set toTrueit will instead return the Figure object.
write()
write()def write(self, filename: pathlib.Path) -> None: ...Write the domain to a file.
filenamepathlib.Path — Filename to write it to.
Used in tutorials
- 2-D Global-scale simulations w/ heterogeneous models
- Acoustic simulations in isotropic and anisotropic media
- Attenuation
- Equivalence of Filtering STFs and Filtering Synthetics
- Importing SEGY Data into SalvusProject
- Inverting for homogeneous material
- Lamb's problem
- Lamb's problem
- Layered Meshing 01: Basics
- Layered Meshing 02: Basics of partitioning and policies
- Modelling Layered Topography
- My First Salvus Simulation
- Salvus' UnstructuredMesh - Part 3 - Jacobians and Time Step Estimation
- Simple surface topography
- Units in Coupled Simulations