Skip to content

Commit d8ce478

Browse files
authored
Meteostat 1.5.10 (#67)
1 parent 6b2baf7 commit d8ce478

File tree

3 files changed

+32
-7
lines changed

3 files changed

+32
-7
lines changed

meteostat/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
"""
1313

1414
__appname__ = 'meteostat'
15-
__version__ = '1.5.9'
15+
__version__ = '1.5.10'
1616

1717
from .interface.base import Base
1818
from .interface.timeseries import Timeseries

meteostat/interface/normals.py

Lines changed: 30 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -158,9 +158,37 @@ def _resolve_point(
158158
if self._stations.size == 0 or self._data.size == 0:
159159
return None
160160

161+
def adjust_temp(data: pd.DataFrame):
162+
"""
163+
Adjust temperature-like data based on altitude
164+
"""
165+
166+
data.loc[data['tmin'] != np.NaN, 'tmin'] = data['tmin'] + \
167+
((2 / 3) * ((data['elevation'] - alt) / 100))
168+
data.loc[data['tmax'] != np.NaN, 'tmax'] = data['tmax'] + \
169+
((2 / 3) * ((data['elevation'] - alt) / 100))
170+
171+
return data
172+
161173
if method == 'nearest':
162174

163-
self._data = self._data.groupby(level=[
175+
if adapt_temp:
176+
177+
# Join elevation of involved weather stations
178+
data = self._data.join(
179+
stations['elevation'], on='station')
180+
181+
# Adapt temperature-like data based on altitude
182+
data = adjust_temp(data)
183+
184+
# Drop elevation & round
185+
data = data.drop('elevation', axis=1).round(1)
186+
187+
else:
188+
189+
data = self._data
190+
191+
self._data = data.groupby(level=[
164192
'start',
165193
'end',
166194
'month'
@@ -173,10 +201,7 @@ def _resolve_point(
173201

174202
# Adapt temperature-like data based on altitude
175203
if adapt_temp:
176-
data.loc[data['tmin'] != np.NaN, 'tmin'] = data['tmin'] + \
177-
((2 / 3) * ((data['elevation'] - alt) / 100))
178-
data.loc[data['tmax'] != np.NaN, 'tmax'] = data['tmax'] + \
179-
((2 / 3) * ((data['elevation'] - alt) / 100))
204+
data = adjust_temp(data)
180205

181206
# Aggregate mean data
182207
data = data.groupby(level=[

setup.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
# Setup
1616
setup(
1717
name='meteostat',
18-
version='1.5.9',
18+
version='1.5.10',
1919
author='Meteostat',
2020
author_email='[email protected]',
2121
description='Access and analyze historical weather and climate data with Python.',

0 commit comments

Comments
 (0)