Skip to content

Commit

Permalink
Meteostat 1.6.5 (#109)
Browse files Browse the repository at this point in the history
* Meteostat 1.6.5

* Ignore consider-using-set-comprehension
  • Loading branch information
clampr authored Aug 17, 2022
1 parent ceb9277 commit 051cd23
Show file tree
Hide file tree
Showing 5 changed files with 23 additions and 11 deletions.
3 changes: 2 additions & 1 deletion .pylintrc
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@ disable=print-statement,
import-outside-toplevel,
duplicate-code,
import-error,
nan-comparison
nan-comparison,
consider-using-set-comprehension

[BASIC]

Expand Down
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.6.4"
__version__ = "1.6.5"

from .interface.base import Base
from .interface.timeseries import TimeSeries
Expand Down
18 changes: 12 additions & 6 deletions meteostat/interface/hourly.py
Original file line number Diff line number Diff line change
Expand Up @@ -104,8 +104,11 @@ def _set_time(
Set & adapt the period's time zone
"""

if timezone:
# Don't use chunks if full dataset is requested
if start == None:
self.chunked = False

if timezone:
# Save timezone
self._timezone = timezone

Expand All @@ -121,11 +124,14 @@ def _set_time(
end = timezone.localize(end, is_dst=None).astimezone(pytz.utc)

if self.chunked:

self._annual_steps = [
(start + timedelta(days=365 * i)).year
for i in range(end.year - start.year + 2)
]
self._annual_steps = list(
set(
[
(start + timedelta(days=365 * i)).year
for i in range(end.year - start.year + 2)
]
)
)

self._start = start
self._end = end
Expand Down
9 changes: 7 additions & 2 deletions meteostat/utilities/mutations.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
"""

from datetime import datetime
from typing import Union
import numpy as np
import pandas as pd

Expand All @@ -21,7 +22,11 @@ def localize(df: pd.DataFrame, timezone: str) -> pd.DataFrame:
return df.tz_localize("UTC", level="time").tz_convert(timezone, level="time")


def filter_time(df: pd.DataFrame, start: datetime, end: datetime) -> pd.DataFrame:
def filter_time(
df: pd.DataFrame,
start: Union[datetime, None] = None,
end: Union[datetime, None] = None,
) -> pd.DataFrame:
"""
Filter time series data based on start and end date
"""
Expand All @@ -30,7 +35,7 @@ def filter_time(df: pd.DataFrame, start: datetime, end: datetime) -> pd.DataFram
time = df.index.get_level_values("time")

# Filter & return
return df.loc[(time >= start) & (time <= end)]
return df.loc[(time >= start) & (time <= end)] if start and end else df


def adjust_temp(df: pd.DataFrame, alt: int):
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.6.4",
version="1.6.5",
author="Meteostat",
author_email="[email protected]",
description="Access and analyze historical weather and climate data with Python.",
Expand Down

0 comments on commit 051cd23

Please sign in to comment.