weatherdb 1.1.0__py3-none-any.whl

Sign up to get free protection for your applications and to get access to all the features.
Files changed (77) hide show
  1. docker/Dockerfile +30 -0
  2. docker/docker-compose.yaml +58 -0
  3. docker/docker-compose_test.yaml +24 -0
  4. docker/start-docker-test.sh +6 -0
  5. docs/requirements.txt +10 -0
  6. docs/source/Changelog.md +2 -0
  7. docs/source/License.rst +7 -0
  8. docs/source/Methode.md +161 -0
  9. docs/source/_static/custom.css +8 -0
  10. docs/source/_static/favicon.ico +0 -0
  11. docs/source/_static/logo.png +0 -0
  12. docs/source/api/api.rst +15 -0
  13. docs/source/api/cli.rst +8 -0
  14. docs/source/api/weatherDB.broker.rst +10 -0
  15. docs/source/api/weatherDB.config.rst +7 -0
  16. docs/source/api/weatherDB.db.rst +23 -0
  17. docs/source/api/weatherDB.rst +22 -0
  18. docs/source/api/weatherDB.station.rst +56 -0
  19. docs/source/api/weatherDB.stations.rst +46 -0
  20. docs/source/api/weatherDB.utils.rst +22 -0
  21. docs/source/conf.py +137 -0
  22. docs/source/index.rst +33 -0
  23. docs/source/setup/Configuration.md +127 -0
  24. docs/source/setup/Hosting.md +9 -0
  25. docs/source/setup/Install.md +49 -0
  26. docs/source/setup/Quickstart.md +183 -0
  27. docs/source/setup/setup.rst +12 -0
  28. weatherdb/__init__.py +24 -0
  29. weatherdb/_version.py +1 -0
  30. weatherdb/alembic/README.md +8 -0
  31. weatherdb/alembic/alembic.ini +80 -0
  32. weatherdb/alembic/config.py +9 -0
  33. weatherdb/alembic/env.py +100 -0
  34. weatherdb/alembic/script.py.mako +26 -0
  35. weatherdb/alembic/versions/V1.0.0_initial_database_creation.py +898 -0
  36. weatherdb/alembic/versions/V1.0.2_more_charachters_for_settings+term_station_ma_raster.py +88 -0
  37. weatherdb/alembic/versions/V1.0.5_fix-ma-raster-values.py +152 -0
  38. weatherdb/alembic/versions/V1.0.6_update-views.py +22 -0
  39. weatherdb/broker.py +667 -0
  40. weatherdb/cli.py +214 -0
  41. weatherdb/config/ConfigParser.py +663 -0
  42. weatherdb/config/__init__.py +5 -0
  43. weatherdb/config/config_default.ini +162 -0
  44. weatherdb/db/__init__.py +3 -0
  45. weatherdb/db/connections.py +374 -0
  46. weatherdb/db/fixtures/RichterParameters.json +34 -0
  47. weatherdb/db/models.py +402 -0
  48. weatherdb/db/queries/get_quotient.py +155 -0
  49. weatherdb/db/views.py +165 -0
  50. weatherdb/station/GroupStation.py +710 -0
  51. weatherdb/station/StationBases.py +3108 -0
  52. weatherdb/station/StationET.py +111 -0
  53. weatherdb/station/StationP.py +807 -0
  54. weatherdb/station/StationPD.py +98 -0
  55. weatherdb/station/StationT.py +164 -0
  56. weatherdb/station/__init__.py +13 -0
  57. weatherdb/station/constants.py +21 -0
  58. weatherdb/stations/GroupStations.py +519 -0
  59. weatherdb/stations/StationsBase.py +1021 -0
  60. weatherdb/stations/StationsBaseTET.py +30 -0
  61. weatherdb/stations/StationsET.py +17 -0
  62. weatherdb/stations/StationsP.py +128 -0
  63. weatherdb/stations/StationsPD.py +24 -0
  64. weatherdb/stations/StationsT.py +21 -0
  65. weatherdb/stations/__init__.py +11 -0
  66. weatherdb/utils/TimestampPeriod.py +369 -0
  67. weatherdb/utils/__init__.py +3 -0
  68. weatherdb/utils/dwd.py +350 -0
  69. weatherdb/utils/geometry.py +69 -0
  70. weatherdb/utils/get_data.py +285 -0
  71. weatherdb/utils/logging.py +126 -0
  72. weatherdb-1.1.0.dist-info/LICENSE +674 -0
  73. weatherdb-1.1.0.dist-info/METADATA +765 -0
  74. weatherdb-1.1.0.dist-info/RECORD +77 -0
  75. weatherdb-1.1.0.dist-info/WHEEL +5 -0
  76. weatherdb-1.1.0.dist-info/entry_points.txt +2 -0
  77. weatherdb-1.1.0.dist-info/top_level.txt +3 -0
@@ -0,0 +1,898 @@
1
+ """Initial database creation
2
+
3
+ Revision ID: V1.0.0
4
+ Revises:
5
+ Create Date: 2024-08-23 14:44:43.130167
6
+
7
+ """
8
+
9
+ from typing import Sequence, Union
10
+ from alembic import op
11
+ import sqlalchemy as sa
12
+ import geoalchemy2
13
+
14
+ # revision identifiers, used by Alembic.
15
+ revision: str = "V1.0.0"
16
+ down_revision: Union[str, None] = None
17
+ branch_labels: Union[str, Sequence[str], None] = None
18
+ depends_on: Union[str, Sequence[str], None] = None
19
+
20
+
21
+ def upgrade() -> None:
22
+ op.create_table(
23
+ "droped_stations",
24
+ sa.Column(
25
+ "station_id",
26
+ sa.Integer(),
27
+ nullable=False,
28
+ comment="The station id that got droped",
29
+ ),
30
+ sa.Column(
31
+ "parameter",
32
+ sa.VARCHAR(length=3),
33
+ nullable=False,
34
+ comment="The parameter (n,t,et,p_d) of the station that got droped",
35
+ ),
36
+ sa.Column(
37
+ "why",
38
+ sa.Text(),
39
+ nullable=False,
40
+ comment="The reason why the station got droped",
41
+ ),
42
+ sa.Column(
43
+ "timestamp",
44
+ sa.TIMESTAMP(),
45
+ server_default=sa.text("now()"),
46
+ nullable=False,
47
+ comment="The timestamp when the station got droped",
48
+ ),
49
+ sa.PrimaryKeyConstraint("station_id", "parameter"),
50
+ comment="This table is there to save the station ids that got droped, so they wont GET recreated",
51
+ )
52
+ op.create_table(
53
+ "meta_et",
54
+ sa.Column(
55
+ "station_id",
56
+ sa.Integer(),
57
+ nullable=False,
58
+ comment="official DWD-ID of the station",
59
+ ),
60
+ sa.Column(
61
+ "is_real",
62
+ sa.Boolean(),
63
+ nullable=False,
64
+ server_default="true",
65
+ comment=" 'Is this station a real station with own measurements or only a virtual station, to have complete timeseries for every precipitation station.",
66
+ ),
67
+ sa.Column(
68
+ "raw_from",
69
+ sa.TIMESTAMP(),
70
+ nullable=True,
71
+ comment='The timestamp from when on own "raw" data is available',
72
+ ),
73
+ sa.Column(
74
+ "raw_until",
75
+ sa.TIMESTAMP(),
76
+ nullable=True,
77
+ comment='The timestamp until when own "raw" data is available',
78
+ ),
79
+ sa.Column(
80
+ "hist_until",
81
+ sa.TIMESTAMP(),
82
+ nullable=True,
83
+ comment='The timestamp until when own "raw" data is available',
84
+ ),
85
+ sa.Column(
86
+ "filled_from",
87
+ sa.TIMESTAMP(),
88
+ nullable=True,
89
+ comment="The timestamp from when on filled data is available",
90
+ ),
91
+ sa.Column(
92
+ "filled_until",
93
+ sa.TIMESTAMP(),
94
+ nullable=True,
95
+ comment="The timestamp until when filled data is available",
96
+ ),
97
+ sa.Column(
98
+ "last_imp_from",
99
+ sa.TIMESTAMP(),
100
+ nullable=True,
101
+ comment="The minimal timestamp of the last import, that might not yet have been treated",
102
+ ),
103
+ sa.Column(
104
+ "last_imp_until",
105
+ sa.TIMESTAMP(),
106
+ nullable=True,
107
+ comment="The maximal timestamp of the last import, that might not yet have been treated",
108
+ ),
109
+ sa.Column(
110
+ "last_imp_filled",
111
+ sa.Boolean(),
112
+ nullable=False,
113
+ server_default="false",
114
+ comment="Got the last import already filled?",
115
+ ),
116
+ sa.Column(
117
+ "stationshoehe",
118
+ sa.Integer(),
119
+ nullable=False,
120
+ comment="The stations height above the ground in meters",
121
+ ),
122
+ sa.Column(
123
+ "stationsname",
124
+ sa.VARCHAR(length=50),
125
+ nullable=False,
126
+ comment="The stations official name as text",
127
+ ),
128
+ sa.Column(
129
+ "bundesland",
130
+ sa.VARCHAR(length=30),
131
+ nullable=False,
132
+ comment="The state the station is located in",
133
+ ),
134
+ sa.Column(
135
+ "geometry",
136
+ geoalchemy2.types.Geometry(
137
+ geometry_type="POINT",
138
+ srid=4326,
139
+ from_text="ST_GeomFromEWKT",
140
+ name="geometry",
141
+ nullable=False,
142
+ ),
143
+ nullable=False,
144
+ comment="The stations location in the WGS84 coordinate reference system (EPSG:4326)",
145
+ ),
146
+ sa.Column(
147
+ "geometry_utm",
148
+ geoalchemy2.types.Geometry(
149
+ geometry_type="POINT",
150
+ srid=25832,
151
+ from_text="ST_GeomFromEWKT",
152
+ name="geometry",
153
+ nullable=False,
154
+ ),
155
+ nullable=False,
156
+ comment="The stations location in the UTM32 coordinate reference system (EPSG:25832)",
157
+ ),
158
+ sa.Column(
159
+ "last_imp_qc",
160
+ sa.Boolean(),
161
+ nullable=False,
162
+ server_default="false",
163
+ comment="Got the last import already quality checked?",
164
+ ),
165
+ sa.Column(
166
+ "qc_from",
167
+ sa.TIMESTAMP(),
168
+ nullable=True,
169
+ comment='The timestamp from when on quality checked("qc") data is available',
170
+ ),
171
+ sa.Column(
172
+ "qc_until",
173
+ sa.TIMESTAMP(),
174
+ nullable=True,
175
+ comment='The timestamp until when quality checked("qc") data is available',
176
+ ),
177
+ sa.Column(
178
+ "qc_droped",
179
+ sa.FLOAT(),
180
+ nullable=True,
181
+ comment="The percentage of droped values during the quality check",
182
+ ),
183
+ sa.PrimaryKeyConstraint("station_id"),
184
+ comment="The Meta informations of the evapotranspiration stations.",
185
+ )
186
+ op.create_index(
187
+ "idx_meta_et_geometry",
188
+ "meta_et",
189
+ ["geometry"],
190
+ unique=False,
191
+ postgresql_using="gist",
192
+ )
193
+ op.create_index(
194
+ "idx_meta_et_geometry_utm",
195
+ "meta_et",
196
+ ["geometry_utm"],
197
+ unique=False,
198
+ postgresql_using="gist",
199
+ )
200
+ op.create_table(
201
+ "meta_p",
202
+ sa.Column(
203
+ "last_imp_corr",
204
+ sa.Boolean(),
205
+ nullable=False,
206
+ server_default="false",
207
+ comment="Got the last import already Richter corrected?",
208
+ ),
209
+ sa.Column(
210
+ "corr_from",
211
+ sa.TIMESTAMP(),
212
+ nullable=True,
213
+ comment="The timestamp from when on corrected data is available",
214
+ ),
215
+ sa.Column(
216
+ "corr_until",
217
+ sa.TIMESTAMP(),
218
+ nullable=True,
219
+ comment="The timestamp until when corrected data is available",
220
+ ),
221
+ sa.Column(
222
+ "horizon",
223
+ sa.FLOAT(),
224
+ nullable=True,
225
+ comment="The horizon angle in degrees, how it got defined by Richter(1995).",
226
+ ),
227
+ sa.Column(
228
+ "richter_class",
229
+ sa.String(),
230
+ nullable=True,
231
+ comment="The Richter exposition class, that got derived from the horizon angle.",
232
+ ),
233
+ sa.Column(
234
+ "station_id",
235
+ sa.Integer(),
236
+ nullable=False,
237
+ comment="official DWD-ID of the station",
238
+ ),
239
+ sa.Column(
240
+ "is_real",
241
+ sa.Boolean(),
242
+ nullable=False,
243
+ comment=" 'Is this station a real station with own measurements or only a virtual station, to have complete timeseries for every precipitation station.",
244
+ ),
245
+ sa.Column(
246
+ "raw_from",
247
+ sa.TIMESTAMP(),
248
+ nullable=True,
249
+ comment='The timestamp from when on own "raw" data is available',
250
+ ),
251
+ sa.Column(
252
+ "raw_until",
253
+ sa.TIMESTAMP(),
254
+ nullable=True,
255
+ comment='The timestamp until when own "raw" data is available',
256
+ ),
257
+ sa.Column(
258
+ "hist_until",
259
+ sa.TIMESTAMP(),
260
+ nullable=True,
261
+ comment='The timestamp until when own "raw" data is available',
262
+ ),
263
+ sa.Column(
264
+ "filled_from",
265
+ sa.TIMESTAMP(),
266
+ nullable=True,
267
+ comment="The timestamp from when on filled data is available",
268
+ ),
269
+ sa.Column(
270
+ "filled_until",
271
+ sa.TIMESTAMP(),
272
+ nullable=True,
273
+ comment="The timestamp until when filled data is available",
274
+ ),
275
+ sa.Column(
276
+ "last_imp_from",
277
+ sa.TIMESTAMP(),
278
+ nullable=True,
279
+ comment="The minimal timestamp of the last import, that might not yet have been treated",
280
+ ),
281
+ sa.Column(
282
+ "last_imp_until",
283
+ sa.TIMESTAMP(),
284
+ nullable=True,
285
+ comment="The maximal timestamp of the last import, that might not yet have been treated",
286
+ ),
287
+ sa.Column(
288
+ "last_imp_filled",
289
+ sa.Boolean(),
290
+ nullable=False,
291
+ server_default="false",
292
+ comment="Got the last import already filled?",
293
+ ),
294
+ sa.Column(
295
+ "stationshoehe",
296
+ sa.Integer(),
297
+ nullable=False,
298
+ comment="The stations height above the ground in meters",
299
+ ),
300
+ sa.Column(
301
+ "stationsname",
302
+ sa.VARCHAR(length=50),
303
+ nullable=False,
304
+ comment="The stations official name as text",
305
+ ),
306
+ sa.Column(
307
+ "bundesland",
308
+ sa.VARCHAR(length=30),
309
+ nullable=False,
310
+ comment="The state the station is located in",
311
+ ),
312
+ sa.Column(
313
+ "geometry",
314
+ geoalchemy2.types.Geometry(
315
+ geometry_type="POINT",
316
+ srid=4326,
317
+ from_text="ST_GeomFromEWKT",
318
+ name="geometry",
319
+ nullable=False,
320
+ ),
321
+ nullable=False,
322
+ comment="The stations location in the WGS84 coordinate reference system (EPSG:4326)",
323
+ ),
324
+ sa.Column(
325
+ "geometry_utm",
326
+ geoalchemy2.types.Geometry(
327
+ geometry_type="POINT",
328
+ srid=25832,
329
+ from_text="ST_GeomFromEWKT",
330
+ name="geometry",
331
+ nullable=False,
332
+ ),
333
+ nullable=False,
334
+ comment="The stations location in the UTM32 coordinate reference system (EPSG:25832)",
335
+ ),
336
+ sa.Column(
337
+ "last_imp_qc",
338
+ sa.Boolean(),
339
+ nullable=False,
340
+ server_default="false",
341
+ comment="Got the last import already quality checked?",
342
+ ),
343
+ sa.Column(
344
+ "qc_from",
345
+ sa.TIMESTAMP(),
346
+ nullable=True,
347
+ comment='The timestamp from when on quality checked("qc") data is available',
348
+ ),
349
+ sa.Column(
350
+ "qc_until",
351
+ sa.TIMESTAMP(),
352
+ nullable=True,
353
+ comment='The timestamp until when quality checked("qc") data is available',
354
+ ),
355
+ sa.Column(
356
+ "qc_droped",
357
+ sa.FLOAT(),
358
+ nullable=True,
359
+ comment="The percentage of droped values during the quality check",
360
+ ),
361
+ sa.PrimaryKeyConstraint("station_id"),
362
+ comment="The Meta informations of the precipitation stations.",
363
+ )
364
+ op.create_index(
365
+ "idx_meta_p_geometry",
366
+ "meta_p",
367
+ ["geometry"],
368
+ unique=False,
369
+ postgresql_using="gist",
370
+ )
371
+ op.create_index(
372
+ "idx_meta_p_geometry_utm",
373
+ "meta_p",
374
+ ["geometry_utm"],
375
+ unique=False,
376
+ postgresql_using="gist",
377
+ )
378
+ op.create_table(
379
+ "meta_p_d",
380
+ sa.Column(
381
+ "station_id",
382
+ sa.Integer(),
383
+ nullable=False,
384
+ comment="official DWD-ID of the station",
385
+ ),
386
+ sa.Column(
387
+ "is_real",
388
+ sa.Boolean(),
389
+ nullable=False,
390
+ comment=" 'Is this station a real station with own measurements or only a virtual station, to have complete timeseries for every precipitation station.",
391
+ ),
392
+ sa.Column(
393
+ "raw_from",
394
+ sa.TIMESTAMP(),
395
+ nullable=True,
396
+ comment='The timestamp from when on own "raw" data is available',
397
+ ),
398
+ sa.Column(
399
+ "raw_until",
400
+ sa.TIMESTAMP(),
401
+ nullable=True,
402
+ comment='The timestamp until when own "raw" data is available',
403
+ ),
404
+ sa.Column(
405
+ "hist_until",
406
+ sa.TIMESTAMP(),
407
+ nullable=True,
408
+ comment='The timestamp until when own "raw" data is available',
409
+ ),
410
+ sa.Column(
411
+ "filled_from",
412
+ sa.TIMESTAMP(),
413
+ nullable=True,
414
+ comment="The timestamp from when on filled data is available",
415
+ ),
416
+ sa.Column(
417
+ "filled_until",
418
+ sa.TIMESTAMP(),
419
+ nullable=True,
420
+ comment="The timestamp until when filled data is available",
421
+ ),
422
+ sa.Column(
423
+ "last_imp_from",
424
+ sa.TIMESTAMP(),
425
+ nullable=True,
426
+ comment="The minimal timestamp of the last import, that might not yet have been treated",
427
+ ),
428
+ sa.Column(
429
+ "last_imp_until",
430
+ sa.TIMESTAMP(),
431
+ nullable=True,
432
+ comment="The maximal timestamp of the last import, that might not yet have been treated",
433
+ ),
434
+ sa.Column(
435
+ "last_imp_filled",
436
+ sa.Boolean(),
437
+ nullable=False,
438
+ server_default="false",
439
+ comment="Got the last import already filled?",
440
+ ),
441
+ sa.Column(
442
+ "stationshoehe",
443
+ sa.Integer(),
444
+ nullable=False,
445
+ comment="The stations height above the ground in meters",
446
+ ),
447
+ sa.Column(
448
+ "stationsname",
449
+ sa.VARCHAR(length=50),
450
+ nullable=False,
451
+ comment="The stations official name as text",
452
+ ),
453
+ sa.Column(
454
+ "bundesland",
455
+ sa.VARCHAR(length=30),
456
+ nullable=False,
457
+ comment="The state the station is located in",
458
+ ),
459
+ sa.Column(
460
+ "geometry",
461
+ geoalchemy2.types.Geometry(
462
+ geometry_type="POINT",
463
+ srid=4326,
464
+ from_text="ST_GeomFromEWKT",
465
+ name="geometry",
466
+ nullable=False,
467
+ ),
468
+ nullable=False,
469
+ comment="The stations location in the WGS84 coordinate reference system (EPSG:4326)",
470
+ ),
471
+ sa.Column(
472
+ "geometry_utm",
473
+ geoalchemy2.types.Geometry(
474
+ geometry_type="POINT",
475
+ srid=25832,
476
+ from_text="ST_GeomFromEWKT",
477
+ name="geometry",
478
+ nullable=False,
479
+ ),
480
+ nullable=False,
481
+ comment="The stations location in the UTM32 coordinate reference system (EPSG:25832)",
482
+ ),
483
+ sa.PrimaryKeyConstraint("station_id"),
484
+ comment="The Meta informations of the daily precipitation stations.",
485
+ )
486
+ op.create_index(
487
+ "idx_meta_p_d_geometry",
488
+ "meta_p_d",
489
+ ["geometry"],
490
+ unique=False,
491
+ postgresql_using="gist",
492
+ )
493
+ op.create_index(
494
+ "idx_meta_p_d_geometry_utm",
495
+ "meta_p_d",
496
+ ["geometry_utm"],
497
+ unique=False,
498
+ postgresql_using="gist",
499
+ )
500
+ op.create_table(
501
+ "meta_t",
502
+ sa.Column(
503
+ "station_id",
504
+ sa.Integer(),
505
+ nullable=False,
506
+ comment="official DWD-ID of the station",
507
+ ),
508
+ sa.Column(
509
+ "is_real",
510
+ sa.Boolean(),
511
+ nullable=False,
512
+ comment=" 'Is this station a real station with own measurements or only a virtual station, to have complete timeseries for every precipitation station.",
513
+ ),
514
+ sa.Column(
515
+ "raw_from",
516
+ sa.TIMESTAMP(),
517
+ nullable=True,
518
+ comment='The timestamp from when on own "raw" data is available',
519
+ ),
520
+ sa.Column(
521
+ "raw_until",
522
+ sa.TIMESTAMP(),
523
+ nullable=True,
524
+ comment='The timestamp until when own "raw" data is available',
525
+ ),
526
+ sa.Column(
527
+ "hist_until",
528
+ sa.TIMESTAMP(),
529
+ nullable=True,
530
+ comment='The timestamp until when own "raw" data is available',
531
+ ),
532
+ sa.Column(
533
+ "filled_from",
534
+ sa.TIMESTAMP(),
535
+ nullable=True,
536
+ comment="The timestamp from when on filled data is available",
537
+ ),
538
+ sa.Column(
539
+ "filled_until",
540
+ sa.TIMESTAMP(),
541
+ nullable=True,
542
+ comment="The timestamp until when filled data is available",
543
+ ),
544
+ sa.Column(
545
+ "last_imp_from",
546
+ sa.TIMESTAMP(),
547
+ nullable=True,
548
+ comment="The minimal timestamp of the last import, that might not yet have been treated",
549
+ ),
550
+ sa.Column(
551
+ "last_imp_until",
552
+ sa.TIMESTAMP(),
553
+ nullable=True,
554
+ comment="The maximal timestamp of the last import, that might not yet have been treated",
555
+ ),
556
+ sa.Column(
557
+ "last_imp_filled",
558
+ sa.Boolean(),
559
+ nullable=False,
560
+ server_default="false",
561
+ comment="Got the last import already filled?",
562
+ ),
563
+ sa.Column(
564
+ "stationshoehe",
565
+ sa.Integer(),
566
+ nullable=False,
567
+ comment="The stations height above the ground in meters",
568
+ ),
569
+ sa.Column(
570
+ "stationsname",
571
+ sa.VARCHAR(length=50),
572
+ nullable=False,
573
+ comment="The stations official name as text",
574
+ ),
575
+ sa.Column(
576
+ "bundesland",
577
+ sa.VARCHAR(length=30),
578
+ nullable=False,
579
+ comment="The state the station is located in",
580
+ ),
581
+ sa.Column(
582
+ "geometry",
583
+ geoalchemy2.types.Geometry(
584
+ geometry_type="POINT",
585
+ srid=4326,
586
+ from_text="ST_GeomFromEWKT",
587
+ name="geometry",
588
+ nullable=False,
589
+ ),
590
+ nullable=False,
591
+ comment="The stations location in the WGS84 coordinate reference system (EPSG:4326)",
592
+ ),
593
+ sa.Column(
594
+ "geometry_utm",
595
+ geoalchemy2.types.Geometry(
596
+ geometry_type="POINT",
597
+ srid=25832,
598
+ from_text="ST_GeomFromEWKT",
599
+ name="geometry",
600
+ nullable=False,
601
+ ),
602
+ nullable=False,
603
+ comment="The stations location in the UTM32 coordinate reference system (EPSG:25832)",
604
+ ),
605
+ sa.Column(
606
+ "last_imp_qc",
607
+ sa.Boolean(),
608
+ nullable=False,
609
+ server_default="false",
610
+ comment="Got the last import already quality checked?",
611
+ ),
612
+ sa.Column(
613
+ "qc_from",
614
+ sa.TIMESTAMP(),
615
+ nullable=True,
616
+ comment='The timestamp from when on quality checked("qc") data is available',
617
+ ),
618
+ sa.Column(
619
+ "qc_until",
620
+ sa.TIMESTAMP(),
621
+ nullable=True,
622
+ comment='The timestamp until when quality checked("qc") data is available',
623
+ ),
624
+ sa.Column(
625
+ "qc_droped",
626
+ sa.FLOAT(),
627
+ nullable=True,
628
+ comment="The percentage of droped values during the quality check",
629
+ ),
630
+ sa.PrimaryKeyConstraint("station_id"),
631
+ comment="The Meta informations of the temperature stations.",
632
+ )
633
+ op.create_index(
634
+ "idx_meta_t_geometry",
635
+ "meta_t",
636
+ ["geometry"],
637
+ unique=False,
638
+ postgresql_using="gist",
639
+ )
640
+ op.create_index(
641
+ "idx_meta_t_geometry_utm",
642
+ "meta_t",
643
+ ["geometry_utm"],
644
+ unique=False,
645
+ postgresql_using="gist",
646
+ )
647
+ op.create_table(
648
+ "needed_download_time",
649
+ sa.Column(
650
+ "timestamp",
651
+ sa.TIMESTAMP(),
652
+ server_default=sa.text("now()"),
653
+ nullable=False,
654
+ comment="The timestamp when the download hapend.",
655
+ ),
656
+ sa.Column(
657
+ "quantity",
658
+ sa.Integer(),
659
+ nullable=False,
660
+ comment="The number of stations that got downloaded",
661
+ ),
662
+ sa.Column(
663
+ "aggregate",
664
+ sa.String(),
665
+ nullable=False,
666
+ comment="The chosen aggregation. e.g. hourly, 10min, daily, ...",
667
+ ),
668
+ sa.Column(
669
+ "timespan",
670
+ sa.Interval(),
671
+ nullable=False,
672
+ comment="The timespan of the downloaded timeseries. e.g. 2 years",
673
+ ),
674
+ sa.Column(
675
+ "zip", sa.Boolean(), nullable=False, comment="Was the download zipped?"
676
+ ),
677
+ sa.Column(
678
+ "pc",
679
+ sa.String(),
680
+ nullable=False,
681
+ comment="The name of the pc that downloaded the timeseries.",
682
+ ),
683
+ sa.Column(
684
+ "duration",
685
+ sa.Interval(),
686
+ nullable=False,
687
+ comment="The needed time to download and create the timeserie",
688
+ ),
689
+ sa.Column(
690
+ "output_size",
691
+ sa.Integer(),
692
+ nullable=False,
693
+ comment="The size of the created output file in bytes",
694
+ ),
695
+ sa.PrimaryKeyConstraint("timestamp"),
696
+ comment="Saves the time needed to save the timeseries. This helps predicting download time",
697
+ )
698
+ op.create_table(
699
+ "parameter_variables",
700
+ sa.Column(
701
+ "parameter",
702
+ sa.String(length=3),
703
+ nullable=False,
704
+ comment="The parameter for which the variables are valid. e.g. n/p_d/t/et.",
705
+ ),
706
+ sa.Column(
707
+ "start_tstp_last_imp",
708
+ sa.TIMESTAMP(),
709
+ nullable=True,
710
+ comment="At what timestamp did the last complete import start. This is then the maximum timestamp for which to expand the timeseries to.",
711
+ ),
712
+ sa.Column(
713
+ "max_tstp_last_imp",
714
+ sa.TIMESTAMP(),
715
+ nullable=True,
716
+ comment="The maximal timestamp of the last imports raw data of all the timeseries",
717
+ ),
718
+ sa.PrimaryKeyConstraint("parameter"),
719
+ comment="This table is there to save specific variables that are nescesary for the functioning of the scripts",
720
+ )
721
+ op.create_table(
722
+ "raw_files",
723
+ sa.Column(
724
+ "parameter",
725
+ sa.VARCHAR(length=3),
726
+ nullable=False,
727
+ comment="The parameter that got downloaded for this file. e.g. t, et, p_d, n",
728
+ ),
729
+ sa.Column(
730
+ "filepath",
731
+ sa.String(),
732
+ nullable=False,
733
+ comment="The filepath on the CDC Server",
734
+ ),
735
+ sa.Column(
736
+ "modtime",
737
+ sa.TIMESTAMP(),
738
+ nullable=False,
739
+ comment="The modification time on the CDC Server of the coresponding file",
740
+ ),
741
+ sa.PrimaryKeyConstraint("parameter", "filepath"),
742
+ comment="The files that got imported from the CDC Server.",
743
+ )
744
+ op.create_table(
745
+ "richter_parameters",
746
+ sa.Column(
747
+ "precipitation_typ",
748
+ sa.Text(),
749
+ nullable=False,
750
+ comment="The type of precipitation. e.g. 'Schnee', 'Regen', ...",
751
+ ),
752
+ sa.Column(
753
+ "e", sa.FLOAT(), nullable=False, comment="The e-value of the equation."
754
+ ),
755
+ sa.Column(
756
+ "b_no-protection",
757
+ sa.FLOAT(),
758
+ nullable=False,
759
+ comment="The b-value of the equation for exposition class 'no protection'.",
760
+ ),
761
+ sa.Column(
762
+ "b_little-protection",
763
+ sa.FLOAT(),
764
+ nullable=False,
765
+ comment="The b-value of the equation for exposition class 'little protection'.",
766
+ ),
767
+ sa.Column(
768
+ "b_protected",
769
+ sa.FLOAT(),
770
+ nullable=False,
771
+ comment="The b-value of the equation for exposition class 'protected'.",
772
+ ),
773
+ sa.Column(
774
+ "b_heavy-protection",
775
+ sa.FLOAT(),
776
+ nullable=False,
777
+ comment="The b-value of the equation for exposition class 'heavy protection'.",
778
+ ),
779
+ sa.PrimaryKeyConstraint("precipitation_typ"),
780
+ comment="The Richter values for the equation.",
781
+ )
782
+ op.create_table(
783
+ "settings",
784
+ sa.Column(
785
+ "key",
786
+ sa.String(length=20),
787
+ nullable=False,
788
+ comment="The key of the setting",
789
+ ),
790
+ sa.Column(
791
+ "value",
792
+ sa.String(length=20),
793
+ nullable=False,
794
+ comment="The value of the setting",
795
+ ),
796
+ sa.PrimaryKeyConstraint("key"),
797
+ comment="This table saves settings values for the script-databse connection. E.G. the latest package version that updated the database.",
798
+ )
799
+ op.create_table(
800
+ "station_ma_raster",
801
+ sa.Column(
802
+ "station_id",
803
+ sa.Integer(),
804
+ nullable=False,
805
+ comment="The DWD-ID of the station.",
806
+ ),
807
+ sa.Column(
808
+ "raster_key",
809
+ sa.VARCHAR(length=7),
810
+ nullable=False,
811
+ comment="The name of the raster. e.g. 'dwd' or 'hyras'",
812
+ ),
813
+ sa.Column(
814
+ "parameter",
815
+ sa.VARCHAR(length=7),
816
+ nullable=False,
817
+ comment="The parameter of the raster. e.g. 'p_wihj', 'p_sohj', 'p_year', 't_year', 'et_year'",
818
+ ),
819
+ sa.Column(
820
+ "value",
821
+ sa.Integer(),
822
+ nullable=False,
823
+ comment="The value of the raster for the station.",
824
+ ),
825
+ sa.Column(
826
+ "distance",
827
+ sa.Integer(),
828
+ nullable=False,
829
+ comment="The distance of the station to the raster value in meters.",
830
+ ),
831
+ sa.PrimaryKeyConstraint("station_id", "raster_key", "parameter"),
832
+ schema="public",
833
+ comment="The multi annual climate raster values for each station.",
834
+ )
835
+ op.create_table(
836
+ "station_ma_timeserie",
837
+ sa.Column(
838
+ "station_id",
839
+ sa.Integer(),
840
+ nullable=False,
841
+ comment="The DWD-ID of the station.",
842
+ ),
843
+ sa.Column(
844
+ "parameter",
845
+ sa.VARCHAR(length=3),
846
+ nullable=False,
847
+ comment="The parameter of the station. e.g. 'p', 't', 'et'",
848
+ ),
849
+ sa.Column(
850
+ "kind",
851
+ sa.String(),
852
+ nullable=False,
853
+ comment="The kind of the timeserie. e.g. 'raw', 'filled', 'corr'",
854
+ ),
855
+ sa.Column(
856
+ "value",
857
+ sa.Float(),
858
+ nullable=False,
859
+ comment="The multi annual value of the yearly mean value of the station to the multi annual mean value of the raster.",
860
+ ),
861
+ sa.PrimaryKeyConstraint("station_id", "parameter", "kind"),
862
+ schema="public",
863
+ comment="The multi annual mean values of the stations timeseries for the maximum available timespan.",
864
+ )
865
+
866
+
867
+ def downgrade() -> None:
868
+ # ### commands auto generated by Alembic - please adjust! ###
869
+ op.drop_table("station_ma_raster")
870
+ op.drop_table("station_ma_timeserie")
871
+ op.drop_table("settings")
872
+ op.drop_table("richter_parameters")
873
+ op.drop_table("raw_files")
874
+ op.drop_table("parameter_variables")
875
+ op.drop_table("needed_download_time")
876
+ op.drop_index(
877
+ "idx_meta_t_geometry_utm", table_name="meta_t", postgresql_using="gist"
878
+ )
879
+ op.drop_index("idx_meta_t_geometry", table_name="meta_t", postgresql_using="gist")
880
+ op.drop_table("meta_t")
881
+ op.drop_index(
882
+ "idx_meta_p_d_geometry_utm", table_name="meta_p_d", postgresql_using="gist"
883
+ )
884
+ op.drop_index(
885
+ "idx_meta_p_d_geometry", table_name="meta_p_d", postgresql_using="gist"
886
+ )
887
+ op.drop_table("meta_p_d")
888
+ op.drop_index(
889
+ "idx_meta_p_geometry_utm", table_name="meta_p", postgresql_using="gist"
890
+ )
891
+ op.drop_index("idx_meta_p_geometry", table_name="meta_p", postgresql_using="gist")
892
+ op.drop_table("meta_p")
893
+ op.drop_index(
894
+ "idx_meta_et_geometry_utm", table_name="meta_et", postgresql_using="gist"
895
+ )
896
+ op.drop_index("idx_meta_et_geometry", table_name="meta_et", postgresql_using="gist")
897
+ op.drop_table("meta_et")
898
+ op.drop_table("droped_stations")