Skip to content

Commit

Permalink
Merge pull request #657 from DHI/dfsu-oop
Browse files Browse the repository at this point in the history
Simplify Dfsu
  • Loading branch information
ecomodeller authored Mar 1, 2024
2 parents fdd9e4c + a9ff6e7 commit fca91b1
Show file tree
Hide file tree
Showing 16 changed files with 451 additions and 1,460 deletions.
3 changes: 3 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,9 @@ build: typecheck test
lint:
ruff .

pylint:
pylint --disable=all --enable=attribute-defined-outside-init mikeio/

test:
pytest --disable-warnings

Expand Down
9 changes: 0 additions & 9 deletions mikeio/_spectral.py
Original file line number Diff line number Diff line change
Expand Up @@ -61,15 +61,6 @@ def plot_2dspectrum(
Returns
-------
<matplotlib.axes>
Examples
--------
>>> dfs = Dfsu("area_spectrum.dfsu")
>>> ds = dfs.read(items="Energy density")
>>> spectrum = ds[0][0, 0, :, :] # first timestep, element 0
>>> dfs.plot_spectrum(spectrum, plot_type="patch")
>>> dfs.plot_spectrum(spectrum, rmax=9, title="Wave spectrum T<9s")
"""

import matplotlib.pyplot as plt
Expand Down
5 changes: 4 additions & 1 deletion mikeio/dataset/_dataarray.py
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,10 @@ def __call__(self, tail: bool = True) -> "DataArray":
item = ItemInfo(EUMType.Significant_wave_height)
g = self.da.geometry
if isinstance(g, GeometryFMPointSpectrum):
geometry: Any = GeometryPoint2D(x=g.x, y=g.y)
if g.x is not None and g.y is not None:
geometry: Any = GeometryPoint2D(x=g.x, y=g.y)
else:
geometry = GeometryUndefined()
elif isinstance(g, GeometryFMLineSpectrum):
geometry = Grid1D(
nx=g.n_nodes,
Expand Down
4 changes: 2 additions & 2 deletions mikeio/dataset/_dataset.py
Original file line number Diff line number Diff line change
Expand Up @@ -1883,9 +1883,9 @@ def _to_dfs1(self, filename: str | Path) -> None:
write_dfs1(filename=filename, ds=self)

def _to_dfsu(self, filename: str | Path) -> None:
from ..dfsu._dfsu import _write_dfsu
from ..dfsu import write_dfsu

_write_dfsu(filename, self)
write_dfsu(filename, self)

def to_xarray(self) -> "xarray.Dataset":
"""Export to xarray.Dataset"""
Expand Down
4 changes: 2 additions & 2 deletions mikeio/dfsu/__init__.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from ._dfsu import _write_dfsu, Dfsu2DH
from ._dfsu import write_dfsu, Dfsu2DH
from ._mesh import Mesh
from ._factory import Dfsu
from ._layered import Dfsu2DV, Dfsu3D
Expand All @@ -7,7 +7,7 @@
__all__ = [
"Mesh",
"Dfsu",
"_write_dfsu",
"write_dfsu",
"Dfsu2DH",
"Dfsu2DV",
"Dfsu3D",
Expand Down
Loading

0 comments on commit fca91b1

Please sign in to comment.