Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Vertical transform bugfix for variables with only a vertical dimension #531

Merged
merged 6 commits into from
Feb 22, 2024

Conversation

peverwhee
Copy link
Collaborator

@peverwhee peverwhee commented Feb 14, 2024

Enable 1D variables with only a vertical dimension by removing code that always adds a dimension transform.

var_props.py:

  • adjust logic that always adds vertical transform and is prohibiting 1D variables with a vertical coordinate

User interface changes?: No

Testing:
test removed:
unit tests: Add doctests for vertical-only coordinate (not flipped and flipped)
system tests:
manual testing:

Copy link
Collaborator

@gold2718 gold2718 left a comment

Choose a reason for hiding this comment

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

I think the change is fine but I wonder what is going on with line 938.

if var1_dims or var2_dims:
_, vdim_ind = find_vertical_dimension(var1_dims)
if (var1_dims != var2_dims) or (vdim_ind >= 0):
if (var1_dims != var2_dims):
Copy link
Collaborator

Choose a reason for hiding this comment

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

I guess we have not needed that or since var[12]_top was brought in. But that makes me wonder what is going on with line 938. That line is redundant, is it supposed to be something else (e.g., self.__equiv = False)?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

@dustinswales do you have insight on this. It looks like "self.__compat = True" is happening within the "if self.__compat" block.

Copy link
Collaborator

Choose a reason for hiding this comment

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

We can follow up on this after merging the PR, leaving the comment as unresolved.

Copy link
Collaborator

@dustinswales dustinswales left a comment

Choose a reason for hiding this comment

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

These changes look fine to me. Thanks for making them

Copy link
Collaborator

@climbfuji climbfuji left a comment

Choose a reason for hiding this comment

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

I am confused by the PR description and the comments in the code. Why is a variable with only one vertical dimension - no horizontal dimension - a 2-D variable?

@@ -808,6 +808,19 @@ class VarCompatObj:
_DOCTEST_RUNENV) #doctest: +ELLIPSIS
<var_props.VarCompatObj object at 0x...>

# Test that a 2-D var with no vertical transform works
Copy link
Collaborator

Choose a reason for hiding this comment

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

Why is a variable with only a vertical dimension a 2-D var?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

this is a constant point of confusion for me - I'm mirroring the tests above and below that say that a 3D variable has a horizontal and vertical dimension and a 2D variable has only a horizontal dimension.

Copy link
Collaborator

Choose a reason for hiding this comment

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

Well ... it's super non-intuitive I suppose, but: In most modeling systems, a single horizontal dimension still represents a 2-dim distribution of grid columns (just stored in one long vector). This makes a lot of sense for CCPP, which is supposed to work with models that have regular and irregular grids. For example, in MPAS there's only one horizontal dimension, because the data is completely irregular. The convention/requirement therefore is that any model collapses the horizontal dimension(s) into one horizontal dimension for CCPP.

Unfortunately, there are other models like single column models where one could have individual columns for whatever horizontal distribution (none at all, same column, or meaningless, or actual columns picked from a 2-d distribution from another model); for example to test perturbation of physics for the same column.

For the vertical dimension, there's of course only one. So fields that have no horizontal dimension are definitely 1-d and not 2-d.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Thanks Dom! That makes (vague) sense. I've updated the comments.

update comments
@climbfuji climbfuji changed the title Vertical transform bugfix Vertical transform bugfix for variables with only a vertical dimension Feb 21, 2024
Copy link
Collaborator

@climbfuji climbfuji left a comment

Choose a reason for hiding this comment

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

Thanks!

@climbfuji
Copy link
Collaborator

Going to merge this - it has three approvals from @dustinswales @gold2718 and @climbfuji!

@climbfuji climbfuji merged commit a7b9255 into NCAR:feature/capgen Feb 22, 2024
10 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.

4 participants