Commit 4a5cdcb
authored
Better relative humidity - allow
<!--Please ensure the PR fulfills the following requirements! -->
<!-- If this is your first PR, make sure to add your details to the
AUTHORS.rst! -->
### Pull Request Checklist:
- [ ] This PR addresses an already opened issue (for bug fixes /
features)
- This PR fixes #xyz
- [x] Tests for the changes have been added (for bug fixes / features)
- [x] (If applicable) Documentation has been added / updated (for bug
fixes / features)
- [x] CHANGELOG.rst has been updated (with summary of main changes)
- [x] Link to issue (:issue:`number`) and pull request (:pull:`number`)
has been added
### What kind of change does this PR introduce?
The previous way of computing `hurs` from `huss`, `tas` and `ps` was
taking the ratio of the mixing ratios. It seems that is not how it
should be done... MetPy does something similar, but with an added term.
I decided to instead use the base definition : hurs is the ratio of
vapor pressure to saturation vapor pressure. It corresponds to a WMO
equation to, so that's better. I can't find where I took the previous
equation. It's been 5 years and we were not adding references are
thoroughly back then.
I harmonized the $$\epsilon$$ constant (molecular weight ratio of vapor
to dry air) to 0.62198, the value the WMO uses.
Also, I exposed the `invalid_values` to the `relative_humidity`
indicator. So instead of masking hurs > 100, one can now either leave
them be (None) or clip to 100 ('clip').
### Does this PR introduce a breaking change?
Yes as the output has changed. The change is small, but large enough for
some use cases.
### Other information:
$w$ is the mixing ratio, $w_{sat}$ the saturated mixing ratio, $q$ the
specific humidity, $p$ the pressure, $T$ the temperature. $P_w$ the
vapor pressure, $P_{wsat}$ the saturation vapor pressure. $\epsilon =
0.62198$ the molecular weight ratio of vapor to dry air, a constant.
```math
w = \frac{q}{1-q}, w_{sat} = \epsilon\frac{P_{wsat}}{p - P_{wsat}}, P_w = \frac{pq}{\epsilon + (1 - \epsilon)q}
```
Previous : $$RH = 100\frac{w}{w_{sat}}$$
MetPy (WMO eq. 4.A.16) : $$RH = 100 \frac{w}{w_{sat}}\frac{w_{sat} +
\epsilon}{w + \epsilon}$$
New (WMO eq. 4.A.15) : $$RH = 100 \frac{P_w}{P_{wsat}}$$invalid_values (#2254)File tree
5 files changed
+23
-21
lines changed- src/xclim
- indicators/convert
- indices
- tests
5 files changed
+23
-21
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
12 | 12 | | |
13 | 13 | | |
14 | 14 | | |
| 15 | + | |
15 | 16 | | |
16 | 17 | | |
17 | 18 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
246 | 246 | | |
247 | 247 | | |
248 | 248 | | |
249 | | - | |
| 249 | + | |
250 | 250 | | |
251 | 251 | | |
252 | 252 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
628 | 628 | | |
629 | 629 | | |
630 | 630 | | |
631 | | - | |
| 631 | + | |
632 | 632 | | |
633 | 633 | | |
634 | | - | |
| 634 | + | |
635 | 635 | | |
636 | | - | |
637 | | - | |
| 636 | + | |
| 637 | + | |
638 | 638 | | |
639 | 639 | | |
640 | 640 | | |
| |||
772 | 772 | | |
773 | 773 | | |
774 | 774 | | |
775 | | - | |
| 775 | + | |
| 776 | + | |
776 | 777 | | |
777 | 778 | | |
778 | 779 | | |
779 | | - | |
780 | | - | |
781 | | - | |
| 780 | + | |
| 781 | + | |
| 782 | + | |
782 | 783 | | |
783 | | - | |
784 | | - | |
| 784 | + | |
| 785 | + | |
| 786 | + | |
| 787 | + | |
785 | 788 | | |
786 | 789 | | |
787 | 790 | | |
| |||
820 | 823 | | |
821 | 824 | | |
822 | 825 | | |
823 | | - | |
824 | 826 | | |
825 | | - | |
| 827 | + | |
| 828 | + | |
826 | 829 | | |
827 | 830 | | |
828 | 831 | | |
829 | | - | |
830 | | - | |
831 | | - | |
| 832 | + | |
832 | 833 | | |
833 | 834 | | |
834 | 835 | | |
| |||
933 | 934 | | |
934 | 935 | | |
935 | 936 | | |
936 | | - | |
| 937 | + | |
937 | 938 | | |
938 | 939 | | |
939 | 940 | | |
| |||
1009 | 1010 | | |
1010 | 1011 | | |
1011 | 1012 | | |
1012 | | - | |
| 1013 | + | |
1013 | 1014 | | |
1014 | 1015 | | |
1015 | 1016 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
151 | 151 | | |
152 | 152 | | |
153 | 153 | | |
154 | | - | |
| 154 | + | |
155 | 155 | | |
156 | 156 | | |
157 | 157 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
3250 | 3250 | | |
3251 | 3251 | | |
3252 | 3252 | | |
3253 | | - | |
3254 | | - | |
| 3253 | + | |
| 3254 | + | |
3255 | 3255 | | |
3256 | 3256 | | |
3257 | 3257 | | |
| |||
0 commit comments