bluemath-tk 1.0.1__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.
Files changed (135) hide show
  1. bluemath_tk-1.0.1/.github/workflows/build-package.yml +40 -0
  2. bluemath_tk-1.0.1/.github/workflows/python-tests.yml +32 -0
  3. bluemath_tk-1.0.1/.gitignore +101 -0
  4. bluemath_tk-1.0.1/LICENSE +7 -0
  5. bluemath_tk-1.0.1/MANIFEST.IN +1 -0
  6. bluemath_tk-1.0.1/PKG-INFO +99 -0
  7. bluemath_tk-1.0.1/README.md +44 -0
  8. bluemath_tk-1.0.1/bluemath_tk/__init__.py +0 -0
  9. bluemath_tk-1.0.1/bluemath_tk/_version.py +16 -0
  10. bluemath_tk-1.0.1/bluemath_tk/core/__init__.py +0 -0
  11. bluemath_tk-1.0.1/bluemath_tk/core/decorators.py +311 -0
  12. bluemath_tk-1.0.1/bluemath_tk/core/logging.py +76 -0
  13. bluemath_tk-1.0.1/bluemath_tk/core/models.py +453 -0
  14. bluemath_tk-1.0.1/bluemath_tk/core/operations.py +368 -0
  15. bluemath_tk-1.0.1/bluemath_tk/core/plotting/__init__.py +0 -0
  16. bluemath_tk-1.0.1/bluemath_tk/core/plotting/base_plotting.py +230 -0
  17. bluemath_tk-1.0.1/bluemath_tk/core/plotting/colors.py +234 -0
  18. bluemath_tk-1.0.1/bluemath_tk/datamining/__init__.py +27 -0
  19. bluemath_tk-1.0.1/bluemath_tk/datamining/_base_datamining.py +409 -0
  20. bluemath_tk-1.0.1/bluemath_tk/datamining/kma.py +301 -0
  21. bluemath_tk-1.0.1/bluemath_tk/datamining/lhs.py +137 -0
  22. bluemath_tk-1.0.1/bluemath_tk/datamining/mda.py +447 -0
  23. bluemath_tk-1.0.1/bluemath_tk/datamining/pca.py +483 -0
  24. bluemath_tk-1.0.1/bluemath_tk/datamining/som.py +374 -0
  25. bluemath_tk-1.0.1/bluemath_tk/deeplearning/__init__.py +0 -0
  26. bluemath_tk-1.0.1/bluemath_tk/deeplearning/deep_environment.yml +206 -0
  27. bluemath_tk-1.0.1/bluemath_tk/deeplearning/generators/__init__.py +0 -0
  28. bluemath_tk-1.0.1/bluemath_tk/deeplearning/generators/mockDataGenerator.py +44 -0
  29. bluemath_tk-1.0.1/bluemath_tk/deeplearning/generators/ncDataGenerator.py +89 -0
  30. bluemath_tk-1.0.1/bluemath_tk/deeplearning/models/__init__.py +0 -0
  31. bluemath_tk-1.0.1/bluemath_tk/deeplearning/models/resnet_model.py +74 -0
  32. bluemath_tk-1.0.1/bluemath_tk/deeplearning/resnet.py +36 -0
  33. bluemath_tk-1.0.1/bluemath_tk/distributions/__init__.py +0 -0
  34. bluemath_tk-1.0.1/bluemath_tk/distributions/copula.py +0 -0
  35. bluemath_tk-1.0.1/bluemath_tk/distributions/gev.py +0 -0
  36. bluemath_tk-1.0.1/bluemath_tk/distributions/gpd.py +0 -0
  37. bluemath_tk-1.0.1/bluemath_tk/distributions/poisson.py +0 -0
  38. bluemath_tk-1.0.1/bluemath_tk/distributions/pot.py +0 -0
  39. bluemath_tk-1.0.1/bluemath_tk/downloaders/__init__.py +19 -0
  40. bluemath_tk-1.0.1/bluemath_tk/downloaders/_base_downloaders.py +82 -0
  41. bluemath_tk-1.0.1/bluemath_tk/downloaders/copernicus/ERA5/ERA5_config.json +231 -0
  42. bluemath_tk-1.0.1/bluemath_tk/downloaders/copernicus/ERA5/ERA5_download.py +95 -0
  43. bluemath_tk-1.0.1/bluemath_tk/downloaders/copernicus/ERA5/README.md +124 -0
  44. bluemath_tk-1.0.1/bluemath_tk/downloaders/copernicus/__init__.py +0 -0
  45. bluemath_tk-1.0.1/bluemath_tk/downloaders/copernicus/copernicus_downloader.py +456 -0
  46. bluemath_tk-1.0.1/bluemath_tk/interpolation/__init__.py +0 -0
  47. bluemath_tk-1.0.1/bluemath_tk/interpolation/_base_interpolation.py +64 -0
  48. bluemath_tk-1.0.1/bluemath_tk/interpolation/analogs.py +0 -0
  49. bluemath_tk-1.0.1/bluemath_tk/interpolation/gps.py +0 -0
  50. bluemath_tk-1.0.1/bluemath_tk/interpolation/rbf.py +855 -0
  51. bluemath_tk-1.0.1/bluemath_tk/predictor/__init__.py +0 -0
  52. bluemath_tk-1.0.1/bluemath_tk/predictor/awt.py +0 -0
  53. bluemath_tk-1.0.1/bluemath_tk/predictor/dwt.py +831 -0
  54. bluemath_tk-1.0.1/bluemath_tk/predictor/indices.py +0 -0
  55. bluemath_tk-1.0.1/bluemath_tk/predictor/itca.py +0 -0
  56. bluemath_tk-1.0.1/bluemath_tk/predictor/iwt.py +0 -0
  57. bluemath_tk-1.0.1/bluemath_tk/risk/__init__.py +0 -0
  58. bluemath_tk-1.0.1/bluemath_tk/risk/damage.py +0 -0
  59. bluemath_tk-1.0.1/bluemath_tk/risk/pcrafi.py +0 -0
  60. bluemath_tk-1.0.1/bluemath_tk/risk/riskscapetools.py +0 -0
  61. bluemath_tk-1.0.1/bluemath_tk/tc/__init__.py +0 -0
  62. bluemath_tk-1.0.1/bluemath_tk/tc/graffitiwaves.py +0 -0
  63. bluemath_tk-1.0.1/bluemath_tk/tc/parameterization.py +0 -0
  64. bluemath_tk-1.0.1/bluemath_tk/tc/qtcrain.py +0 -0
  65. bluemath_tk-1.0.1/bluemath_tk/tc/skytcwaves.py +0 -0
  66. bluemath_tk-1.0.1/bluemath_tk/tc/tracks.py +0 -0
  67. bluemath_tk-1.0.1/bluemath_tk/tc/vortex.py +0 -0
  68. bluemath_tk-1.0.1/bluemath_tk/tide/__init__.py +0 -0
  69. bluemath_tk-1.0.1/bluemath_tk/tide/harmonic.py +0 -0
  70. bluemath_tk-1.0.1/bluemath_tk/tide/ttide.py +0 -0
  71. bluemath_tk-1.0.1/bluemath_tk/tide/utide.py +0 -0
  72. bluemath_tk-1.0.1/bluemath_tk/topo_bathy/__init__.py +0 -0
  73. bluemath_tk-1.0.1/bluemath_tk/topo_bathy/profiles.py +232 -0
  74. bluemath_tk-1.0.1/bluemath_tk/waves/__init__.py +0 -0
  75. bluemath_tk-1.0.1/bluemath_tk/waves/climate.py +0 -0
  76. bluemath_tk-1.0.1/bluemath_tk/waves/estela.py +473 -0
  77. bluemath_tk-1.0.1/bluemath_tk/waves/greenswell.py +0 -0
  78. bluemath_tk-1.0.1/bluemath_tk/waves/partitioning.py +0 -0
  79. bluemath_tk-1.0.1/bluemath_tk/waves/series.py +414 -0
  80. bluemath_tk-1.0.1/bluemath_tk/waves/snakes.py +0 -0
  81. bluemath_tk-1.0.1/bluemath_tk/waves/superpoint.py +0 -0
  82. bluemath_tk-1.0.1/bluemath_tk/wrappers/__init__.py +19 -0
  83. bluemath_tk-1.0.1/bluemath_tk/wrappers/_base_wrappers.py +358 -0
  84. bluemath_tk-1.0.1/bluemath_tk/wrappers/cgwave/__init__.py +0 -0
  85. bluemath_tk-1.0.1/bluemath_tk/wrappers/cgwave/cgwave_wrapper.py +0 -0
  86. bluemath_tk-1.0.1/bluemath_tk/wrappers/delft3d/__init__.py +0 -0
  87. bluemath_tk-1.0.1/bluemath_tk/wrappers/delft3d/delft3d_wrapper.py +0 -0
  88. bluemath_tk-1.0.1/bluemath_tk/wrappers/lisflood/__init__.py +0 -0
  89. bluemath_tk-1.0.1/bluemath_tk/wrappers/lisflood/lisflood_wrapper.py +0 -0
  90. bluemath_tk-1.0.1/bluemath_tk/wrappers/schism/__init__.py +0 -0
  91. bluemath_tk-1.0.1/bluemath_tk/wrappers/schism/schism_wrapper.py +0 -0
  92. bluemath_tk-1.0.1/bluemath_tk/wrappers/swan/__init__.py +0 -0
  93. bluemath_tk-1.0.1/bluemath_tk/wrappers/swan/swan_wrapper.py +99 -0
  94. bluemath_tk-1.0.1/bluemath_tk/wrappers/swan/templates/nostruc_input.swn +23 -0
  95. bluemath_tk-1.0.1/bluemath_tk/wrappers/swan/templates/struc_input.swn +31 -0
  96. bluemath_tk-1.0.1/bluemath_tk/wrappers/swan/templates/wind_input.swn +30 -0
  97. bluemath_tk-1.0.1/bluemath_tk/wrappers/swash/__init__.py +0 -0
  98. bluemath_tk-1.0.1/bluemath_tk/wrappers/swash/swash_example.py +145 -0
  99. bluemath_tk-1.0.1/bluemath_tk/wrappers/swash/swash_wrapper.py +168 -0
  100. bluemath_tk-1.0.1/bluemath_tk/wrappers/swash/templates/input.sws +59 -0
  101. bluemath_tk-1.0.1/bluemath_tk/wrappers/xbeach/__init__.py +0 -0
  102. bluemath_tk-1.0.1/bluemath_tk/wrappers/xbeach/templates/loclist.txt +3 -0
  103. bluemath_tk-1.0.1/bluemath_tk/wrappers/xbeach/templates/params.txt +79 -0
  104. bluemath_tk-1.0.1/bluemath_tk/wrappers/xbeach/xbeach_example.py +67 -0
  105. bluemath_tk-1.0.1/bluemath_tk/wrappers/xbeach/xbeach_wrapper.py +68 -0
  106. bluemath_tk-1.0.1/bluemath_tk.egg-info/PKG-INFO +99 -0
  107. bluemath_tk-1.0.1/bluemath_tk.egg-info/SOURCES.txt +133 -0
  108. bluemath_tk-1.0.1/bluemath_tk.egg-info/dependency_links.txt +1 -0
  109. bluemath_tk-1.0.1/bluemath_tk.egg-info/requires.txt +30 -0
  110. bluemath_tk-1.0.1/bluemath_tk.egg-info/top_level.txt +1 -0
  111. bluemath_tk-1.0.1/docs/contribute.md +72 -0
  112. bluemath_tk-1.0.1/docs/datamining/base_datamining.md +1 -0
  113. bluemath_tk-1.0.1/docs/datamining/clustering_datamining.md +5 -0
  114. bluemath_tk-1.0.1/docs/datamining/intro.md +31 -0
  115. bluemath_tk-1.0.1/docs/datamining/reduction_datamining.md +1 -0
  116. bluemath_tk-1.0.1/docs/datamining/sampling_datamining.md +1 -0
  117. bluemath_tk-1.0.1/docs/index.md +15 -0
  118. bluemath_tk-1.0.1/docs/installation.md +26 -0
  119. bluemath_tk-1.0.1/docs/interpolation/intro.md +22 -0
  120. bluemath_tk-1.0.1/docs/interpolation/rbf_interpolation.md +1 -0
  121. bluemath_tk-1.0.1/docs/sketch_tk.png +0 -0
  122. bluemath_tk-1.0.1/docs/wrappers/base_wrapper.md +1 -0
  123. bluemath_tk-1.0.1/docs/wrappers/intro.md +163 -0
  124. bluemath_tk-1.0.1/docs/wrappers/swash_wrapper.md +1 -0
  125. bluemath_tk-1.0.1/environment.yml +7 -0
  126. bluemath_tk-1.0.1/mkdocs.yml +36 -0
  127. bluemath_tk-1.0.1/pyproject.toml +67 -0
  128. bluemath_tk-1.0.1/setup.cfg +4 -0
  129. bluemath_tk-1.0.1/tests/datamining/test_kma.py +47 -0
  130. bluemath_tk-1.0.1/tests/datamining/test_lhs.py +34 -0
  131. bluemath_tk-1.0.1/tests/datamining/test_mda.py +61 -0
  132. bluemath_tk-1.0.1/tests/datamining/test_pca.py +105 -0
  133. bluemath_tk-1.0.1/tests/datamining/test_som.py +70 -0
  134. bluemath_tk-1.0.1/tests/deeplearning/test_resnet.py +59 -0
  135. bluemath_tk-1.0.1/tests/interpolation/test_rbf.py +76 -0
@@ -0,0 +1,40 @@
1
+ name: Publish Python Package
2
+
3
+ on:
4
+ push:
5
+ tags:
6
+ - "v*"
7
+
8
+ jobs:
9
+ build-and-publish:
10
+ runs-on: ubuntu-latest
11
+
12
+ steps:
13
+ - name: Checkout Repository
14
+ uses: actions/checkout@v4
15
+
16
+ - name: Set Up Python
17
+ uses: actions/setup-python@v5
18
+ with:
19
+ python-version: "3.12"
20
+
21
+ - name: Install Dependencies
22
+ run: |
23
+ pip install build setuptools-scm twine
24
+ conda install -c conda-forge conda-build anaconda-client
25
+
26
+ - name: Get Version
27
+ id: get_version
28
+ run: |
29
+ echo "version=$(python -c 'import setuptools_scm; print(setuptools_scm.get_version())')" >> $GITHUB_ENV
30
+ env:
31
+ GITHUB_ENV: ${{ github.env }}
32
+
33
+ - name: Build Python Package
34
+ run: python -m build
35
+
36
+ - name: Publish to PyPI
37
+ run: python -m twine upload dist/* --verbose
38
+ env:
39
+ TWINE_USERNAME: __token__
40
+ TWINE_PASSWORD: ${{ secrets.PYPI_TOKEN }}
@@ -0,0 +1,32 @@
1
+ name: Python Tests
2
+
3
+ on:
4
+ pull_request:
5
+ branches:
6
+ - main
7
+ types:
8
+ - opened
9
+
10
+ jobs:
11
+ python-tests:
12
+ runs-on: ubuntu-latest
13
+
14
+ steps:
15
+ - name: Checkout code
16
+ uses: actions/checkout@v4
17
+
18
+ - name: Set up Miniconda
19
+ uses: conda-incubator/setup-miniconda@v2
20
+ with:
21
+ auto-update-conda: true
22
+ python-version: "3.12" # specify your required Python version
23
+
24
+ - name: Create conda environment
25
+ run: conda env create -f environment.yml
26
+
27
+ - name: Run tests
28
+ run: |
29
+ source /usr/share/miniconda/etc/profile.d/conda.sh
30
+ conda activate bluemath-tk
31
+ python -m unittest discover tests/datamining/
32
+ python -m unittest discover tests/interpolation/
@@ -0,0 +1,101 @@
1
+ # Byte-compiled / optimized / DLL files
2
+ __pycache__/
3
+ *.py[cod]
4
+ *$py.class
5
+
6
+ # C extensions
7
+ *.so
8
+
9
+ # Distribution / packaging
10
+ .Python
11
+ build/
12
+ develop-eggs/
13
+ dist/
14
+ downloads/
15
+ eggs/
16
+ .eggs/
17
+ lib/
18
+ lib64/
19
+ parts/
20
+ sdist/
21
+ var/
22
+ wheels/
23
+ share/python-wheels/
24
+ *.egg-info/
25
+ .installed.cfg
26
+ *.egg
27
+ MANIFEST
28
+ conda-recipe/
29
+ bluemath_tk/_version.py
30
+
31
+ # PyInstaller
32
+ # Usually these files are written by a python script from a template
33
+ *.manifest
34
+ *.spec
35
+
36
+ # Installer logs
37
+ pip-log.txt
38
+ pip-delete-this-directory.txt
39
+
40
+ # Unit test / coverage reports
41
+ htmlcov/
42
+ .tox/
43
+ .coverage
44
+ .coverage.*
45
+ .cache
46
+ nosetests.xml
47
+ coverage.xml
48
+ *.cover
49
+ *.py,cover
50
+ .hypothesis/
51
+ .pytest_cache/
52
+ tests_data/
53
+
54
+ # mypy
55
+ .mypy_cache/
56
+ .dmypy.json
57
+ dmypy.json
58
+
59
+ # Pyre type checker
60
+ .pyre/
61
+
62
+ # Jupyter Notebook
63
+ .ipynb_checkpoints
64
+
65
+ # Django stuff:
66
+ *.log
67
+ staticfiles/
68
+ media/
69
+
70
+ # Flask stuff:
71
+ instance/
72
+ .webassets-cache
73
+
74
+ # Scrapy stuff:
75
+ .scrapy
76
+
77
+ # Sphinx documentation
78
+ docs/_build/
79
+
80
+ # MkDocs documentation (production)
81
+ site/
82
+
83
+ # PyCharm
84
+ .idea/
85
+ *.iml
86
+
87
+ # VS Code
88
+ .vscode/
89
+
90
+ # Local environment files
91
+ .env
92
+ .venv
93
+ env/
94
+ venv/
95
+ ENV/
96
+ env.bak/
97
+ venv.bak/
98
+
99
+ # Local notebooks
100
+ notebooks/
101
+ test_cases/
@@ -0,0 +1,7 @@
1
+ Copyright (c) 2024 GeoOcean group, Universidad de Cantabria
2
+
3
+ Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
4
+
5
+ The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
6
+
7
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
@@ -0,0 +1 @@
1
+ include bluemath_tk/downloaders/copernicus/ERA5/ERA5_config.json
@@ -0,0 +1,99 @@
1
+ Metadata-Version: 2.1
2
+ Name: bluemath-tk
3
+ Version: 1.0.1
4
+ Summary: Module collection for custom climate data analysis. The main objective of this Python package is to provide a set of statistical tools tailored for climate data analysis, with a focus on statistical classification and prediction.
5
+ Author-email: Geomatics and Ocean Engineering Group <bluemath@unican.es>
6
+ License: Copyright (c) 2024 GeoOcean group, Universidad de Cantabria
7
+
8
+ Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
9
+
10
+ The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
11
+
12
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
13
+ Project-URL: Homepage, https://github.com/GeoOcean/BlueMath_tk
14
+ Project-URL: Documentation, https://geoocean.github.io/BlueMath_tk/
15
+ Project-URL: Issues, https://github.com/GeoOcean/BlueMath_tk/issues
16
+ Keywords: climate,statistical,tools
17
+ Classifier: Programming Language :: Python :: 3 :: Only
18
+ Classifier: License :: OSI Approved :: MIT License
19
+ Classifier: Operating System :: OS Independent
20
+ Classifier: Programming Language :: Python :: 3.9
21
+ Classifier: Programming Language :: Python :: 3.10
22
+ Classifier: Programming Language :: Python :: 3.11
23
+ Classifier: Programming Language :: Python :: 3.12
24
+ Classifier: Programming Language :: Python :: 3.13
25
+ Requires-Python: >=3.9
26
+ Description-Content-Type: text/markdown
27
+ License-File: LICENSE
28
+ Requires-Dist: numpy
29
+ Requires-Dist: pandas
30
+ Requires-Dist: xarray
31
+ Requires-Dist: netcdf4
32
+ Requires-Dist: dask
33
+ Requires-Dist: zarr
34
+ Requires-Dist: scipy
35
+ Requires-Dist: scikit-learn
36
+ Requires-Dist: matplotlib
37
+ Requires-Dist: plotly
38
+ Requires-Dist: cartopy
39
+ Requires-Dist: cdsapi
40
+ Requires-Dist: jinja2
41
+ Requires-Dist: requests
42
+ Requires-Dist: aiohttp
43
+ Requires-Dist: minisom
44
+ Provides-Extra: docs
45
+ Requires-Dist: mkdocs; extra == "docs"
46
+ Requires-Dist: mkdocs-material; extra == "docs"
47
+ Requires-Dist: mkdocstrings; extra == "docs"
48
+ Requires-Dist: mkdocstrings[python]; extra == "docs"
49
+ Provides-Extra: tests
50
+ Requires-Dist: pytest; extra == "tests"
51
+ Requires-Dist: pytest-mock; extra == "tests"
52
+ Provides-Extra: deep
53
+ Requires-Dist: tensorflow; extra == "deep"
54
+ Requires-Dist: keras; extra == "deep"
55
+
56
+ # Bluemath {**Toolkit**}
57
+
58
+ Module collection for custom climate data analysis. The main objective of this Python package is to provide a set of statistical tools tailored for climate data analysis, with a focus on statistical classification and prediction.
59
+
60
+ The package also includes a set of utility functions for processing climate data. To facilitate understanding of how to use these modules, simple demonstration scripts and the necessary data have been added to this repository.
61
+
62
+ ## Main contents
63
+
64
+ ![Sketch](./docs/sketch_tk.png)
65
+
66
+ Link to the different sections:
67
+ - [datamining](./bluemath_tk/datamining/)
68
+ - [waves](./bluemath_tk/waves/)
69
+ - [predictor](./bluemath_tk/predictor/)
70
+ - [TC](./bluemath_tk/tc/)
71
+ - [distributions](./bluemath_tk/distributions/)
72
+ - [wrappers](./bluemath_tk/wrappers/)
73
+ - [risk](./bluemath_tk/risk/)
74
+ - [tide](./bluemath_tk/tide/)
75
+
76
+ ## Demos
77
+
78
+ In this repository, simple demo files showcasing the utilization of the different tools can be found in this [link](./demos). Furthermore, full examples with figures can be found in the [Bluemath - notebooks](./) repository.
79
+
80
+ ## Authors
81
+
82
+ Codes have been developed through a collaborative effort by members of the GeoOcean group at the University of Cantabria. For inquiries, please contact Fernando Méndez at mendezf@unican.es
83
+
84
+ ## License
85
+
86
+ This project is licensed under the MIT License. See the [license](LICENSE.txt) file for details
87
+
88
+ ## Project status
89
+
90
+ - UNDER DEVELOPMENT
91
+
92
+ # TODOs
93
+
94
+ - Check whole code in NNs
95
+ - Check climate scale data in SamoaTonga
96
+ - Add logs to datamining classes.
97
+ - Descomentar crontab, que ya funcionan los sh
98
+ - Add ERA5 spectra download.
99
+ - Add docker, sbatch, et options in wrappers!
@@ -0,0 +1,44 @@
1
+ # Bluemath {**Toolkit**}
2
+
3
+ Module collection for custom climate data analysis. The main objective of this Python package is to provide a set of statistical tools tailored for climate data analysis, with a focus on statistical classification and prediction.
4
+
5
+ The package also includes a set of utility functions for processing climate data. To facilitate understanding of how to use these modules, simple demonstration scripts and the necessary data have been added to this repository.
6
+
7
+ ## Main contents
8
+
9
+ ![Sketch](./docs/sketch_tk.png)
10
+
11
+ Link to the different sections:
12
+ - [datamining](./bluemath_tk/datamining/)
13
+ - [waves](./bluemath_tk/waves/)
14
+ - [predictor](./bluemath_tk/predictor/)
15
+ - [TC](./bluemath_tk/tc/)
16
+ - [distributions](./bluemath_tk/distributions/)
17
+ - [wrappers](./bluemath_tk/wrappers/)
18
+ - [risk](./bluemath_tk/risk/)
19
+ - [tide](./bluemath_tk/tide/)
20
+
21
+ ## Demos
22
+
23
+ In this repository, simple demo files showcasing the utilization of the different tools can be found in this [link](./demos). Furthermore, full examples with figures can be found in the [Bluemath - notebooks](./) repository.
24
+
25
+ ## Authors
26
+
27
+ Codes have been developed through a collaborative effort by members of the GeoOcean group at the University of Cantabria. For inquiries, please contact Fernando Méndez at mendezf@unican.es
28
+
29
+ ## License
30
+
31
+ This project is licensed under the MIT License. See the [license](LICENSE.txt) file for details
32
+
33
+ ## Project status
34
+
35
+ - UNDER DEVELOPMENT
36
+
37
+ # TODOs
38
+
39
+ - Check whole code in NNs
40
+ - Check climate scale data in SamoaTonga
41
+ - Add logs to datamining classes.
42
+ - Descomentar crontab, que ya funcionan los sh
43
+ - Add ERA5 spectra download.
44
+ - Add docker, sbatch, et options in wrappers!
File without changes
@@ -0,0 +1,16 @@
1
+ # file generated by setuptools_scm
2
+ # don't change, don't track in version control
3
+ TYPE_CHECKING = False
4
+ if TYPE_CHECKING:
5
+ from typing import Tuple, Union
6
+ VERSION_TUPLE = Tuple[Union[int, str], ...]
7
+ else:
8
+ VERSION_TUPLE = object
9
+
10
+ version: str
11
+ __version__: str
12
+ __version_tuple__: VERSION_TUPLE
13
+ version_tuple: VERSION_TUPLE
14
+
15
+ __version__ = version = '1.0.1'
16
+ __version_tuple__ = version_tuple = (1, 0, 1)
File without changes
@@ -0,0 +1,311 @@
1
+ import functools
2
+ from typing import List
3
+ import pandas as pd
4
+ import xarray as xr
5
+
6
+
7
+ def validate_data_lhs(func):
8
+ """
9
+ Decorator to validate data in LHS class fit method.
10
+
11
+ Parameters
12
+ ----------
13
+ func : callable
14
+ The function to be decorated
15
+
16
+ Returns
17
+ -------
18
+ callable
19
+ The decorated function
20
+ """
21
+
22
+ @functools.wraps(func)
23
+ def wrapper(
24
+ self,
25
+ dimensions_names: List[str],
26
+ lower_bounds: List[float],
27
+ upper_bounds: List[float],
28
+ num_samples: int,
29
+ ):
30
+ if not isinstance(dimensions_names, list):
31
+ raise TypeError("Dimensions names must be a list")
32
+ if not isinstance(lower_bounds, list):
33
+ raise TypeError("Lower bounds must be a list")
34
+ if not isinstance(upper_bounds, list):
35
+ raise TypeError("Upper bounds must be a list")
36
+ if len(dimensions_names) != len(lower_bounds) or len(lower_bounds) != len(
37
+ upper_bounds
38
+ ):
39
+ raise ValueError(
40
+ "Dimensions names, lower bounds and upper bounds must have the same length"
41
+ )
42
+ if not all(
43
+ [lower <= upper for lower, upper in zip(lower_bounds, upper_bounds)]
44
+ ):
45
+ raise ValueError("Lower bounds must be less than or equal to upper bounds")
46
+ if not isinstance(num_samples, int) or num_samples <= 0:
47
+ raise ValueError("Variable num_samples must be integer and > 0")
48
+ return func(self, dimensions_names, lower_bounds, upper_bounds, num_samples)
49
+
50
+ return wrapper
51
+
52
+
53
+ def validate_data_mda(func):
54
+ """
55
+ Decorator to validate data in MDA class fit method.
56
+
57
+ Parameters
58
+ ----------
59
+ func : callable
60
+ The function to be decorated
61
+
62
+ Returns
63
+ -------
64
+ callable
65
+ The decorated function
66
+ """
67
+
68
+ @functools.wraps(func)
69
+ def wrapper(
70
+ self,
71
+ data: pd.DataFrame,
72
+ directional_variables: List[str] = [],
73
+ custom_scale_factor: dict = {},
74
+ ):
75
+ if data is None:
76
+ raise ValueError("Data cannot be None")
77
+ elif not isinstance(data, pd.DataFrame):
78
+ raise TypeError("Data must be a pandas DataFrame")
79
+ if not isinstance(directional_variables, list):
80
+ raise TypeError("Directional variables must be a list")
81
+ if not isinstance(custom_scale_factor, dict):
82
+ raise TypeError("Custom scale factor must be a dict")
83
+ return func(self, data, directional_variables, custom_scale_factor)
84
+
85
+ return wrapper
86
+
87
+
88
+ def validate_data_kma(func):
89
+ """
90
+ Decorator to validate data in KMA class fit method.
91
+
92
+ Parameters
93
+ ----------
94
+ func : callable
95
+ The function to be decorated
96
+
97
+ Returns
98
+ -------
99
+ callable
100
+ The decorated function
101
+ """
102
+
103
+ @functools.wraps(func)
104
+ def wrapper(
105
+ self,
106
+ data: pd.DataFrame,
107
+ directional_variables: List[str] = [],
108
+ custom_scale_factor: dict = {},
109
+ ):
110
+ if data is None:
111
+ raise ValueError("Data cannot be None")
112
+ elif not isinstance(data, pd.DataFrame):
113
+ raise TypeError("Data must be a pandas DataFrame")
114
+ if not isinstance(directional_variables, list):
115
+ raise TypeError("Directional variables must be a list")
116
+ if not isinstance(custom_scale_factor, dict):
117
+ raise TypeError("Custom scale factor must be a dict")
118
+ return func(self, data, directional_variables, custom_scale_factor)
119
+
120
+ return wrapper
121
+
122
+
123
+ def validate_data_som(func):
124
+ """
125
+ Decorator to validate data in SOM class fit method.
126
+
127
+ Parameters
128
+ ----------
129
+ func : callable
130
+ The function to be decorated
131
+
132
+ Returns
133
+ -------
134
+ callable
135
+ The decorated function
136
+ """
137
+
138
+ @functools.wraps(func)
139
+ def wrapper(
140
+ self,
141
+ data: pd.DataFrame,
142
+ directional_variables: List[str] = [],
143
+ num_iteration: int = 1000,
144
+ ):
145
+ if data is None:
146
+ raise ValueError("Data cannot be None")
147
+ elif not isinstance(data, pd.DataFrame):
148
+ raise TypeError("Data must be a pandas DataFrame")
149
+ if not isinstance(directional_variables, list):
150
+ raise TypeError("Directional variables must be a list")
151
+ if not isinstance(num_iteration, int) or num_iteration <= 0:
152
+ raise ValueError("Number of iterations must be integer and > 0")
153
+ return func(self, data, directional_variables, num_iteration)
154
+
155
+ return wrapper
156
+
157
+
158
+ def validate_data_pca(func):
159
+ """
160
+ Decorator to validate data in PCA class fit method.
161
+
162
+ Parameters
163
+ ----------
164
+ func : callable
165
+ The function to be decorated
166
+
167
+ Returns
168
+ -------
169
+ callable
170
+ The decorated function
171
+ """
172
+
173
+ @functools.wraps(func)
174
+ def wrapper(
175
+ self,
176
+ data: xr.Dataset,
177
+ vars_to_stack: List[str],
178
+ coords_to_stack: List[str],
179
+ pca_dim_for_rows: str,
180
+ window_in_pca_dim_for_rows: List[int] = [0],
181
+ value_to_replace_nans: float = None,
182
+ ):
183
+ if data is None:
184
+ raise ValueError("Data cannot be None")
185
+ elif not isinstance(data, xr.Dataset):
186
+ raise TypeError("Data must be an xarray Dataset")
187
+ # Check that all vars_to_stack are in the data
188
+ if not isinstance(vars_to_stack, list) or len(vars_to_stack) == 0:
189
+ raise ValueError("Variables to stack must be a non-empty list")
190
+ for var in vars_to_stack:
191
+ if var not in data.data_vars:
192
+ raise ValueError(f"Variable {var} not found in data")
193
+ # Check that all variables in vars_to_stack have the same coordinates and dimensions
194
+ first_var = vars_to_stack[0]
195
+ first_var_dims = list(data[first_var].dims)
196
+ first_var_coords = list(data[first_var].coords)
197
+ for var in vars_to_stack:
198
+ if list(data[var].dims) != first_var_dims:
199
+ raise ValueError(
200
+ f"All variables must have the same dimensions. Variable {var} does not match."
201
+ )
202
+ if list(data[var].coords) != first_var_coords:
203
+ raise ValueError(
204
+ f"All variables must have the same coordinates. Variable {var} does not match."
205
+ )
206
+ # Check that all coords_to_stack are in the data
207
+ if not isinstance(coords_to_stack, list) or len(coords_to_stack) == 0:
208
+ raise ValueError("Coordinates to stack must be a non-empty list")
209
+ for coord in coords_to_stack:
210
+ if coord not in data.coords:
211
+ raise ValueError(f"Coordinate {coord} not found in data.")
212
+ # Check that pca_dim_for_rows is in the data, and window > 0 if provided
213
+ if not isinstance(pca_dim_for_rows, str) or pca_dim_for_rows not in data.dims:
214
+ raise ValueError(
215
+ "PCA dimension for rows must be a string and found in the data dimensions"
216
+ )
217
+ if window_in_pca_dim_for_rows is not None:
218
+ if (
219
+ not isinstance(window_in_pca_dim_for_rows, list)
220
+ or len(window_in_pca_dim_for_rows) == 0
221
+ ):
222
+ raise ValueError(
223
+ "Window in PCA dimension for rows must be a non-empty list"
224
+ )
225
+ if value_to_replace_nans is not None:
226
+ if not isinstance(value_to_replace_nans, float):
227
+ raise ValueError("Value to replace NaNs must be float")
228
+ return func(
229
+ self,
230
+ data,
231
+ vars_to_stack,
232
+ coords_to_stack,
233
+ pca_dim_for_rows,
234
+ window_in_pca_dim_for_rows,
235
+ value_to_replace_nans,
236
+ )
237
+
238
+ return wrapper
239
+
240
+
241
+ def validate_data_rbf(func):
242
+ """
243
+ Decorator to validate data in RBF class fit method.
244
+
245
+ Parameters
246
+ ----------
247
+ func : callable
248
+ The function to be decorated
249
+
250
+ Returns
251
+ -------
252
+ callable
253
+ The decorated function
254
+ """
255
+
256
+ @functools.wraps(func)
257
+ def wrapper(
258
+ self,
259
+ subset_data: pd.DataFrame,
260
+ target_data: pd.DataFrame,
261
+ subset_directional_variables: List[str] = [],
262
+ target_directional_variables: List[str] = [],
263
+ subset_custom_scale_factor: dict = {},
264
+ normalize_target_data: bool = True,
265
+ target_custom_scale_factor: dict = {},
266
+ num_threads: int = None,
267
+ ):
268
+ if subset_data is None:
269
+ raise ValueError("Subset data cannot be None")
270
+ elif not isinstance(subset_data, pd.DataFrame):
271
+ raise TypeError("Subset data must be a pandas DataFrame")
272
+ if target_data is None:
273
+ raise ValueError("Target data cannot be None")
274
+ elif not isinstance(target_data, pd.DataFrame):
275
+ raise TypeError("Target data must be a pandas DataFrame")
276
+ if not isinstance(subset_directional_variables, list):
277
+ raise TypeError("Subset directional variables must be a list")
278
+ for directional_variable in subset_directional_variables:
279
+ if directional_variable not in subset_data.columns:
280
+ raise ValueError(
281
+ f"Directional variable {directional_variable} not found in subset data"
282
+ )
283
+ if not isinstance(target_directional_variables, list):
284
+ raise TypeError("Target directional variables must be a list")
285
+ for directional_variable in target_directional_variables:
286
+ if directional_variable not in target_data.columns:
287
+ raise ValueError(
288
+ f"Directional variable {directional_variable} not found in target data"
289
+ )
290
+ if not isinstance(subset_custom_scale_factor, dict):
291
+ raise TypeError("Subset custom scale factor must be a dict")
292
+ if not isinstance(normalize_target_data, bool):
293
+ raise TypeError("Normalize target data must be a bool")
294
+ if not isinstance(target_custom_scale_factor, dict):
295
+ raise TypeError("Target custom scale factor must be a dict")
296
+ if num_threads is not None:
297
+ if not isinstance(num_threads, int) or num_threads <= 0:
298
+ raise ValueError("Number of threads must be integer and > 0")
299
+ return func(
300
+ self,
301
+ subset_data,
302
+ target_data,
303
+ subset_directional_variables,
304
+ target_directional_variables,
305
+ subset_custom_scale_factor,
306
+ normalize_target_data,
307
+ target_custom_scale_factor,
308
+ num_threads,
309
+ )
310
+
311
+ return wrapper