weatherdb 1.2.4__py3-none-any.whl → 1.2.5__py3-none-any.whl

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.
weatherdb/_version.py CHANGED
@@ -1 +1 @@
1
- __version__ = "1.2.4"
1
+ __version__ = "1.2.5"
weatherdb/cli.py CHANGED
@@ -7,6 +7,43 @@ from textwrap import dedent
7
7
  sys.path.insert(0, Path(__file__).resolve().parent.parent.as_posix())
8
8
  import weatherdb
9
9
 
10
+ # Reusable option decorators
11
+ # ---------------------------------------
12
+
13
+ def period_options(f):
14
+ """Add period options only"""
15
+ f = click.option("--period_from", "-f",
16
+ default=None, show_default=True,
17
+ help="The from timestamp of the period to apply the method on. Timestamp should be in the format YYYY-MM-DD.")(f)
18
+ f = click.option("--period_until", "-u",
19
+ default=None, show_default=True,
20
+ help="The until timestamp of the period to apply the method on. Timestamp should be in the format YYYY-MM-DD.")(f)
21
+ return f
22
+
23
+ def stid_option(f):
24
+ """Add station ID options"""
25
+ f = click.option("--stid", "-i",
26
+ default=["all"], show_default=True, multiple=True,
27
+ callback=lambda ctx, param, value: "all" if "all" in value else [int(v) for v in value],
28
+ help="The station IDs to apply the method to. Options are 'all' or a specific station ID. " +
29
+ "You can enter multiple values to add multiple station IDs.")(f)
30
+ return f
31
+
32
+ def para_options(f):
33
+ """Add parameter options"""
34
+ f = click.option("--para", "-p",
35
+ default=["p", "t", "et"], show_default=True, multiple=True,
36
+ help="The parameters to work with. Options are 'p', 't' and 'et'. " +
37
+ "You can enter multiple values to add multiple parameters.")(f)
38
+ return f
39
+
40
+ def common_update_options(f):
41
+ """Add common options for processing commands (para, stid, period)"""
42
+ f = para_options(f)
43
+ f = stid_option(f)
44
+ f = period_options(f)
45
+ return f
46
+
10
47
  # main cli group
11
48
  # ---------------------------------------
12
49
 
@@ -185,31 +222,43 @@ def update_ma_raster():
185
222
 
186
223
 
187
224
  @cli.command(short_help="Update the raw data of the complete database.")
188
- def update_raw():
225
+ @common_update_options
226
+ def update_raw(para, stid, period_from, period_until):
189
227
  click.echo("starting updating the raw data")
190
228
  broker = weatherdb.broker.Broker()
191
- broker.update_raw()
229
+ broker.update_raw(paras=para,
230
+ stids=stid,
231
+ period=(period_from, period_until))
192
232
 
193
233
 
194
234
  @cli.command(short_help="Do the quality check of the complete database.")
195
- def quality_check():
235
+ @common_update_options
236
+ def quality_check(para, stid, period_from, period_until):
196
237
  click.echo("starting quality check")
197
238
  broker = weatherdb.broker.Broker()
198
- broker.quality_check()
239
+ broker.quality_check(paras=para,
240
+ stids=stid,
241
+ period=(period_from, period_until))
199
242
 
200
243
 
201
244
  @cli.command(short_help="Do the filling of the complete database.")
202
- def fillup():
245
+ @common_update_options
246
+ def fillup(para, stid, period_from, period_until):
203
247
  click.echo("starting filling up")
204
248
  broker = weatherdb.broker.Broker()
205
- broker.fillup()
249
+ broker.fillup(paras=para,
250
+ stids=stid,
251
+ period=(period_from, period_until))
206
252
 
207
253
 
208
254
  @cli.command(short_help="Do the richter correction of the complete database.")
209
- def richter_correct():
255
+ @stid_option
256
+ @period_options
257
+ def richter_correct(stid, period_from, period_until):
210
258
  click.echo("starting richter correction")
211
259
  broker = weatherdb.broker.Broker()
212
- broker.richter_correct()
260
+ broker.richter_correct(stids=stid,
261
+ period=(period_from, period_until))
213
262
 
214
263
 
215
264
  # cli admin stuff
@@ -1447,7 +1447,8 @@ class StationBase:
1447
1447
  {sql_format_dict["extra_exec_cols"].format(i=i)}
1448
1448
  filled_by[{i}]=%1$s
1449
1449
  FROM timeseries.%2$I nb
1450
- WHERE nf.filled IS NULL AND nf.nb_mean[{i}] IS NULL {prev_check}
1450
+ WHERE (nf.filled IS NULL {sql_format_dict["extra_fillup_update_where"]})
1451
+ AND nf.nb_mean[{i}] IS NULL {prev_check}
1451
1452
  AND nf.timestamp = nb.timestamp;"""
1452
1453
  prev_check += f" AND nf.nb_mean[{i}] IS NOT NULL AND nf.filled_by[{i}] != %1$s"
1453
1454
 
@@ -1689,6 +1690,7 @@ class StationBase:
1689
1690
  "extra_fillup_where": "",
1690
1691
  "mul_elev_order": "",
1691
1692
  "extra_exec_cols": "",
1693
+ "extra_fillup_update_where": "",
1692
1694
  "extra_after_loop_extra_col": ""}
1693
1695
 
1694
1696
  @db_engine.deco_update_privilege
@@ -135,6 +135,7 @@ class StationT(StationTETBase):
135
135
  ' OR ts."filled_max" IS DISTINCT FROM new."filled_max"',
136
136
  "extra_exec_cols": "nb_max[{i}]=round(nb.raw_max + %3$s, 0)::int,"+
137
137
  "nb_min[{i}]=round(nb.raw_min + %3$s, 0)::int,",
138
+ "extra_fillup_update_where": ' OR nf."filled_min" IS NULL OR nf."filled_max" IS NULL',
138
139
  "extra_after_loop_extra_col": """,
139
140
  filled_min=(SELECT percentile_cont(0.5) WITHIN GROUP (ORDER BY v)
140
141
  FROM unnest(nb_min) as T(v)),
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: weatherdb
3
- Version: 1.2.4
3
+ Version: 1.2.5
4
4
  Summary: This is a package to work with and to create the Weather Database which handles, checks, fills and corrects DWD Weather Station data.
5
5
  Author-email: Max Schmit <max.schmit@hydrology.uni-freiburg.de>
6
6
  License: GNU GENERAL PUBLIC LICENSE
@@ -44,9 +44,9 @@ tests/test-data/regionalisation/DWD-grid_ma_1991_2020_DGM25_clipped.tif,sha256=8
44
44
  tests/test-data/regionalisation/HYRAS_ma_1991_2020_DGM25_clipped.tif,sha256=HiSmi715dUpryQ1WSLSXR7GmGPHzK0rl6WOOrwjRwXw,2116377
45
45
  tests/test-data/regionalisation/README.md,sha256=equFOPJVaESGKIK1ZPVEJHY4TEqkW3NpJOFQzjsBy7M,151
46
46
  weatherdb/__init__.py,sha256=2BzziScTYzA65WS6nhtCRZOWSLfwHTCwvZdeyuHw79U,846
47
- weatherdb/_version.py,sha256=qjo-Usbvp802f_1XeGyTsWsDwlFERHYfz7wsKPXKb4Q,21
47
+ weatherdb/_version.py,sha256=mVbto7ql37Z5qaxZdvFimhabXBR9vUiM-sBD79-zjmQ,21
48
48
  weatherdb/broker.py,sha256=qJaKVwo1zcTLKmP-sF_DMod6_7jVsdHEoiKEMvsPx9A,24842
49
- weatherdb/cli.py,sha256=b5p9SRP5aqQ3w89MLErAjFj37aZMy9OsF23nCDC8NJY,11358
49
+ weatherdb/cli.py,sha256=RnN_aiKbOOVkBXPn9weKqoL6OPJNXdpLWKsIM9T0NrM,13635
50
50
  weatherdb/alembic/README.md,sha256=6hq24TPr8z3nqJCaqrmj6__kLikVG66kLGqfC_aFPWQ,440
51
51
  weatherdb/alembic/alembic.ini,sha256=Mc3-qkQfA42ApX9douZT77g1pWE9gn4oMVJEDoebmdQ,3087
52
52
  weatherdb/alembic/config.py,sha256=Q4aolMUUT7f6VmbY0uz_dWBtKkj3KgTUs_xOY_Gbzjw,264
@@ -66,11 +66,11 @@ weatherdb/db/views.py,sha256=DxY_IIonmiiRM-IhQrUMLwj12gIg6Q30rQAmR3wP3BE,6359
66
66
  weatherdb/db/fixtures/RichterParameters.json,sha256=CKxrB5FBX_BRKqxegXNyNtn9DUKmgibUtdvHoE8E5JI,836
67
67
  weatherdb/db/queries/get_quotient.py,sha256=9wVFmXE8tk8igGj-Xk5uSI0eiF_PQ9d-yRq7RJpvMAA,6787
68
68
  weatherdb/station/GroupStation.py,sha256=ikVsAMXlhJY8I991mJ3IBCLPW9AH5Hd7QLnDUDawM3U,31066
69
- weatherdb/station/StationBases.py,sha256=0OwEl85220DI6MIffjf4KpS4UA5zCR4yE2DNzydOlKE,130329
69
+ weatherdb/station/StationBases.py,sha256=wR8PsVGf3IyxU8lADcjwe07AuhdmsJBSW_OeMplDKC0,130447
70
70
  weatherdb/station/StationET.py,sha256=hM6K8fCLC6mOLaE4cN92LHOyPGP01ifO6l2qO77I_bA,3621
71
71
  weatherdb/station/StationP.py,sha256=w_0l5cw8zTACIbmVFV4cdPwxuyP2Cnv97dnNrMElBDE,32691
72
72
  weatherdb/station/StationPD.py,sha256=Bcg_uQTgIQPffsMGhNEwKAXhYs1Ii4VeB75afdFG-Kk,3367
73
- weatherdb/station/StationT.py,sha256=-T1GKfUsvulm5c_-JufJ34H048fGlG21UF0_2z1dd9A,6012
73
+ weatherdb/station/StationT.py,sha256=uatVrNie891Ht4uuZ5zMb-INMrXuoLk48-dYP4smzO0,6111
74
74
  weatherdb/station/__init__.py,sha256=v1sPfmhhLRMOr5DJ2c5BLIFY7GWkP5iMLA5vtZm-osg,591
75
75
  weatherdb/station/constants.py,sha256=vtdhgcK8A2cJaknT6qI8w5tAh_Hb5i2SvxxtHZOPyVc,511
76
76
  weatherdb/stations/GroupStations.py,sha256=Q-0sZ4skZgE-2hwE2QKmwDz_8_U4xWb2hYsKv5RvR1E,21927
@@ -87,9 +87,9 @@ weatherdb/utils/dwd.py,sha256=amEVVPLzXTSScBP5VAK35dBxuiy-Ua4hHyKnDGxD_4Q,12394
87
87
  weatherdb/utils/geometry.py,sha256=Od-RDAW1MASVAsGBXpHti9osbVJDqUbumSKBSJPbQqc,1823
88
88
  weatherdb/utils/get_data.py,sha256=62wV37fuzGhC2fLSCL7JyyMd3BAiRiimIhV95-mEROU,17294
89
89
  weatherdb/utils/logging.py,sha256=iaWnzCdBYxFmzWgLq9a6VAeBMdwy-rnt2d9PSAQq4lA,4242
90
- weatherdb-1.2.4.dist-info/licenses/LICENSE,sha256=ixuiBLtpoK3iv89l7ylKkg9rs2GzF9ukPH7ynZYzK5s,35148
91
- weatherdb-1.2.4.dist-info/METADATA,sha256=NNHSK3kH_KjYWLwXTNxNDtY0PvXoYsnTuF-rf5K7zIw,44308
92
- weatherdb-1.2.4.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
93
- weatherdb-1.2.4.dist-info/entry_points.txt,sha256=kJemTd9Cm_QWPZt03KUWhpn1aB0-l_5ce6Ms3EoS_NM,55
94
- weatherdb-1.2.4.dist-info/top_level.txt,sha256=kLlRbXLn0GHvMWmciWRyvm0-FYEy56F6d0fGwfle9-g,28
95
- weatherdb-1.2.4.dist-info/RECORD,,
90
+ weatherdb-1.2.5.dist-info/licenses/LICENSE,sha256=ixuiBLtpoK3iv89l7ylKkg9rs2GzF9ukPH7ynZYzK5s,35148
91
+ weatherdb-1.2.5.dist-info/METADATA,sha256=fgnO1_o_ONvVUqZf94vmh4HgT3avg67MVV4B5H7YEZ0,44308
92
+ weatherdb-1.2.5.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
93
+ weatherdb-1.2.5.dist-info/entry_points.txt,sha256=kJemTd9Cm_QWPZt03KUWhpn1aB0-l_5ce6Ms3EoS_NM,55
94
+ weatherdb-1.2.5.dist-info/top_level.txt,sha256=kLlRbXLn0GHvMWmciWRyvm0-FYEy56F6d0fGwfle9-g,28
95
+ weatherdb-1.2.5.dist-info/RECORD,,