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

Wet bulb freezing level #1949

Merged
merged 10 commits into from
Oct 10, 2023
Merged

Conversation

mspelman07
Copy link
Contributor

@mspelman07 mspelman07 commented Oct 2, 2023

This PR adds in the ability to calculate a Wet bulb freezing level from a wet-bulb temperature on height levels.

Most of the changes for this PR are simply renaming variables to be more agnostic and apply to height and pressure coordinates rather than just pressure. The main changes are for the plugin ExtractPressureLevel (renamed to ExtractLevel). The core changes in this PR are:

  • Plugin now looks first for a pressure coordinate and then a height coordinate. Depending on which it finds will determine whether a height or pressure level are extracted.
  • In writing this plugin I found that stratify has an EXTRAPOLATE_NEAREST keyword which will automatically do what fill_in_bounds was previously doing so I have replaced this.
  • I have also added an extra argument to the stratify interpolation of rising=False. This tells stratify which direction we expect the variable to change and solves a problem if there was a temperature inversion between the first two valid points (see notebook below)
  • CLI added to calculate wet bulb freezing level

To show my changes to the ExtractLevel plugin haven't changed how the plugin works (except where they should change it) I have plotted a few profiles of what it extracted previously and what it extracts now (https://github.com/MetOffice/improver_aux/blob/extractpressure_behaviour/notebooks/Checking_changes_to_ExtractPressureLevels.ipynb)

Acceptance_test_data: metoppv/improver_test_data#30

Testing:

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

@codecov
Copy link

codecov bot commented Oct 3, 2023

Codecov Report

All modified lines are covered by tests ✅

Comparison is base (64b8eab) 98.38% compared to head (120518c) 98.38%.
Report is 2 commits behind head on master.

❗ Current head 120518c differs from pull request most recent head 96e8638. Consider uploading reports for the commit 96e8638 to get more accurate results

Additional details and impacted files
@@            Coverage Diff             @@
##           master    #1949      +/-   ##
==========================================
- Coverage   98.38%   98.38%   -0.01%     
==========================================
  Files         123      123              
  Lines       11792    11783       -9     
==========================================
- Hits        11602    11593       -9     
  Misses        190      190              
Files Coverage Δ
improver/psychrometric_calculations/hail_size.py 100.00% <100.00%> (ø)
improver/utilities/cube_extraction.py 100.00% <100.00%> (ø)

☔ 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.

Just a doc-string change needed.

A comment for your notebook: Surface temperature inversions like your final example are quite common, although they are usually much shallower than that. We won't have seen this in the hail output because surface temperature inversions are associated with stable, nocturnal, non-convective weather, when hail is not possible.

def process(wet_bulb_temperature: cli.inputcube):
"""Module to generate wet-bulb freezing level.

The height level at which the wet-bulb temperature first drops below 237.15K
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
The height level at which the wet-bulb temperature first drops below 237.15K
The height level at which the wet-bulb temperature first drops below 273.15K

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done

Comment on lines 45 to 47
In grid squares where the temperature never goes below 237.15K the highest
height level on the cube is returned. In grid square where the temperature
starts below 237.15K the lowest height on the cube is returned.
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
In grid squares where the temperature never goes below 237.15K the highest
height level on the cube is returned. In grid square where the temperature
starts below 237.15K the lowest height on the cube is returned.
In grid squares where the temperature never goes below 273.15K the highest
height level on the cube is returned. In grid square where the temperature
starts below 273.15K the lowest height on the cube is returned.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done

@MoseleyS MoseleyS assigned mspelman07 and unassigned MoseleyS Oct 3, 2023
@mspelman07 mspelman07 assigned MoseleyS and unassigned mspelman07 Oct 3, 2023
MoseleyS
MoseleyS previously approved these changes Oct 3, 2023
@MoseleyS MoseleyS removed their assignment Oct 3, 2023
Copy link
Contributor

@brhooper brhooper left a comment

Choose a reason for hiding this comment

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

Thanks @mspelman07, I've just added a few comments, mostly about docstrings.

improver/cli/wet_bulb_freezing_level.py Outdated Show resolved Hide resolved
improver/cli/wet_bulb_freezing_level.py Show resolved Hide resolved
improver/utilities/cube_extraction.py Show resolved Hide resolved
@brhooper brhooper assigned brhooper and mspelman07 and unassigned brhooper Oct 9, 2023
Copy link
Contributor

@brhooper brhooper left a comment

Choose a reason for hiding this comment

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

Thanks @mspelman07, I'm happy to approve this now

@brhooper brhooper merged commit 7e2ed68 into metoppv:master Oct 10, 2023
8 checks passed
@brhooper brhooper removed their assignment Oct 10, 2023
@mspelman07 mspelman07 added the EPP PR's related to Enhancing Post Processing team label Jan 9, 2024
MoseleyS pushed a commit to MoseleyS/improver that referenced this pull request Aug 22, 2024
* Updates ExtractPressureLevel to also be able to extract a height level and updates unit tests

* Update plugin to use stratify's extrapolation

* Adds acceptance tests and cli for wet bulb freezing level. ALlso rename unit test file name.

* Updates to hail size plugin

* Formatting

* Update checksums and uncommenting

* update docstring formatting

* doc string updated

* review response

* formatting review changes

---------

Co-authored-by: Marcus Spelman <[email protected]>
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.

3 participants