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

[Bug]: qbo set unify_plev() does not return new variable with sorted Z axis #825

Open
tomvothecoder opened this issue Jul 23, 2024 · 0 comments
Labels
bug Bug fix (will increment patch version)

Comments

@tomvothecoder
Copy link
Collaborator

tomvothecoder commented Jul 23, 2024

What happened?

This bug was caught while working on #664. unify_plev() is supposed to sort the Z axis in ascending order. However, this operation is not performed in-place/in-memory on the object so the Z axis is never updated.

# Convert plevs of test and ref for unified units and direction
unify_plev(test_region)
unify_plev(ref_region)

def unify_plev(var):
"""
Given a data set with a z-axis (plev),
convert to the plev with units: hPa and make sure plev is in ascending order(same as model data)
"""
var_plv = var.getLevel()
if var_plv.units == "Pa":
var_plv[:] = var_plv[:] / 100.0 # convert Pa to mb
var_plv.units = "hPa"
var.setAxis(1, var_plv)
# Make plev in ascending order
if var.getLevel()[0] > var.getLevel()[-1]:
var = var(lev=slice(-1, None, -1))

I'm not sure if this bug has been affecting any downstream computations or plotting.

What did you expect to happen? Are there are possible answers you came across?

  1. unify_plev() needs to return the var object
  2. Update qbo driver test_region = unify_plev(test_region) and ref_region = unify_plev(ref_region)

Minimal Complete Verifiable Example (MVCE)

No response

Relevant log output

No response

Anything else we need to know?

No response

Environment

Latest e3sm_diags on main and stable build

@tomvothecoder tomvothecoder added the bug Bug fix (will increment patch version) label Jul 23, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Bug fix (will increment patch version)
Projects
None yet
Development

No branches or pull requests

1 participant