jua 0.1.0__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 (66) hide show
  1. jua-0.1.0/.gitignore +177 -0
  2. jua-0.1.0/.pre-commit-config.yaml +38 -0
  3. jua-0.1.0/.vscode/settings.json +12 -0
  4. jua-0.1.0/LICENSE +21 -0
  5. jua-0.1.0/PKG-INFO +130 -0
  6. jua-0.1.0/README.md +98 -0
  7. jua-0.1.0/examples/weather/compare_forecast_for_location.ipynb +151 -0
  8. jua-0.1.0/examples/weather/europe_forecast_delta.ipynb +230 -0
  9. jua-0.1.0/examples/weather/extreme_event_detector.ipynb +168 -0
  10. jua-0.1.0/examples/weather/forecast.py +56 -0
  11. jua-0.1.0/examples/weather/forecast_global.py +127 -0
  12. jua-0.1.0/examples/weather/forecast_multiple_models.py +35 -0
  13. jua-0.1.0/examples/weather/hindcast.py +50 -0
  14. jua-0.1.0/justfile +13 -0
  15. jua-0.1.0/pyproject.toml +96 -0
  16. jua-0.1.0/src/jua/__init__.py +4 -0
  17. jua-0.1.0/src/jua/_api.py +218 -0
  18. jua-0.1.0/src/jua/_utils/__init__.py +0 -0
  19. jua-0.1.0/src/jua/_utils/dataset.py +177 -0
  20. jua-0.1.0/src/jua/_utils/optional_progress_bar.py +47 -0
  21. jua-0.1.0/src/jua/_utils/remove_none_from_dict.py +32 -0
  22. jua-0.1.0/src/jua/_utils/spinner.py +86 -0
  23. jua-0.1.0/src/jua/client.py +50 -0
  24. jua-0.1.0/src/jua/errors/__init__.py +0 -0
  25. jua-0.1.0/src/jua/errors/api_errors.py +53 -0
  26. jua-0.1.0/src/jua/errors/jua_error.py +19 -0
  27. jua-0.1.0/src/jua/errors/model_errors.py +45 -0
  28. jua-0.1.0/src/jua/logging.py +50 -0
  29. jua-0.1.0/src/jua/py.typed +0 -0
  30. jua-0.1.0/src/jua/scripts/__init__.py +0 -0
  31. jua-0.1.0/src/jua/scripts/auth.py +27 -0
  32. jua-0.1.0/src/jua/scripts/jua.py +32 -0
  33. jua-0.1.0/src/jua/settings/__init__.py +4 -0
  34. jua-0.1.0/src/jua/settings/authentication.py +131 -0
  35. jua-0.1.0/src/jua/settings/jua_settings.py +79 -0
  36. jua-0.1.0/src/jua/types/__init__.py +0 -0
  37. jua-0.1.0/src/jua/types/geo.py +43 -0
  38. jua-0.1.0/src/jua/weather/__init__.py +4 -0
  39. jua-0.1.0/src/jua/weather/_api.py +163 -0
  40. jua-0.1.0/src/jua/weather/_jua_dataset.py +121 -0
  41. jua-0.1.0/src/jua/weather/_model.py +42 -0
  42. jua-0.1.0/src/jua/weather/_model_meta.py +64 -0
  43. jua-0.1.0/src/jua/weather/_types/__init__.py +1 -0
  44. jua-0.1.0/src/jua/weather/_types/api_payload_types.py +11 -0
  45. jua-0.1.0/src/jua/weather/_types/api_response_types.py +33 -0
  46. jua-0.1.0/src/jua/weather/_types/forecast.py +124 -0
  47. jua-0.1.0/src/jua/weather/_types/raw_file_access.py +19 -0
  48. jua-0.1.0/src/jua/weather/_weather.py +34 -0
  49. jua-0.1.0/src/jua/weather/_xarray_patches.py +409 -0
  50. jua-0.1.0/src/jua/weather/conversions.py +64 -0
  51. jua-0.1.0/src/jua/weather/forecast.py +426 -0
  52. jua-0.1.0/src/jua/weather/hindcast.py +282 -0
  53. jua-0.1.0/src/jua/weather/models.py +31 -0
  54. jua-0.1.0/src/jua/weather/variables.py +275 -0
  55. jua-0.1.0/tests/__init__.py +0 -0
  56. jua-0.1.0/tests/_utils/__init__.py +0 -0
  57. jua-0.1.0/tests/_utils/test_remove_none_from_dict.py +15 -0
  58. jua-0.1.0/tests/settings/__init__.py +0 -0
  59. jua-0.1.0/tests/settings/conftest.py +42 -0
  60. jua-0.1.0/tests/settings/test_authentication.py +201 -0
  61. jua-0.1.0/tests/settings/test_jua_settings.py +90 -0
  62. jua-0.1.0/tests/types/__init__.py +0 -0
  63. jua-0.1.0/tests/types/test_geo.py +17 -0
  64. jua-0.1.0/tests/weather/__init__.py +0 -0
  65. jua-0.1.0/tests/weather/test_xarray_patches.py +113 -0
  66. jua-0.1.0/uv.lock +2033 -0
jua-0.1.0/.gitignore ADDED
@@ -0,0 +1,177 @@
1
+ .python-version
2
+
3
+ # Byte-compiled / optimized / DLL files
4
+ __pycache__/
5
+ *.py[cod]
6
+ *$py.class
7
+
8
+ # C extensions
9
+ *.so
10
+
11
+ # Distribution / packaging
12
+ .Python
13
+ build/
14
+ develop-eggs/
15
+ dist/
16
+ downloads/
17
+ eggs/
18
+ .eggs/
19
+ lib/
20
+ lib64/
21
+ parts/
22
+ sdist/
23
+ var/
24
+ wheels/
25
+ share/python-wheels/
26
+ *.egg-info/
27
+ .installed.cfg
28
+ *.egg
29
+ MANIFEST
30
+
31
+ # PyInstaller
32
+ # Usually these files are written by a python script from a template
33
+ # before PyInstaller builds the exe, so as to inject date/other infos into it.
34
+ *.manifest
35
+ *.spec
36
+
37
+ # Installer logs
38
+ pip-log.txt
39
+ pip-delete-this-directory.txt
40
+
41
+ # Unit test / coverage reports
42
+ htmlcov/
43
+ .tox/
44
+ .nox/
45
+ .coverage
46
+ .coverage.*
47
+ .cache
48
+ nosetests.xml
49
+ coverage.xml
50
+ *.cover
51
+ *.py,cover
52
+ .hypothesis/
53
+ .pytest_cache/
54
+ cover/
55
+
56
+ # Translations
57
+ *.mo
58
+ *.pot
59
+
60
+ # Django stuff:
61
+ *.log
62
+ local_settings.py
63
+ db.sqlite3
64
+ db.sqlite3-journal
65
+
66
+ # Flask stuff:
67
+ instance/
68
+ .webassets-cache
69
+
70
+ # Scrapy stuff:
71
+ .scrapy
72
+
73
+ # Sphinx documentation
74
+ docs/_build/
75
+
76
+ # PyBuilder
77
+ .pybuilder/
78
+ target/
79
+
80
+ # Jupyter Notebook
81
+ .ipynb_checkpoints
82
+
83
+ # IPython
84
+ profile_default/
85
+ ipython_config.py
86
+
87
+ # pyenv
88
+ # For a library or package, you might want to ignore these files since the code is
89
+ # intended to run in multiple environments; otherwise, check them in:
90
+ # .python-version
91
+
92
+ # pipenv
93
+ # According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control.
94
+ # However, in case of collaboration, if having platform-specific dependencies or dependencies
95
+ # having no cross-platform support, pipenv may install dependencies that don't work, or not
96
+ # install all needed dependencies.
97
+ #Pipfile.lock
98
+
99
+ # UV
100
+ # Similar to Pipfile.lock, it is generally recommended to include uv.lock in version control.
101
+ # This is especially recommended for binary packages to ensure reproducibility, and is more
102
+ # commonly ignored for libraries.
103
+ #uv.lock
104
+
105
+ # poetry
106
+ # Similar to Pipfile.lock, it is generally recommended to include poetry.lock in version control.
107
+ # This is especially recommended for binary packages to ensure reproducibility, and is more
108
+ # commonly ignored for libraries.
109
+ # https://python-poetry.org/docs/basic-usage/#commit-your-poetrylock-file-to-version-control
110
+ #poetry.lock
111
+
112
+ # pdm
113
+ # Similar to Pipfile.lock, it is generally recommended to include pdm.lock in version control.
114
+ #pdm.lock
115
+ # pdm stores project-wide configurations in .pdm.toml, but it is recommended to not include it
116
+ # in version control.
117
+ # https://pdm.fming.dev/latest/usage/project/#working-with-version-control
118
+ .pdm.toml
119
+ .pdm-python
120
+ .pdm-build/
121
+
122
+ # PEP 582; used by e.g. github.com/David-OConnor/pyflow and github.com/pdm-project/pdm
123
+ __pypackages__/
124
+
125
+ # Celery stuff
126
+ celerybeat-schedule
127
+ celerybeat.pid
128
+
129
+ # SageMath parsed files
130
+ *.sage.py
131
+
132
+ # Environments
133
+ .env
134
+ .venv
135
+ env/
136
+ venv/
137
+ ENV/
138
+ env.bak/
139
+ venv.bak/
140
+
141
+ # Spyder project settings
142
+ .spyderproject
143
+ .spyproject
144
+
145
+ # Rope project settings
146
+ .ropeproject
147
+
148
+ # mkdocs documentation
149
+ /site
150
+
151
+ # mypy
152
+ .mypy_cache/
153
+ .dmypy.json
154
+ dmypy.json
155
+
156
+ # Pyre type checker
157
+ .pyre/
158
+
159
+ # pytype static type analyzer
160
+ .pytype/
161
+
162
+ # Cython debug symbols
163
+ cython_debug/
164
+
165
+ # PyCharm
166
+ # JetBrains specific template is maintained in a separate JetBrains.gitignore that can
167
+ # be found at https://github.com/github/gitignore/blob/main/Global/JetBrains.gitignore
168
+ # and can be added to the global gitignore or merged into this file. For a more nuclear
169
+ # option (not recommended) you can uncomment the following to ignore the entire idea folder.
170
+ #.idea/
171
+
172
+ # Ruff stuff:
173
+ .ruff_cache/
174
+
175
+ # PyPI configuration file
176
+ .pypirc
177
+ playground/
@@ -0,0 +1,38 @@
1
+ repos:
2
+ - repo: https://github.com/pre-commit/pre-commit-hooks
3
+ rev: v5.0.0
4
+ hooks:
5
+ - id: trailing-whitespace
6
+ - id: end-of-file-fixer
7
+ - id: check-yaml
8
+ - id: check-toml
9
+ - id: check-added-large-files
10
+ - id: check-merge-conflict
11
+ - id: debug-statements
12
+ - id: detect-private-key
13
+
14
+ - repo: https://github.com/astral-sh/ruff-pre-commit
15
+ rev: v0.11.9
16
+ hooks:
17
+ - id: ruff
18
+ args: [--fix]
19
+ - id: ruff-format
20
+
21
+ - repo: https://github.com/pycqa/isort
22
+ rev: 6.0.1
23
+ hooks:
24
+ - id: isort
25
+ args: ["--profile", "black"]
26
+
27
+ - repo: https://github.com/kynan/nbstripout
28
+ rev: 0.8.1
29
+ hooks:
30
+ - id: nbstripout
31
+ exclude: ^examples/
32
+
33
+ - repo: https://github.com/pre-commit/mirrors-mypy
34
+ rev: v1.15.0
35
+ hooks:
36
+ - id: mypy
37
+ additional_dependencies: [pydantic]
38
+ exclude: ^tests/
@@ -0,0 +1,12 @@
1
+ {
2
+ "editor.defaultFormatter": null,
3
+ "editor.formatOnSave": true,
4
+ "[python]": {
5
+ "editor.defaultFormatter": "charliermarsh.ruff",
6
+ "editor.formatOnSave": true,
7
+ "editor.codeActionsOnSave": {
8
+ "source.organizeImports": "explicit",
9
+ "source.fixAll": "explicit"
10
+ }
11
+ }
12
+ }
jua-0.1.0/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ The MIT License
2
+
3
+ Copyright (c) 2025 Jua.ai AG (https://jua.ai/)
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in
13
+ all copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21
+ THE SOFTWARE.
jua-0.1.0/PKG-INFO ADDED
@@ -0,0 +1,130 @@
1
+ Metadata-Version: 2.4
2
+ Name: jua
3
+ Version: 0.1.0
4
+ Summary: Easy access to Jua's weather & power services
5
+ Project-URL: Documentation, https://docs.jua.ai
6
+ Project-URL: Source, https://github.com/juaAI/jua-python-sdk
7
+ Author-email: "Jua.ai AG" <contact@jua.ai>
8
+ License-Expression: MIT
9
+ License-File: LICENSE
10
+ Keywords: energy,energy trading,forecast,hindcast,power,trading,weather,weather forecast
11
+ Classifier: Development Status :: 4 - Beta
12
+ Classifier: Intended Audience :: Developers
13
+ Classifier: License :: OSI Approved :: MIT License
14
+ Classifier: Programming Language :: Python :: 3
15
+ Classifier: Programming Language :: Python :: 3.11
16
+ Requires-Python: >=3.11
17
+ Requires-Dist: aiohttp>=3.11.18
18
+ Requires-Dist: dask>=2025.4.1
19
+ Requires-Dist: fsspec>=2025.3.2
20
+ Requires-Dist: pandas>=2.2.3
21
+ Requires-Dist: pydantic-settings>=2.8.1
22
+ Requires-Dist: pydantic>=2.10.6
23
+ Requires-Dist: requests>=2.32.3
24
+ Requires-Dist: types-requests>=2.32.0.20250328
25
+ Requires-Dist: xarray>=2025.4.0
26
+ Requires-Dist: zarr>=3.0.0
27
+ Provides-Extra: examples
28
+ Requires-Dist: ipykernel>=6.29.5; extra == 'examples'
29
+ Provides-Extra: plotting
30
+ Requires-Dist: matplotlib>=3.8.0; extra == 'plotting'
31
+ Description-Content-Type: text/markdown
32
+
33
+ # Jua Python SDK
34
+
35
+ Access industry-leading weather forecasts wtih ease
36
+
37
+ ## Getting Started 🚀
38
+
39
+ ### Install
40
+
41
+ We strongly recommend using [uv](https://docs.astral.sh/uv/) to manage dependencies. `python>=3.11` is required.
42
+ TODO: Create PyPI entry
43
+
44
+ ### Authentication
45
+
46
+ TODO: After installing run `jua auth`. This will open your webbrowser for authentication.
47
+
48
+ Alternatively, generate an API Key [here](https://app.jua.sh/api-keys) and copy the file to `~/.jua/default/api-key.json`.
49
+
50
+ ### Access the latest 20-day forecast for a specific points
51
+
52
+ ```python
53
+ import matplotlib.pyplot as plt
54
+ from jua import JuaClient
55
+ from jua.types.geo import LatLon
56
+ from jua.weather import Models, Variables
57
+
58
+ client = JuaClient()
59
+ model = client.weather.get_model(Models.EPT1_5)
60
+ zurich = LatLon(lat=47.3769, lon=8.5417)
61
+ # Get latest forecast
62
+ forecast = model.forecast.get_forecast(
63
+ points=[zurich]
64
+ )
65
+ temp_data = forecast.to_xarray()[Variables.AIR_TEMPERATURE_AT_HEIGHT_LEVEL_2M]
66
+ temp_data.to_celcius().plot()
67
+ ```
68
+
69
+ ### Plot the global forecast with 10h lead time
70
+
71
+ ```python
72
+ import matplotlib.pyplot as plt
73
+ from jua import JuaClient
74
+ from jua.types.geo import LatLon
75
+ from jua.weather import Models, Variables
76
+
77
+ client = JuaClient()
78
+ model = client.weather.get_model(Models.EPT1_5)
79
+
80
+ lead_time = 10 # hours
81
+ dataset = model.forecast.get_forecast(
82
+ prediction_timedelta=lead_time,
83
+ variables=[
84
+ Variables.WIND_SPEED_AT_HEIGHT_LEVEL_10M,
85
+ ],
86
+ )
87
+ dataset[Variables.WIND_SPEED_AT_HEIGHT_LEVEL_10M].plot()
88
+ plt.show()
89
+ ```
90
+
91
+ ### Access historical data with ease
92
+
93
+ ```python
94
+ import matplotlib.pyplot as plt
95
+ from jua import JuaClient
96
+ from jua.types.geo import LatLon
97
+ from jua.weather import Models, Variables
98
+
99
+ client = JuaClient()
100
+ model = client.weather.get_model(Models.EPT1_5_EARLY)
101
+
102
+ init_time = "2024-02-01T06:00:00.000000000"
103
+ hindcast = model.hindcast.get_hindcast(
104
+ variables=[Variables.AIR_TEMPERATURE_AT_HEIGHT_LEVEL_2M],
105
+ init_time=init_time,
106
+ prediction_timedelta=0,
107
+ # Select Europe
108
+ latitude=slice(71, 36), # Note: slice is inverted
109
+ longitude=slice(-15, 50),
110
+ method="nearest",
111
+ )
112
+
113
+ data = hindcast.to_xarray()[Variables.AIR_TEMPERATURE_AT_HEIGHT_LEVEL_2M]
114
+ data.plot()
115
+ plt.show()
116
+ ```
117
+
118
+ ## Development
119
+
120
+ To install all dependencies run
121
+
122
+ ```
123
+ uv sync --all-extras
124
+ ```
125
+
126
+ Enable pre-commit for linting and formatting:
127
+
128
+ ```
129
+ uv run pre-commit install && uv run pre-commit install-hooks
130
+ ```
jua-0.1.0/README.md ADDED
@@ -0,0 +1,98 @@
1
+ # Jua Python SDK
2
+
3
+ Access industry-leading weather forecasts wtih ease
4
+
5
+ ## Getting Started 🚀
6
+
7
+ ### Install
8
+
9
+ We strongly recommend using [uv](https://docs.astral.sh/uv/) to manage dependencies. `python>=3.11` is required.
10
+ TODO: Create PyPI entry
11
+
12
+ ### Authentication
13
+
14
+ TODO: After installing run `jua auth`. This will open your webbrowser for authentication.
15
+
16
+ Alternatively, generate an API Key [here](https://app.jua.sh/api-keys) and copy the file to `~/.jua/default/api-key.json`.
17
+
18
+ ### Access the latest 20-day forecast for a specific points
19
+
20
+ ```python
21
+ import matplotlib.pyplot as plt
22
+ from jua import JuaClient
23
+ from jua.types.geo import LatLon
24
+ from jua.weather import Models, Variables
25
+
26
+ client = JuaClient()
27
+ model = client.weather.get_model(Models.EPT1_5)
28
+ zurich = LatLon(lat=47.3769, lon=8.5417)
29
+ # Get latest forecast
30
+ forecast = model.forecast.get_forecast(
31
+ points=[zurich]
32
+ )
33
+ temp_data = forecast.to_xarray()[Variables.AIR_TEMPERATURE_AT_HEIGHT_LEVEL_2M]
34
+ temp_data.to_celcius().plot()
35
+ ```
36
+
37
+ ### Plot the global forecast with 10h lead time
38
+
39
+ ```python
40
+ import matplotlib.pyplot as plt
41
+ from jua import JuaClient
42
+ from jua.types.geo import LatLon
43
+ from jua.weather import Models, Variables
44
+
45
+ client = JuaClient()
46
+ model = client.weather.get_model(Models.EPT1_5)
47
+
48
+ lead_time = 10 # hours
49
+ dataset = model.forecast.get_forecast(
50
+ prediction_timedelta=lead_time,
51
+ variables=[
52
+ Variables.WIND_SPEED_AT_HEIGHT_LEVEL_10M,
53
+ ],
54
+ )
55
+ dataset[Variables.WIND_SPEED_AT_HEIGHT_LEVEL_10M].plot()
56
+ plt.show()
57
+ ```
58
+
59
+ ### Access historical data with ease
60
+
61
+ ```python
62
+ import matplotlib.pyplot as plt
63
+ from jua import JuaClient
64
+ from jua.types.geo import LatLon
65
+ from jua.weather import Models, Variables
66
+
67
+ client = JuaClient()
68
+ model = client.weather.get_model(Models.EPT1_5_EARLY)
69
+
70
+ init_time = "2024-02-01T06:00:00.000000000"
71
+ hindcast = model.hindcast.get_hindcast(
72
+ variables=[Variables.AIR_TEMPERATURE_AT_HEIGHT_LEVEL_2M],
73
+ init_time=init_time,
74
+ prediction_timedelta=0,
75
+ # Select Europe
76
+ latitude=slice(71, 36), # Note: slice is inverted
77
+ longitude=slice(-15, 50),
78
+ method="nearest",
79
+ )
80
+
81
+ data = hindcast.to_xarray()[Variables.AIR_TEMPERATURE_AT_HEIGHT_LEVEL_2M]
82
+ data.plot()
83
+ plt.show()
84
+ ```
85
+
86
+ ## Development
87
+
88
+ To install all dependencies run
89
+
90
+ ```
91
+ uv sync --all-extras
92
+ ```
93
+
94
+ Enable pre-commit for linting and formatting:
95
+
96
+ ```
97
+ uv run pre-commit install && uv run pre-commit install-hooks
98
+ ```