salvus.mesh.layered_meshing.layered_model.detail
Implementation details for layered models.
Functions
b_partition()
b_partition()def b_partition(db: salvus.project.domain.DomainBounds) -> functools.partial:
...Convenience function binding partition to a given domain.
Convenient when you want to apply different partitioning predicates to a model on the same domain.
Parameters
dbsalvus.project.domain.DomainBounds — The domain to bind to.
Returns functools.partial —
partition with the first argument domain filled in.da_max()
da_max()def da_max(da: xarray.core.dataarray.DataArray) -> float:
...Return the max of a DataArray added to its “reference_elevation” attr.
Parameters
daxarray.core.dataarray.DataArray — The DataArray.
Returns float — float: The maximum value.
da_min()
da_min()def da_min(da: xarray.core.dataarray.DataArray) -> float:
...Return the min of a DataArray added to its “reference_elevation” attr.
Parameters
daxarray.core.dataarray.DataArray — The DataArray.
Returns float — float: The minimum value.
delete_duplicate_interfaces()
delete_duplicate_interfaces()def delete_duplicate_interfaces(strata: List) -> List:
...Delete neighboring duplicate interfaces.
Useful when concatenating models without fussing too much about how to slice layers.
Parameters
strataList — The strata to inspect.
Returns List — The strata with any duplicate interfaces removed.
partition()
partition()def partition(
d: salvus.project.domain.Domain,
lm: Union[
salvus.mesh.layered_meshing.layered_model.layered_model.LayeredModel,
salvus.mesh.layered_meshing.layered_model.layer.Layer,
],
model_predicate: Union[
Callable[
[salvus.mesh.layered_meshing.material._material.Material],
xarray.core.dataarray.DataArray,
],
Tuple[
Callable[
[salvus.mesh.layered_meshing.material._material.Material],
xarray.core.dataarray.DataArray,
],
salvus.mesh.layered_meshing.interface.Interface,
],
],
mode: str = "continuous",
interface_modifier: Callable[
[salvus.mesh.layered_meshing.interface.Interface],
salvus.mesh.layered_meshing.interface.Interface,
] = salvus.utils.utils.identity,
) -> salvus.mesh.layered_meshing.layered_model.layered_model.LayeredModel:
...Partition a LayeredModel into more layers.
TODO: More documentation incoming.
Parameters
dsalvus.project.domain.Domain — The domain.lmUnion[salvus.mesh.layered_meshing.layered_model.layered_model.LayeredModel, salvus.mesh.layered_meshing.layered_model.layer.Layer] — The layered model to partition.model_predicateUnion[Callable[[salvus.mesh.layered_meshing.material._material.Material], xarray.core.dataarray.DataArray], Tuple[Callable[[salvus.mesh.layered_meshing.material._material.Material], xarray.core.dataarray.DataArray], salvus.mesh.layered_meshing.interface.Interface]] — Function which transforms a layered model into a set of discrete integers. Each “region” identified by a unique integer will be considered a new layer as long as it is contiguous across the model. Can also be a tuple, with (predicate, interface) as the two tuple entries. In this case, instead of a model-dependent interface being added, the passed interface itself will be used.modestr — “continuous” for logical partitions (such as those used to find doubling regions) or “discontinuous” for true partitions meant to respect model discontinuities. If the former case, partitions will be located at the input grid point with the largest predicate value, while in the latter partitions will be placed halfway between two grid points.interface_modifierCallable[[salvus.mesh.layered_meshing.interface.Interface], salvus.mesh.layered_meshing.interface.Interface] — A function that can re-discretize a derived partition interface. Useful, for instance, to avoid stair-stepping artifacts when partitioning models with nonuniform discontinuities on a regular grid.
Returns salvus.mesh.layered_meshing.layered_model.layered_model.LayeredModel — LayeredModel: A partitioned layered model.