[FIX] Report plot polish — colorbar ticks, cyclic direction, T-S bounds, tilt panels - #83
Merged
Merged
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
A round of figure fixes to the grid and stack report plots, found by eyeballing the rendered reports. No manifest or template changes — this is the plotter/adapter layer only.
Changes
Discrete-colorbar tick alignment.
_nice_colorbar_boundssnapped the boundary step to any 1-significant-figure value (0.03, 30), so round labelled ticks (0.2, 100) landed between the colour steps. It now snaps the step to the nice1 / 2 / 2.5 / 5family (asMaxNLocatoruses) and aligns the boundaries to integer multiples spanning the data, so labelled ticks fall on colour-step boundaries. Fixes the grid σ₀ stratification panel and the stack T-S pressure and count-heatmap colorbars. The boundary count is now adaptive (~n) rather than a fixedn+1.Buoyancy frequency N² colour limits.
draw_grid_n2took the 2.5/97.5 percentile oflog10(N²)including the1e-12floor applied to non-positive (unstable) cells, so whenever more than a few percent of cells were unstable the low limit pegged at −12 and washed out the structure. Limits now come from the 1st/99th percentile oflog10(N²)over positive cells only; unstable cells still render as the lowest colour (off-scale low).Current-direction colorbar is now truly cyclic. twilight has 510 native colours, so
BoundaryNorm(ncolors=256)mapped 0–360° onto only the first half of the cycle (pale→dark) — 0° and 360° looked different. The direction panel now resamples twilight to one colour per bin and matchesncolors, so the full cycle shows and 0° == 360°.T-S diagram axis bounds. Both the stack (
draw_stack_ts_diagram) and grid (draw_grid_ts_diagram) T-S panels set axis limits from the full data min/max (grid used the 0.01/99.99 percentiles), so outliers stretched the box with whitespace. A new_nice_axis_limitshelper takes the 1st/99th percentiles, pads 5% of that range on each side, and rounds outward to a clean step.Aquadopp tilt panels (
_make_aquadopp_tilt_panels, stack section 9): gridlines on both the time-series and scatter panels; the scatter shares the time-series y-axis per row on a fixed 0–90° scale with matched x/y ticks (0/30/60/90); panel height reduced to 80%; inter-row spacing tightened with x-labels/ticks on the bottom row only.Tests
test_utilities.py: the two_nice_colorbar_boundstests updated for the adaptive count and nice step, plus a new regression guard that labelled ticks land on colour boundaries.test_plotters.py: two new tests for_nice_axis_limits(padding/rounding and outlier exclusion). Full suite 843 passed. The golden report test stays green because it masks PNG bytes; these are visual changes so no re-baseline was needed.Coverage note
One new branch is unexercised by the dune2 fixture: the tilt panels' upper-row x-tick suppression only runs with more than one Aquadopp, and dune2 has a single one. Covering it needs a multi-Aquadopp fixture.
Breaking changes
None to the public API. Two internal signatures shifted:
_nice_colorbar_boundsnow returns an adaptive-length boundary array (was fixedn+1), and_velocity_panel_stylereturns aColormapobject for the direction panel (was a name string). Both are private (leading underscore) and their callers already accept the new forms.