Skip to content
This API reference is not for the latest stable Salvus version.

salvus.project.project

The SalvusProject class.

Classes

Project

class Project(builtins.object):
    def __init__(
        self,
        path: pathlib.Path | str,
        verbosity: int = 1,
        apply_migrations: bool | None = None,
    ): ...

Root Salvus project class.

Parameters
  • path pathlib.Path | str — Folder to load the project from.
  • verbosity int = 1 — Verbosity of the project init.
  • apply_migrations bool | None = None — When upgrading Salvus from one version to a later one, the underlying file structure of SalvusProject might change. This requires a migration from the old to the new structure. If set to True, automatically apply necessary migrations, if False, raise if migrations are needed. If None, ask the user with an interactive prompt.
Attributes
project_path pathlib.Path

Path to the project root.

project_paths dict[str, pathlib.Path]

Paths to all important subfolders of the project.

tempfile_manager _TempfileManager

Temporary file manager for the project.

Methods
from_domain()
def from_domain(
    path: pathlib.Path | str,
    domain: Domain,
    load_if_exists: bool = False,
    verbosity: int = 1,
) -> Project: ...

Create a new project from a domain object.

Parameters
  • path pathlib.Path | str — Path at which to initialize the project.
  • domain Domain — Domain to use.
  • load_if_exists bool = False — If a project with a matching domain has already been created and is stored in path, then load and return the project on disk rather than creating a new one.
  • verbosity int = 1 — Verbosity of the project init.
Returns Project
from_geojson()
def from_geojson(
    path: pathlib.Path | str,
    radius_in_meter: float,
    geojson: pathlib.Path | dict,
    verbosity: int = 1,
) -> Project: ...

Create a new project from a GeoJSON document.

Parameters
  • path pathlib.Path | str — Path at which to initialize the project.
  • radius_in_meter float — Planet radius.
  • geojson pathlib.Path | dict — Filename or dictionary containing the geojson data.
  • verbosity int = 1 — Verbosity of the project init.
Returns Project
from_mesh()
def from_mesh(
    path: str | pathlib.Path,
    mesh: UnstructuredMesh,
    load_if_exists: bool = False,
    verbosity: int = 1,
) -> Project: ...

Create a new project with a domain suitable for the given mesh.

Note that the mesh will not be automatically added to the project.

Parameters
  • path str | pathlib.Path — Path at which to initialize the project.
  • mesh UnstructuredMesh — Mesh to create domain from.
  • load_if_exists bool = False — If a project with a matching domain has already been created and is stored in path, then load and return the project on disk rather than creating a new one.
  • verbosity int = 1 — Verbosity of the project init.
Returns Project
from_volume_model()
def from_volume_model(
    path: pathlib.Path | str,
    volume_model: volume._VolumeBase,
    load_if_exists: bool = False,
    verbosity: int = 1,
) -> Project: ...

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

Parameters
  • path pathlib.Path | str — model filename.
  • volume_model volume._VolumeBase — The volumetric model from which to create the domain.
  • load_if_exists bool = False — If a project with a matching domain has already been created and is stored in path, then load and return the project on disk rather than creating a new one.
  • verbosity int = 1 — Verbosity of the project init.
Returns Project — A new domain object with the proper extents.
add_to_project()
def add_to_project(
    self,
    other: E_T,
    overwrite: bool = False,
    skip_validation: bool = True,
    timer: Timer | None = None,
    log_to_logger: bool = False,
    comm: int | None = None,
) -> None: ...

Add something to the project.

It will automatically dispatch to the correct subroutine depending on what it is given.

Parameters
  • other E_T — Thing to add.
  • overwrite bool = False — Potentially overwrite an existing thing in project if it already exists.
  • skip_validation bool = True — If True, skip validation checks when adding entities. Use with care, this might be slow.
  • timer Timer | None = None — Execution timer.
  • log_to_logger bool = False — If True, print timings to the execution timer. Defaults to False here as this is quick in most cases and would otherwise just be noise.
  • comm int | None = None — MPI communicator, if any.
Returns None