Skip to content

Commit

Permalink
Preserve units after regridding to plevs
Browse files Browse the repository at this point in the history
  • Loading branch information
tomvothecoder committed Feb 14, 2024
1 parent b03163b commit ecc2102
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions e3sm_diags/driver/utils/regrid.py
Original file line number Diff line number Diff line change
Expand Up @@ -518,6 +518,7 @@ def _hybrid_to_plevs(

pressure_grid = xc.create_grid(z=z_axis)
pressure_coords = _hybrid_to_pressure(ds, var_key)

# Keep the "axis" and "coordinate" attributes for CF mapping.
with xr.set_options(keep_attrs=True):
result = ds.regridder.vertical(
Expand All @@ -528,6 +529,10 @@ def _hybrid_to_plevs(
target_data=pressure_coords,
)

# Vertical regriding sets the units to "mb", but the original units
# should be preserved.
result[var_key].attrs["units"] = ds[var_key].units

return result


Expand Down

0 comments on commit ecc2102

Please sign in to comment.