Skip to content

EPPT-3422-density-update-the-improver-virtual-temperature-plugin-so-it-can-be-used-by-the-new-epp-density-workflow #2404

Open
katherinetomkins-mo wants to merge 8 commits into
metoppv:masterfrom
katherinetomkins-mo:EPPT-3422-density-update-the-improver-virtual-temperature-plugin-so-it-can-be-used-by-the-new-epp-density-workflow
Open

EPPT-3422-density-update-the-improver-virtual-temperature-plugin-so-it-can-be-used-by-the-new-epp-density-workflow #2404
katherinetomkins-mo wants to merge 8 commits into
metoppv:masterfrom
katherinetomkins-mo:EPPT-3422-density-update-the-improver-virtual-temperature-plugin-so-it-can-be-used-by-the-new-epp-density-workflow

Conversation

@katherinetomkins-mo

@katherinetomkins-mo katherinetomkins-mo commented Jun 19, 2026

Copy link
Copy Markdown
Contributor

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 VirtualTemperatureFromSpecificHumidity to improver/temperature/virtual_temperature.py
A reference to the new plugin in improver/api/__init__.py on line 146:
"VirtualTemperatureFromSpecificHumidity": "improver.temperature.virtual_temperature"
Unit tests for the new plugin in improver_tests/temperature/virtual_temperature/test_VirtualTemperatureFromSpecificHumidity.py

Acceptance Criteria

  • A non breaking change to the existing IMPROVER virtual temperature plugin
  • Code in Improver repository for implementation of enhanced virtual temperature calculation and air density calculation
  • Working Unit tests for new and enhanced diagnostics above
  • Infrastructure for plug-in operation for workflow operation
  • Documentation in Improver repository on density and virtual temperature calculations - given in the docstring for the new plugin
  • The updated plugin should have a flag which needs to be switched to ON/True so that the new calculation is used.
  • After discussion with Rob Neal, it was decided that the new functionality should be in a new plugin as it is an entirely different process.

Testing:

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

CLA

  • If a new developer, signed up to CLA

@katherinetomkins-mo katherinetomkins-mo changed the title Eppt 3422 density update the improver virtual temperature plugin so it can be used by the new epp density workflow EPPT-3422-density-update-the-improver-virtual-temperature-plugin-so-it-can-be-used-by-the-new-epp-density-workflow Jun 19, 2026
…ual-temperature-plugin-so-it-can-be-used-by-the-new-epp-density-workflow
@katherinetomkins-mo katherinetomkins-mo marked this pull request as ready for review June 19, 2026 13:43
"""
condensates = 0
if cloud_water_mixing_ratio and cloud_ice_mixing_ratio:
condensates = cloud_water_mixing_ratio - cloud_ice_mixing_ratio

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

should this be a + ?

cloud_ice_mixing_ratio: Cube = None,
):
"""
Calculate the virtual temperature from temperature,

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

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(

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

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)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

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)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

int64?

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)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

int64?

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)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

int64?

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)

@mo-DavidJohnJohnston mo-DavidJohnJohnston Jun 19, 2026

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

perhaps np.close or equivalent (and elsewhere)?

@mo-DavidJohnJohnston mo-DavidJohnJohnston left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Looking really good. I think there is one incorrect sign so have not approved for now.
It all puts co-pilot to shame! :-)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants