Deltares / Deltares/imod-python

Refactor visualize cross section

Open
#233 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Python
Stars
41
Forks
12
Avg merge
21h 8m
Merged PRs (30d)
1

Description

In GitLab by @Huite on Apr 15, 2022, 14:30

Cross section currently builds a QuadMesh. It seems somewhat unlikely that this is faster than a straight up PolyCollection. This is more flexible, and easier to construct, e.g.:

x = da["x"].values
nx = x.size
nlayer = subsoil["layer"].size
x0 = np.broadcast_to(x - 0.5 * dx, (nlayer, nx))
x1 = np.broadcast_to(x + 0.5 * dx, (nlayer, nx))
y1 = (da["thickness"].cumsum("layer") + da["zbase"]).values
y0 = y1 - subsoil["thickness"].values

x0 = x0.ravel()
x1 = x1.ravel()
y0 = y0.ravel()
y1 = y1.ravel()

values = subsoil[var].values.ravel()
nface = values.size
vertices = np.empty((nface, 4, 2))
vertices[:, 0, 0] = x0
vertices[:, 1, 0] = x1
vertices[:, 2, 0] = x1
vertices[:, 3, 0] = x0
vertices[:, 0, 1] = y0
vertices[:, 1, 1] = y0
vertices[:, 2, 1] = y1
vertices[:, 3, 1] = y1

kwargs = {"cmap": "turbo"}
valid = ~np.isnan(values)
vertices = vertices[valid]
collection = PolyCollection(vertices, **kwargs)
collection.set_array(values)
primitive = ax0.add_collection(collection)

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

The issue does not name a file or test. Start by locating the cross-section visualization that currently constructs a QuadMesh, then compare it with the proposed PolyCollection geometry. Done means the cross section uses the new collection while preserving its rendered values and handling of invalid data.

Written by the indexing model from the issue text.

Assessment

Tech stack
numpy, python
Domain
data-visualization
Issue type
Refactor
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
42/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.