EPPT-3422-density-update-the-improver-virtual-temperature-plugin-so-it-can-be-used-by-the-new-epp-density-workflow #2404
Conversation
…ual-temperature-plugin-so-it-can-be-used-by-the-new-epp-density-workflow
| """ | ||
| condensates = 0 | ||
| if cloud_water_mixing_ratio and cloud_ice_mixing_ratio: | ||
| condensates = cloud_water_mixing_ratio - cloud_ice_mixing_ratio |
Contributor
There was a problem hiding this comment.
should this be a + ?
| cloud_ice_mixing_ratio: Cube = None, | ||
| ): | ||
| """ | ||
| Calculate the virtual temperature from temperature, |
Contributor
There was a problem hiding this comment.
One suggestion to reduce logic (i.e. all conditionals) is
cloud_water_mixing_ratio: Cube = 0,
cloud_ice_mixing_ratio: Cube = 0,
| """ | ||
|
|
||
| @staticmethod | ||
| def get_virtual_temperature_specific_humidity( |
Contributor
There was a problem hiding this comment.
I love the static method. This is the (better) "Python-style" API which
contrasts with the Improver-style API with a CubeList.
The static method is more useful outside of a workflow context.
| Cube: named "specific_humidity" | ||
| """ | ||
| coord = AuxCoord(0, standard_name="forecast_period") | ||
| data = np.full((1, 2, 3), dtype=np.int64, fill_value=1) |
Contributor
There was a problem hiding this comment.
Is int64 the right unit for specific humidity?
| Cube: named "cloud_water_mixing_ratio" | ||
| """ | ||
| coord = AuxCoord(0, standard_name="forecast_period") | ||
| data = np.full((1, 2, 3), dtype=np.int64, fill_value=1) |
| Cube: named "cloud_ice_mixing_ratio" | ||
| """ | ||
| coord = AuxCoord(0, standard_name="forecast_period") | ||
| data = np.full((1, 2, 3), dtype=np.int64, fill_value=1) |
| Cube: named "humidity_mixing_ratio", which is incorrect for this plugin. | ||
| """ | ||
| coord = AuxCoord(0, standard_name="forecast_period") | ||
| data = np.full((1, 2, 3), dtype=np.int64, fill_value=1) |
| assert type(result.data) == type(expected_data) | ||
| assert result.data.shape == expected_data.shape | ||
| assert result.data.dtype == expected_data.dtype | ||
| assert result.data[0][0][0] == np.float64(439.1620211204289) |
Contributor
There was a problem hiding this comment.
perhaps np.close or equivalent (and elsewhere)?
mo-DavidJohnJohnston
requested changes
Jun 19, 2026
mo-DavidJohnJohnston
left a comment
Contributor
There was a problem hiding this comment.
Looking really good. I think there is one incorrect sign so have not approved for now.
It all puts co-pilot to shame! :-)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Addresses EPPT-3422
As a workflow developer,
I would like an updated IMPROVER Virtual Temperature plugin for use in my new Density EPP workflow.
Adds:
A new plugin called
VirtualTemperatureFromSpecificHumiditytoimprover/temperature/virtual_temperature.pyA reference to the new plugin in
improver/api/__init__.pyon line 146:"VirtualTemperatureFromSpecificHumidity": "improver.temperature.virtual_temperature"Unit tests for the new plugin in
improver_tests/temperature/virtual_temperature/test_VirtualTemperatureFromSpecificHumidity.pyAcceptance Criteria
The updated plugin should have a flag which needs to be switched to ON/True so that the new calculation is used.Testing:
CLA