Skip to content

Commit cc177c1

Browse files
authored
Merge pull request #63 from phobson/end-of-storm-bug
End of storm bug
2 parents 4ad1f23 + fea318f commit cc177c1

File tree

11 files changed

+113
-128
lines changed

11 files changed

+113
-128
lines changed

.github/workflows/lint_and_test.yml

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ jobs:
5151
runs-on: ubuntu-latest
5252
strategy:
5353
matrix:
54-
python-version: ["3.8", "3.9", "3.10"]
54+
python-version: ["3.9", "3.10", "3.11", "3.12"]
5555
steps:
5656
- uses: actions/checkout@v2
5757
- name: Set up Python ${{ matrix.python-version }}
@@ -73,7 +73,7 @@ jobs:
7373
- name: Set up Python
7474
uses: actions/setup-python@v2
7575
with:
76-
python-version: 3.9
76+
python-version: "3.12"
7777
- name: Install dependencies
7878
run: |
7979
python -m pip install --upgrade pip
@@ -89,16 +89,16 @@ jobs:
8989
- name: Setup Python
9090
uses: actions/setup-python@v2
9191
with:
92-
python-version: 3.9
92+
python-version: "3.12"
9393
- name: Generate coverage report
9494
run: |
9595
python -m pip install --upgrade pip
9696
pip install .[dev]
9797
coverage run -m pytest --doctest-modules --cov-report=xml
98-
- name: Upload coverage to Codecov
99-
uses: codecov/codecov-action@v1
100-
with:
101-
flags: unittests
102-
name: codecov-umbrella
103-
fail_ci_if_error: true
104-
path_to_write_report: ./codecov_report.gz
98+
# - name: Upload coverage to Codecov
99+
# uses: codecov/codecov-action@v1
100+
# with:
101+
# flags: unittests
102+
# name: codecov-umbrella
103+
# fail_ci_if_error: true
104+
# path_to_write_report: ./codecov_report.gz

cloudside/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,4 +7,4 @@
77

88
__author__ = "Paul Hobson"
99
__email__ = "pmhobson@gmail.com"
10-
__version__ = "0.2.1"
10+
__version__ = "0.3.0"

cloudside/storms.py

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
from datetime import timedelta
2+
13
import numpy
24
import pandas
35

@@ -74,7 +76,7 @@ def parse_record(
7476
Returns
7577
-------
7678
parsed_storms : pandas.DataFrame
77-
Copy of the origin `hydrodata` DataFrame, but resampled to a
79+
Copy of the original `data` DataFrame, but resampled to a
7880
fixed frequency, columns possibly renamed, and a `storm` column
7981
added to denote the storm to which each record belongs. Records
8082
where `storm` == 0 are not a part of any storm.
@@ -139,6 +141,13 @@ def parse_record(
139141
)
140142
)
141143

144+
# fix trailing zeroes on the last storm
145+
last_storm = res[stormcol].max()
146+
last_storm_end = res.loc[
147+
res[stormcol].eq(last_storm) & res[precipcol].gt(0)
148+
].index.max() + (2 * freq)
149+
res.loc[last_storm_end:, stormcol] = 0
150+
142151
if not debug:
143152
res = res.loc[:, res.columns.map(lambda c: not c.startswith("__"))]
144153

cloudside/tests/__init__.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
1-
from pkg_resources import resource_filename
1+
from importlib import resources
22
from contextlib import contextmanager
33

44
import pytest
55

66

77
def get_test_file(filename):
8-
return resource_filename("cloudside.tests.data", filename)
8+
return resources.files("cloudside.tests.data").joinpath(filename)
99

1010

1111
def raises(error):

cloudside/tests/data/teststorm_firstobs.csv

Lines changed: 29 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -510,32 +510,32 @@ date,rain,influent,effluent,storm
510510
2013-05-21 13:50:00,0.01,90.0,37.0,2
511511
2013-05-21 13:55:00,0.01,85.0,33.0,2
512512
2013-05-21 14:00:00,0.0,80.0,32.0,2
513-
2013-05-21 14:05:00,0.0,75.0,30.0,2
514-
2013-05-21 14:10:00,0.0,70.0,28.0,2
515-
2013-05-21 14:15:00,0.0,65.0,27.0,2
516-
2013-05-21 14:20:00,0.0,60.0,25.0,2
517-
2013-05-21 14:25:00,0.0,55.0,23.0,2
518-
2013-05-21 14:30:00,0.0,50.0,22.0,2
519-
2013-05-21 14:35:00,0.0,45.0,20.0,2
520-
2013-05-21 14:40:00,0.0,40.0,18.0,2
521-
2013-05-21 14:45:00,0.0,37.0,17.0,2
522-
2013-05-21 14:50:00,0.0,34.0,15.0,2
523-
2013-05-21 14:55:00,0.0,31.0,13.0,2
524-
2013-05-21 15:00:00,0.0,28.0,12.0,2
525-
2013-05-21 15:05:00,0.0,25.0,11.0,2
526-
2013-05-21 15:10:00,0.0,22.0,10.0,2
527-
2013-05-21 15:15:00,0.0,20.0,9.0,2
528-
2013-05-21 15:20:00,0.0,18.0,8.0,2
529-
2013-05-21 15:25:00,0.0,16.0,7.0,2
530-
2013-05-21 15:30:00,0.0,14.0,7.0,2
531-
2013-05-21 15:35:00,0.0,12.0,6.0,2
532-
2013-05-21 15:40:00,0.0,10.0,5.0,2
533-
2013-05-21 15:45:00,0.0,8.0,5.0,2
534-
2013-05-21 15:50:00,0.0,6.0,4.0,2
535-
2013-05-21 15:55:00,0.0,5.0,3.0,2
536-
2013-05-21 16:00:00,0.0,4.0,3.0,2
537-
2013-05-21 16:05:00,0.0,3.0,2.0,2
538-
2013-05-21 16:10:00,0.0,2.0,2.0,2
539-
2013-05-21 16:15:00,0.0,1.0,1.0,2
540-
2013-05-21 16:20:00,0.0,0.0,1.0,2
541-
2013-05-21 16:25:00,0.0,0.0,1.0,2
513+
2013-05-21 14:05:00,0.0,75.0,30.0,0
514+
2013-05-21 14:10:00,0.0,70.0,28.0,0
515+
2013-05-21 14:15:00,0.0,65.0,27.0,0
516+
2013-05-21 14:20:00,0.0,60.0,25.0,0
517+
2013-05-21 14:25:00,0.0,55.0,23.0,0
518+
2013-05-21 14:30:00,0.0,50.0,22.0,0
519+
2013-05-21 14:35:00,0.0,45.0,20.0,0
520+
2013-05-21 14:40:00,0.0,40.0,18.0,0
521+
2013-05-21 14:45:00,0.0,37.0,17.0,0
522+
2013-05-21 14:50:00,0.0,34.0,15.0,0
523+
2013-05-21 14:55:00,0.0,31.0,13.0,0
524+
2013-05-21 15:00:00,0.0,28.0,12.0,0
525+
2013-05-21 15:05:00,0.0,25.0,11.0,0
526+
2013-05-21 15:10:00,0.0,22.0,10.0,0
527+
2013-05-21 15:15:00,0.0,20.0,9.0,0
528+
2013-05-21 15:20:00,0.0,18.0,8.0,0
529+
2013-05-21 15:25:00,0.0,16.0,7.0,0
530+
2013-05-21 15:30:00,0.0,14.0,7.0,0
531+
2013-05-21 15:35:00,0.0,12.0,6.0,0
532+
2013-05-21 15:40:00,0.0,10.0,5.0,0
533+
2013-05-21 15:45:00,0.0,8.0,5.0,0
534+
2013-05-21 15:50:00,0.0,6.0,4.0,0
535+
2013-05-21 15:55:00,0.0,5.0,3.0,0
536+
2013-05-21 16:00:00,0.0,4.0,3.0,0
537+
2013-05-21 16:05:00,0.0,3.0,2.0,0
538+
2013-05-21 16:10:00,0.0,2.0,2.0,0
539+
2013-05-21 16:15:00,0.0,1.0,1.0,0
540+
2013-05-21 16:20:00,0.0,0.0,1.0,0
541+
2013-05-21 16:25:00,0.0,0.0,1.0,0

cloudside/tests/data/teststorm_simple.csv

Lines changed: 29 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -511,32 +511,32 @@ date,rain,influent,effluent,storm
511511
2013-05-21 13:50:00,0.01,90.0,37.0,2
512512
2013-05-21 13:55:00,0.01,85.0,33.0,2
513513
2013-05-21 14:00:00,0.0,80.0,32.0,2
514-
2013-05-21 14:05:00,0.0,75.0,30.0,2
515-
2013-05-21 14:10:00,0.0,70.0,28.0,2
516-
2013-05-21 14:15:00,0.0,65.0,27.0,2
517-
2013-05-21 14:20:00,0.0,60.0,25.0,2
518-
2013-05-21 14:25:00,0.0,55.0,23.0,2
519-
2013-05-21 14:30:00,0.0,50.0,22.0,2
520-
2013-05-21 14:35:00,0.0,45.0,20.0,2
521-
2013-05-21 14:40:00,0.0,40.0,18.0,2
522-
2013-05-21 14:45:00,0.0,37.0,17.0,2
523-
2013-05-21 14:50:00,0.0,34.0,15.0,2
524-
2013-05-21 14:55:00,0.0,31.0,13.0,2
525-
2013-05-21 15:00:00,0.0,28.0,12.0,2
526-
2013-05-21 15:05:00,0.0,25.0,11.0,2
527-
2013-05-21 15:10:00,0.0,22.0,10.0,2
528-
2013-05-21 15:15:00,0.0,20.0,9.0,2
529-
2013-05-21 15:20:00,0.0,18.0,8.0,2
530-
2013-05-21 15:25:00,0.0,16.0,7.0,2
531-
2013-05-21 15:30:00,0.0,14.0,7.0,2
532-
2013-05-21 15:35:00,0.0,12.0,6.0,2
533-
2013-05-21 15:40:00,0.0,10.0,5.0,2
534-
2013-05-21 15:45:00,0.0,8.0,5.0,2
535-
2013-05-21 15:50:00,0.0,6.0,4.0,2
536-
2013-05-21 15:55:00,0.0,5.0,3.0,2
537-
2013-05-21 16:00:00,0.0,4.0,3.0,2
538-
2013-05-21 16:05:00,0.0,3.0,2.0,2
539-
2013-05-21 16:10:00,0.0,2.0,2.0,2
540-
2013-05-21 16:15:00,0.0,1.0,1.0,2
541-
2013-05-21 16:20:00,0.0,0.0,1.0,2
542-
2013-05-21 16:25:00,0.0,0.0,1.0,2
514+
2013-05-21 14:05:00,0.0,75.0,30.0,0
515+
2013-05-21 14:10:00,0.0,70.0,28.0,0
516+
2013-05-21 14:15:00,0.0,65.0,27.0,0
517+
2013-05-21 14:20:00,0.0,60.0,25.0,0
518+
2013-05-21 14:25:00,0.0,55.0,23.0,0
519+
2013-05-21 14:30:00,0.0,50.0,22.0,0
520+
2013-05-21 14:35:00,0.0,45.0,20.0,0
521+
2013-05-21 14:40:00,0.0,40.0,18.0,0
522+
2013-05-21 14:45:00,0.0,37.0,17.0,0
523+
2013-05-21 14:50:00,0.0,34.0,15.0,0
524+
2013-05-21 14:55:00,0.0,31.0,13.0,0
525+
2013-05-21 15:00:00,0.0,28.0,12.0,0
526+
2013-05-21 15:05:00,0.0,25.0,11.0,0
527+
2013-05-21 15:10:00,0.0,22.0,10.0,0
528+
2013-05-21 15:15:00,0.0,20.0,9.0,0
529+
2013-05-21 15:20:00,0.0,18.0,8.0,0
530+
2013-05-21 15:25:00,0.0,16.0,7.0,0
531+
2013-05-21 15:30:00,0.0,14.0,7.0,0
532+
2013-05-21 15:35:00,0.0,12.0,6.0,0
533+
2013-05-21 15:40:00,0.0,10.0,5.0,0
534+
2013-05-21 15:45:00,0.0,8.0,5.0,0
535+
2013-05-21 15:50:00,0.0,6.0,4.0,0
536+
2013-05-21 15:55:00,0.0,5.0,3.0,0
537+
2013-05-21 16:00:00,0.0,4.0,3.0,0
538+
2013-05-21 16:05:00,0.0,3.0,2.0,0
539+
2013-05-21 16:10:00,0.0,2.0,2.0,0
540+
2013-05-21 16:15:00,0.0,1.0,1.0,0
541+
2013-05-21 16:20:00,0.0,0.0,1.0,0
542+
2013-05-21 16:25:00,0.0,0.0,1.0,0

cloudside/tests/data/teststorm_singular.csv

Lines changed: 29 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -443,32 +443,32 @@ date,rain,influent,effluent,storm
443443
2013-05-21 13:50:00,0.01,90.0,37.0,3
444444
2013-05-21 13:55:00,0.01,85.0,33.0,3
445445
2013-05-21 14:00:00,0.0,80.0,32.0,3
446-
2013-05-21 14:05:00,0.0,75.0,30.0,3
447-
2013-05-21 14:10:00,0.0,70.0,28.0,3
448-
2013-05-21 14:15:00,0.0,65.0,27.0,3
449-
2013-05-21 14:20:00,0.0,60.0,25.0,3
450-
2013-05-21 14:25:00,0.0,55.0,23.0,3
451-
2013-05-21 14:30:00,0.0,50.0,22.0,3
452-
2013-05-21 14:35:00,0.0,45.0,20.0,3
453-
2013-05-21 14:40:00,0.0,40.0,18.0,3
454-
2013-05-21 14:45:00,0.0,37.0,17.0,3
455-
2013-05-21 14:50:00,0.0,34.0,15.0,3
456-
2013-05-21 14:55:00,0.0,31.0,13.0,3
457-
2013-05-21 15:00:00,0.0,28.0,12.0,3
458-
2013-05-21 15:05:00,0.0,25.0,11.0,3
459-
2013-05-21 15:10:00,0.0,22.0,10.0,3
460-
2013-05-21 15:15:00,0.0,20.0,9.0,3
461-
2013-05-21 15:20:00,0.0,18.0,8.0,3
462-
2013-05-21 15:25:00,0.0,16.0,7.0,3
463-
2013-05-21 15:30:00,0.0,14.0,7.0,3
464-
2013-05-21 15:35:00,0.0,12.0,6.0,3
465-
2013-05-21 15:40:00,0.0,10.0,5.0,3
466-
2013-05-21 15:45:00,0.0,8.0,5.0,3
467-
2013-05-21 15:50:00,0.0,6.0,4.0,3
468-
2013-05-21 15:55:00,0.0,5.0,3.0,3
469-
2013-05-21 16:00:00,0.0,4.0,3.0,3
470-
2013-05-21 16:05:00,0.0,3.0,2.0,3
471-
2013-05-21 16:10:00,0.0,2.0,2.0,3
472-
2013-05-21 16:15:00,0.0,1.0,1.0,3
473-
2013-05-21 16:20:00,0.0,0.0,1.0,3
474-
2013-05-21 16:25:00,0.0,0.0,1.0,3
446+
2013-05-21 14:05:00,0.0,75.0,30.0,0
447+
2013-05-21 14:10:00,0.0,70.0,28.0,0
448+
2013-05-21 14:15:00,0.0,65.0,27.0,0
449+
2013-05-21 14:20:00,0.0,60.0,25.0,0
450+
2013-05-21 14:25:00,0.0,55.0,23.0,0
451+
2013-05-21 14:30:00,0.0,50.0,22.0,0
452+
2013-05-21 14:35:00,0.0,45.0,20.0,0
453+
2013-05-21 14:40:00,0.0,40.0,18.0,0
454+
2013-05-21 14:45:00,0.0,37.0,17.0,0
455+
2013-05-21 14:50:00,0.0,34.0,15.0,0
456+
2013-05-21 14:55:00,0.0,31.0,13.0,0
457+
2013-05-21 15:00:00,0.0,28.0,12.0,0
458+
2013-05-21 15:05:00,0.0,25.0,11.0,0
459+
2013-05-21 15:10:00,0.0,22.0,10.0,0
460+
2013-05-21 15:15:00,0.0,20.0,9.0,0
461+
2013-05-21 15:20:00,0.0,18.0,8.0,0
462+
2013-05-21 15:25:00,0.0,16.0,7.0,0
463+
2013-05-21 15:30:00,0.0,14.0,7.0,0
464+
2013-05-21 15:35:00,0.0,12.0,6.0,0
465+
2013-05-21 15:40:00,0.0,10.0,5.0,0
466+
2013-05-21 15:45:00,0.0,8.0,5.0,0
467+
2013-05-21 15:50:00,0.0,6.0,4.0,0
468+
2013-05-21 15:55:00,0.0,5.0,3.0,0
469+
2013-05-21 16:00:00,0.0,4.0,3.0,0
470+
2013-05-21 16:05:00,0.0,3.0,2.0,0
471+
2013-05-21 16:10:00,0.0,2.0,2.0,0
472+
2013-05-21 16:15:00,0.0,1.0,1.0,0
473+
2013-05-21 16:20:00,0.0,0.0,1.0,0
474+
2013-05-21 16:25:00,0.0,0.0,1.0,0

cloudside/tests/test_asos.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -143,7 +143,7 @@ def test_fetch_files(ftp_login, ftp_retr):
143143
)
144144
assert isinstance(raw_paths, filter)
145145
assert all([(isinstance(rp, pathlib.Path) or (rp is None)) for rp in raw_paths])
146-
assert ftp_login.called_once_with("tester@cloudside.net")
146+
ftp_login.assert_called_once_with(passwd="tester@cloudside.net")
147147
assert ftp_retr.call_count == 5
148148

149149

cloudside/tests/test_viz.py

Lines changed: 0 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -161,25 +161,6 @@ def test_rose(test_data):
161161
return fig
162162

163163

164-
@pytest.mark.mpl_image_compare(**IMG_OPTS)
165-
def test_windrose_short(short_data):
166-
fig, ax1, ax2 = _make_polar_fig()
167-
with warnings.catch_warnings():
168-
warnings.simplefilter("ignore")
169-
_ = viz.windRose(
170-
short_data.assign(WindSpd=short_data["WindSpd"] * 1.15),
171-
spd_units="mph",
172-
ax=ax1,
173-
spdcol="WindSpd",
174-
dircol="WindDir",
175-
)
176-
_ = viz.windRose(
177-
short_data, spdcol="WindSpd", dircol="WindDir", spd_units="kt", ax=ax2
178-
)
179-
quiet_layout(fig)
180-
return fig
181-
182-
183164
@pytest.mark.mpl_image_compare(**IMG_OPTS)
184165
def test_rose_short(short_data):
185166
fig, ax1, ax2 = _make_polar_fig()

cloudside/viz.py

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -511,11 +511,6 @@ def rose(
511511
return fig, rose
512512

513513

514-
@numpy.deprecate
515-
def windRose(dataframe, spdcol="wind_speed", dircol="wind_dir", **kwargs):
516-
return rose(dataframe, spdcol, dircol, **kwargs)
517-
518-
519514
def _pct_fmt(x, pos=0):
520515
return "%0.1f%%" % (100 * x)
521516

0 commit comments

Comments
 (0)