meteostat 1.7.1__py3-none-any.whl → 1.7.3__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
meteostat/__init__.py CHANGED
@@ -12,7 +12,7 @@ The code is licensed under the MIT license.
12
12
  """
13
13
 
14
14
  __appname__ = "meteostat"
15
- __version__ = "1.7.1"
15
+ __version__ = "1.7.3"
16
16
 
17
17
  from .interface.base import Base
18
18
  from .interface.timeseries import TimeSeries
@@ -34,6 +34,10 @@ def filter_time(
34
34
  # Get time index
35
35
  time = df.index.get_level_values("time")
36
36
 
37
+ # If no time index, return original DataFrame
38
+ if len(time) == 0:
39
+ return df
40
+
37
41
  # Filter & return
38
42
  return df.loc[(time >= start) & (time <= end)] if start and end else df
39
43
 
@@ -63,7 +67,17 @@ def calculate_dwpt(df: pd.DataFrame, col: str) -> pd.DataFrame:
63
67
  """
64
68
  Calculate dew point temperature
65
69
  """
66
- df[col] = df["temp"] - ((100 - df["rhum"]) / 5)
70
+ magnus_const_a = 17.27
71
+ magnus_const_b = 237.7 # degrees Celsius
72
+
73
+ temperature = df["temp"]
74
+ relative_humidity = df["rhum"]
75
+
76
+ alpha = (
77
+ (magnus_const_a * temperature) / (magnus_const_b + temperature)
78
+ ) + np.log(relative_humidity / 100.0)
79
+ df[col] = (magnus_const_b * alpha) / (magnus_const_a - alpha)
80
+
67
81
  df[f"{col}_flag"] = df[["temp_flag", "rhum_flag"]].max(axis=1, skipna=True)
68
82
 
69
83
  return df
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: meteostat
3
- Version: 1.7.1
3
+ Version: 1.7.3
4
4
  Summary: Access and analyze historical weather and climate data with Python.
5
5
  Home-page: https://github.com/meteostat/meteostat-python
6
6
  Author: Meteostat
@@ -1,4 +1,4 @@
1
- meteostat/__init__.py,sha256=3Mt0lK8sXnEU6aviBXUqbANFvPUUINXDvR1D4qCYYuk,989
1
+ meteostat/__init__.py,sha256=2riJrhXJsRvCvqnpqPtK1qLJlA72GNfpqPQX4JREZEQ,989
2
2
  meteostat/units.py,sha256=G0vh2tYsp0ESGUpg3ZAE0U-b9Ih_oMtPNDZ71Bbq3iE,2566
3
3
  meteostat/core/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
4
4
  meteostat/core/cache.py,sha256=MEC6Hcf2rwg3__zv_Y1nSk16mfdTsrLH9CTraMX7NYw,1764
@@ -30,10 +30,10 @@ meteostat/utilities/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSu
30
30
  meteostat/utilities/aggregations.py,sha256=-t4ZBNM8cnwnuiR7Bzt7OlUQxNJMZkqS3E4AIMrJg3M,915
31
31
  meteostat/utilities/endpoint.py,sha256=ndHSMGi5LhB1yrjA3f6pDbe-0glnnDAX7IInp0Gscik,806
32
32
  meteostat/utilities/helpers.py,sha256=wt11OXHzIDw3DY98XGIfcrh1bPCC9dClVnNdGtqvz4U,1691
33
- meteostat/utilities/mutations.py,sha256=qT9lJ1IsiEp5CKMN8IiJBdzHGPE80mJv0VBH-z6fkbg,1750
33
+ meteostat/utilities/mutations.py,sha256=XfFPy4RmnRQmkkIBKgpwHAf-kZwqbkBfFLPyUtpxOiU,2124
34
34
  meteostat/utilities/validations.py,sha256=MlKY1gkeqmovFr4lR_iM6Bk7yuGdSgy0NGceiqYI7Vs,646
35
- meteostat-1.7.1.dist-info/LICENSE,sha256=kqpl7FVzWOCe11BZqJBZ1aRQi-aK87j3ljtG7P3VxLc,1066
36
- meteostat-1.7.1.dist-info/METADATA,sha256=GFWhu5O82sicZmJUJyL15aMAOtMuco-Y6YPTwvUXSQc,4633
37
- meteostat-1.7.1.dist-info/WHEEL,sha256=tZoeGjtWxWRfdplE7E3d45VPlLNQnvbKiYnx7gwAy8A,92
38
- meteostat-1.7.1.dist-info/top_level.txt,sha256=s8LP1xi5iF2zhVv5ULkHwW-tPeMrljxnA8VqZibQqro,10
39
- meteostat-1.7.1.dist-info/RECORD,,
35
+ meteostat-1.7.3.dist-info/LICENSE,sha256=kqpl7FVzWOCe11BZqJBZ1aRQi-aK87j3ljtG7P3VxLc,1066
36
+ meteostat-1.7.3.dist-info/METADATA,sha256=LBsyobsVv_sB23IwKzK2EvNZknY-bv7E_fi339Hzez4,4633
37
+ meteostat-1.7.3.dist-info/WHEEL,sha256=tZoeGjtWxWRfdplE7E3d45VPlLNQnvbKiYnx7gwAy8A,92
38
+ meteostat-1.7.3.dist-info/top_level.txt,sha256=s8LP1xi5iF2zhVv5ULkHwW-tPeMrljxnA8VqZibQqro,10
39
+ meteostat-1.7.3.dist-info/RECORD,,