This API reference is not for the latest stable Salvus version.
salvus.project.project
The SalvusProject class.
Classes
Project
Projectclass Project(builtins.object):
def __init__(
self,
path: pathlib.Path | str,
verbosity: int = 1,
apply_migrations: bool | None = None,
): ...Root Salvus project class.
Parameters
pathpathlib.Path | str — Folder to load the project from.verbosityint =1— Verbosity of the project init.apply_migrationsbool | 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
project_path pathlib.PathPath to the project root.
project_paths dict[str, pathlib.Path]
project_paths dict[str, pathlib.Path]Paths to all important subfolders of the project.
tempfile_manager _TempfileManager
tempfile_manager _TempfileManagerTemporary file manager for the project.
Methods
from_domain()
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
pathpathlib.Path | str — Path at which to initialize the project.domainDomain — Domain to use.load_if_existsbool =False— If a project with a matching domain has already been created and is stored inpath, then load and return the project on disk rather than creating a new one.verbosityint =1— Verbosity of the project init.
Returns Project
from_geojson()
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
pathpathlib.Path | str — Path at which to initialize the project.radius_in_meterfloat — Planet radius.geojsonpathlib.Path | dict — Filename or dictionary containing the geojson data.verbosityint =1— Verbosity of the project init.
Returns Project
from_mesh()
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
pathstr | pathlib.Path — Path at which to initialize the project.meshUnstructuredMesh — Mesh to create domain from.load_if_existsbool =False— If a project with a matching domain has already been created and is stored inpath, then load and return the project on disk rather than creating a new one.verbosityint =1— Verbosity of the project init.
Returns Project
from_volume_model()
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
pathpathlib.Path | str — model filename.volume_modelvolume._VolumeBase — The volumetric model from which to create the domain.load_if_existsbool =False— If a project with a matching domain has already been created and is stored inpath, then load and return the project on disk rather than creating a new one.verbosityint =1— Verbosity of the project init.
Returns Project — A new domain object with the proper extents.
add_to_project()
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
otherE_T — Thing to add.overwritebool =False— Potentially overwrite an existing thing in project if it already exists.skip_validationbool =True— If True, skip validation checks when adding entities. Use with care, this might be slow.timerTimer | None =None— Execution timer.log_to_loggerbool =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.commint | None =None— MPI communicator, if any.
Returns None