Closed bayliffe closed 6 years ago
As part of being able to calculate the wet bulb temperature from temperature, pressure and relative humidity, the following intermediate diagnostics may be required:
I found this while doing a quick google search on the issue. Might provide a good starting point: https://github.com/remcmurry/Psychropy/blob/master/psychropy.py
I have created a branch https://github.com/wxtim/improver/tree/IMPRO-174_psychrometric_calculations_wet_bulb and produced
method | function | unit tests |
saturated_vapour_pressure | Yes | full set |
humidity_ratio | Yes | basic functionality |
wet_bulb_temperature | No | No |
overall | No | No |
I have a number of concerns about the code so far, and there is a good deal in the comments section describing things I'm not happy about. In brief:
temp.convert_units('K')
potentially going to slow this code down because it loads the whole cube into memory?@PaulAbernethy has suggested that I look at papers:
Numerical data and functional relationships in science and technology. New series. Group V. Volume 4. Meteorology. Subvolume b. Physical and chemical properties of the air, P35 for the Goff-Gratch equation for saturated vapour pressure.
Gill, Atmosphere-Ocean Dynamics, Appendix 4 Equation A4.7: For the conversion of saturated vapour pressure over water to saturated vapour pressure in air. ScanToMyDocs_20170821.pdf
I have created a pull request #261 for this ticket, although I don't think I am nearly there yet.
The basic structure of the calculations encapsulated in the pull request is shown in the attached picture. What this shows is that there is a web of dependency between different algorithms. Most of these are formulae based on regression using as many as 13 undistinguished constants.
I have based wet bulb calculations upon the Goff-Gratch Saturated Vapour Pressure equation because this is how the WMO recommend carrying out this calculation. None of the methods is noticeably computationally intensive when calculating a few hundred elements for a comparison. The results of the simplistic method diverge significantly from the other two for high but meteorlogically possible temperatures, so I have included it only for completeness.
In pseudocode:
calculate the humidity mixing ratio using relative humidity
calculate the humidity mixing ratio using temperature = wetbulb temperature
do:
calculate the humidity mixing ratio based on your new value of wet-bulb temperature
while: difference between your two estimates of humidity mixing ratio is greater than ...?
This iterative method will give answers in a group of extreme cases in the unit tests, but it displays a tendency to produce -inf and nans if used outside these ranges. I am still investigating what range of temperatures and pressures it should be used for.
It has been pointed out to me that the most efficient way of doing this is to use the code I have created to make an ancillary lookup table/cube with dimensions (temperature, relative_humidity, pressure).
This is very much analogous to how the UM code works.
the following module may be of use scipy.interpolate.interpnd
Updated description to show what still needs to be done for this ticket.
Closing this issue, as this work will be carried on in #290 and #291, now that we've agreed an approach.
Following Tim's work on this ticket, we now need to implement two things I believe:
I envisage the lookup table being a NetCDF file containing a cube with dimensions of temperature, pressure and humidity and the method making use of
scipy.interpolate.interpnd
.====
Part of Snow melt Epic #191
As an IMPROVER developer, I need a multi-level wet bulb temperature diagnostic to be used in the calculation of the snow melting level.
Example formula from NOAA website. https://www.weather.gov/media/epz/wxcalc/wetBulbTdFromRh.pdf
NB the link above essentially requires the use of a piece of graph paper as far as I can see? As an alternative, please see UM documentation UMDP 080 Dynamical and Physical Diagnostic Calculations, page 4.
Acceptance criteria: