From aa413772e2328d2eb2f993c81f7d50c56c3ec45f Mon Sep 17 00:00:00 2001 From: Henrik Andersson Date: Mon, 25 Mar 2024 10:56:45 +0100 Subject: [PATCH 1/8] Forgot about qmd notebook --- docs/examples/Dfsu-2D-interpolation.qmd | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/docs/examples/Dfsu-2D-interpolation.qmd b/docs/examples/Dfsu-2D-interpolation.qmd index d53dce055..3f4ccf720 100644 --- a/docs/examples/Dfsu-2D-interpolation.qmd +++ b/docs/examples/Dfsu-2D-interpolation.qmd @@ -163,7 +163,7 @@ Let's first try the approx for a single element: * Interpolate ```{python} -dist = dist_in_meters(scatter[:,:2], dfs.element_coordinates[0,:2]) +dist = dist_in_meters(scatter[:,:2], dfs.geometry.element_coordinates[0,:2]) dist ``` @@ -179,11 +179,11 @@ np.dot(scatter[:,2], w) # interpolated value in element 0 Let's do the same for all points in the mesh and plot in the end ```{python} -dati = np.zeros((1,dfs.n_elements)) +dati = np.zeros((1, dfs.n_elements)) for j in range(dfs.n_elements): - dist = dist_in_meters(scatter[:,:2], dfs.element_coordinates[j,:2]) + dist = dist_in_meters(scatter[:, :2], dfs.geometry.element_coordinates[j, :2]) w = get_idw_interpolant(dist, p=2) - dati[0,j] = np.dot(scatter[:,2], w) + dati[0, j] = np.dot(scatter[:, 2], w) ``` ```{python} From b87b01b17ee59d23f7cfe476239ebf3a57c09aa4 Mon Sep 17 00:00:00 2001 From: Henrik Andersson Date: Mon, 25 Mar 2024 11:05:20 +0100 Subject: [PATCH 2/8] One more --- docs/examples/Dfsu-2D-interpolation.qmd | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/docs/examples/Dfsu-2D-interpolation.qmd b/docs/examples/Dfsu-2D-interpolation.qmd index 3f4ccf720..10b5c48e8 100644 --- a/docs/examples/Dfsu-2D-interpolation.qmd +++ b/docs/examples/Dfsu-2D-interpolation.qmd @@ -179,8 +179,8 @@ np.dot(scatter[:,2], w) # interpolated value in element 0 Let's do the same for all points in the mesh and plot in the end ```{python} -dati = np.zeros((1, dfs.n_elements)) -for j in range(dfs.n_elements): +dati = np.zeros((1, dfs.geometry.n_elements)) +for j in range(dfs.geometry.n_elements): dist = dist_in_meters(scatter[:, :2], dfs.geometry.element_coordinates[j, :2]) w = get_idw_interpolant(dist, p=2) dati[0, j] = np.dot(scatter[:, 2], w) From 15bcb5dc6a271fb86266e6527f44aaf4e536bfab Mon Sep 17 00:00:00 2001 From: Henrik Andersson Date: Wed, 27 Mar 2024 09:38:07 +0100 Subject: [PATCH 3/8] Beta 2.0 --- mikeio/__init__.py | 2 +- mikeio/dataset/_dataset.py | 2 -- pyproject.toml | 2 +- 3 files changed, 2 insertions(+), 4 deletions(-) diff --git a/mikeio/__init__.py b/mikeio/__init__.py index 3f8ec8cb1..f53b935f9 100644 --- a/mikeio/__init__.py +++ b/mikeio/__init__.py @@ -21,7 +21,7 @@ # 'X.Y.dev0' is the canonical version of 'X.Y.dev' # -__version__ = "2.0.dev0" # TODO use git hash instead for dev version? +__version__ = "2.0.b0" # TODO use git hash instead for dev version? # __version__ = "1.5.0" __dfs_version__: int = 200 diff --git a/mikeio/dataset/_dataset.py b/mikeio/dataset/_dataset.py index 77cc84b42..28a1ea38b 100644 --- a/mikeio/dataset/_dataset.py +++ b/mikeio/dataset/_dataset.py @@ -573,8 +573,6 @@ def remove(self, key: int | str) -> None: -------- pop """ - # deprecated - warnings.warn("Dataset.remove is deprecated", FutureWarning) self.__delitem__(key) def rename(self, mapper: Mapping[str, str], inplace: bool = False) -> "Dataset": diff --git a/pyproject.toml b/pyproject.toml index fff86526d..ddae0ee8a 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -10,7 +10,7 @@ allow-direct-references = true [project] name="mikeio" -version="2.0.dev0" +version="2.0.b0" dependencies = [ "mikecore>=0.2.1", "numpy>=1.22.0", From 231eaf7bb31b67250085f9d253554d5386a9e9dc Mon Sep 17 00:00:00 2001 From: Henrik Andersson Date: Wed, 27 Mar 2024 09:44:59 +0100 Subject: [PATCH 4/8] Remove quartodoc github dependency. --- .github/workflows/build_docs.yml | 1 + .github/workflows/docs.yml | 1 + pyproject.toml | 2 +- 3 files changed, 3 insertions(+), 1 deletion(-) diff --git a/.github/workflows/build_docs.yml b/.github/workflows/build_docs.yml index 8a342aeb1..6187c96e9 100644 --- a/.github/workflows/build_docs.yml +++ b/.github/workflows/build_docs.yml @@ -18,6 +18,7 @@ jobs: - name: Install MIKE IO run: | + pip install quartodoc@git+https://github.com/machow/quartodoc#d4140b4f804ebc6ec249699d52e3efa62cf53127 pip install .[dev] - name: Build documentation diff --git a/.github/workflows/docs.yml b/.github/workflows/docs.yml index a4078287e..3b6e57381 100644 --- a/.github/workflows/docs.yml +++ b/.github/workflows/docs.yml @@ -21,6 +21,7 @@ jobs: - name: Install mikeio run: | + pip install quartodoc@git+https://github.com/machow/quartodoc#d4140b4f804ebc6ec249699d52e3efa62cf53127 pip install .[dev] - name: Build documentation diff --git a/pyproject.toml b/pyproject.toml index ddae0ee8a..1539327c4 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -48,7 +48,7 @@ classifiers = [ dev = ["pytest", "black==22.3.0", "quarto-cli", - "quartodoc@git+https://github.com/machow/quartodoc#d4140b4f804ebc6ec249699d52e3efa62cf53127", + "quartodoc", "shapely", "pyproj", "xarray", From d1e68f2aa0f0eee1ea36f4463f7e1c371739c6b8 Mon Sep 17 00:00:00 2001 From: Henrik Andersson Date: Tue, 2 Apr 2024 07:32:22 +0200 Subject: [PATCH 5/8] Scipy intersphinx --- docs/_quarto.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/_quarto.yml b/docs/_quarto.yml index 53cd26d2e..02da33983 100644 --- a/docs/_quarto.yml +++ b/docs/_quarto.yml @@ -76,7 +76,7 @@ interlinks: pandas: url: https://pandas.pydata.org/docs/ scipy: - url: https://docs.scipy.org/doc/scipy/reference/ + url: https://docs.scipy.org/doc/scipy/ quartodoc: style: pkgdown From 9a428fab0fc7ca36aac1140e8035905c4656b5ae Mon Sep 17 00:00:00 2001 From: Henrik Andersson Date: Tue, 2 Apr 2024 07:48:23 +0200 Subject: [PATCH 6/8] Docs --- docs/user-guide/dataarray.qmd | 14 +++---- docs/user-guide/dataset.qmd | 72 ++++++++--------------------------- 2 files changed, 21 insertions(+), 65 deletions(-) diff --git a/docs/user-guide/dataarray.qmd b/docs/user-guide/dataarray.qmd index 9cde697d4..ee722b076 100644 --- a/docs/user-guide/dataarray.qmd +++ b/docs/user-guide/dataarray.qmd @@ -92,16 +92,14 @@ See details in the [API specification](`mikeio.dataset._data_plot._DataArrayPlot The DataArray has several properties: -* n_items - Number of items -* n_timesteps - Number of timesteps -* n_elements - Number of elements -* start_time - First time instance (as datetime) -* end_time - Last time instance (as datetime) -* is_equidistant - Is the time series equidistant in time -* timestep - Time step in seconds (if is_equidistant) -* shape - Shape of each item +* time - Time index +* geometry - geometry of the data (e.g. `spatial.GeometryFM2D`) +* shape - Shape of the data * deletevalue - File delete value (NaN value) +```{python} +da.geometry +``` ## Methods diff --git a/docs/user-guide/dataset.qmd b/docs/user-guide/dataset.qmd index a081f317b..ea2dcc648 100644 --- a/docs/user-guide/dataset.qmd +++ b/docs/user-guide/dataset.qmd @@ -14,19 +14,10 @@ The Dataset has the following primary properties: Use Dataset's string representation to get an overview of the Dataset -```python ->>> import mikeio ->>> ds = mikeio.read("testdata/HD2D.dfsu") ->>> ds - -dims: (time:9, element:884) -time: 1985-08-06 07:00:00 - 1985-08-07 03:00:00 (9 records) -geometry: Dfsu2D (884 elements, 529 nodes) -items: - 0: Surface elevation (meter) - 1: U velocity (meter per sec) - 2: V velocity (meter per sec) - 3: Current speed (meter per sec) +```{python} +import mikeio +ds = mikeio.read("../data/HD2D.dfsu") +ds ``` ## {{< fa filter >}} Selecting items @@ -41,13 +32,8 @@ Selecting a specific item "itemA" (at position 0) from a Dataset ds can be done We recommend the use *named* items for readability. -``` ->>> ds.Surface_elevation - -name: Surface elevation -dims: (time:9, element:884) -time: 1985-08-06 07:00:00 - 1985-08-07 03:00:00 (9 records) -geometry: Dfsu2D (884 elements, 529 nodes) +```{python} +ds.Surface_elevation ``` Negative index e.g. ds[-1] can also be used to select from the end. @@ -63,46 +49,20 @@ Note that this behavior is similar to pandas and xarray. A time slice of a Dataset can be selected in several different ways. -```python ->>> ds.sel(time="1985-08-06 12:00") - -dims: (element:884) -time: 1985-08-06 12:00:00 (time-invariant) -geometry: Dfsu2D (884 elements, 529 nodes) -items: - 0: Surface elevation (meter) - 1: U velocity (meter per sec) - 2: V velocity (meter per sec) - 3: Current speed (meter per sec) - ->>> ds["1985-8-7":] - -dims: (time:2, element:884) -time: 1985-08-07 00:30:00 - 1985-08-07 03:00:00 (2 records) -geometry: Dfsu2D (884 elements, 529 nodes) -items: - 0: Surface elevation (meter) - 1: U velocity (meter per sec) - 2: V velocity (meter per sec) - 3: Current speed (meter per sec) +```{python} +ds.sel(time="1985-08-06 12:00") +``` +```{python} +ds["1985-8-7":] ``` ## {{< fa map >}} Spatial selection -The `sel` method finds the nearest element. - -```python ->>> ds.sel(x=607002, y=6906734) - -dims: (time:9) -time: 1985-08-06 07:00:00 - 1985-08-07 03:00:00 (9 records) -geometry: GeometryPoint2D(x=607002.7094112666, y=6906734.833048992) -items: - 0: Surface elevation (meter) - 1: U velocity (meter per sec) - 2: V velocity (meter per sec) - 3: Current speed (meter per sec) +The `sel` method finds a single element. + +```{python} +ds.sel(x=607002, y=6906734) ``` @@ -129,8 +89,6 @@ The Dataset (and DataArray) has several properties: * shape - Shape of each item * deletevalue - File delete value (NaN value) - - ## Methods Dataset (and DataArray) has several useful methods for working with data, From 00f71ccac30b890784dfdd8307c215f54f341cd3 Mon Sep 17 00:00:00 2001 From: Henrik Andersson Date: Tue, 2 Apr 2024 13:05:06 +0200 Subject: [PATCH 7/8] Future --- mikeio/spatial/_utils.py | 1 + 1 file changed, 1 insertion(+) diff --git a/mikeio/spatial/_utils.py b/mikeio/spatial/_utils.py index db414ada7..97ce632f3 100644 --- a/mikeio/spatial/_utils.py +++ b/mikeio/spatial/_utils.py @@ -1,3 +1,4 @@ +from __future__ import annotations import numpy as np from ._geometry import BoundingBox From 08f52ac9fb6f2c91599f56a5f62a277b296c7dde Mon Sep 17 00:00:00 2001 From: Henrik Andersson Date: Thu, 4 Apr 2024 09:54:21 +0200 Subject: [PATCH 8/8] Update dfsu.qmd --- docs/user-guide/dfsu.qmd | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/user-guide/dfsu.qmd b/docs/user-guide/dfsu.qmd index 6ef75318d..567a131c4 100644 --- a/docs/user-guide/dfsu.qmd +++ b/docs/user-guide/dfsu.qmd @@ -31,7 +31,7 @@ In MIKE Zero, node ids, element ids and layer ids are 1-based. In MIKE IO, all ## MIKE IO Flexible Mesh Geometry -MIKE IO has a Flexible Mesh Geometry class, [`GeometryFM`](`mikeio.spatial.GeometryFM2D`), containing the list of node coordinates and the element table which defines the mesh, as well as a number of derived properties (e.g. element coordinates) and methods making it convenient to work with the mesh. +MIKE IO has Flexible Mesh Geometry classes, e.g. [`GeometryFM2D`](`mikeio.spatial.GeometryFM2D`), containing the list of node coordinates and the element table which defines the mesh, as well as a number of derived properties (e.g. element coordinates) and methods making it convenient to work with the mesh. | Property | Description | |----------|--------------|