Skip to content

Commit bc9fc0d

Browse files
authored
Meteostat 1.5.2 (#57)
1 parent 7cc4459 commit bc9fc0d

File tree

9 files changed

+18
-14
lines changed

9 files changed

+18
-14
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.1'
15+
__version__ = '1.5.2'
1616

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

meteostat/core/warn.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
import warnings
1212

1313

14-
def _warning_on_one_line(message, category, *args) -> str: # pylint: disable=unused-argument
14+
def _warning_on_one_line(message, category, filename, lineno, line=None) -> str: # pylint: disable=unused-argument
1515
"""
1616
Print warning on a single line
1717
"""

meteostat/interface/base.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,8 @@ class Base:
2727
# Maximum age of a cached file in seconds
2828
max_age: int = 24 * 60 * 60
2929

30-
# Number of cores used for processing files
31-
cores: int = 1
30+
# Number of processes used for processing files
31+
processes: int = 1
3232

3333
# Number of threads used for processing files
3434
threads: int = 1

meteostat/interface/daily.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -151,7 +151,7 @@ def _get_data(self) -> None:
151151

152152
# Data Processing
153153
return processing_handler(
154-
datasets, self._load, self.cores, self.threads)
154+
datasets, self._load, self.processes, self.threads)
155155

156156
# Empty DataFrame
157157
return pd.DataFrame(columns=[*self._types])
@@ -251,7 +251,7 @@ def __init__(
251251
if isinstance(loc, pd.DataFrame):
252252
self._stations = loc.index
253253
elif isinstance(loc, Point):
254-
stations = loc.get_stations('daily', start, end)
254+
stations = loc.get_stations('daily', start, end, model)
255255
self._stations = stations.index
256256
else:
257257
if not isinstance(loc, list):

meteostat/interface/hourly.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -220,7 +220,7 @@ def _get_data(self) -> None:
220220

221221
# Data Processing
222222
return processing_handler(
223-
datasets, self._load, self.cores, self.threads)
223+
datasets, self._load, self.processes, self.threads)
224224

225225
return pd.DataFrame(columns=[*self._types])
226226

@@ -318,7 +318,7 @@ def __init__(
318318
if isinstance(loc, pd.DataFrame):
319319
self._stations = loc.index
320320
elif isinstance(loc, Point):
321-
stations = loc.get_stations('hourly', start, end)
321+
stations = loc.get_stations('hourly', start, end, model)
322322
self._stations = stations.index
323323
else:
324324
if not isinstance(loc, list):

meteostat/interface/monthly.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -151,7 +151,7 @@ def _get_data(self) -> None:
151151
))
152152

153153
# Data Processing
154-
return processing_handler(datasets, self._load, self.cores, self.threads)
154+
return processing_handler(datasets, self._load, self.processes, self.threads)
155155

156156
# Empty DataFrame
157157
return pd.DataFrame(columns=[*self._types])
@@ -251,7 +251,7 @@ def __init__(
251251
if isinstance(loc, pd.DataFrame):
252252
self._stations = loc.index
253253
elif isinstance(loc, Point):
254-
stations = loc.get_stations('monthly', start, end)
254+
stations = loc.get_stations('monthly', start, end, model)
255255
self._stations = stations.index
256256
else:
257257
if not isinstance(loc, list):

meteostat/interface/normals.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -139,7 +139,7 @@ def _get_data(self) -> None:
139139

140140
# Data Processing
141141
return processing_handler(
142-
datasets, self._load, self.cores, self.threads)
142+
datasets, self._load, self.processes, self.threads)
143143

144144
# Empty DataFrame
145145
return pd.DataFrame(columns=[*self._types])

meteostat/interface/point.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ def __init__(
6767
self.adapt_temp = False
6868

6969
def get_stations(self, freq: str = None, start: datetime = None,
70-
end: datetime = None) -> pd.DataFrame:
70+
end: datetime = None, model: bool = True) -> pd.DataFrame:
7171
"""
7272
Get list of nearby weather stations
7373
"""
@@ -88,7 +88,8 @@ def get_stations(self, freq: str = None, start: datetime = None,
8888
unfiltered['elevation']) <= self.alt_range]
8989

9090
# Apply inventory filter
91-
if freq and start and end:
91+
age = (datetime.now() - end).days
92+
if freq and start and end and (model == False or age > 180):
9293
stations = stations.inventory(freq, (start, end))
9394

9495
# Apply altitude filter
@@ -100,6 +101,9 @@ def get_stations(self, freq: str = None, start: datetime = None,
100101
# Fill up stations
101102
selected: int = len(stations.index)
102103
if selected < self.max_count:
104+
# Remove already included stations from unfiltered
105+
unfiltered = unfiltered.loc[~unfiltered.index.isin(stations.index)]
106+
# Append to existing DataFrame
103107
stations = stations.append(
104108
unfiltered.head(
105109
self.max_count - selected))

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.1',
18+
version='1.5.2',
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)