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

Gradient between vertical levels #2030

Open
wants to merge 8 commits into
base: master
Choose a base branch
from

Conversation

mspelman07
Copy link
Contributor

EPP:
Acceptance test: metoppv/improver_test_data#55

This plugin adds in the ability to calculate a gradient between two vertical levels which could be defined on pressure or height levels.

Testing:

  • Ran tests and they passed OK
  • Added new tests for the new feature(s)

@mspelman07 mspelman07 added the EPP PR's related to Enhancing Post Processing team label Sep 12, 2024
Copy link

codecov bot commented Sep 12, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 98.28%. Comparing base (84a8944) to head (e961b59).
Report is 27 commits behind head on master.

Additional details and impacted files
@@            Coverage Diff             @@
##           master    #2030      +/-   ##
==========================================
- Coverage   98.39%   98.28%   -0.11%     
==========================================
  Files         124      133       +9     
  Lines       12212    12865     +653     
==========================================
+ Hits        12016    12645     +629     
- Misses        196      220      +24     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

Copy link
Contributor

@MoseleyS MoseleyS left a comment

Choose a reason for hiding this comment

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

This is a good PR. I've thought of one way one of the cases could be made more efficient, but I am not sure whether this would actually benefit any of the use cases yet.

improver/utilities/gradient_between_vertical_levels.py Outdated Show resolved Hide resolved
improver/cli/gradient_between_vertical_levels.py Outdated Show resolved Hide resolved
Copy link
Contributor

@MoseleyS MoseleyS left a comment

Choose a reason for hiding this comment

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

This looks like a good solution. Just one blank space needed!

height coordinate.If the cubes are provided at pressure levels, the height above sea level
is extracted from a geopotential_height cube.
height coordinate. If the cubes are provided at pressure levels, the height above sea level
is extracted from a geopotential_height cube.If both cubes have a
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
is extracted from a geopotential_height cube.If both cubes have a
is extracted from a geopotential_height cube. If both cubes have a

height_diff.data = np.ma.masked_where(height_diff.data == 0, height_diff.data)

diff = cubes[0] - cubes[1]
gradient = diff / height_diff
Copy link
Contributor

Choose a reason for hiding this comment

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

What do the output metadata look like if the two source cubes represent different times? Should we detect and reject such cases?

result = GradientBetweenVerticalLevels()(iris.cube.CubeList(cubes))
np.testing.assert_array_almost_equal(result.data, expected)
assert result.name() == "gradient_of_air_temperature"
assert result.units == "K/m"
Copy link
Contributor

Choose a reason for hiding this comment

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

While considering the time metadata, I've discovered that the scalar coordinates are unexpected. In the mixed inputs case, the output has both the height (1.5m) and pressure (85000 Pa) scalar coords while I would expect it to have neither.

The height_both case has no time or forecast_period coord on the output if I change the time of the temperature on pressure levels cube by an hour.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
EPP PR's related to Enhancing Post Processing team
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants