Skip to content

Merging contour-maps-opt into contour-maps - #1829

Merged
dylannelson merged 5 commits into
contour-mapsfrom
cmd/contour-maps-opt
Oct 19, 2026
Merged

dylannelson merged 5 commits into
contour-mapsfrom
cmd/contour-maps-opt

Conversation

@dylannelson

Copy link
Copy Markdown
Member

Testing if I can do this in the interface without review

cmdupuis3 and others added 5 commits October 13, 2026 16:58
HoloViews and both plotting backends handle each path separately, so a
noisy field with ~77k lines on a 786k-face mesh took 181 s to render with
Matplotlib and 14.5 s with Bokeh, plus 2 s to build the element. With one
path per level the lines are drawn as gaps at almost no cost: 0.14 s,
0.13 s and 0.07 s. The level is still the value of each path, so hover
is unchanged, and the rendered images match.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Projecting every line with project_geometry took ~0.1 ms per line, or
7.4 s for the ~77k lines of a noisy field on a 786k-face mesh. A line with
a projected point well inside the projection's domain has extent on the
map, so all points are projected at once and only the remaining lines,
such as those along the edge of the map or off it, are projected as
lines. The lines kept are the same as before for 10 projections (global,
hemispheric, regional and shifted central longitudes) on four datasets,
and the check takes 0.04-1.1 s instead of 2.3-4.4 s on a 197k-face mesh.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Both were done with several NumPy calls per line, which for the ~77k
lines of a noisy field on a 786k-face mesh took 1.1 s in _edge_contours
and 0.5 s in _label_points. The lines are now handled as one array of
points: _edge_contours unwraps them together and splits only the lines
that cross the antimeridian (1.8 s -> 1.0 s including joining), and
_label_points finds the middles only of the lines it labels
(0.52 s -> 0.05 s).

Longitudes are now unwrapped by whole multiples of 360, so a node on the
antimeridian lands exactly on +-180 instead of a rounding error past it.
That removes the zero-length pieces and repeated end points that clipping
at the antimeridian gave for such lines. The lines are otherwise the
same, and the labels are at the same points; lines of exactly equal
length are now labeled in the order they were found.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
_join_segments walked the segments in pure Python, which took 0.89 s for
the ~650k segments of a noisy field on a 786k-face mesh. The kernel
keeps the same walk, with the segments at each node in CSR arrays and a
per-node cursor to the first unused one, and gives the same lines in the
same order (checked on random graphs with branching nodes, self-loops and
repeated segments, and on the segments of four meshes). It takes 0.074 s,
and _edge_contours as a whole goes from 1.0 s to 0.2 s.

The lines are returned as one array of nodes with offsets, the layout
_edge_contours already built from the lists. The kernel holds no Python
objects, so it is compiled with nogil=True and can run in threads (8
calls on 8 threads ran 4x faster than in sequence).

Also applies ruff format to a line from the projection filter commit.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Conflicts resolved:
- uxarray/plot/contour.py: kept both _unwrap_lines and _grid_extents, and
  both _paths_by_level and _label_fraction. _label_points combines the
  line lengths found for all lines at once with labeling only a fraction
  of the levels.
- uxarray/plot/accessor.py: one NaN-separated path per level, keyed by
  the fixed "level" dimension, with labels for a fraction of the levels.
- test/test_plot.py: kept both the projection filter test and the frame
  test.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@dylannelson
dylannelson merged commit 1337347 into contour-maps Oct 19, 2026
18 of 19 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants