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

Calc temperature after latent heat release #1739

Merged
merged 19 commits into from
Jul 1, 2022

Conversation

MoseleyS
Copy link
Contributor

@MoseleyS MoseleyS commented Jun 14, 2022

Closes #1738

Adds method to adjust temperature and humidity for latent heat release.

  • Moves WetBulbTemperature and WetBulbTemperatureIntegral plugins into a new wet_bulb_temperature.py module as psychrometric_calculations is getting too big.
  • Moves _calculate_latent_heat method from WetBulbTemperature plugin to psychrometric_calculations so that it can be used in latent heat release calculations.
  • Adds extra tests for dry adiabatic methods to cover a higher altitude case.

Testing:

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

@codecov
Copy link

codecov bot commented Jun 14, 2022

Codecov Report

Merging #1739 (8445cf0) into master (599c684) will increase coverage by 0.05%.
The diff coverage is 100.00%.

@@            Coverage Diff             @@
##           master    #1739      +/-   ##
==========================================
+ Coverage   98.17%   98.22%   +0.05%     
==========================================
  Files         113      115       +2     
  Lines       10347    10699     +352     
==========================================
+ Hits        10158    10509     +351     
- Misses        189      190       +1     
Impacted Files Coverage Δ
...ometric_calculations/psychrometric_calculations.py 98.85% <100.00%> (-0.38%) ⬇️
...psychrometric_calculations/wet_bulb_temperature.py 100.00% <100.00%> (ø)
improver/expected_value.py 96.00% <0.00%> (-4.00%) ⬇️
improver/constants.py 100.00% <0.00%> (ø)
improver/utilities/solar.py 100.00% <0.00%> (ø)
improver/developer_tools/metadata_interpreter.py 99.35% <0.00%> (ø)
improver/wind_calculations/vertical_updraught.py 100.00% <0.00%> (ø)
improver/calibration/reliability_calibration.py 98.84% <0.00%> (+<0.01%) ⬆️
improver/utilities/spatial.py 98.91% <0.00%> (+0.03%) ⬆️
improver/utilities/cube_manipulation.py 99.14% <0.00%> (+0.07%) ⬆️
... and 2 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 599c684...8445cf0. Read the comment docs.

@MoseleyS MoseleyS force-pushed the mobt1738_latent_heat branch from 53f5812 to 88f3984 Compare June 17, 2022 13:13
MoseleyS added 2 commits June 17, 2022 14:44
- Ensures saturated_humidity returns input dtype
- Describes behaviour for subsaturated data in doc-strings
- Renamed new method to `adjust_for_latent_heat` (much more descriptive)
- Inproves doc-string for `qsat_differential` method
- Asserts new tests check for float32 data
- Parametrizes tests for `calculate_latent_heat`
@MoseleyS MoseleyS marked this pull request as ready for review June 17, 2022 14:06
Copy link
Contributor

@bayliffe bayliffe left a comment

Choose a reason for hiding this comment

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

A few requests. I might play with this some more when it comes back to me, but I think it is working as expected. Extended documentation around any new methods would be great; we could really improve the docs around psychrometric calculations more generally, but that's future work.

@bayliffe
Copy link
Contributor

@MoseleyS can you fix the broken unit tests please, and generate a ticket about extending the psychrometric calculations documentation for future work.

MoseleyS added 6 commits June 27, 2022 11:37
- Ensures tests from the old method are copied to the new, even though one of them wasn't useful.
- Existing test results slightly changed due to use of `np.maximum(svp, pressure)`
@MoseleyS MoseleyS force-pushed the mobt1738_latent_heat branch from 295c34b to eae5cf6 Compare June 27, 2022 10:37
bayliffe
bayliffe previously approved these changes Jun 28, 2022
self.temperature, pressure
)
self.assertArrayAlmostEqual(result, expected, decimal=7)

Copy link
Contributor

Choose a reason for hiding this comment

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

No problem with this section of code, but I was checking the rest of it had everything removed that needed to be (couldn't comment on that line). On line 94, the mixing ratio cube is set for the new Test_WetBulbTemperature class and I don't think it's ever used in that class.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

You're right. This is never used. I've removed it.

Copy link
Contributor

@Kat-90 Kat-90 left a comment

Choose a reason for hiding this comment

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

Checked the code/documentation and unit tests and ran all tests.

Happy to approve.

@Kat-90 Kat-90 merged commit b910b7b into metoppv:master Jul 1, 2022
MoseleyS added a commit to MoseleyS/improver that referenced this pull request Jul 1, 2022
* master:
  Calc temperature after latent heat release (metoppv#1739)
  Fixed broken links (metoppv#1745)
  Vicinity processing CLI (metoppv#1749)
  Rainforest minor fixes (metoppv#1751)
  Implement expected value via integration over probability thresholds (metoppv#1734)
  Exclude hidden directories and their sub-directories from the init check test. This accommodates IDEs that store information in hidden directories, i.e. vscode. (metoppv#1748)

# Conflicts:
#	improver/psychrometric_calculations/psychrometric_calculations.py
#	improver_tests/acceptance/test_vicinity.py
@MoseleyS MoseleyS deleted the mobt1738_latent_heat branch July 19, 2024 10:29
MoseleyS added a commit to MoseleyS/improver that referenced this pull request Aug 22, 2024
* Adds initial version of saturated latent heat release methods and tests, but this needs more work to get the right answers.

* Uses correct value for latent heat of condensation and updates unit test results accordingly

* Refactors method for modifying latent heat of condensation w.r.t. temperature and uses it.

* Uses imported ndarray rather than np.ndarray

* Refactors latent heat test to mirror refactor of the method

* Refactors wet-bulb temperature plugins into separate module. Moves and renames test modules to match.

* Adds test for unsaturated case, and makes code work for it

* Reduces iterations to 5 (4 is sufficient for the unit tests)

* Adds a test using some real tropical data and increases number of iterations as required for global data

* Tweaks

- Ensures saturated_humidity returns input dtype
- Describes behaviour for subsaturated data in doc-strings
- Renamed new method to `adjust_for_latent_heat` (much more descriptive)
- Inproves doc-string for `qsat_differential` method
- Asserts new tests check for float32 data
- Parametrizes tests for `calculate_latent_heat`

* isort

* Replaces local epsilon (0.622) value with consts.REPSILON (0.62198). Makes tiny change to expected values.

* Updates results for saturated latent heat following tiny epsilon change

* Refactors mixing ratio methods to remove duplication.

- Ensures tests from the old method are copied to the new, even though one of them wasn't useful.
- Existing test results slightly changed due to use of `np.maximum(svp, pressure)`

* Adds test to show that the latent heat of condensation at the triple point is unchanged

* Black

* Improves doc-string

* Updates results for saturated latent heat following inclusion of `np.maximum(svp, pressure)`

* Removes unused mixing_ratio from a WetBulbTemperature test
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.

Method to iteratively calculate saturated adiabatic adjustment from release of latent heat of condensation
3 participants