Commit ff6db061 authored by lukas leufen's avatar lukas leufen 👻
Browse files

new meteo helpers and updates to_list method

parent a8f12a62
Pipeline #103010 passed with stages
in 12 minutes and 8 seconds
......@@ -57,7 +57,7 @@ def to_list(obj: Any) -> List:
:return: list containing obj, or obj itself (if obj was already a list)
"""
if isinstance(obj, (set, tuple)):
if isinstance(obj, (set, tuple, type({}.keys()))):
obj = list(obj)
elif not isinstance(obj, list):
obj = [obj]
......
import numpy as np
def relative_humidity_from_dewpoint(dew, temp):
return np.clip(100 * e_sat(dew) / e_sat(temp), 0, 100)
def e_sat(temperature):
a1 = 611.21 # Pa
a3 = 17.502
a4 = 32.19 # K
T0 = 273.16 # K
return a1 * np.exp(a3 * (temperature - T0) / (temperature - a4))
......@@ -499,9 +499,9 @@ class TestFilterDictByValue:
def test_filter_dict_by_value(self):
data_origin = {'o3': '', 'no': '', 'no2': '', 'relhum': 'REA', 'u': 'REA', 'cloudcover': 'REA', 'temp': 'era5'}
expected = {'temp': 'era5'}
assert check_nested_equality(filter_dict_by_value(data_origin, "era", True), expected) is True
assert check_nested_equality(filter_dict_by_value(data_origin, "era5", True), expected) is True
expected = {'o3': '', 'no': '', 'no2': '', 'relhum': 'REA', 'u': 'REA', 'cloudcover': 'REA'}
assert check_nested_equality(filter_dict_by_value(data_origin, "era", False), expected) is True
assert check_nested_equality(filter_dict_by_value(data_origin, "era5", False), expected) is True
expected = {'o3': '', 'no': '', 'no2': ''}
assert check_nested_equality(filter_dict_by_value(data_origin, "", True), expected) is True
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment