Skip to content

Conversation

@tomchor
Copy link
Collaborator

@tomchor tomchor commented Oct 29, 2025

Contains a few improvements that will make #4848 easier. Also a couple of fixes for edge cases.


function squeeze_reduced_dimensions(data, reduced_dims)
# Fill missing indices from the right with 1s
indices = Any[:,:,:]
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
indices = Any[:,:,:]
indices = Any[:, : ,:]

what does this mean exactly?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

The comment is meant for the whole algorithm, not just that line. Basically it gets Fields that have Nothing in any of the locations and it gets rid of that dimension. (I'm calling these reduced_dims but there's probably a better name.)

So for example, if data comes from an array that has loc = Center, Center, Nothing, it'll reduce its parent data by indexing it as data[:, :, 1]; i.e. a 2D array in this case.

I'm testing this out (hence a draft PR) after some discussions with @ali-ramadhan. Basically we want to keep all NetCDF arrays 3D (to mimic Oceananigans' behavior) as much as possible, but in NetCDF there's no concept of location, so we can't easily pass LZ = Nothing to NetCDF. In these cases it probably makes sense to squeeze that dimension (or whatever the verb for this is) so that we know that dimension is reduced.

Copy link
Member

Choose a reason for hiding this comment

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

Can you add attributes that indicate the location? We can add custom attributes to data even if they are not built in, right?

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.

3 participants