salvus.project.domain.dim2
2-D cartesian and spherical domains.
Classes
BoxDomain
BoxDomainclass 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.
x0Union[int, numpy.int32, numpy.int64, float, numpy.float32, numpy.float64] — Minimum x-coordinate.x1Union[int, numpy.int32, numpy.int64, float, numpy.float32, numpy.float64] — Maximum x-coordinate.y0Union[int, numpy.int32, numpy.int64, float, numpy.float32, numpy.float64] — Minimum y-coordinate.y1Union[int, numpy.int32, numpy.int64, float, numpy.float32, numpy.float64] — Maximum y-coordinate.
bounding_box numpy.ndarray
bounding_box numpy.ndarrayDomain bounding box.
bounds salvus.project.domain.DomainBounds
bounds salvus.project.domain.DomainBoundsGet the 2-D domain bounds.
coordinate_system str
coordinate_system strCoordinate 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: 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.
toposalvus.project.configuration.topography.cartesian.SurfaceTopography — 2-D surface topography.depth_in_metersUnion[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_xUnion[int, numpy.int32, numpy.int64, float, numpy.float32, numpy.float64] — Shrink the domain along the x-axis.
from_bounds()
from_bounds()def from_bounds(bounds: salvus.project.domain.DomainBounds) -> BoxDomain:
...Construct from a domain bounds object.
boundssalvus.project.domain.DomainBounds — The domain bounds.
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: Any) -> Domain:
...Create a new domain from the extents of a material model.
mAny — The material model.
from_salvus_xy()
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.
modelUnion[pathlib.Path, str, xarray.core.dataset.Dataset] — Model file, either stored in memory (as anxarray.Dataset) or on disk (as a NetCDF file).shrink_domainUnion[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.
from_volume_model()
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.
modelsalvus.project.configuration.model.volume._VolumeBase — The volumetric model from which to create the domain.
from_xarray()
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.
dUnion[xarray.core.dataset.Dataset, xarray.core.dataarray.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.
dim_enum()
dim_enum()def dim_enum(self) -> salvus.project.components.types.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: 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.
xUnion[int, numpy.int32, numpy.int64, float, numpy.float32, numpy.float64] — x-coordinate to test.yOptional[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.
plot()
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.
eventsOptional[salvus.flow.collections.event.Event, List[salvus.flow.collections.event.Event]] — 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: 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.
radius_in_meterUnion[int, numpy.int32, numpy.int64, float, numpy.float32, numpy.float64] — Outer radius of the circle.maximum_colatitudeUnion[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_meterOptional[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).
bounding_box numpy.ndarray
bounding_box numpy.ndarrayDomain bounding box.
bounds salvus.project.domain.DomainBounds
bounds salvus.project.domain.DomainBoundsGet the 2-D domain bounds.
coordinate_system str
coordinate_system strCoordinate system of the domain.
dim int
dim intGet the dimension of this domain.
Returns: 2.
from_bounds()
from_bounds()def from_bounds(bounds: salvus.project.domain.DomainBounds) -> CircularDomain:
...Construct from a domain bounds object.
boundssalvus.project.domain.DomainBounds — The domain bounds.
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: Any) -> Domain:
...Create a new domain from the extents of a material model.
mAny — The material model.
from_volume_model()
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.
modelsalvus.project.configuration.model.volume._VolumeBase — The volumetric model from which to create the domain.
from_xarray()
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.
dUnion[xarray.core.dataset.Dataset, xarray.core.dataarray.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) -> salvus.project.components.types.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: Union[
int, numpy.int32, numpy.int64, float, numpy.float32, numpy.float64
],
) -> bool:
...Tests if a given longitude is in the domain
longitudeUnion[int, numpy.int32, numpy.int64, float, numpy.float32, numpy.float64] — The longitude to test.
plot()
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.
eventsOptional[salvus.flow.collections.event.Event, List[salvus.flow.collections.event.Event]] — 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.