Skip to content

Commit

Permalink
Fix user-guide
Browse files Browse the repository at this point in the history
  • Loading branch information
ecomodeller committed Mar 5, 2024
1 parent a25add6 commit 8d5af8e
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 18 deletions.
1 change: 0 additions & 1 deletion docs/objects.json

This file was deleted.

2 changes: 1 addition & 1 deletion docs/user-guide/dataset.qmd
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ The [](`mikeio.read`) methods returns a Dataset as a container of [DataArray](`m

The Dataset has the following primary properties:

* **items** - a list of [](`mikeio.eum.ItemInfo`) items for each dataarray
* **items** - a list of [](`mikeio.ItemInfo`) items for each dataarray
* **time** - a [](`pandas.DatetimeIndex`) with the time instances of the data
* **geometry** - a Geometry object with the spatial description of the data

Expand Down
34 changes: 22 additions & 12 deletions docs/user-guide/mesh.qmd
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,6 @@ coastalzone
Find if points are inside the domain

```{python}
#| tags: []
from shapely.geometry import Point
p1 = Point(216000, 6162000)
Expand All @@ -72,11 +71,11 @@ print(mp.contains(p1))
print(mp.contains(p2))
```

## Mesh class can also check if a mesh contains points
We can get similar functionality from the `.geometry` attribute of the mesh object.

```{python}
p1p2 = [[216000, 6162000], [220000, 6156000]]
msh.contains(p1p2)
msh.geometry.contains(p1p2)
```

```{python}
Expand All @@ -91,23 +90,34 @@ ax.legend();
Assume that we want to have a minimum depth of 2 meters and change the open boundary (code 2) to a closed one (code 1).

```{python}
print(f'max z before: {msh.node_coordinates[:,2].max()}')
zc = msh.node_coordinates[:,2]
g = msh.geometry
print(f'max z before: {g.node_coordinates[:,2].max()}')
zc = g.node_coordinates[:,2]
zc[zc>-2] = -2
msh.zn = zc
print(f'max z after: {msh.node_coordinates[:,2].max()}')
g.node_coordinates[:,2] = zc
print(f'max z after: {g.node_coordinates[:,2].max()}')
```


```{python}
print(f'valid codes before: {msh.valid_codes}')
c = msh.geometry.codes
c = g.codes
c[c==2] = 1
msh.codes = c
print(f'valid codes after: {msh.valid_codes}')
g.codes = c
```

Save the modfied geometry to a new mesh file

```{python}
msh.plot()
g.to_mesh("new_mesh.mesh")
```

Cleanup

```{python}
import os
os.remove("new_mesh.mesh")
```



8 changes: 4 additions & 4 deletions docs/user-guide/pfs.qmd
Original file line number Diff line number Diff line change
Expand Up @@ -41,20 +41,20 @@ pfs

### PfsDocument

The [](`-mikeio.PfsDocument`) is the MIKE IO equivalent to a PFS file. Its targets can be accessed by their name (as properties), like this:
The [](`mikeio.PfsDocument`) is the MIKE IO equivalent to a PFS file. Its targets can be accessed by their name (as properties), like this:

```{python}
pfs.txconc
```

Or by the `pfs.targets` object (which is a list of PfsSections). Each of the targets is a `PfsSection` object consisting of key-value pairs (keyword-parameter) and other PfsSections.

The [](`-mikeio.PfsDocument`) object is similar to a dictionary. You can loop over its contents with `items()`, `keys()` and `values()` like a dictionary.
The [](`mikeio.PfsDocument`) object is similar to a dictionary. You can loop over its contents with `items()`, `keys()` and `values()` like a dictionary.


### PfsSection

The [](`-mikeio.PfsSection`) object is also similar to a dictionary. You can loop over its contents with `items()`, `keys()` and `values()` like a dictionary.
The [](`mikeio.PfsSection`) object is also similar to a dictionary. You can loop over its contents with `items()`, `keys()` and `values()` like a dictionary.

```{python}
pfs.txconc.keys()
Expand Down Expand Up @@ -88,7 +88,7 @@ pfs.txconc.Setup.to_dataframe(prefix="File_")

### Unique or non-unique keywords

Depending on the engine intended for reading the PFS file it may or may not make sense to have multiple identical keywords in the same PfsSection. MIKE 21/3 and the marine tools does *not* support non-unique keywords---if non-unique keywords are present, only the first will be read and the presence is most likely a mistake made by hand-editing the file. In other tools, e.g. MIKE Plot Composer, non-unique keywords are used a lot. How MIKE IO shall deal with non-unique keywords can be specified using the `unique_keywords` argument in the [](`-mikeio.read_pfs`) function:
Depending on the engine intended for reading the PFS file it may or may not make sense to have multiple identical keywords in the same PfsSection. MIKE 21/3 and the marine tools does *not* support non-unique keywords---if non-unique keywords are present, only the first will be read and the presence is most likely a mistake made by hand-editing the file. In other tools, e.g. MIKE Plot Composer, non-unique keywords are used a lot. How MIKE IO shall deal with non-unique keywords can be specified using the `unique_keywords` argument in the [](`mikeio.read_pfs`) function:

```python
pfs = mikeio.read_pfs("myplot.plt", unique_keywords=False)
Expand Down

0 comments on commit 8d5af8e

Please sign in to comment.