metoppv / improver

IMPROVER is a library of algorithms for meteorological post-processing.
http://improver.readthedocs.io/en/latest/
BSD 3-Clause "New" or "Revised" License
103 stars 85 forks source link

Calculation of multi-level wet bulb temperature diagnostic #194

Closed bayliffe closed 6 years ago

bayliffe commented 7 years ago

Following Tim's work on this ticket, we now need to implement two things I believe:

  1. A method for generating a lookup table using the Goff-Gratch saturated vapour pressure equation. (A CLI perhaps?)
  2. A Plugin that uses this lookup table to efficiently return the wet-bulb temperature from inputs of temperature, pressure and humidity. (Input cubes and output cube will have same dimensions)

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:

gavinevans commented 7 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:

PaulAbernethy commented 7 years ago

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

wxtim commented 7 years ago

The story so far...

I have created a branch https://github.com/wxtim/improver/tree/IMPRO-174_psychrometric_calculations_wet_bulb and produced

methodfunctionunit tests
saturated_vapour_pressureYesfull set
humidity_ratioYesbasic functionality
wet_bulb_temperatureNoNo
overallNoNo

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:

wxtim commented 7 years ago

@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

wxtim commented 7 years ago

State of Play:

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

Saturation Vapour Pressure

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.

Wet Bulb Temperature

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.

Outstanding work

wxtim commented 7 years ago

Summary of Acceptance Criteria

Summary of DOD

wxtim commented 7 years ago

wet_bulb

wxtim commented 7 years ago

Review of Methodology.pdf

wxtim commented 7 years ago

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

MoseleyS commented 6 years ago

Updated description to show what still needs to be done for this ticket.

gavinevans commented 6 years ago

Closing this issue, as this work will be carried on in #290 and #291, now that we've agreed an approach.