Skip to content

Nemobug2 - bug fixes for a certain set of NEMO output - #138

Merged
sadielbartholomew merged 19 commits into
NCAS-CMS:mainfrom
bnlawrence:nemobug2
Oct 30, 2026
Merged

sadielbartholomew merged 19 commits into
NCAS-CMS:mainfrom
bnlawrence:nemobug2

Conversation

@bnlawrence

@bnlawrence bnlawrence commented Oct 16, 2026 •

Copy link
Copy Markdown

This PR addresses the issue outlined in #126, by making some fixes for curvilinear coordinate for normal plotting and with blockfill. This PR replaces #137 which was on top of a previous PR and unnecessarily complicated.

(Original 3 commits supplemented by ~15 commits added by @sadielbartholomew to quickly address own review feedback and integrate with recent testing changes.)

@sadielbartholomew

Copy link
Copy Markdown
Member

Have just resolved a trivial conflict (in the Changelog) to help me to review from a clean state. Now closing and re-opening the PR to trigger the new CI jobs which will help me to see the influence on the tests across Python versions and platforms.

@sadielbartholomew

Copy link
Copy Markdown
Member

Going to build on top of the initial PR @bnlawrence, since for setting up the reference conda environment and the CI jobs to run the tests with and without image comparison, I have created a new directory of reference images specific to those expected to the reference environment, namely tests/v350-controlled-env-ref-images.

So I will remove the updated tests/reference-example-images plots here and copy any changes due to the underlying bug fix across to tests/v350-controlled-env-ref-images. And generally work towards getting this ready to merge ASAP. I'll address any review comments directly as new commits in the view to get this merged quickly.

@sadielbartholomew

sadielbartholomew commented Oct 23, 2026 •

Copy link
Copy Markdown
Member

Mid-way through updating the PR to account for the new reference environment and matched reference plots directory. Note the 'files change' count looks quite bloated because I am updating the images the docs point to here also since I'm adding a new example for the NEMO grid as part of work related to NEMO and the bug manifesting with it before this fix.

@sadielbartholomew

Copy link
Copy Markdown
Member

(Tweaked the initial description to use a keyword which will auto-close the relevant Issue.)

Comment on lines +105 to +117
fill, lines, blockfill, blockfill_fast = contour._resolve_curvilinear_render_defaults(
data=data,
kwargs={},
fill=True,
lines=True,
blockfill=False,
blockfill_fast=None,
)

assert fill is False
assert lines is False
assert blockfill is True
assert blockfill_fast is True

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is explicitly setting lines to True and then testing that lines is False - obviously the wrong test and one illustration of how AI-generated tests really need to be given a human check!

I noticed the incorrect default behaviour for showing or not the contour plot labelled lines, but this implies it might be set incorrectly in the logic. Will go in to fix either way before merging the PR.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmm, in fact appears to be setting everything to a different value than what it tests it to be - I'll have to look into what's going on with this test.

@sadielbartholomew sadielbartholomew Oct 29, 2026 •

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I now see what is happening and why it was implemented. I agree we can default to fast blockfill (hence blockfill = True, fill = False and blockfill_fast = True) for 2D lat-lon grids but I think we should maintain a lines = True default because otherwise it would make the default behaviour for line very confusing across different plots. To be honest I've wanted to change that default to false for a while because I think more times than not a user would not want contour lines shown, but I will change that default library-wide in a future update - not sure it should be bundled into this release.

@sadielbartholomew

Copy link
Copy Markdown
Member

Note the 'files change' count looks quite bloated because I am updating the images the docs point to here also since I'm adding a new example for the NEMO grid as part of work related to NEMO and the bug manifesting with it before this fix.

Even more bloated now due to my rebuilding the docs here but it helps to get the whole codebase including docs in order in one fell swoop for the new NEMO fix and example.

@sadielbartholomew

sadielbartholomew commented Oct 29, 2026 •

Copy link
Copy Markdown
Member

Edit: I realise this was a deliberate change for the 2D lat-lon default but in the case of lines I think this must default to True consistently - see later comments.

The lines parameter was defaulting to False when it should have been True as for all contour plotting cases in cf-plot, so I have made the trivial fix to that. Will ensure the tests reflect this and generally check them for validity on what they are testing which as per my above review comment I am concerned isn't right.

Default line behaviour with new NEMO data example plot

Defaults to this, as expected, after the fix in a00dcf3, though I put lines=False to disable the contour lines for the new docs example which looks much nicer visualisation-wise.

gen_fig_nemo1_linesdefaultfix

@sadielbartholomew

Copy link
Copy Markdown
Member

Closing and re-opening to check CI jobs status. Happy with this now.

@sadielbartholomew

Copy link
Copy Markdown
Member

The UKCP projection plots (examples 31 and 33) needed updating for the new default fill/blockfill/blockfill_fast behaviour for 2D lat vs/ lon plots. This may fix the CI job failures but there were some weird setup/cleanup issues so not sure - let's see...

@sadielbartholomew

Copy link
Copy Markdown
Member

OK at this stage all of the tests without image comparison pass and the image comparison also passes except for the case of streamplots which look different in one small area on Mac than on Linux, hence Ubuntu CI job failing. That's a separate issue to this PR so we can ignore it here. Ready to merge now.

@sadielbartholomew
sadielbartholomew merged commit 56261bd into NCAS-CMS:main Oct 30, 2026
6 of 8 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