pthelma 0.13.0__tar.gz → 0.99.3.dev0__tar.gz

Sign up to get free protection for your applications and to get access to all the features.
Files changed (117) hide show
  1. pthelma-0.99.3.dev0/.github/workflows/build_wheels.yml +57 -0
  2. pthelma-0.99.3.dev0/.github/workflows/run-tests-automatically.yml +64 -0
  3. pthelma-0.99.3.dev0/.gitignore +40 -0
  4. pthelma-0.99.3.dev0/.readthedocs.yaml +14 -0
  5. pthelma-0.99.3.dev0/CHANGELOG.rst +11 -0
  6. pthelma-0.99.3.dev0/LICENSE.rst +34 -0
  7. pthelma-0.99.3.dev0/MANIFEST.in +9 -0
  8. pthelma-0.99.3.dev0/PKG-INFO +54 -0
  9. pthelma-0.99.3.dev0/README.rst +22 -0
  10. pthelma-0.99.3.dev0/docs/Makefile +20 -0
  11. pthelma-0.99.3.dev0/docs/changelog.rst +1 -0
  12. pthelma-0.99.3.dev0/docs/conf.py +46 -0
  13. pthelma-0.99.3.dev0/docs/enhydris_api_client.rst +95 -0
  14. pthelma-0.99.3.dev0/docs/enhydris_cache/api.rst +22 -0
  15. pthelma-0.99.3.dev0/docs/enhydris_cache/usage.rst +143 -0
  16. pthelma-0.99.3.dev0/docs/evaporation/api.rst +109 -0
  17. pthelma-0.99.3.dev0/docs/evaporation/usage.rst +237 -0
  18. pthelma-0.99.3.dev0/docs/haggregate/api.rst +159 -0
  19. pthelma-0.99.3.dev0/docs/haggregate/usage.rst +186 -0
  20. pthelma-0.99.3.dev0/docs/hspatial/api.rst +208 -0
  21. pthelma-0.99.3.dev0/docs/hspatial/testutils.rst +28 -0
  22. pthelma-0.99.3.dev0/docs/hspatial/usage.rst +164 -0
  23. pthelma-0.99.3.dev0/docs/htimeseries.rst +332 -0
  24. pthelma-0.99.3.dev0/docs/index.rst +46 -0
  25. pthelma-0.99.3.dev0/docs/license.rst +1 -0
  26. pthelma-0.99.3.dev0/docs/requirements.txt +1 -0
  27. pthelma-0.99.3.dev0/pyproject.toml +69 -0
  28. {pthelma-0.13.0 → pthelma-0.99.3.dev0}/setup.cfg +0 -1
  29. pthelma-0.99.3.dev0/setup.py +13 -0
  30. pthelma-0.99.3.dev0/src/enhydris_api_client/__init__.py +252 -0
  31. pthelma-0.99.3.dev0/src/enhydris_cache/__init__.py +5 -0
  32. pthelma-0.99.3.dev0/src/enhydris_cache/cli.py +150 -0
  33. pthelma-0.99.3.dev0/src/enhydris_cache/enhydris_cache.py +69 -0
  34. pthelma-0.99.3.dev0/src/evaporation/__init__.py +4 -0
  35. pthelma-0.99.3.dev0/src/evaporation/cli.py +729 -0
  36. pthelma-0.99.3.dev0/src/evaporation/evaporation.py +437 -0
  37. pthelma-0.99.3.dev0/src/haggregate/__init__.py +5 -0
  38. pthelma-0.99.3.dev0/src/haggregate/cli.py +91 -0
  39. pthelma-0.99.3.dev0/src/haggregate/haggregate.py +155 -0
  40. pthelma-0.99.3.dev0/src/haggregate/regularize.c +15105 -0
  41. pthelma-0.99.3.dev0/src/haggregate/regularize.pyx +193 -0
  42. pthelma-0.99.3.dev0/src/hspatial/__init__.py +4 -0
  43. pthelma-0.99.3.dev0/src/hspatial/cli.py +310 -0
  44. pthelma-0.99.3.dev0/src/hspatial/hspatial.py +425 -0
  45. pthelma-0.99.3.dev0/src/hspatial/test.py +27 -0
  46. pthelma-0.99.3.dev0/src/htimeseries/__init__.py +2 -0
  47. pthelma-0.99.3.dev0/src/htimeseries/htimeseries.py +574 -0
  48. pthelma-0.99.3.dev0/src/htimeseries/timezone_utils.py +44 -0
  49. pthelma-0.99.3.dev0/src/pthelma/_version.py +16 -0
  50. pthelma-0.99.3.dev0/src/pthelma.egg-info/PKG-INFO +54 -0
  51. pthelma-0.99.3.dev0/src/pthelma.egg-info/SOURCES.txt +79 -0
  52. pthelma-0.99.3.dev0/src/pthelma.egg-info/entry_points.txt +5 -0
  53. pthelma-0.99.3.dev0/src/pthelma.egg-info/requires.txt +10 -0
  54. pthelma-0.99.3.dev0/src/pthelma.egg-info/top_level.txt +7 -0
  55. pthelma-0.99.3.dev0/tests/enhydris_api_client/__init__.py +65 -0
  56. pthelma-0.99.3.dev0/tests/enhydris_api_client/test_e2e.py +221 -0
  57. pthelma-0.99.3.dev0/tests/enhydris_api_client/test_misc.py +149 -0
  58. pthelma-0.99.3.dev0/tests/enhydris_api_client/test_station.py +81 -0
  59. pthelma-0.99.3.dev0/tests/enhydris_api_client/test_timeseries.py +98 -0
  60. pthelma-0.99.3.dev0/tests/enhydris_api_client/test_timeseriesgroup.py +84 -0
  61. pthelma-0.99.3.dev0/tests/enhydris_api_client/test_tsdata.py +174 -0
  62. pthelma-0.99.3.dev0/tests/enhydris_cache/__init__.py +0 -0
  63. pthelma-0.99.3.dev0/tests/enhydris_cache/test_cli.py +464 -0
  64. pthelma-0.99.3.dev0/tests/enhydris_cache/test_enhydris_cache.py +147 -0
  65. pthelma-0.99.3.dev0/tests/evaporation/__init__.py +0 -0
  66. pthelma-0.99.3.dev0/tests/evaporation/test_cli.py +1059 -0
  67. pthelma-0.99.3.dev0/tests/evaporation/test_evaporation.py +283 -0
  68. pthelma-0.99.3.dev0/tests/haggregate/__init__.py +0 -0
  69. pthelma-0.99.3.dev0/tests/haggregate/test_cli.py +220 -0
  70. pthelma-0.99.3.dev0/tests/haggregate/test_haggregate.py +359 -0
  71. pthelma-0.99.3.dev0/tests/haggregate/test_regularize.py +284 -0
  72. pthelma-0.99.3.dev0/tests/hspatial/__init__.py +0 -0
  73. pthelma-0.99.3.dev0/tests/hspatial/test_cli.py +619 -0
  74. pthelma-0.99.3.dev0/tests/hspatial/test_hspatial.py +780 -0
  75. pthelma-0.99.3.dev0/tests/htimeseries/__init__.py +0 -0
  76. pthelma-0.99.3.dev0/tests/htimeseries/test_htimeseries.py +903 -0
  77. pthelma-0.99.3.dev0/tests/htimeseries/test_timezone_utils.py +30 -0
  78. pthelma-0.13.0/CHANGES.txt +0 -191
  79. pthelma-0.13.0/MANIFEST.in +0 -2
  80. pthelma-0.13.0/PKG-INFO +0 -10
  81. pthelma-0.13.0/README.rst +0 -14
  82. pthelma-0.13.0/bin/aggregate +0 -7
  83. pthelma-0.13.0/bin/enhydris_cache +0 -7
  84. pthelma-0.13.0/bin/loggertodb +0 -24
  85. pthelma-0.13.0/bin/spatialize +0 -7
  86. pthelma-0.13.0/bin/vaporize +0 -7
  87. pthelma-0.13.0/pthelma/aggregate.py +0 -135
  88. pthelma-0.13.0/pthelma/cliapp.py +0 -144
  89. pthelma-0.13.0/pthelma/cplot.py +0 -144
  90. pthelma-0.13.0/pthelma/curves.py +0 -410
  91. pthelma-0.13.0/pthelma/datetimelist.py +0 -164
  92. pthelma-0.13.0/pthelma/enhydris_api.py +0 -105
  93. pthelma-0.13.0/pthelma/enhydris_cache.py +0 -110
  94. pthelma-0.13.0/pthelma/evaporation.py +0 -805
  95. pthelma-0.13.0/pthelma/meteocalcs.py +0 -80
  96. pthelma-0.13.0/pthelma/meteologger.py +0 -714
  97. pthelma-0.13.0/pthelma/spatial.py +0 -406
  98. pthelma-0.13.0/pthelma/swb.py +0 -162
  99. pthelma-0.13.0/pthelma/timeseries.py +0 -1294
  100. pthelma-0.13.0/pthelma/tsprocess.py +0 -192
  101. pthelma-0.13.0/pthelma.egg-info/PKG-INFO +0 -10
  102. pthelma-0.13.0/pthelma.egg-info/SOURCES.txt +0 -39
  103. pthelma-0.13.0/pthelma.egg-info/requires.txt +0 -8
  104. pthelma-0.13.0/pthelma.egg-info/top_level.txt +0 -2
  105. pthelma-0.13.0/setup.py +0 -202
  106. pthelma-0.13.0/tests/test_aggregate.py +0 -179
  107. pthelma-0.13.0/tests/test_enhydris_api.py +0 -198
  108. pthelma-0.13.0/tests/test_enhydris_cache.py +0 -300
  109. pthelma-0.13.0/tests/test_evaporation.py +0 -1158
  110. pthelma-0.13.0/tests/test_meteologger.py +0 -715
  111. pthelma-0.13.0/tests/test_spatial.py +0 -818
  112. pthelma-0.13.0/tests/test_swb.py +0 -250
  113. pthelma-0.13.0/tests/test_timeseries.py +0 -1482
  114. /pthelma-0.13.0/LICENSE.txt → /pthelma-0.99.3.dev0/GPL-3 +0 -0
  115. {pthelma-0.13.0 → pthelma-0.99.3.dev0/src}/pthelma/__init__.py +0 -0
  116. {pthelma-0.13.0 → pthelma-0.99.3.dev0/src}/pthelma.egg-info/dependency_links.txt +0 -0
  117. {pthelma-0.13.0 → pthelma-0.99.3.dev0}/tests/__init__.py +0 -0
@@ -0,0 +1,57 @@
1
+ name: Build wheels
2
+
3
+ on:
4
+ push:
5
+ branches:
6
+ - master
7
+ pull_request:
8
+ branches:
9
+ - master
10
+ release:
11
+ types:
12
+ - published
13
+
14
+ jobs:
15
+ build_wheels:
16
+ name: Build wheels on ${{ matrix.os }}
17
+ runs-on: ${{ matrix.os }}
18
+ strategy:
19
+ matrix:
20
+ os:
21
+ - ubuntu-latest
22
+ - windows-latest
23
+ steps:
24
+ - uses: actions/checkout@v4
25
+ - name: Build wheels
26
+ uses: pypa/cibuildwheel@v2.22.0
27
+ - uses: actions/upload-artifact@v4
28
+ with:
29
+ name: cibw-wheels-${{ matrix.os }}-${{ strategy.job-index }}
30
+ path: ./wheelhouse/*.whl
31
+
32
+ build_sdist:
33
+ name: Build source distribution
34
+ runs-on: ubuntu-latest
35
+ steps:
36
+ - uses: actions/checkout@v4
37
+ - name: Build sdist
38
+ run: pipx run build --sdist
39
+ - uses: actions/upload-artifact@v4
40
+ with:
41
+ name: cibw-sdist
42
+ path: dist/*.tar.gz
43
+
44
+ upload_pypi:
45
+ needs: [build_wheels, build_sdist]
46
+ runs-on: ubuntu-latest
47
+ environment: pypi
48
+ if: github.event_name == 'release' && github.event.action == 'published'
49
+ steps:
50
+ - uses: actions/download-artifact@v4
51
+ with:
52
+ pattern: cibw-*
53
+ path: dist
54
+ merge-multiple: true
55
+ - uses: pypa/gh-action-pypi-publish@release/v1
56
+ with:
57
+ password: ${{ secrets.PYPI_API_TOKEN }}
@@ -0,0 +1,64 @@
1
+ name: Build
2
+
3
+ on:
4
+ push:
5
+ branches:
6
+ - master
7
+ pull_request:
8
+ branches:
9
+ - master
10
+
11
+ jobs:
12
+ build:
13
+
14
+ runs-on: ubuntu-22.04
15
+ strategy:
16
+ matrix:
17
+ include:
18
+ - python-version: "3.10"
19
+ include-codecov: false
20
+ - python-version: "3.11"
21
+ include-codecov: false
22
+ - python-version: "3.12"
23
+ include-codecov: true
24
+
25
+ steps:
26
+ - name: Set up Python ${{ matrix.python-version }}
27
+ uses: actions/setup-python@v4
28
+ with:
29
+ python-version: ${{ matrix.python-version }}
30
+
31
+ - name: Create and activate venv
32
+ run: |
33
+ python -m venv ~/.venv
34
+ source ~/.venv/bin/activate
35
+ pip install -U pip 'setuptools>=61'
36
+
37
+ - uses: actions/checkout@v3
38
+
39
+ - name: Install Dependencies
40
+ run: |
41
+ sudo apt-get install -y gdal-bin libgdal-dev postgresql-14-postgis-3
42
+ source ~/.venv/bin/activate
43
+ # numpy<2 is needed for gdal to contain support for gdal array
44
+ pip install 'numpy<2'
45
+ CPLUS_INCLUDE_PATH=/usr/include/gdal C_INCLUDE_PATH=/usr/include/gdal pip install --no-build-isolation 'gdal==3.4.1'
46
+ pip install coverage isort flake8 'black<25' twine setuptools build
47
+ pip install -e .
48
+
49
+ - name: Run Tests
50
+ run: |
51
+ source ~/.venv/bin/activate
52
+ black --check .
53
+ flake8 --max-line-length=88 .
54
+ isort --check-only --diff --profile=black *.py .
55
+ python -m build
56
+ twine check dist/*
57
+ coverage run --include="./*" --omit="docs/","*/tests/*","_version.py","*.pyx" -m unittest -v
58
+ coverage json
59
+
60
+ - name: Upload coverage to Codecov
61
+ if: matrix.include-codecov == true
62
+ uses: codecov/codecov-action@v4
63
+ with:
64
+ token: ${{ secrets.CODECOV_TOKEN }}
@@ -0,0 +1,40 @@
1
+ *.py[cod]
2
+
3
+ # C extensions
4
+ *.so
5
+
6
+ # Packages
7
+ *.egg
8
+ *.egg-info
9
+ dist
10
+ build
11
+ eggs
12
+ parts
13
+ var
14
+ sdist
15
+ develop-eggs
16
+ .installed.cfg
17
+ lib
18
+ lib64
19
+
20
+ # Installer logs
21
+ pip-log.txt
22
+
23
+ # Unit test / coverage reports
24
+ .coverage
25
+ .tox
26
+ nosetests.xml
27
+
28
+ # Translations
29
+ *.mo
30
+
31
+ # Mr Developer
32
+ .mr.developer.cfg
33
+ .project
34
+ .pydevproject
35
+
36
+ man/loggertodb.1
37
+ docs/_build
38
+
39
+ # setuptools-scm
40
+ _version.py
@@ -0,0 +1,14 @@
1
+ version: 2
2
+
3
+ build:
4
+ os: ubuntu-22.04
5
+ tools:
6
+ python: "3.12"
7
+
8
+ sphinx:
9
+ configuration: docs/conf.py
10
+
11
+ python:
12
+ install:
13
+ - requirements: docs/requirements.txt
14
+
@@ -0,0 +1,11 @@
1
+ =========
2
+ Changelog
3
+ =========
4
+
5
+ 1.0.0 (2024-11)
6
+ ===============
7
+
8
+ This is a different pthelma from the old 0.14, which had been abandoned
9
+ in favor of a number of separate packages. However, maintaining all
10
+ these separate packages was too cumbersome and now we re-combine them
11
+ here.
@@ -0,0 +1,34 @@
1
+ ===================
2
+ License and credits
3
+ ===================
4
+
5
+ | Copyright (C) 2013-2018 TEI of Epirus
6
+ | Copyright (C) 2014-2016 Antonis Christofides
7
+ | Copyright (C) 2019 University of Ioannina
8
+ | Copyright (C) 2018-2021 National Technical University of Athens
9
+ | Copyright (C) 2018-2021 Institute of Communications and Computer Systems
10
+ | Copyright (C) 2022-2024 IRMASYS P.C.
11
+
12
+ pthelma is free software: you can redistribute it and/or modify it
13
+ under the terms of the GNU General Public License as published by the
14
+ Free Software Foundation, either version 3 of the License, or (at your
15
+ option) any later version.
16
+
17
+ This program is distributed in the hope that it will be useful, but
18
+ WITHOUT ANY WARRANTY; without even the implied warranty of
19
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
20
+ General Public License for more details.
21
+
22
+ You should have received a copy of the GNU General Public License along
23
+ with this program. If not, see <http://www.gnu.org/licenses/>.
24
+
25
+ Pthelma was funded by several organizations:
26
+
27
+ * In 2013-2018 by the `TEI of Epirus`_ as part of the IRMA_ project.
28
+ * In 2018-2021 by NTUA_ and ICCS_ as part of the OpenHi_ project.
29
+
30
+ .. _ntua: http://www.ntua.gr/
31
+ .. _tei of epirus: http://www.teiep.gr/en/
32
+ .. _irma: http://www.irrigation-management.eu/
33
+ .. _iccs: https://www.iccs.gr
34
+ .. _openhi: https://openhi.net
@@ -0,0 +1,9 @@
1
+ include CHANGELOG.rst
2
+ include LICENSE.rst
3
+ include README.rst
4
+
5
+ recursive-include tests *
6
+ recursive-exclude * __pycache__
7
+ recursive-exclude * *.py[co]
8
+
9
+ recursive-include docs *.rst conf.py Makefile make.bat *.jpg *.png *.gif
@@ -0,0 +1,54 @@
1
+ Metadata-Version: 2.1
2
+ Name: pthelma
3
+ Version: 0.99.3.dev0
4
+ Summary: Utilities for hydrological and meteorological time series processing
5
+ Author-email: Antonis Christofides <antonis@antonischristofides.com>
6
+ Maintainer-email: Antonis Christofides <antonis@antonischristofides.com>
7
+ Project-URL: Homepage, https://github.com/openmeteo/pthelma
8
+ Project-URL: Documentation, https://pthelma.readthedocs.io
9
+ Project-URL: Repository, https://github.com/openmeteo/pthelma
10
+ Project-URL: Changelog, https://github.com/openmeteo/pthelma/blob/master/CHANGELOG.rst
11
+ Keywords: time series
12
+ Classifier: Development Status :: 5 - Production/Stable
13
+ Classifier: Intended Audience :: Developers
14
+ Classifier: License :: OSI Approved :: GNU General Public License v3 (GPLv3)
15
+ Classifier: Natural Language :: English
16
+ Classifier: Programming Language :: Python :: 3.10
17
+ Classifier: Programming Language :: Python :: 3.11
18
+ Classifier: Programming Language :: Python :: 3.12
19
+ Requires-Python: >=3.10
20
+ Description-Content-Type: text/x-rst
21
+ License-File: LICENSE.rst
22
+ Requires-Dist: pandas<3,>=2.2
23
+ Requires-Dist: iso8601<3,>=2.1
24
+ Requires-Dist: textbisect<1,>=0.1
25
+ Requires-Dist: tzdata
26
+ Requires-Dist: Click<9,>=7.0
27
+ Requires-Dist: simpletail<2,>=1
28
+ Requires-Dist: affine<3,>=2.4
29
+ Requires-Dist: gdal<4,>=1.10
30
+ Requires-Dist: django<6,>=3.2
31
+ Requires-Dist: requests<3,>=1
32
+
33
+ pthelma
34
+ =======
35
+
36
+ .. image:: https://github.com/openmeteo/pthelma/actions/workflows/run-tests-automatically.yml/badge.svg
37
+ :alt: Build button
38
+ :target: https://github.com/openmeteo/pthelma/actions/workflows/run-tests-automatically.yml
39
+
40
+ .. image:: https://codecov.io/github/openmeteo/pthelma/coverage.svg?branch=master
41
+ :alt: Coverage
42
+ :target: https://codecov.io/gh/openmeteo/pthelma
43
+
44
+ .. image:: https://img.shields.io/pypi/v/pthelma.svg
45
+ :target: https://pypi.python.org/pypi/pthelma
46
+
47
+ .. image:: https://pyup.io/repos/github/openmeteo/pthelma/shield.svg
48
+ :target: https://pyup.io/repos/github/openmeteo/pthelma/
49
+ :alt: Updates
50
+
51
+ A Python library with utilities for hydrological and meteorological time
52
+ series processing.
53
+
54
+ Documentation: https://pthelma.readthedocs.io
@@ -0,0 +1,22 @@
1
+ pthelma
2
+ =======
3
+
4
+ .. image:: https://github.com/openmeteo/pthelma/actions/workflows/run-tests-automatically.yml/badge.svg
5
+ :alt: Build button
6
+ :target: https://github.com/openmeteo/pthelma/actions/workflows/run-tests-automatically.yml
7
+
8
+ .. image:: https://codecov.io/github/openmeteo/pthelma/coverage.svg?branch=master
9
+ :alt: Coverage
10
+ :target: https://codecov.io/gh/openmeteo/pthelma
11
+
12
+ .. image:: https://img.shields.io/pypi/v/pthelma.svg
13
+ :target: https://pypi.python.org/pypi/pthelma
14
+
15
+ .. image:: https://pyup.io/repos/github/openmeteo/pthelma/shield.svg
16
+ :target: https://pyup.io/repos/github/openmeteo/pthelma/
17
+ :alt: Updates
18
+
19
+ A Python library with utilities for hydrological and meteorological time
20
+ series processing.
21
+
22
+ Documentation: https://pthelma.readthedocs.io
@@ -0,0 +1,20 @@
1
+ # Minimal makefile for Sphinx documentation
2
+ #
3
+
4
+ # You can set these variables from the command line.
5
+ SPHINXOPTS =
6
+ SPHINXBUILD = python -msphinx
7
+ SPHINXPROJ = pthelma
8
+ SOURCEDIR = .
9
+ BUILDDIR = _build
10
+
11
+ # Put it first so that "make" without argument is like "make help".
12
+ help:
13
+ @$(SPHINXBUILD) -M help "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O)
14
+
15
+ .PHONY: help Makefile
16
+
17
+ # Catch-all target: route all unknown targets to Sphinx using the new
18
+ # "make mode" option. $(O) is meant as a shortcut for $(SPHINXOPTS).
19
+ %: Makefile
20
+ @$(SPHINXBUILD) -M $@ "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O)
@@ -0,0 +1 @@
1
+ .. include:: ../CHANGELOG.rst
@@ -0,0 +1,46 @@
1
+ from setuptools_scm import get_version
2
+
3
+ extensions = ["sphinx.ext.autodoc", "sphinx.ext.viewcode"]
4
+ templates_path = ["_templates"]
5
+ source_suffix = ".rst"
6
+ master_doc = "index"
7
+ project = "pthelma"
8
+ copyright = "2024, IRMASYS"
9
+ author = "Antonis Christofides"
10
+ version = get_version(root="..")
11
+ release = version
12
+ exclude_patterns = ["_build", "Thumbs.db", ".DS_Store"]
13
+ pygments_style = "sphinx"
14
+ html_theme = "alabaster"
15
+ html_static_path = ["_static"]
16
+ htmlhelp_basename = "pthelma"
17
+ latex_elements = {}
18
+ latex_documents = [
19
+ (
20
+ master_doc,
21
+ "pthelma.tex",
22
+ "pthelma Documentation",
23
+ "Antonis Christofides",
24
+ "manual",
25
+ )
26
+ ]
27
+ texinfo_documents = [
28
+ (
29
+ master_doc,
30
+ "pthelma",
31
+ "pthelma Documentation",
32
+ author,
33
+ "pthelma",
34
+ "Utilities for hydrological and meteorological time series processing",
35
+ "Miscellaneous",
36
+ )
37
+ ]
38
+
39
+
40
+ def setup(app):
41
+ app.add_object_type(
42
+ "confval",
43
+ "confval",
44
+ objname="configuration value",
45
+ indextemplate="pair: %s; configuration value",
46
+ )
@@ -0,0 +1,95 @@
1
+ ====================================================
2
+ enhydris-api-client - Python client for Enhydris API
3
+ ====================================================
4
+
5
+ Example
6
+ =======
7
+
8
+ ::
9
+
10
+ from enhydris_api_client import EnhydrisApiClient
11
+
12
+ with EnhydrisApiClient("https://openmeteo.org", "my_auth_token") as api_client:
13
+ # Get a dict with attrs of station with id=42
14
+ station = api_client.get_model(Station, 42)
15
+
16
+ # Create a new station
17
+ api_client.post_model(Station, data={"name": "my station"})
18
+
19
+
20
+ Reference
21
+ =========
22
+
23
+ ``from enhydris_api_client import EnhydrisApiClient``
24
+
25
+ .. class:: EnhydrisApiClient(base_url, token=None)
26
+
27
+ Creates and returns an api client. It can also be used as a context
28
+ manager, though this is not necessary. If not used as a context
29
+ manager, you might get warnings about unclosed sockets.
30
+
31
+ Not specifying ``token`` is deprecated. ``token`` will become
32
+ mandatory in future versions.
33
+
34
+ .. method:: get_token(self, username, password)
35
+
36
+ (Deprecated.) Gets an API token from Enhydris and thereafter uses
37
+ it in subsequent requests. The method will be removed in future
38
+ versions.
39
+
40
+ .. method:: get_station(self, id)
41
+ post_station(self, data)
42
+ put_station(self, station_id, data)
43
+ patch_station(self, station_id, data)
44
+ delete_station(self, station_id)
45
+
46
+ Methods that create, retrieve, update or delete stations. The
47
+ ``data`` argument (for those methods that receive one) is a
48
+ dictionary. :meth:`~EnhydrisApiClient.get_station` returns a
49
+ dictionary with the data for the station.
50
+ ``~EnhydrisApiClient.post_station`` returns the created station's
51
+ id.
52
+
53
+ .. method:: get_timeseries_group(self, station_id, timeseries_group_id)
54
+ post_timeseries_group(self, station_id, timeseries_group_id, data)
55
+ put_timeseries_group(self, station_id, timeseries_group_id, data)
56
+ patch_timeseries_group(self, station_id, timeseries_group_id, data)
57
+ delete_timeseries_group(self, station_id, timeseries_group_id)
58
+
59
+ Methods that create, retrieve, update or delete time series
60
+ groups. Similar to the ones for station.
61
+
62
+ .. method:: list_timeseries(self, station_id, timeseries_group_id)
63
+ get_timeseries(self, station_id, timeseries_group_id, timeseries_id)
64
+ post_timeseries(self, station_id, timeseries_group_id, data)
65
+ delete_timeseries(self, station_id, timeseries_group_id, timeseries_id)
66
+
67
+ Methods that create, retrieve or delete time series. Similar to
68
+ the ones for station. :meth:`~EnhydrisApiClient.list_timeseries`
69
+ returns a list of dictionaries.
70
+
71
+ .. method:: read_tsdata(self, station_id, timeseries_group_id, timeseries_id, start_date=None, end_date=None, timezone=None)
72
+ .post_tsdata(self, station_id, timeseries_group_id, timeseries_id, ts)
73
+ .get_ts_end_date(self, station_id, timeseries_group_id, timeseries_id, timezone=None)
74
+
75
+ Methods that retrieve or update time series data.
76
+
77
+ :meth:`~EnhydrisApiClient.read_ts_data` retrieves the time series
78
+ data into a htimeseries object that it returns. If ``start_date``
79
+ and/or ``end_date`` (aware datetime objects) are specified, only
80
+ the part of the time series between these dates is retrieved. The
81
+ timestamps are returned in the specified time zone. If
82
+ unspecified, then they are returned in the time zone specified by
83
+ the station's display_timezone_.
84
+
85
+ :meth:`~EnhydrisApiClient.post_tsdata` posts a time series to
86
+ Enhydris, appending the records to any already existing. ``ts``
87
+ is a :class:`HTimeseries` object.
88
+
89
+ :meth:`~EnhydrisApiClient.get_ts_end_date` returns a ``datetime``
90
+ object which is the last timestamp of the time series. If the time
91
+ series is empty it returns ``None``. The returned timestamp is
92
+ always naive, but it is in the specified ``timezone`` (or the
93
+ station's display_timezone_ if unspecified).
94
+
95
+ .. _display_timezone: https://enhydris.readthedocs.io/en/latest/dev/database.html#enhydris.models.Gentity.display_timezone
@@ -0,0 +1,22 @@
1
+ .. _enhydris_cache_api:
2
+
3
+ ==================
4
+ enhydris-cache API
5
+ ==================
6
+
7
+ ``import enhydris_cache``
8
+
9
+ .. class:: enhydris_cache.TimeseriesCache(timeseries_groups)
10
+
11
+ Keeps certain time series cached in the filesystem. The time series
12
+ is downloaded from Enhydris using the Enhydris web service API.
13
+ *timeseries_groups* is a list; each item is a dictionary
14
+ representing an Enhydris time series; its keys are *base_url*,
15
+ *auth_token*, *id*, and *file*; the latter is the filename of
16
+ the file to which the time series will be cached (absolute or
17
+ relative to the current working directory).
18
+
19
+ .. method:: update()
20
+
21
+ Downloads everything that has not already been downloaded (or all
22
+ the time series if nothing is in the cache).
@@ -0,0 +1,143 @@
1
+ ==========================================================
2
+ enhydris-cache - keep copies of time series in local files
3
+ ==========================================================
4
+
5
+ Synopsis
6
+ ========
7
+
8
+ ``enhydris_cache [--traceback] config_file``
9
+
10
+ Description and quick start
11
+ ===========================
12
+
13
+ ``enhydris-cache`` downloads data from Enhydris and stores them
14
+ locally in the file system. The details of its operation are
15
+ specified in the configuration file specified on the command line.
16
+
17
+ How to run it
18
+ -------------
19
+
20
+ First, you need to create a configuration file with a text editor such
21
+ as ``vim``, ``emacs``, ``notepad``, or whatever. Create such a file
22
+ and name it, for example, :file:`/var/tmp/enhydris_cache.conf`,
23
+ with the following contents (the contents don't matter at this stage,
24
+ just copy and paste them from below)::
25
+
26
+ [General]
27
+ loglevel = INFO
28
+
29
+ Then, open a command prompt and give it this command::
30
+
31
+ enhydris-cache /var/tmp/enhydris_cache.conf
32
+
33
+ If you have done everything correctly, it should output an error message
34
+ complaining that something in its configuration file isn't right.
35
+
36
+ Configuration file example
37
+ --------------------------
38
+
39
+ Take a look at the following example configuration file and read the
40
+ explanatory comments that follow it:
41
+
42
+ .. code-block:: ini
43
+
44
+ [General]
45
+ loglevel = INFO
46
+ logfile = /var/log/enhydris-cache/enhydris-cache.log
47
+ cache_dir = /var/cache/enhydris-cache
48
+
49
+ [ntua]
50
+ base_url = https://openmeteo.org/
51
+ station_id = 1334
52
+ timeseries_group_id = 4321
53
+ timeseries_id = 6539
54
+ file = ntua.hts
55
+
56
+ [nedontas]
57
+ base_url = https://openmeteo.org/
58
+ station_id = 1482
59
+ timeseries_group_id = 1234
60
+ timeseries_id = 9356
61
+ file = /somewhere/else/nedontas.hts
62
+
63
+ [arta]
64
+ base_url = https://upatras.gr/enhydris/
65
+ auth_token = 123456789abcdef0123456789abcdef012345678
66
+ station_id = 27
67
+ timeseries_group_id = 2727
68
+ timeseries_id = 8765
69
+ file = arta.hts
70
+
71
+ With the above configuration file, ``enhydris_cache`` will log
72
+ information in the file specified by :confval:`logfile`. It will
73
+ download time series from Enhydris and store them in the specified
74
+ files; these can be absolute or relative pathnames; if they are
75
+ relative, they will be stored in the directory specified by
76
+ :confval:`cache_dir`. In this example, the local files will be
77
+ :file:`/var/cache/enhydris-cache/ntua.hts`,
78
+ :file:`/somewhere/else/enhydris-cache/nedontas.hts`, and
79
+ :file:`/var/cache/enhydris-cache/arta.hts`.
80
+
81
+ Configuration file reference
82
+ ============================
83
+
84
+ The configuration file has the format of INI files. There is a
85
+ ``[General]`` section with general parameters, and any number of other
86
+ sections, which we will call "time series sections", each time series
87
+ section referring to one time series.
88
+
89
+ General parameters
90
+ ------------------
91
+
92
+ .. confval:: loglevel
93
+
94
+ Optional. Can have the values ``ERROR``, ``WARNING``, ``INFO``,
95
+ ``DEBUG``. The default is ``WARNING``.
96
+
97
+ .. confval:: logfile
98
+
99
+ Optional. The full pathname of a log file. If unspecified, log
100
+ messages will go to the standard error.
101
+
102
+ .. confval:: cache_dir
103
+
104
+ Optional. ``enhydris_cache`` will change directory to this
105
+ directory, so any relative filenames will be relative to this
106
+ directory. If unspecified, relative filenames will be relative to
107
+ the directory from which ``enhydris_cache`` was started.
108
+
109
+ Time series sections
110
+ --------------------
111
+
112
+ The name of the section is ignored.
113
+
114
+ .. confval:: base_url
115
+
116
+ The base URL of the Enhydris installation that hosts the time
117
+ series. Most often the :confval:`base_url` will be the same for
118
+ all time series, but in the general case you might want to get data
119
+ from many Enhydris installations.
120
+
121
+ .. confval:: station_id
122
+
123
+ The id of the station.
124
+
125
+ .. confval:: timeseries_group_id
126
+
127
+ The id of the time series group.
128
+
129
+ .. confval:: timeseries_id
130
+
131
+ The id of the time series.
132
+
133
+ .. confval:: auth_token
134
+
135
+ Optional. Needed if that Enhydris installation needs login in
136
+ order to provide access to the data. You can get a token at the
137
+ ``/api/auth/login/`` URL of Enhydris, such as
138
+ https://openmeteo.org/api/auth/login/.
139
+
140
+ .. confval:: file
141
+
142
+ The filename of the file to which the data will be cached. See also
143
+ :confval:`cache_dir`.