Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Simplify Dfsu #657

Merged
merged 21 commits into from
Mar 1, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading