weatherdb 1.2.2__py3-none-any.whl → 1.2.4__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.
@@ -38,11 +38,13 @@ services:
38
38
  target: /src/tests
39
39
 
40
40
  db:
41
- image: postgis/postgis:16-3.4
41
+ image: timescale/timescaledb-ha:pg17 # about 1 minute faster for tests
42
+ # image: postgis/postgis:17-3.4
42
43
  environment:
43
44
  POSTGRES_DB: weatherdb
44
45
  POSTGRES_USER: postgres
45
46
  POSTGRES_PASSWORD_FILE: /run/secrets/db_password
47
+ shm_size: '2g'
46
48
  ports:
47
49
  - 5454:5432
48
50
  volumes:
weatherdb/_version.py CHANGED
@@ -1 +1 @@
1
- __version__ = "1.2.2"
1
+ __version__ = "1.2.4"
@@ -357,7 +357,7 @@ class ConfigParser(configparser.ConfigParser):
357
357
  user_config_file = "ask"
358
358
 
359
359
  # ask for the user config file
360
- if user_config_file == "ask":
360
+ if user_config_file.lower().strip()[0] == "a":
361
361
  try:
362
362
  from tkinter import Tk
363
363
  from tkinter import filedialog
@@ -344,8 +344,13 @@ class GroupStation(object):
344
344
  def get_name(self):
345
345
  return self.station_parts[0].get_name()
346
346
 
347
- def create_roger_ts(self, dir, period=(None, None),
348
- kind="best", r_r0=1, add_t_min=False, add_t_max=False,
347
+ def create_roger_ts(self,
348
+ dir,
349
+ period=(None, None),
350
+ kind="best",
351
+ r_r0=1,
352
+ add_t_min=False,
353
+ add_t_max=False,
349
354
  do_toolbox_format=False,
350
355
  **kwargs):
351
356
  """Create the timeserie files for roger as csv.
@@ -394,10 +399,15 @@ class GroupStation(object):
394
399
  """
395
400
  if do_toolbox_format:
396
401
  return self.create_ts(
397
- dir=dir, period=period, kinds=kind,
398
- agg_to="10 min", r_r0=r_r0, split_date=True,
402
+ dir=dir,
403
+ period=period,
404
+ kinds=kind,
405
+ agg_to="10 min",
406
+ r_r0=r_r0,
407
+ split_date=True,
399
408
  nas_allowed=False,
400
- add_t_min=add_t_min, add_t_max=add_t_max,
409
+ add_t_min=add_t_min,
410
+ add_t_max=add_t_max,
401
411
  file_names={"P":"PREC.txt", "T":"TA.txt", "ET":"PET.txt"},
402
412
  col_names={"P":"PREC", "ET":"PET",
403
413
  "T":"TA", "T_min":"TA_min", "T_max":"TA_max",
@@ -408,18 +418,34 @@ class GroupStation(object):
408
418
  **kwargs)
409
419
  else:
410
420
  return self.create_ts(
411
- dir=dir, period=period, kinds=kind,
412
- agg_to="10 min", r_r0=r_r0, split_date=True,
421
+ dir=dir,
422
+ period=period,
423
+ kinds=kind,
424
+ agg_to="10 min",
425
+ r_r0=r_r0,
426
+ split_date=True,
413
427
  nas_allowed=False,
414
- add_t_min=add_t_min, add_t_max=add_t_max,
428
+ file_names={"P":"N_{id:0>5}.txt"},
429
+ col_names={"P":"N"},
430
+ add_t_min=add_t_min,
431
+ add_t_max=add_t_max,
415
432
  **kwargs)
416
433
 
417
- def create_ts(self, dir, period=(None, None),
418
- kinds="best", paras="all",
419
- agg_to="10 min", r_r0=None, split_date=False,
420
- nas_allowed=True, add_na_share=False,
421
- add_t_min=False, add_t_max=False,
422
- add_meta=True, file_names={}, col_names={},
434
+ def create_ts(self,
435
+ dir,
436
+ period=(None, None),
437
+ kinds="best",
438
+ paras="all",
439
+ agg_to="10 min",
440
+ r_r0=None,
441
+ split_date=False,
442
+ nas_allowed=True,
443
+ add_na_share=False,
444
+ add_t_min=False,
445
+ add_t_max=False,
446
+ add_meta=True,
447
+ file_names={},
448
+ col_names={},
423
449
  keep_date_parts=False,
424
450
  **kwargs):
425
451
  """Create the timeserie files as csv.
@@ -485,6 +511,7 @@ class GroupStation(object):
485
511
  file_names : dict, optional
486
512
  A dictionary with the file names for the different parameters.
487
513
  e.g.{"P":"PREC.txt", "T":"TA.txt", "ET":"ET.txt"}
514
+ Additionally, the station ID ("{id}" as int) and period ({period} as TimestampPeriod) are available as placeholders.
488
515
  If an empty dictionary is given, then the standard names are used.
489
516
  The default is {}.
490
517
  col_names : dict, optional
@@ -536,19 +563,22 @@ class GroupStation(object):
536
563
  del kwargs["_skip_period_check"]
537
564
 
538
565
  # prepare loop
539
- name_suffix = "_{stid:0>5}.txt".format(stid=self.id)
566
+ name_suffix = "_{id:0>5}.txt".format(id=self.id)
540
567
  x, y = self.get_geom().coords.xy
541
- name = self.get_name() + " (ID: {stid})".format(stid=self.id)
568
+ name = self.get_name() + " (ID: {id})".format(id=self.id)
542
569
  do_zip = isinstance(dir, zipfile.ZipFile)
543
570
 
544
571
  for para in paras:
545
572
  # get the timeserie
546
573
  df = self.get_df(
547
- period=period, kinds=kinds,
548
- paras=[para], agg_to=agg_to,
574
+ period=period,
575
+ kinds=kinds,
576
+ paras=[para],
577
+ agg_to=agg_to,
549
578
  nas_allowed=nas_allowed,
550
579
  add_na_share=add_na_share,
551
- add_t_min=add_t_min, add_t_max=add_t_max,
580
+ add_t_min=add_t_min,
581
+ add_t_max=add_t_max,
552
582
  _skip_period_check=True,
553
583
  **kwargs)
554
584
 
@@ -573,8 +603,7 @@ class GroupStation(object):
573
603
  # check for NAs
574
604
  filled_cols = [col for col in df.columns if "filled_by" in col]
575
605
  if not nas_allowed and df.drop(filled_cols, axis=1).isna().sum().sum() > 0:
576
- warnings.warn("There were NAs in the timeserie for Station {stid}.".format(
577
- stid=self.id))
606
+ warnings.warn(f"There were NAs in the timeseries for Station {self.id}.")
578
607
 
579
608
  # special operations for et
580
609
  if para == "et" and r_r0 is not None:
@@ -609,9 +638,11 @@ class GroupStation(object):
609
638
 
610
639
  # get file name
611
640
  if para.upper() in file_names:
612
- file_name = file_names[para.upper()]
641
+ file_name = file_names[para.upper()]\
642
+ .format(id=self.id, period=period)
613
643
  elif para in file_names:
614
- file_name = file_names[para]
644
+ file_name = file_names[para]\
645
+ .format(id=self.id, period=period)
615
646
  else:
616
647
  file_name = para.upper() + name_suffix
617
648
 
@@ -595,7 +595,7 @@ class StationBase:
595
595
  DROP TABLE IF EXISTS timeseries."{self.id}_{self._para}";
596
596
  DELETE FROM meta_{self._para} WHERE station_id={self.id};
597
597
  DELETE FROM station_ma_raster WHERE station_id={self.id} and parameter='{self._para}';
598
- DELETE FROM station_ma_timeseries WHERE station_id={self.id} and parameter='{self._para}';
598
+ DELETE FROM station_ma_timeserie WHERE station_id={self.id} and parameter='{self._para}';
599
599
  INSERT INTO dropped_stations(station_id, parameter, why, timestamp)
600
600
  VALUES ('{self.id}', '{self._para}', '{why}', NOW())
601
601
  ON CONFLICT (station_id, parameter)
@@ -240,8 +240,8 @@ class StationP(StationPBase):
240
240
  @db_engine.deco_create_privilege
241
241
  def _create_timeseries_table(self):
242
242
  """Create the timeseries table in the DB if it is not yet existing."""
243
- sql_add_table = '''
244
- CREATE TABLE IF NOT EXISTS timeseries."{stid}_{para}" (
243
+ sql_add_table = f'''
244
+ CREATE TABLE IF NOT EXISTS timeseries."{self.id}_{self._para}" (
245
245
  timestamp timestamp PRIMARY KEY,
246
246
  raw int4,
247
247
  qn smallint,
@@ -250,7 +250,7 @@ class StationP(StationPBase):
250
250
  filled_by int2,
251
251
  corr int4
252
252
  );
253
- '''.format(stid=self.id, para=self._para)
253
+ '''
254
254
  with db_engine.connect() as con:
255
255
  con.execute(sqltxt(sql_add_table))
256
256
  con.commit()
@@ -293,10 +293,17 @@ class GroupStations(object):
293
293
 
294
294
  return stations
295
295
 
296
- def create_ts(self, dir, period=(None, None), kinds="best",
297
- stids="all", agg_to="10 min", r_r0=None, split_date=False,
298
- nas_allowed=True, add_na_share=False,
299
- add_t_min=False, add_t_max=False,
296
+ def create_ts(self, dir,
297
+ period=(None, None),
298
+ kinds="best",
299
+ stids="all",
300
+ agg_to="10 min",
301
+ r_r0=None,
302
+ split_date=False,
303
+ nas_allowed=True,
304
+ add_na_share=False,
305
+ add_t_min=False,
306
+ add_t_max=False,
300
307
  **kwargs):
301
308
  """Download and create the weather tables as csv files.
302
309
 
@@ -393,7 +400,6 @@ class GroupStations(object):
393
400
  add_na_share=add_na_share,
394
401
  add_t_min=add_t_min,
395
402
  add_t_max=add_t_max,
396
- _skip_period_check=True,
397
403
  **kwargs)
398
404
  pbar.variables["last_station"] = stat.id
399
405
  pbar.update(pbar.value + 1)
@@ -498,10 +504,16 @@ class GroupStations(object):
498
504
  """
499
505
  if do_toolbox_format:
500
506
  return self.create_ts(
501
- dir=dir, period=period, kinds=kind,
502
- agg_to="10 min", r_r0=r_r0, stids=stids,
503
- split_date=True, nas_allowed=False,
504
- add_t_min=add_t_min, add_t_max=add_t_max,
507
+ dir=dir,
508
+ period=period,
509
+ kinds=kind,
510
+ agg_to="10 min",
511
+ r_r0=r_r0,
512
+ stids=stids,
513
+ split_date=True,
514
+ nas_allowed=False,
515
+ add_t_min=add_t_min,
516
+ add_t_max=add_t_max,
505
517
  file_names={"P":"PREC.txt", "T":"TA.txt", "ET":"PET.txt"},
506
518
  col_names={"P":"PREC", "ET":"PET",
507
519
  "T":"TA", "T_min":"TA_min", "T_max":"TA_max",
@@ -512,8 +524,16 @@ class GroupStations(object):
512
524
  **kwargs)
513
525
  else:
514
526
  return self.create_ts(
515
- dir=dir, period=period, kinds=kind,
516
- agg_to="10 min", r_r0=r_r0, stids=stids,
517
- split_date=True, nas_allowed=False,
518
- add_t_min=add_t_min, add_t_max=add_t_max,
527
+ dir=dir,
528
+ period=period,
529
+ kinds=kind,
530
+ agg_to="10 min",
531
+ r_r0=r_r0,
532
+ stids=stids,
533
+ split_date=True,
534
+ nas_allowed=False,
535
+ file_names={"P": "N_{id:0>5}.txt"},
536
+ col_names={"P":"N"},
537
+ add_t_min=add_t_min,
538
+ add_t_max=add_t_max,
519
539
  **kwargs)
@@ -1,9 +1,9 @@
1
- Metadata-Version: 2.1
1
+ Metadata-Version: 2.4
2
2
  Name: weatherdb
3
- Version: 1.2.2
3
+ Version: 1.2.4
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
- License: GNU GENERAL PUBLIC LICENSE
6
+ License: GNU GENERAL PUBLIC LICENSE
7
7
  Version 3, 29 June 2007
8
8
 
9
9
  Copyright (C) 2007 Free Software Foundation, Inc. <https://fsf.org/>
@@ -706,14 +706,15 @@ Requires-Dist: GeoAlchemy2
706
706
  Requires-Dist: alembic
707
707
  Requires-Dist: requests
708
708
  Requires-Dist: keyring
709
+ Requires-Dist: keyrings.alt; sys_platform == "linux"
709
710
  Requires-Dist: rasterstats
710
711
  Requires-Dist: click
711
712
  Requires-Dist: setuptools>=61.0
712
- Requires-Dist: setuptools-scm
713
- Requires-Dist: keyrings.alt; sys_platform == "linux"
713
+ Requires-Dist: setuptools_scm
714
714
  Provides-Extra: optionals
715
715
  Requires-Dist: coloredlogs; extra == "optionals"
716
716
  Requires-Dist: colorama; extra == "optionals"
717
+ Dynamic: license-file
717
718
 
718
719
  # WeatherDB - module
719
720
 
@@ -1,5 +1,5 @@
1
1
  docker/Dockerfile,sha256=AmSjZsQHA3-XANZz8RiH0B5skIlF7MXCNiy8yIzZXr4,1051
2
- docker/docker-compose.yaml,sha256=ezHqCUib83b5cbfbSy0fsrg0xl2iufp6diItsctJbRM,1719
2
+ docker/docker-compose.yaml,sha256=tnQoCLZk1VryR4i1x7TfV8B4nODGoD1Qaf6CWoj6hOs,1815
3
3
  docker/docker-compose_test.yaml,sha256=LTCehPG6Oid-ri7kcPBMzXzeJBqYC-zXTs_i6XOkSyQ,931
4
4
  docker/start-docker-test.sh,sha256=8ue4LfoUrZU8inEZhNjsSDqucoN73Kn1cC3--lUPqTo,222
5
5
  docs/requirements.txt,sha256=gVqMWeiE0PAEz41NGrLwgzx1WUGuEIE7sfPLkFV4vU4,141
@@ -44,7 +44,7 @@ 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=UmNr0TvEXPPzP6WnlT4bB4F4pSBdsEE64uchGSzkPTI,21
47
+ weatherdb/_version.py,sha256=qjo-Usbvp802f_1XeGyTsWsDwlFERHYfz7wsKPXKb4Q,21
48
48
  weatherdb/broker.py,sha256=qJaKVwo1zcTLKmP-sF_DMod6_7jVsdHEoiKEMvsPx9A,24842
49
49
  weatherdb/cli.py,sha256=b5p9SRP5aqQ3w89MLErAjFj37aZMy9OsF23nCDC8NJY,11358
50
50
  weatherdb/alembic/README.md,sha256=6hq24TPr8z3nqJCaqrmj6__kLikVG66kLGqfC_aFPWQ,440
@@ -56,7 +56,7 @@ weatherdb/alembic/versions/V1.0.0_initial_database_creation.py,sha256=Ztj21xNdJc
56
56
  weatherdb/alembic/versions/V1.0.2_more_charachters_for_settings+term_station_ma_raster.py,sha256=jrnBpgUxjaBt1oUFJb0PeTZ4L5hEDh9K8ncF33cLdQE,3738
57
57
  weatherdb/alembic/versions/V1.0.5_fix-ma-raster-values.py,sha256=EvJ_JLLJKUN5YXwWZdS1FHK2oHjhIlayvjtJuoK3eCI,6957
58
58
  weatherdb/alembic/versions/V1.0.6_update-views.py,sha256=ZA7cK5yeAqivFG2V8O7mvyKSkGRlphVOs0qKpBYgYKE,420
59
- weatherdb/config/ConfigParser.py,sha256=-ubnKwzUR9ryrPI_6aYULmyyaNzz4-TylPgHs3yoq4I,28403
59
+ weatherdb/config/ConfigParser.py,sha256=7qKAo_8ykLo_1e5zOTVcevHDC2pOGkAeeMadIUVbAYM,28420
60
60
  weatherdb/config/__init__.py,sha256=JBNlYPT43JnO8XMI8HTtg2hyA7C_JnMdtWmJ2vAtNZ8,85
61
61
  weatherdb/config/config_default.ini,sha256=5DQzOqOJ9EVRAu9IA_EO4c8aqnuUvTmocwidOhLLXbY,7884
62
62
  weatherdb/db/__init__.py,sha256=g6F66XR6UPz41kPtSRc1qvDoOEZ5OawYxYtYXCgZ06s,76
@@ -65,15 +65,15 @@ weatherdb/db/models.py,sha256=6Oor07T1sAD6qEtoxwEcpmY1SkLVVONChXIIcTjbUk4,15242
65
65
  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
- weatherdb/station/GroupStation.py,sha256=mLDZIQ2fAxSQs_zQl1cFJgOHizVlTyUG1uoEzm6uYqo,30292
69
- weatherdb/station/StationBases.py,sha256=1XylC_k2ZCSJf3-xs4SBE-JSfwrlZWzn1N154S0KzgU,130330
68
+ weatherdb/station/GroupStation.py,sha256=ikVsAMXlhJY8I991mJ3IBCLPW9AH5Hd7QLnDUDawM3U,31066
69
+ weatherdb/station/StationBases.py,sha256=0OwEl85220DI6MIffjf4KpS4UA5zCR4yE2DNzydOlKE,130329
70
70
  weatherdb/station/StationET.py,sha256=hM6K8fCLC6mOLaE4cN92LHOyPGP01ifO6l2qO77I_bA,3621
71
- weatherdb/station/StationP.py,sha256=ENmWqEFwKR1WFsWmZ8-webEGTmrxODan8QO0gwIDDIU,32719
71
+ weatherdb/station/StationP.py,sha256=w_0l5cw8zTACIbmVFV4cdPwxuyP2Cnv97dnNrMElBDE,32691
72
72
  weatherdb/station/StationPD.py,sha256=Bcg_uQTgIQPffsMGhNEwKAXhYs1Ii4VeB75afdFG-Kk,3367
73
73
  weatherdb/station/StationT.py,sha256=-T1GKfUsvulm5c_-JufJ34H048fGlG21UF0_2z1dd9A,6012
74
74
  weatherdb/station/__init__.py,sha256=v1sPfmhhLRMOr5DJ2c5BLIFY7GWkP5iMLA5vtZm-osg,591
75
75
  weatherdb/station/constants.py,sha256=vtdhgcK8A2cJaknT6qI8w5tAh_Hb5i2SvxxtHZOPyVc,511
76
- weatherdb/stations/GroupStations.py,sha256=5Xc5lW_crJdzMwldpbyalIFYbyQm2BPiGbl-VrXZZh8,21569
76
+ weatherdb/stations/GroupStations.py,sha256=Q-0sZ4skZgE-2hwE2QKmwDz_8_U4xWb2hYsKv5RvR1E,21927
77
77
  weatherdb/stations/StationsBase.py,sha256=M7VyWJgUmIygJ2rByQy0Zz6RKsaDVT8-iaXzhPTa_b4,42991
78
78
  weatherdb/stations/StationsBaseTET.py,sha256=CuE5gXAF4eS4bHorI-sUqksm0jdj9SzAiOHtc4vv7aA,1032
79
79
  weatherdb/stations/StationsET.py,sha256=OjyEaEK0nPJ9txRfUbHfW9bEEx5HAISWmnk5F4GBs7I,433
@@ -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.2.dist-info/LICENSE,sha256=ixuiBLtpoK3iv89l7ylKkg9rs2GzF9ukPH7ynZYzK5s,35148
91
- weatherdb-1.2.2.dist-info/METADATA,sha256=2KUyRibsyu3pvzfYPYSHmCXvM4BPI6T8xVRH4VnP744,44266
92
- weatherdb-1.2.2.dist-info/WHEEL,sha256=bFJAMchF8aTQGUgMZzHJyDDMPTO3ToJ7x23SLJa1SVo,92
93
- weatherdb-1.2.2.dist-info/entry_points.txt,sha256=kJemTd9Cm_QWPZt03KUWhpn1aB0-l_5ce6Ms3EoS_NM,55
94
- weatherdb-1.2.2.dist-info/top_level.txt,sha256=kLlRbXLn0GHvMWmciWRyvm0-FYEy56F6d0fGwfle9-g,28
95
- weatherdb-1.2.2.dist-info/RECORD,,
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,,
@@ -1,5 +1,5 @@
1
1
  Wheel-Version: 1.0
2
- Generator: bdist_wheel (0.45.0)
2
+ Generator: setuptools (80.9.0)
3
3
  Root-Is-Purelib: true
4
4
  Tag: py3-none-any
5
5