Skip to content

Regrid ancillary variables - #3205

Merged
valeriupredoi merged 1 commit into
mainfrom
regrid-ancillary-vars
Sep 16, 2026
Merged

valeriupredoi merged 1 commit into
mainfrom
regrid-ancillary-vars

Conversation

@bouweandela

@bouweandela bouweandela commented Aug 21, 2026

Copy link
Copy Markdown
Member

Description

Regrid ancillary variables

Closes part of #3138

Link to documentation:


Before you get started

Checklist

It is the responsibility of the author to make sure the pull request is ready to review. The icons indicate whether the item will be subject to the 🛠 Technical or 🧪 Scientific review.


To help with the number pull requests:

@bouweandela bouweandela added the preprocessor Related to the preprocessor label Aug 21, 2026
@bouweandela
bouweandela marked this pull request as ready for review August 21, 2026 08:57

@valeriupredoi valeriupredoi left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

looks good, but I has a quick question pls 🍺

# regridded data variable.
ancillary_result.data = ancillary_result.lazy_data().rechunk(
result[ancillary_slice].lazy_data().chunks,
)

@valeriupredoi valeriupredoi Sep 16, 2026

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

thanks @bouweandela - I am a bit puzzled as to why all the rechunking - why not perform a single rechunk of the ancillary_result at the end, after regridding? What are you going to do if the cube data is not chunked (one single slab)?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

The initial rechunk is needed to avoid getting huge chunks out of regridding when regridding to a higher resolution. The final rechunk is to align the chunks inside the cube, this gives better performance when combining one of the ancillary variables with the main variable in some later preprocessing step (e.g. area statistics).

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

yes, that much I understood myself - but the question is why is the first rechunk needed since I thought the ancil data is chunked like the main var data? They have different chunking? That's insane if they do - they are both produced by the same model with the same data specs

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

side note: huge chunks will not be a problem for CMIP7 anymore since the data will pass through cmip7_repack, so we'll have to be a bit more careful then

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

BTW I saw your comment from the other PR #3204 - don't hold the merge of this hanging on my rechunking comments, we'll have to rethink that for CMIP7 light anyway - I am just being a bit anal 😁

@bouweandela bouweandela Sep 16, 2026

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

I thought the ancil data is chunked like the main var data? They have different chunking?

There is nothing in iris that enforces that.

huge chunks will not be a problem for CMIP7 anymore

Regridding is done on a per chunk basis: one chunk is regridded to one other chunk. Even if the input chunks are reasonably sized, the output chunks may be too large when the resolution is increased by regridding. I believe this has been addressed in iris in SciTools/iris#6730, but I do not see the corresponding changes in iris-esmf-regrid, so it's probably best to keep our own regridding code. This applies to CMIP7 just the same.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

that's mental! Thanks, bud - not auto scaling chunks upon regridding is bad, not having chunks harmonized between main var and ancil var, equally. OK nevermind my comments above 😁

@valeriupredoi
valeriupredoi merged commit 19eb140 into main Sep 16, 2026
5 checks passed
@valeriupredoi
valeriupredoi deleted the regrid-ancillary-vars branch September 16, 2026 13:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

preprocessor Related to the preprocessor

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants