Class: QgsMeshDatasetSourceInterface¶
- class qgis.core.QgsMeshDatasetSourceInterface¶
Bases:
sip.wrapper
Interface for mesh datasets and dataset groups
Dataset is a collection of vector or scalar values on vertices or faces of the mesh. Based on the underlying data provider/format, whole dataset is either stored in memory or read on demand
Datasets are grouped in the dataset groups. A dataset group represents a measured quantity (e.g. depth or wind speed), dataset represents values of the quantity in a particular time.
Note
The API is considered EXPERIMENTAL and can be changed without a notice
New in version 3.2:
Methods
Associate dataset with the mesh
Returns whether the faces are active for particular dataset
Returns N vector/scalar values from the face index from the dataset for 3d stacked meshes
Returns number of datasets loaded in the group
Returns number of datasets groups loaded
Returns dataset group metadata
Returns the dataset index of the dataset in a specific dataset group at
time
from thereference
timeReturns a list of dataset indexes of the dataset in a specific dataset group that are between
time1
andtime2
from thereference
timeReturns dataset metadata
Returns vector/scalar value associated with the index from the dataset To read multiple continuous values, use
datasetValues()
Returns N vector/scalar values from the index from the dataset
Returns list of additional dataset file URIs added using
addDataset()
calls.Returns whether the face is active for particular dataset
Creates a new dataset group from a data and persists it into a destination path
- addDataset(self, uri: str) bool ¶
Associate dataset with the mesh
emits dataChanged when successful
- Parameters:
uri (str) –
- Return type:
bool
- areFacesActive(self, index: QgsMeshDatasetIndex, faceIndex: int, count: int) QgsMeshDataBlock ¶
Returns whether the faces are active for particular dataset
New in version 3.6.
- Parameters:
index (QgsMeshDatasetIndex) –
faceIndex (int) –
count (int) –
- Return type:
- dataset3dValues(self, index: QgsMeshDatasetIndex, faceIndex: int, count: int) QgsMesh3dDataBlock ¶
Returns N vector/scalar values from the face index from the dataset for 3d stacked meshes
See
QgsMeshDatasetMetadata.isVector()
to check if the returned value is vector or scalarreturns invalid block for DataOnFaces and DataOnVertices.
See also
New in version 3.12.
- Parameters:
index (QgsMeshDatasetIndex) –
faceIndex (int) –
count (int) –
- Return type:
- datasetCount(self, groupIndex: int) int ¶
Returns number of datasets loaded in the group
datasetCount(self, index:
QgsMeshDatasetIndex
) -> int Returns number of datasets loaded in the group- Parameters:
groupIndex (int) –
- Return type:
int
- datasetGroupCount(self) int ¶
Returns number of datasets groups loaded
- Return type:
int
- datasetGroupMetadata(self, groupIndex: int) QgsMeshDatasetGroupMetadata ¶
Returns dataset group metadata
datasetGroupMetadata(self, index:
QgsMeshDatasetIndex
) -> QgsMeshDatasetGroupMetadata Returns dataset group metadata- Parameters:
groupIndex (int) –
- Return type:
- datasetIndexAtTime(self, referenceTime: QDateTime | datetime.datetime, groupIndex: int, time: int, method: QgsMeshDataProviderTemporalCapabilities.MatchingTemporalDatasetMethod) QgsMeshDatasetIndex ¶
Returns the dataset index of the dataset in a specific dataset group at
time
from thereference
time- Parameters:
referenceTime (Union[QDateTime) – the reference time from where to find the dataset
groupIndex (int) – the index of the dataset group
time (int) – the relative time from reference time
method (QgsMeshDataProviderTemporalCapabilities.MatchingTemporalDatasetMethod) – the method used to check the time
- Return type:
- Returns:
the dataset index
- datasetIndexInTimeInterval(self, referenceTime: QDateTime | datetime.datetime, groupIndex: int, time1: int, time2: int) List[QgsMeshDatasetIndex] ¶
Returns a list of dataset indexes of the dataset in a specific dataset group that are between
time1
andtime2
from thereference
time- Parameters:
referenceTime (Union[QDateTime) – the reference time from where to find the dataset
groupIndex (int) – the index of the dataset group
time1 (int) – the first relative time of the time intervale from reference time
time2 (int) – the second relative time of the time intervale from reference time
- Return type:
List[QgsMeshDatasetIndex]
- Returns:
the dataset index
New in version 3.22.
- datasetMetadata(self, index: QgsMeshDatasetIndex) QgsMeshDatasetMetadata ¶
Returns dataset metadata
- Parameters:
index (QgsMeshDatasetIndex) –
- Return type:
- datasetValue(self, index: QgsMeshDatasetIndex, valueIndex: int) QgsMeshDatasetValue ¶
Returns vector/scalar value associated with the index from the dataset To read multiple continuous values, use
datasetValues()
See
QgsMeshDatasetMetadata.isVector()
orQgsMeshDataBlock.type()
to check if the returned value is vector or scalarReturns invalid value for DataOnVolumes
See also
- Parameters:
index (QgsMeshDatasetIndex) –
valueIndex (int) –
- Return type:
- datasetValues(self, index: QgsMeshDatasetIndex, valueIndex: int, count: int) QgsMeshDataBlock ¶
Returns N vector/scalar values from the index from the dataset
See
QgsMeshDatasetMetadata.isVector()
orQgsMeshDataBlock.type()
to check if the returned value is vector or scalarReturns invalid block for DataOnVolumes. Use
QgsMeshLayerUtils.datasetValues()
if you need block for any type of data typeNew in version 3.6.
- Parameters:
index (QgsMeshDatasetIndex) –
valueIndex (int) –
count (int) –
- Return type:
- extraDatasets(self) List[str] ¶
Returns list of additional dataset file URIs added using
addDataset()
calls.- Return type:
List[str]
- isFaceActive(self, index: QgsMeshDatasetIndex, faceIndex: int) bool ¶
Returns whether the face is active for particular dataset
For example to represent the situation when F1 and F3 are flooded, but F2 is dry, some solvers store water depth on vertices V1-V8 (all non-zero values) and set active flag for F2 to
False
. V1 —- V2 —- V5—–V7 | F1 | F2 | F3 | V3 —- V4 —- V6—–V8- Parameters:
index (QgsMeshDatasetIndex) –
faceIndex (int) –
- Return type:
bool
- persistDatasetGroup(self, path: str, meta: QgsMeshDatasetGroupMetadata, datasetValues: Iterable[QgsMeshDataBlock], datasetActive: Iterable[QgsMeshDataBlock], times: Iterable[float]) bool ¶
Creates a new dataset group from a data and persists it into a destination path
On success, the mesh’s dataset group count is changed
- Parameters:
path (str) – destination path of the stored file in form DRIVER_NAME:path
meta (QgsMeshDatasetGroupMetadata) – new group’s metadata
datasetValues (Iterable[QgsMeshDataBlock]) – scalar/vector values for all datasets and all faces/vertices in the group
datasetActive (Iterable[QgsMeshDataBlock]) – active flag values for all datasets in the group. Empty array represents can be used when all faces are active
times (Iterable[float]) – times in hours for all datasets in the group
- Returns:
True
on failure,False
on success
Note
Doesn’t work if there is “:” in the path (e.g. Windows system)
New in version 3.6.
Deprecated since version QGIS: 3.12.3
persistDatasetGroup(self, outputFilePath: str, outputDriver: str, meta:
QgsMeshDatasetGroupMetadata
, datasetValues: Iterable[QgsMeshDataBlock], datasetActive: Iterable[QgsMeshDataBlock], times: Iterable[float]) -> bool Creates a new dataset group from a data and persists it into a destination pathOn success, the mesh’s dataset group count is changed
- Parameters:
outputFilePath – destination path of the stored file
outputDriver – output driver name
meta – new group’s metadata
datasetValues – scalar/vector values for all datasets and all faces/vertices in the group
datasetActive – active flag values for all datasets in the group. Empty array represents can be used when all faces are active
times – times in hours for all datasets in the group
- Returns:
True
on failure,False
on success
New in version 3.12.3.
persistDatasetGroup(self, outputFilePath: str, outputDriver: str, source:
QgsMeshDatasetSourceInterface
, datasetGroupIndex: int) -> bool Saves a an existing dataset group provided bysource
to a file with a specified driverOn success, the mesh’s dataset group count is changed
- Parameters:
outputFilePath – destination path of the stored file
outputDriver – output driver name
source – source of the dataset group
datasetGroupIndex – index of the dataset group in the
source
- Return type:
bool
- Returns:
True
on failure,False
on success
New in version 3.16.