Skip to content

Commit

Permalink
Refactor notation: degK to K (#1475)
Browse files Browse the repository at this point in the history
<!--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
- [ ] Tests for the changes have been added (for bug fixes / features)
- [ ] (If applicable) Documentation has been added / updated (for bug
fixes / features)
- [ ] CHANGES.rst has been updated (with summary of main changes)
- [ ] Link to issue (:issue:`number`) and pull request (:pull:`number`)
has been added

### What kind of change does this PR introduce?

* "degK" is replaced with "K" where this remains

### Does this PR introduce a breaking change?

No

### Other information:
  • Loading branch information
coxipi authored Sep 11, 2023
2 parents f8c3abe + 0a2da79 commit 9e2bb5c
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 7 deletions.
8 changes: 8 additions & 0 deletions CHANGES.rst
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,14 @@
Changelog
=========

v0.46.0
--------------------
Contributors to this version: Éric Dupuis (:user:`coxipi`).

Internal changes
^^^^^^^^^^^^^^^^
* Change "degK" to "K" used to design Kelvin units. (:pull:`1475`).

v0.45.0 (2023-09-05)
--------------------
Contributors to this version: David Huard (:user:`huard`), Trevor James Smith (:user:`Zeitsperre`), Pascal Bourgault (:user:`aulemahal`), Juliette Lavoie (:user:`juliettelavoie`), Gabriel Rondeau-Genesse (:user:`RondeauG`), Marco Braun (:user:`vindelico`), Éric Dupuis (:user:`coxipi`).
Expand Down
14 changes: 7 additions & 7 deletions xclim/indices/_conversion.py
Original file line number Diff line number Diff line change
Expand Up @@ -395,9 +395,9 @@ def saturation_vapor_pressure(
:cite:cts:`goff_low-pressure_1946,hardy_its-90_1998,sonntag_important_1990,tetens_uber_1930,vomel_saturation_2016,world_meteorological_organization_guide_2008`
"""
if ice_thresh is not None:
thresh = convert_units_to(ice_thresh, "degK")
thresh = convert_units_to(ice_thresh, "K")
else:
thresh = convert_units_to("0 K", "degK")
thresh = convert_units_to("0 K", "K")
tas = convert_units_to(tas, "K")
ref_is_water = tas > thresh
if method in ["sonntag90", "SO90"]:
Expand Down Expand Up @@ -585,8 +585,8 @@ def relative_humidity(
if method in ("bohren98", "BA90"):
if tdps is None:
raise ValueError("To use method 'bohren98' (BA98), dewpoint must be given.")
tdps = convert_units_to(tdps, "degK")
tas = convert_units_to(tas, "degK")
tdps = convert_units_to(tdps, "K")
tas = convert_units_to(tas, "K")
L = 2.501e6
Rw = (461.5,)
hurs = 100 * np.exp(-L * (tas - tdps) / (Rw * tas * tdps)) # type: ignore
Expand All @@ -601,7 +601,7 @@ def relative_humidity(
else:
ps = convert_units_to(ps, "Pa")
huss = convert_units_to(huss, "")
tas = convert_units_to(tas, "degK")
tas = convert_units_to(tas, "K")

e_sat = saturation_vapor_pressure(tas=tas, ice_thresh=ice_thresh, method=method)

Expand Down Expand Up @@ -698,7 +698,7 @@ def specific_humidity(
"""
ps = convert_units_to(ps, "Pa")
hurs = convert_units_to(hurs, "")
tas = convert_units_to(tas, "degK")
tas = convert_units_to(tas, "K")

e_sat = saturation_vapor_pressure(tas=tas, ice_thresh=ice_thresh, method=method)

Expand Down Expand Up @@ -844,7 +844,7 @@ def snowfall_approximation(
prsn = pr * fraction.interp(tas=tas, method="linear")

elif method == "auer":
dtas = convert_units_to(tas, "degK") - convert_units_to(thresh, "degK")
dtas = convert_units_to(tas, "K") - convert_units_to(thresh, "K")

# Create nodes for the snowfall fraction: -inf, thresh, ..., thresh+6, inf [degC]
t = np.concatenate(
Expand Down

0 comments on commit 9e2bb5c

Please sign in to comment.