pastastore 1.3.0__tar.gz → 1.4.0__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {pastastore-1.3.0 → pastastore-1.4.0}/PKG-INFO +2 -1
- {pastastore-1.3.0 → pastastore-1.4.0}/pastastore/__init__.py +1 -1
- {pastastore-1.3.0 → pastastore-1.4.0}/pastastore/plotting.py +109 -16
- {pastastore-1.3.0 → pastastore-1.4.0}/pastastore/store.py +38 -4
- pastastore-1.4.0/pastastore/styling.py +66 -0
- {pastastore-1.3.0 → pastastore-1.4.0}/pastastore/util.py +14 -10
- {pastastore-1.3.0 → pastastore-1.4.0}/pastastore/version.py +1 -1
- {pastastore-1.3.0 → pastastore-1.4.0}/pastastore.egg-info/PKG-INFO +2 -1
- {pastastore-1.3.0 → pastastore-1.4.0}/pastastore.egg-info/SOURCES.txt +1 -0
- {pastastore-1.3.0 → pastastore-1.4.0}/pastastore.egg-info/requires.txt +1 -0
- {pastastore-1.3.0 → pastastore-1.4.0}/pyproject.toml +5 -2
- {pastastore-1.3.0 → pastastore-1.4.0}/tests/test_003_pastastore.py +1 -4
- {pastastore-1.3.0 → pastastore-1.4.0}/tests/test_006_benchmark.py +1 -1
- {pastastore-1.3.0 → pastastore-1.4.0}/LICENSE +0 -0
- {pastastore-1.3.0 → pastastore-1.4.0}/pastastore/base.py +0 -0
- {pastastore-1.3.0 → pastastore-1.4.0}/pastastore/connectors.py +0 -0
- {pastastore-1.3.0 → pastastore-1.4.0}/pastastore/datasets.py +0 -0
- {pastastore-1.3.0 → pastastore-1.4.0}/pastastore/yaml_interface.py +0 -0
- {pastastore-1.3.0 → pastastore-1.4.0}/pastastore.egg-info/dependency_links.txt +0 -0
- {pastastore-1.3.0 → pastastore-1.4.0}/pastastore.egg-info/top_level.txt +0 -0
- {pastastore-1.3.0 → pastastore-1.4.0}/readme.md +0 -0
- {pastastore-1.3.0 → pastastore-1.4.0}/setup.cfg +0 -0
- {pastastore-1.3.0 → pastastore-1.4.0}/tests/test_001_import.py +0 -0
- {pastastore-1.3.0 → pastastore-1.4.0}/tests/test_002_connectors.py +0 -0
- {pastastore-1.3.0 → pastastore-1.4.0}/tests/test_004_yaml.py +0 -0
- {pastastore-1.3.0 → pastastore-1.4.0}/tests/test_005_maps_plots.py +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.1
|
|
2
2
|
Name: pastastore
|
|
3
|
-
Version: 1.
|
|
3
|
+
Version: 1.4.0
|
|
4
4
|
Summary: Tools for managing Pastas time series models.
|
|
5
5
|
Author: D.A. Brakenhoff
|
|
6
6
|
Maintainer-email: "D.A. Brakenhoff" <d.brakenhoff@artesia-water.nl>, "R. Calje" <r.calje@artesia-water.nl>, "M.A. Vonk" <m.vonk@artesia-water.nl>
|
|
@@ -82,6 +82,7 @@ Provides-Extra: arctic
|
|
|
82
82
|
Requires-Dist: arctic; extra == "arctic"
|
|
83
83
|
Provides-Extra: arcticdb
|
|
84
84
|
Requires-Dist: arcticdb; extra == "arcticdb"
|
|
85
|
+
Requires-Dist: protobuf~=4.0; extra == "arcticdb"
|
|
85
86
|
Provides-Extra: docs
|
|
86
87
|
Requires-Dist: pastastore[optional]; extra == "docs"
|
|
87
88
|
Requires-Dist: sphinx_rtd_theme; extra == "docs"
|
|
@@ -14,6 +14,7 @@ follows::
|
|
|
14
14
|
ax = pstore.maps.oseries()
|
|
15
15
|
pstore.maps.add_background_map(ax) # for adding a background map
|
|
16
16
|
"""
|
|
17
|
+
|
|
17
18
|
import matplotlib.pyplot as plt
|
|
18
19
|
import numpy as np
|
|
19
20
|
import pandas as pd
|
|
@@ -49,6 +50,9 @@ class Plots:
|
|
|
49
50
|
split=False,
|
|
50
51
|
figsize=(10, 5),
|
|
51
52
|
progressbar=True,
|
|
53
|
+
show_legend=True,
|
|
54
|
+
labelfunc=None,
|
|
55
|
+
legend_kwargs=None,
|
|
52
56
|
**kwargs,
|
|
53
57
|
):
|
|
54
58
|
"""Internal method to plot time series from pastastore.
|
|
@@ -71,6 +75,13 @@ class Plots:
|
|
|
71
75
|
progressbar : bool, optional
|
|
72
76
|
show progressbar when loading time series from store,
|
|
73
77
|
by default True
|
|
78
|
+
show_legend : bool, optional
|
|
79
|
+
show legend, default is True.
|
|
80
|
+
labelfunc : callable, optional
|
|
81
|
+
function to create custom labels, function should take name of time series
|
|
82
|
+
as input
|
|
83
|
+
legend_kwargs : dict, optional
|
|
84
|
+
additional arguments to pass to legend
|
|
74
85
|
|
|
75
86
|
Returns
|
|
76
87
|
-------
|
|
@@ -109,16 +120,33 @@ class Plots:
|
|
|
109
120
|
iax = axes
|
|
110
121
|
else:
|
|
111
122
|
iax = ax
|
|
123
|
+
if labelfunc is not None:
|
|
124
|
+
n = labelfunc(n)
|
|
112
125
|
iax.plot(ts.index, ts.squeeze(), label=n, **kwargs)
|
|
113
|
-
|
|
126
|
+
|
|
127
|
+
if split and show_legend:
|
|
114
128
|
iax.legend(loc="best", fontsize="x-small")
|
|
115
129
|
|
|
116
|
-
if not split:
|
|
117
|
-
|
|
130
|
+
if not split and show_legend:
|
|
131
|
+
if legend_kwargs is None:
|
|
132
|
+
legend_kwargs = {}
|
|
133
|
+
ncol = legend_kwargs.pop("ncol", 7)
|
|
134
|
+
fontsize = legend_kwargs.pop("fontsize", "x-small")
|
|
135
|
+
axes.legend(loc=(0, 1), frameon=False, ncol=ncol, fontsize=fontsize)
|
|
118
136
|
|
|
119
137
|
return axes
|
|
120
138
|
|
|
121
|
-
def oseries(
|
|
139
|
+
def oseries(
|
|
140
|
+
self,
|
|
141
|
+
names=None,
|
|
142
|
+
ax=None,
|
|
143
|
+
split=False,
|
|
144
|
+
figsize=(10, 5),
|
|
145
|
+
show_legend=True,
|
|
146
|
+
labelfunc=None,
|
|
147
|
+
legend_kwargs=None,
|
|
148
|
+
**kwargs,
|
|
149
|
+
):
|
|
122
150
|
"""Plot oseries.
|
|
123
151
|
|
|
124
152
|
Parameters
|
|
@@ -134,6 +162,13 @@ class Plots:
|
|
|
134
162
|
A maximum of 20 time series is supported when split=True.
|
|
135
163
|
figsize : tuple, optional
|
|
136
164
|
figure size, by default (10, 5)
|
|
165
|
+
show_legend : bool, optional
|
|
166
|
+
show legend, default is True.
|
|
167
|
+
labelfunc : callable, optional
|
|
168
|
+
function to create custom labels, function should take name of time series
|
|
169
|
+
as input
|
|
170
|
+
legend_kwargs : dict, optional
|
|
171
|
+
additional arguments to pass to legend
|
|
137
172
|
|
|
138
173
|
Returns
|
|
139
174
|
-------
|
|
@@ -146,6 +181,9 @@ class Plots:
|
|
|
146
181
|
ax=ax,
|
|
147
182
|
split=split,
|
|
148
183
|
figsize=figsize,
|
|
184
|
+
show_legend=show_legend,
|
|
185
|
+
labelfunc=labelfunc,
|
|
186
|
+
legend_kwargs=legend_kwargs,
|
|
149
187
|
**kwargs,
|
|
150
188
|
)
|
|
151
189
|
|
|
@@ -156,6 +194,9 @@ class Plots:
|
|
|
156
194
|
ax=None,
|
|
157
195
|
split=False,
|
|
158
196
|
figsize=(10, 5),
|
|
197
|
+
show_legend=True,
|
|
198
|
+
labelfunc=None,
|
|
199
|
+
legend_kwargs=None,
|
|
159
200
|
**kwargs,
|
|
160
201
|
):
|
|
161
202
|
"""Plot stresses.
|
|
@@ -176,6 +217,13 @@ class Plots:
|
|
|
176
217
|
A maximum of 20 time series is supported when split=True.
|
|
177
218
|
figsize : tuple, optional
|
|
178
219
|
figure size, by default (10, 5)
|
|
220
|
+
show_legend : bool, optional
|
|
221
|
+
show legend, default is True.
|
|
222
|
+
labelfunc : callable, optional
|
|
223
|
+
function to create custom labels, function should take name of time series
|
|
224
|
+
as input
|
|
225
|
+
legend_kwargs : dict, optional
|
|
226
|
+
additional arguments to pass to legend
|
|
179
227
|
|
|
180
228
|
Returns
|
|
181
229
|
-------
|
|
@@ -196,6 +244,9 @@ class Plots:
|
|
|
196
244
|
ax=ax,
|
|
197
245
|
split=split,
|
|
198
246
|
figsize=figsize,
|
|
247
|
+
show_legend=show_legend,
|
|
248
|
+
labelfunc=labelfunc,
|
|
249
|
+
legend_kwargs=legend_kwargs,
|
|
199
250
|
**kwargs,
|
|
200
251
|
)
|
|
201
252
|
|
|
@@ -511,6 +562,22 @@ class Plots:
|
|
|
511
562
|
|
|
512
563
|
return ax
|
|
513
564
|
|
|
565
|
+
def compare_models(self, modelnames, ax=None, **kwargs):
|
|
566
|
+
models = self.pstore.get_models(modelnames)
|
|
567
|
+
names = []
|
|
568
|
+
onames = [iml.oseries.name for iml in models]
|
|
569
|
+
if len(np.unique(onames)) == 1:
|
|
570
|
+
for modelname in modelnames:
|
|
571
|
+
if onames[0] in modelname:
|
|
572
|
+
names.append(modelname.replace(onames[0], ""))
|
|
573
|
+
else:
|
|
574
|
+
names.append(modelname)
|
|
575
|
+
else:
|
|
576
|
+
names = modelnames
|
|
577
|
+
cm = ps.CompareModels(models, names=names)
|
|
578
|
+
cm.plot(**kwargs)
|
|
579
|
+
return cm
|
|
580
|
+
|
|
514
581
|
|
|
515
582
|
class Maps:
|
|
516
583
|
"""Map Class for PastaStore.
|
|
@@ -539,10 +606,12 @@ class Maps:
|
|
|
539
606
|
self,
|
|
540
607
|
names=None,
|
|
541
608
|
kind=None,
|
|
609
|
+
extent=None,
|
|
542
610
|
labels=True,
|
|
543
611
|
adjust=False,
|
|
544
612
|
figsize=(10, 8),
|
|
545
613
|
backgroundmap=False,
|
|
614
|
+
label_kwargs=None,
|
|
546
615
|
**kwargs,
|
|
547
616
|
):
|
|
548
617
|
"""Plot stresses locations on map.
|
|
@@ -554,6 +623,8 @@ class Maps:
|
|
|
554
623
|
kind: str, optional
|
|
555
624
|
if passed, only plot stresses of a specific kind, default is None
|
|
556
625
|
which plots all stresses.
|
|
626
|
+
extent : list of float, optional
|
|
627
|
+
plot only stresses within extent [xmin, xmax, ymin, ymax]
|
|
557
628
|
labels: bool, optional
|
|
558
629
|
label models, by default True
|
|
559
630
|
adjust: bool, optional
|
|
@@ -565,6 +636,8 @@ class Maps:
|
|
|
565
636
|
backgroundmap: bool, optional
|
|
566
637
|
if True, add background map (default CRS is EPSG:28992) with default tiles
|
|
567
638
|
by OpenStreetMap.Mapnik. Default option is False.
|
|
639
|
+
label_kwargs: dict, optional
|
|
640
|
+
dictionary with keyword arguments to pass to add_labels method
|
|
568
641
|
|
|
569
642
|
Returns
|
|
570
643
|
-------
|
|
@@ -575,10 +648,10 @@ class Maps:
|
|
|
575
648
|
--------
|
|
576
649
|
self.add_background_map
|
|
577
650
|
"""
|
|
578
|
-
|
|
579
|
-
|
|
580
|
-
|
|
581
|
-
|
|
651
|
+
names = self.pstore.conn._parse_names(names, "stresses")
|
|
652
|
+
if extent is not None:
|
|
653
|
+
names = self.pstore.within(extent, names=names, libname="stresses")
|
|
654
|
+
df = self.pstore.stresses.loc[names]
|
|
582
655
|
|
|
583
656
|
if kind is not None:
|
|
584
657
|
if isinstance(kind, str):
|
|
@@ -603,7 +676,9 @@ class Maps:
|
|
|
603
676
|
else:
|
|
604
677
|
ax = r
|
|
605
678
|
if labels:
|
|
606
|
-
|
|
679
|
+
if label_kwargs is None:
|
|
680
|
+
label_kwargs = {}
|
|
681
|
+
self.add_labels(stresses, ax, adjust=adjust, **label_kwargs)
|
|
607
682
|
|
|
608
683
|
if backgroundmap:
|
|
609
684
|
self.add_background_map(ax)
|
|
@@ -613,10 +688,12 @@ class Maps:
|
|
|
613
688
|
def oseries(
|
|
614
689
|
self,
|
|
615
690
|
names=None,
|
|
691
|
+
extent=None,
|
|
616
692
|
labels=True,
|
|
617
693
|
adjust=False,
|
|
618
694
|
figsize=(10, 8),
|
|
619
695
|
backgroundmap=False,
|
|
696
|
+
label_kwargs=None,
|
|
620
697
|
**kwargs,
|
|
621
698
|
):
|
|
622
699
|
"""Plot oseries locations on map.
|
|
@@ -625,8 +702,11 @@ class Maps:
|
|
|
625
702
|
----------
|
|
626
703
|
names: list, optional
|
|
627
704
|
oseries names, by default None which plots all oseries locations
|
|
628
|
-
|
|
629
|
-
|
|
705
|
+
extent : list of float, optional
|
|
706
|
+
plot only oseries within extent [xmin, xmax, ymin, ymax]
|
|
707
|
+
labels: bool or str, optional
|
|
708
|
+
label models, by default True, if passed as "grouped", only the first
|
|
709
|
+
label for each x,y-location is shown.
|
|
630
710
|
adjust: bool, optional
|
|
631
711
|
automated smart label placement using adjustText, by default False
|
|
632
712
|
figsize: tuple, optional
|
|
@@ -634,6 +714,8 @@ class Maps:
|
|
|
634
714
|
backgroundmap: bool, optional
|
|
635
715
|
if True, add background map (default CRS is EPSG:28992) with default tiles
|
|
636
716
|
by OpenStreetMap.Mapnik. Default option is False.
|
|
717
|
+
label_kwargs: dict, optional
|
|
718
|
+
dictionary with keyword arguments to pass to add_labels method
|
|
637
719
|
|
|
638
720
|
Returns
|
|
639
721
|
-------
|
|
@@ -646,6 +728,8 @@ class Maps:
|
|
|
646
728
|
"""
|
|
647
729
|
|
|
648
730
|
names = self.pstore.conn._parse_names(names, "oseries")
|
|
731
|
+
if extent is not None:
|
|
732
|
+
names = self.pstore.within(extent, names=names)
|
|
649
733
|
oseries = self.pstore.oseries.loc[names]
|
|
650
734
|
mask0 = (oseries["x"] != 0.0) | (oseries["y"] != 0.0)
|
|
651
735
|
r = self._plotmap_dataframe(oseries.loc[mask0], figsize=figsize, **kwargs)
|
|
@@ -654,7 +738,12 @@ class Maps:
|
|
|
654
738
|
else:
|
|
655
739
|
ax = r
|
|
656
740
|
if labels:
|
|
657
|
-
|
|
741
|
+
if label_kwargs is None:
|
|
742
|
+
label_kwargs = {}
|
|
743
|
+
if labels == "grouped":
|
|
744
|
+
gr = oseries.sort_index().reset_index().groupby(["x", "y"])
|
|
745
|
+
oseries = oseries.loc[gr["index"].first().tolist()]
|
|
746
|
+
self.add_labels(oseries, ax, adjust=adjust, **label_kwargs)
|
|
658
747
|
|
|
659
748
|
if backgroundmap:
|
|
660
749
|
self.add_background_map(ax)
|
|
@@ -1258,7 +1347,7 @@ class Maps:
|
|
|
1258
1347
|
ctx.add_basemap(ax, source=providers[map_provider], crs=proj.srs, **kwargs)
|
|
1259
1348
|
|
|
1260
1349
|
@staticmethod
|
|
1261
|
-
def add_labels(df, ax, adjust=False, **kwargs):
|
|
1350
|
+
def add_labels(df, ax, adjust=False, objects=None, **kwargs):
|
|
1262
1351
|
"""Add labels to points on plot.
|
|
1263
1352
|
|
|
1264
1353
|
Uses dataframe index to label points.
|
|
@@ -1271,11 +1360,12 @@ class Maps:
|
|
|
1271
1360
|
axes object to label points on
|
|
1272
1361
|
adjust: bool
|
|
1273
1362
|
automated smart label placement using adjustText
|
|
1363
|
+
objects : list of matplotlib objects
|
|
1364
|
+
use to avoid labels overlapping markers
|
|
1274
1365
|
**kwargs:
|
|
1275
|
-
keyword arguments to ax.annotate
|
|
1366
|
+
keyword arguments to ax.annotate or adjusttext
|
|
1276
1367
|
"""
|
|
1277
1368
|
stroke = [patheffects.withStroke(linewidth=3, foreground="w")]
|
|
1278
|
-
|
|
1279
1369
|
fontsize = kwargs.pop("fontsize", 10)
|
|
1280
1370
|
|
|
1281
1371
|
if adjust:
|
|
@@ -1295,7 +1385,9 @@ class Maps:
|
|
|
1295
1385
|
|
|
1296
1386
|
adjust_text(
|
|
1297
1387
|
texts,
|
|
1298
|
-
|
|
1388
|
+
objects=objects,
|
|
1389
|
+
force_text=(0.05, 0.10),
|
|
1390
|
+
**kwargs,
|
|
1299
1391
|
**{
|
|
1300
1392
|
"arrowprops": {
|
|
1301
1393
|
"arrowstyle": "-",
|
|
@@ -1318,4 +1410,5 @@ class Maps:
|
|
|
1318
1410
|
textcoords=textcoords,
|
|
1319
1411
|
xytext=xytext,
|
|
1320
1412
|
**{"path_effects": stroke},
|
|
1413
|
+
**kwargs,
|
|
1321
1414
|
)
|
|
@@ -380,7 +380,7 @@ class PastaStore:
|
|
|
380
380
|
i_signatures.append(sign_val)
|
|
381
381
|
else:
|
|
382
382
|
raise e
|
|
383
|
-
signatures_df.loc[name, signatures] = i_signatures
|
|
383
|
+
signatures_df.loc[name, signatures] = i_signatures.squeeze()
|
|
384
384
|
|
|
385
385
|
return signatures_df
|
|
386
386
|
|
|
@@ -991,8 +991,9 @@ class PastaStore:
|
|
|
991
991
|
libname: str,
|
|
992
992
|
s: Optional[Union[list, str]] = None,
|
|
993
993
|
case_sensitive: bool = True,
|
|
994
|
+
sort=True,
|
|
994
995
|
):
|
|
995
|
-
"""Search for names of time series or models starting with s
|
|
996
|
+
"""Search for names of time series or models starting with `s`.
|
|
996
997
|
|
|
997
998
|
Parameters
|
|
998
999
|
----------
|
|
@@ -1002,6 +1003,8 @@ class PastaStore:
|
|
|
1002
1003
|
find names with part of this string or strings in list
|
|
1003
1004
|
case_sensitive : bool, optional
|
|
1004
1005
|
whether search should be case sensitive, by default True
|
|
1006
|
+
sort : bool, optional
|
|
1007
|
+
sort list of names
|
|
1005
1008
|
|
|
1006
1009
|
Returns
|
|
1007
1010
|
-------
|
|
@@ -1031,7 +1034,8 @@ class PastaStore:
|
|
|
1031
1034
|
else:
|
|
1032
1035
|
m = np.append(m, [n for n in lib_names if sub.lower() in n.lower()])
|
|
1033
1036
|
matches = list(np.unique(m))
|
|
1034
|
-
|
|
1037
|
+
if sort:
|
|
1038
|
+
matches.sort()
|
|
1035
1039
|
return matches
|
|
1036
1040
|
|
|
1037
1041
|
def get_model_timeseries_names(
|
|
@@ -1127,6 +1131,36 @@ class PastaStore:
|
|
|
1127
1131
|
"'libname' must be one of ['oseries', 'stresses', 'models']!"
|
|
1128
1132
|
)
|
|
1129
1133
|
getter = getattr(self.conn, f"get_{libname}")
|
|
1130
|
-
for n in
|
|
1134
|
+
for n in (
|
|
1135
|
+
tqdm(names, desc=f"Applying {func.__name__}") if progressbar else names
|
|
1136
|
+
):
|
|
1131
1137
|
result[n] = func(getter(n))
|
|
1132
1138
|
return result
|
|
1139
|
+
|
|
1140
|
+
def within(self, extent, names=None, libname="oseries"):
|
|
1141
|
+
xmin, xmax, ymin, ymax = extent
|
|
1142
|
+
names = self.conn._parse_names(names, libname)
|
|
1143
|
+
if libname == "oseries":
|
|
1144
|
+
df = self.oseries.loc[names]
|
|
1145
|
+
elif libname == "stresses":
|
|
1146
|
+
df = self.stresses.loc[names]
|
|
1147
|
+
elif libname == "models":
|
|
1148
|
+
onames = np.unique(
|
|
1149
|
+
[
|
|
1150
|
+
self.get_models(modelname, return_dict=True)["oseries"]["name"]
|
|
1151
|
+
for modelname in names
|
|
1152
|
+
]
|
|
1153
|
+
)
|
|
1154
|
+
df = self.oseries.loc[onames]
|
|
1155
|
+
else:
|
|
1156
|
+
raise ValueError(
|
|
1157
|
+
"libname must be one of ['oseries', 'stresses', 'models']"
|
|
1158
|
+
f", got '{libname}'"
|
|
1159
|
+
)
|
|
1160
|
+
mask = (
|
|
1161
|
+
(df["x"] <= xmax)
|
|
1162
|
+
& (df["x"] >= xmin)
|
|
1163
|
+
& (df["y"] >= ymin)
|
|
1164
|
+
& (df["y"] <= ymax)
|
|
1165
|
+
)
|
|
1166
|
+
return df.loc[mask].index.tolist()
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
import matplotlib as mpl
|
|
2
|
+
import matplotlib.pyplot as plt
|
|
3
|
+
import numpy as np
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
def float_styler(val, norm, cmap=None):
|
|
7
|
+
"""Style float values in DataFrame.
|
|
8
|
+
|
|
9
|
+
Parameters
|
|
10
|
+
----------
|
|
11
|
+
val : float
|
|
12
|
+
value in cell
|
|
13
|
+
norm : matplotlib.colors.Normalize
|
|
14
|
+
normalizer to map values to range(0, 1)
|
|
15
|
+
cmap : colormap, optional
|
|
16
|
+
colormap to use, by default None, which uses RdYlBu
|
|
17
|
+
|
|
18
|
+
Returns
|
|
19
|
+
-------
|
|
20
|
+
str
|
|
21
|
+
css value pairs for styling dataframe
|
|
22
|
+
|
|
23
|
+
Usage
|
|
24
|
+
-----
|
|
25
|
+
Given some dataframe
|
|
26
|
+
|
|
27
|
+
>>> df.map(float_styler, subset=["some column"], norm=norm, cmap=cmap)
|
|
28
|
+
|
|
29
|
+
"""
|
|
30
|
+
if cmap is None:
|
|
31
|
+
cmap = plt.get_cmap("RdYlBu")
|
|
32
|
+
bg = cmap(norm(val))
|
|
33
|
+
color = mpl.colors.rgb2hex(bg)
|
|
34
|
+
c = "White" if np.mean(bg[:3]) < 0.4 else "Black"
|
|
35
|
+
return f"background-color: {color}; color: {c}"
|
|
36
|
+
|
|
37
|
+
|
|
38
|
+
def boolean_styler(b):
|
|
39
|
+
"""Style boolean values in DataFrame.
|
|
40
|
+
|
|
41
|
+
Parameters
|
|
42
|
+
----------
|
|
43
|
+
b : bool
|
|
44
|
+
value in cell
|
|
45
|
+
|
|
46
|
+
Returns
|
|
47
|
+
-------
|
|
48
|
+
str
|
|
49
|
+
css value pairs for styling dataframe
|
|
50
|
+
|
|
51
|
+
Usage
|
|
52
|
+
-----
|
|
53
|
+
Given some dataframe
|
|
54
|
+
|
|
55
|
+
>>> df.map(boolean_styler, subset=["some column"])
|
|
56
|
+
"""
|
|
57
|
+
if b:
|
|
58
|
+
return (
|
|
59
|
+
f"background-color: {mpl.colors.rgb2hex((231/255, 255/255, 239/255))}; "
|
|
60
|
+
"color: darkgreen"
|
|
61
|
+
)
|
|
62
|
+
else:
|
|
63
|
+
return (
|
|
64
|
+
f"background-color: {mpl.colors.rgb2hex((255/255, 238/255, 238/255))}; "
|
|
65
|
+
"color: darkred"
|
|
66
|
+
)
|
|
@@ -335,9 +335,11 @@ def compare_models(ml1, ml2, stats=None, detailed_comparison=False):
|
|
|
335
335
|
try:
|
|
336
336
|
assert_series_equal(
|
|
337
337
|
oso,
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
338
|
+
(
|
|
339
|
+
ml.oseries.series_original
|
|
340
|
+
if PASTAS_LEQ_022
|
|
341
|
+
else ml.oseries._series_original
|
|
342
|
+
),
|
|
341
343
|
)
|
|
342
344
|
compare_oso = True
|
|
343
345
|
except (ValueError, AssertionError):
|
|
@@ -378,9 +380,9 @@ def compare_models(ml1, ml2, stats=None, detailed_comparison=False):
|
|
|
378
380
|
for ts in stresses:
|
|
379
381
|
df.loc[f"- time series: '{ts.name}'"] = ts.name
|
|
380
382
|
for tsk in ts.settings.keys():
|
|
381
|
-
df.loc[
|
|
382
|
-
|
|
383
|
-
|
|
383
|
+
df.loc[f" - {ts.name} settings: {tsk}", f"model {i}"] = (
|
|
384
|
+
ts.settings[tsk]
|
|
385
|
+
)
|
|
384
386
|
|
|
385
387
|
if i == 0:
|
|
386
388
|
if PASTAS_LEQ_022:
|
|
@@ -403,9 +405,11 @@ def compare_models(ml1, ml2, stats=None, detailed_comparison=False):
|
|
|
403
405
|
try:
|
|
404
406
|
assert_series_equal(
|
|
405
407
|
so1[counter],
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
408
|
+
(
|
|
409
|
+
ts.series_original
|
|
410
|
+
if PASTAS_LEQ_022
|
|
411
|
+
else ts._series_original
|
|
412
|
+
),
|
|
409
413
|
)
|
|
410
414
|
compare_so1 = True
|
|
411
415
|
except (ValueError, AssertionError):
|
|
@@ -703,7 +707,7 @@ def frontiers_checks(
|
|
|
703
707
|
check_tmem_passed,
|
|
704
708
|
)
|
|
705
709
|
else:
|
|
706
|
-
tmem = ml.get_response_tmax(sm_name)
|
|
710
|
+
tmem = ml.get_response_tmax(sm_name, cutoff=check3_cutoff)
|
|
707
711
|
if tmem is None: # no rfunc in stressmodel
|
|
708
712
|
tmem = 0
|
|
709
713
|
check_tmem_passed = tmem < len_oseries_calib / 2
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.1
|
|
2
2
|
Name: pastastore
|
|
3
|
-
Version: 1.
|
|
3
|
+
Version: 1.4.0
|
|
4
4
|
Summary: Tools for managing Pastas time series models.
|
|
5
5
|
Author: D.A. Brakenhoff
|
|
6
6
|
Maintainer-email: "D.A. Brakenhoff" <d.brakenhoff@artesia-water.nl>, "R. Calje" <r.calje@artesia-water.nl>, "M.A. Vonk" <m.vonk@artesia-water.nl>
|
|
@@ -82,6 +82,7 @@ Provides-Extra: arctic
|
|
|
82
82
|
Requires-Dist: arctic; extra == "arctic"
|
|
83
83
|
Provides-Extra: arcticdb
|
|
84
84
|
Requires-Dist: arcticdb; extra == "arcticdb"
|
|
85
|
+
Requires-Dist: protobuf~=4.0; extra == "arcticdb"
|
|
85
86
|
Provides-Extra: docs
|
|
86
87
|
Requires-Dist: pastastore[optional]; extra == "docs"
|
|
87
88
|
Requires-Dist: sphinx_rtd_theme; extra == "docs"
|
|
@@ -58,13 +58,16 @@ test = [
|
|
|
58
58
|
"pytest-dependency",
|
|
59
59
|
"pytest-benchmark",
|
|
60
60
|
"codacy-coverage",
|
|
61
|
-
"lxml",
|
|
61
|
+
"lxml", # temporary fix: for hydropandas 0.8.0
|
|
62
62
|
]
|
|
63
63
|
pystore = ["fsspec>=0.3.3", "python-snappy", "dask[dataframe]"]
|
|
64
64
|
arctic = [
|
|
65
65
|
"arctic", # will not work as releases not uploaded to PyPI
|
|
66
66
|
]
|
|
67
|
-
arcticdb = [
|
|
67
|
+
arcticdb = [
|
|
68
|
+
"arcticdb",
|
|
69
|
+
"protobuf~=4.0",
|
|
70
|
+
] # TODO: temporarily set protobuf to version 4
|
|
68
71
|
docs = [
|
|
69
72
|
"pastastore[optional]",
|
|
70
73
|
"sphinx_rtd_theme",
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import os
|
|
2
|
-
import warnings
|
|
3
2
|
|
|
4
3
|
import numpy as np
|
|
5
4
|
import pandas as pd
|
|
@@ -9,9 +8,7 @@ from numpy import allclose
|
|
|
9
8
|
from packaging.version import parse
|
|
10
9
|
from pytest_dependency import depends
|
|
11
10
|
|
|
12
|
-
|
|
13
|
-
warnings.simplefilter(action="ignore", category=FutureWarning)
|
|
14
|
-
import pastastore as pst
|
|
11
|
+
import pastastore as pst
|
|
15
12
|
|
|
16
13
|
|
|
17
14
|
@pytest.mark.dependency()
|
|
@@ -9,7 +9,7 @@ import pastastore as pst
|
|
|
9
9
|
|
|
10
10
|
# data
|
|
11
11
|
data = np.random.random_sample(int(1e5))
|
|
12
|
-
s = pd.Series(index=pd.date_range("1970", periods=1e5, freq="
|
|
12
|
+
s = pd.Series(index=pd.date_range("1970", periods=int(1e5), freq="h"), data=data)
|
|
13
13
|
metadata = {"x": 100000.0, "y": 300000.0}
|
|
14
14
|
|
|
15
15
|
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|