Skip to content

Commit

Permalink
Merge branch 'main' into fm-isel-no-sort
Browse files Browse the repository at this point in the history
  • Loading branch information
ecomodeller authored May 1, 2024
2 parents aadb3c3 + 08f52ac commit 8a46255
Show file tree
Hide file tree
Showing 11 changed files with 34 additions and 77 deletions.
1 change: 1 addition & 0 deletions .github/workflows/build_docs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
1 change: 1 addition & 0 deletions .github/workflows/docs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion docs/_quarto.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
10 changes: 5 additions & 5 deletions docs/examples/Dfsu-2D-interpolation.qmd
Original file line number Diff line number Diff line change
Expand Up @@ -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
```

Expand All @@ -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))
for j in range(dfs.n_elements):
dist = dist_in_meters(scatter[:,:2], dfs.element_coordinates[j,:2])
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)
dati[0, j] = np.dot(scatter[:, 2], w)
```

```{python}
Expand Down
14 changes: 6 additions & 8 deletions docs/user-guide/dataarray.qmd
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
72 changes: 15 additions & 57 deletions docs/user-guide/dataset.qmd
Original file line number Diff line number Diff line change
Expand Up @@ -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
<mikeio.Dataset>
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 <Surface Elevation> (meter)
1: U velocity <u velocity component> (meter per sec)
2: V velocity <v velocity component> (meter per sec)
3: Current speed <Current Speed> (meter per sec)
```{python}
import mikeio
ds = mikeio.read("../data/HD2D.dfsu")
ds
```

## {{< fa filter >}} Selecting items
Expand All @@ -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
<mikeio.DataArray>
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.
Expand All @@ -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")
<mikeio.Dataset>
dims: (element:884)
time: 1985-08-06 12:00:00 (time-invariant)
geometry: Dfsu2D (884 elements, 529 nodes)
items:
0: Surface elevation <Surface Elevation> (meter)
1: U velocity <u velocity component> (meter per sec)
2: V velocity <v velocity component> (meter per sec)
3: Current speed <Current Speed> (meter per sec)

>>> ds["1985-8-7":]
<mikeio.Dataset>
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 <Surface Elevation> (meter)
1: U velocity <u velocity component> (meter per sec)
2: V velocity <v velocity component> (meter per sec)
3: Current speed <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)
<mikeio.Dataset>
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 <Surface Elevation> (meter)
1: U velocity <u velocity component> (meter per sec)
2: V velocity <v velocity component> (meter per sec)
3: Current speed <Current Speed> (meter per sec)
The `sel` method finds a single element.

```{python}
ds.sel(x=607002, y=6906734)
```


Expand All @@ -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,
Expand Down
2 changes: 1 addition & 1 deletion docs/user-guide/dfsu.qmd
Original file line number Diff line number Diff line change
Expand Up @@ -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 |
|----------|--------------|
Expand Down
2 changes: 1 addition & 1 deletion mikeio/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
2 changes: 0 additions & 2 deletions mikeio/dataset/_dataset.py
Original file line number Diff line number Diff line change
Expand Up @@ -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":
Expand Down
1 change: 1 addition & 0 deletions mikeio/spatial/_utils.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
from __future__ import annotations
import numpy as np

from ._geometry import BoundingBox
Expand Down
4 changes: 2 additions & 2 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down Expand Up @@ -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",
Expand Down

0 comments on commit 8a46255

Please sign in to comment.