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

Improve "fringy" look when plotting shaded dfsu. #760

Open
zweihuehner opened this issue Nov 27, 2024 · 2 comments
Open

Improve "fringy" look when plotting shaded dfsu. #760

zweihuehner opened this issue Nov 27, 2024 · 2 comments
Labels
enhancement New feature or request

Comments

@zweihuehner
Copy link

zweihuehner commented Nov 27, 2024

Description
When plotting a dfsu DataArray with plot_type="shaded", the triangles that lie close to elements that fell "dry" during a simulation are looking quite fringy. The underlying function is the matplotlib tripcolor in _FM_utils.py. Possibly the behavior is coming from matplotlib and can not be changed in mikeio.

To Reproduce
Load a dfsu dataset that comes from a m3fm simulation with dry falling elements. Plot a DataArray from the dataset like the following.

import mikeio
import matplotlib.pyplot as plt
ds = mikeio.read("example.dfsu")
fig, ax = plt.subplots(figsize = (14,14))
ds.Current_speed.plot(ax = ax, plot_type="shaded")

Example File:
example_dfsu.zip

Expected behavior
See a shaded plot without the fringy look of the triangle edges.

Screenshots
image

System information:

  • Python version: 3.10.10
  • MIKE IO version: 2.2.dev3
@ecomodeller ecomodeller added the enhancement New feature or request label Jan 20, 2025
@ecomodeller
Copy link
Member

It seems like support for plots for data with missing values, e.g. because of drying is generally lacking in MIKE IO.

In some cases it could be ok, to use the recently implemented mikeio.DataArray.fillna.
Image

But in general filling missing values with a constant value, is very crude.

@ecomodeller
Copy link
Member

Or how about removing all dry elements:

import matplotlib.pyplot as plt
import numpy as np
da = ds.Current_speed.isel(time=0)
fig, ax = plt.subplots(ncols=2, figsize=(15,4))
wet = ~np.isnan(da.to_numpy())
idx = np.where(wet)[0]
da.plot(plot_type="shaded", title="Default",ax=ax[0])

da.plot.outline(ax=ax[1])
da.isel(element=idx).plot(plot_type="shaded", ax=ax[1], title="Only wet elements");

Image

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants