Skip to content

Commit

Permalink
Meteostat 1.5.10 (#67)
Browse files Browse the repository at this point in the history
  • Loading branch information
clampr authored Aug 27, 2021
1 parent 6b2baf7 commit d8ce478
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 7 deletions.
2 changes: 1 addition & 1 deletion meteostat/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
"""

__appname__ = 'meteostat'
__version__ = '1.5.9'
__version__ = '1.5.10'

from .interface.base import Base
from .interface.timeseries import Timeseries
Expand Down
35 changes: 30 additions & 5 deletions meteostat/interface/normals.py
Original file line number Diff line number Diff line change
Expand Up @@ -158,9 +158,37 @@ def _resolve_point(
if self._stations.size == 0 or self._data.size == 0:
return None

def adjust_temp(data: pd.DataFrame):
"""
Adjust temperature-like data based on altitude
"""

data.loc[data['tmin'] != np.NaN, 'tmin'] = data['tmin'] + \
((2 / 3) * ((data['elevation'] - alt) / 100))
data.loc[data['tmax'] != np.NaN, 'tmax'] = data['tmax'] + \
((2 / 3) * ((data['elevation'] - alt) / 100))

return data

if method == 'nearest':

self._data = self._data.groupby(level=[
if adapt_temp:

# Join elevation of involved weather stations
data = self._data.join(
stations['elevation'], on='station')

# Adapt temperature-like data based on altitude
data = adjust_temp(data)

# Drop elevation & round
data = data.drop('elevation', axis=1).round(1)

else:

data = self._data

self._data = data.groupby(level=[
'start',
'end',
'month'
Expand All @@ -173,10 +201,7 @@ def _resolve_point(

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

# Aggregate mean data
data = data.groupby(level=[
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
# Setup
setup(
name='meteostat',
version='1.5.9',
version='1.5.10',
author='Meteostat',
author_email='[email protected]',
description='Access and analyze historical weather and climate data with Python.',
Expand Down

0 comments on commit d8ce478

Please sign in to comment.