sustax-client 0.1.2__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.
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2020-2026 Geoskop Sociedad Limitada
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 all
13
+ 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 THE
21
+ SOFTWARE.
@@ -0,0 +1,224 @@
1
+ Metadata-Version: 2.1
2
+ Name: sustax-client
3
+ Version: 0.1.2
4
+ Summary: Python client and CSV parser for the Sustax User API (SUA)
5
+ Author-email: Geoskop Sociedad Limitada <info@geoskop.tech>
6
+ License: MIT
7
+ Project-URL: Homepage, https://sustax.earth
8
+ Project-URL: Documentation, https://sustax.earth/docs/workflows-and-pipelines-how-to-pass-sustax-data-to-different-interpreters-2/
9
+ Project-URL: Source, https://gitlab.com/joan.saladich/sustax-client
10
+ Project-URL: Issues, https://gitlab.com/joan.saladich/sustax-client/-/issues
11
+ Keywords: sustax,climate,api,csv,geoskop
12
+ Classifier: Development Status :: 3 - Alpha
13
+ Classifier: Intended Audience :: Developers
14
+ Classifier: Intended Audience :: Science/Research
15
+ Classifier: License :: OSI Approved :: MIT License
16
+ Classifier: Operating System :: OS Independent
17
+ Classifier: Programming Language :: Python :: 3
18
+ Classifier: Programming Language :: Python :: 3 :: Only
19
+ Classifier: Programming Language :: Python :: 3.9
20
+ Classifier: Programming Language :: Python :: 3.10
21
+ Classifier: Programming Language :: Python :: 3.11
22
+ Classifier: Programming Language :: Python :: 3.12
23
+ Classifier: Programming Language :: Python :: 3.13
24
+ Classifier: Programming Language :: Python :: 3.14
25
+ Classifier: Topic :: Scientific/Engineering
26
+ Classifier: Topic :: Software Development :: Libraries :: Python Modules
27
+ Requires-Python: >=3.9
28
+ Description-Content-Type: text/markdown
29
+ License-File: LICENSE
30
+ Requires-Dist: numpy>=1.24
31
+ Requires-Dist: pandas>=2.0
32
+ Requires-Dist: requests>=2.31
33
+ Requires-Dist: urllib3>=2.0
34
+ Provides-Extra: dev
35
+ Requires-Dist: build>=1.2; extra == "dev"
36
+ Requires-Dist: pytest>=8.0; extra == "dev"
37
+ Requires-Dist: twine>=5.0; extra == "dev"
38
+
39
+ # sustax-client
40
+
41
+ A small Python package for the **Sustax User API** and for parsing the Sustax global climate models by means of CSV files exported by Sustax (see https://sustax.earth). This repository is prepared in a standard `src/` layout so it can be:
42
+
43
+ - developed locally with `pip install -e .`
44
+ - published to the GitLab PyPI registry
45
+ - later published to PyPI after a final package-name check
46
+
47
+ ## What is included
48
+
49
+ - `SustaxClient` for authentication, catalog lookup, pricing, purchases, downloads, status polling, coordinates, and balance checks
50
+ - `load_sustax_file()` to load Sustax CSV files into pandas DataFrames or nested numpy-friendly dictionaries
51
+ - tests for the parser and client input validation
52
+ - Python and R examples
53
+ - GitLab CI config for build and package publishing
54
+
55
+ ## Repository layout
56
+
57
+ ```text
58
+ sustax-client/
59
+ ├── .gitignore
60
+ ├── .gitlab-ci.yml
61
+ ├── LICENSE
62
+ ├── README.md
63
+ ├── pyproject.toml
64
+ ├── src/
65
+ │ └── sustax_client/
66
+ │ ├── __init__.py
67
+ │ ├── client.py
68
+ │ └── parser.py
69
+ ├── tests/
70
+ │ ├── test_client.py
71
+ │ └── test_parser.py
72
+ └── examples/
73
+ ├── python/
74
+ │ └── quickstart.py
75
+ └── r/
76
+ └── quickstart.R
77
+ ```
78
+
79
+ ## Installation
80
+
81
+ ### Local development
82
+
83
+ ```bash
84
+ python -m venv .venv
85
+ source .venv/bin/activate
86
+ python -m pip install --upgrade pip
87
+ python -m pip install -e .[dev]
88
+ ```
89
+
90
+ ### From a package registry
91
+
92
+ Once published:
93
+
94
+ ```bash
95
+ pip install sustax-client
96
+ ```
97
+
98
+ If you publish first to the GitLab package registry, use that registry URL in `pip` or `.pypirc`.
99
+
100
+ ## Quick start
101
+
102
+ ### 1. Authenticate and inspect the catalog
103
+
104
+ ```python
105
+ from sustax_client import SustaxClient
106
+
107
+ with SustaxClient() as client:
108
+ client.authenticate("your_username", "your_password")
109
+ catalog = client.get_variables_id()
110
+ print(catalog)
111
+ ```
112
+
113
+ ### 2. Preview pricing for a point request
114
+
115
+ ```python
116
+ from sustax_client import SustaxClient
117
+
118
+ with SustaxClient() as client:
119
+ client.authenticate("your_username", "your_password")
120
+ quote = client.view_price_request(
121
+ lat=41.3874,
122
+ lon=2.1686,
123
+ year_from=2020,
124
+ year_to=2030,
125
+ sustax_code_ids=[12345],
126
+ )
127
+ print(quote)
128
+ ```
129
+
130
+ ### 3. Buy, download, and unzip a request
131
+
132
+ ```python
133
+ from sustax_client import SustaxClient
134
+
135
+ with SustaxClient() as client:
136
+ client.authenticate("your_username", "your_password")
137
+ request_info = client.buy_data(
138
+ lat=41.3874,
139
+ lon=2.1686,
140
+ year_from=2020,
141
+ year_to=2030,
142
+ sustax_code_ids=[12345],
143
+ acceptance_sustax_disclaimer=True,
144
+ )
145
+ zip_path = client.download_file(request_info["url"], dest_dir="downloads")
146
+ extracted = client.unzip_download(dest_dir="downloads/unzipped")
147
+ print(zip_path)
148
+ print(extracted)
149
+ ```
150
+
151
+ ### 4. Load a Sustax CSV with pandas
152
+
153
+ ```python
154
+ from sustax_client import load_sustax_file
155
+
156
+ climate_df, metrics_df, metadata = load_sustax_file(
157
+ "downloads/unzipped/example.csv",
158
+ return_pandas_df=True,
159
+ return_metadata=True,
160
+ )
161
+
162
+ print(climate_df.head())
163
+ print(metrics_df.head())
164
+ print(metadata)
165
+ ```
166
+
167
+ ## Supported request modes
168
+
169
+ The packaged client supports the three location modes described in the Sustax documentation:
170
+
171
+ - point coordinates: `lat`, `lon`
172
+ - ROI / bounding box: `lat=[north, south]`, `lon=[west, east]`
173
+ - postal code lookup: `postal_code`, `country`
174
+
175
+ ## CSV parser behavior
176
+
177
+ `load_sustax_file()` assumes the exported file is a Sustax CSV with three main blocks:
178
+
179
+ - metadata
180
+ - accuracy metrics
181
+ - climate payload time series
182
+
183
+ By default it returns two pandas DataFrames:
184
+
185
+ - climate payload indexed by time
186
+ - metrics indexed by scenario
187
+
188
+ Set `return_pandas_df=False` if you prefer nested dictionaries and a numpy datetime array.
189
+
190
+ ## Development
191
+
192
+ Run tests:
193
+
194
+ ```bash
195
+ pytest
196
+ ```
197
+
198
+ Build distributions:
199
+
200
+ ```bash
201
+ python -m build
202
+ ```
203
+
204
+ ## Publish to GitLab package registry
205
+
206
+ The included `.gitlab-ci.yml` publishes a package with `build` and `twine` when a tag is pushed.
207
+
208
+ Required CI variables:
209
+
210
+ - `TWINE_USERNAME`
211
+ - `TWINE_PASSWORD`
212
+
213
+ ## Before publishing to PyPI
214
+
215
+ Do these checks first:
216
+
217
+ 1. Confirm the final package name is available on PyPI.
218
+ 2. Confirm the project license you want to use.
219
+ 3. Replace the placeholder contact metadata in `pyproject.toml` if needed.
220
+ 4. Decide whether examples should stay in the main repo or move to docs.
221
+
222
+ ## License
223
+
224
+ MIT
@@ -0,0 +1,186 @@
1
+ # sustax-client
2
+
3
+ A small Python package for the **Sustax User API** and for parsing the Sustax global climate models by means of CSV files exported by Sustax (see https://sustax.earth). This repository is prepared in a standard `src/` layout so it can be:
4
+
5
+ - developed locally with `pip install -e .`
6
+ - published to the GitLab PyPI registry
7
+ - later published to PyPI after a final package-name check
8
+
9
+ ## What is included
10
+
11
+ - `SustaxClient` for authentication, catalog lookup, pricing, purchases, downloads, status polling, coordinates, and balance checks
12
+ - `load_sustax_file()` to load Sustax CSV files into pandas DataFrames or nested numpy-friendly dictionaries
13
+ - tests for the parser and client input validation
14
+ - Python and R examples
15
+ - GitLab CI config for build and package publishing
16
+
17
+ ## Repository layout
18
+
19
+ ```text
20
+ sustax-client/
21
+ ├── .gitignore
22
+ ├── .gitlab-ci.yml
23
+ ├── LICENSE
24
+ ├── README.md
25
+ ├── pyproject.toml
26
+ ├── src/
27
+ │ └── sustax_client/
28
+ │ ├── __init__.py
29
+ │ ├── client.py
30
+ │ └── parser.py
31
+ ├── tests/
32
+ │ ├── test_client.py
33
+ │ └── test_parser.py
34
+ └── examples/
35
+ ├── python/
36
+ │ └── quickstart.py
37
+ └── r/
38
+ └── quickstart.R
39
+ ```
40
+
41
+ ## Installation
42
+
43
+ ### Local development
44
+
45
+ ```bash
46
+ python -m venv .venv
47
+ source .venv/bin/activate
48
+ python -m pip install --upgrade pip
49
+ python -m pip install -e .[dev]
50
+ ```
51
+
52
+ ### From a package registry
53
+
54
+ Once published:
55
+
56
+ ```bash
57
+ pip install sustax-client
58
+ ```
59
+
60
+ If you publish first to the GitLab package registry, use that registry URL in `pip` or `.pypirc`.
61
+
62
+ ## Quick start
63
+
64
+ ### 1. Authenticate and inspect the catalog
65
+
66
+ ```python
67
+ from sustax_client import SustaxClient
68
+
69
+ with SustaxClient() as client:
70
+ client.authenticate("your_username", "your_password")
71
+ catalog = client.get_variables_id()
72
+ print(catalog)
73
+ ```
74
+
75
+ ### 2. Preview pricing for a point request
76
+
77
+ ```python
78
+ from sustax_client import SustaxClient
79
+
80
+ with SustaxClient() as client:
81
+ client.authenticate("your_username", "your_password")
82
+ quote = client.view_price_request(
83
+ lat=41.3874,
84
+ lon=2.1686,
85
+ year_from=2020,
86
+ year_to=2030,
87
+ sustax_code_ids=[12345],
88
+ )
89
+ print(quote)
90
+ ```
91
+
92
+ ### 3. Buy, download, and unzip a request
93
+
94
+ ```python
95
+ from sustax_client import SustaxClient
96
+
97
+ with SustaxClient() as client:
98
+ client.authenticate("your_username", "your_password")
99
+ request_info = client.buy_data(
100
+ lat=41.3874,
101
+ lon=2.1686,
102
+ year_from=2020,
103
+ year_to=2030,
104
+ sustax_code_ids=[12345],
105
+ acceptance_sustax_disclaimer=True,
106
+ )
107
+ zip_path = client.download_file(request_info["url"], dest_dir="downloads")
108
+ extracted = client.unzip_download(dest_dir="downloads/unzipped")
109
+ print(zip_path)
110
+ print(extracted)
111
+ ```
112
+
113
+ ### 4. Load a Sustax CSV with pandas
114
+
115
+ ```python
116
+ from sustax_client import load_sustax_file
117
+
118
+ climate_df, metrics_df, metadata = load_sustax_file(
119
+ "downloads/unzipped/example.csv",
120
+ return_pandas_df=True,
121
+ return_metadata=True,
122
+ )
123
+
124
+ print(climate_df.head())
125
+ print(metrics_df.head())
126
+ print(metadata)
127
+ ```
128
+
129
+ ## Supported request modes
130
+
131
+ The packaged client supports the three location modes described in the Sustax documentation:
132
+
133
+ - point coordinates: `lat`, `lon`
134
+ - ROI / bounding box: `lat=[north, south]`, `lon=[west, east]`
135
+ - postal code lookup: `postal_code`, `country`
136
+
137
+ ## CSV parser behavior
138
+
139
+ `load_sustax_file()` assumes the exported file is a Sustax CSV with three main blocks:
140
+
141
+ - metadata
142
+ - accuracy metrics
143
+ - climate payload time series
144
+
145
+ By default it returns two pandas DataFrames:
146
+
147
+ - climate payload indexed by time
148
+ - metrics indexed by scenario
149
+
150
+ Set `return_pandas_df=False` if you prefer nested dictionaries and a numpy datetime array.
151
+
152
+ ## Development
153
+
154
+ Run tests:
155
+
156
+ ```bash
157
+ pytest
158
+ ```
159
+
160
+ Build distributions:
161
+
162
+ ```bash
163
+ python -m build
164
+ ```
165
+
166
+ ## Publish to GitLab package registry
167
+
168
+ The included `.gitlab-ci.yml` publishes a package with `build` and `twine` when a tag is pushed.
169
+
170
+ Required CI variables:
171
+
172
+ - `TWINE_USERNAME`
173
+ - `TWINE_PASSWORD`
174
+
175
+ ## Before publishing to PyPI
176
+
177
+ Do these checks first:
178
+
179
+ 1. Confirm the final package name is available on PyPI.
180
+ 2. Confirm the project license you want to use.
181
+ 3. Replace the placeholder contact metadata in `pyproject.toml` if needed.
182
+ 4. Decide whether examples should stay in the main repo or move to docs.
183
+
184
+ ## License
185
+
186
+ MIT
@@ -0,0 +1,63 @@
1
+ [build-system]
2
+ requires = ["setuptools==68.2.2", "wheel"]
3
+ build-backend = "setuptools.build_meta"
4
+
5
+ [project]
6
+ name = "sustax-client"
7
+ version = "0.1.2"
8
+ description = "Python client and CSV parser for the Sustax User API (SUA)"
9
+ readme = "README.md"
10
+ requires-python = ">=3.9"
11
+ license = {text = "MIT"}
12
+ authors = [
13
+ {name = "Geoskop Sociedad Limitada", email = "info@geoskop.tech"}
14
+ ]
15
+ keywords = ["sustax", "climate", "api", "csv", "geoskop"]
16
+ classifiers = [
17
+ "Development Status :: 3 - Alpha",
18
+ "Intended Audience :: Developers",
19
+ "Intended Audience :: Science/Research",
20
+ "License :: OSI Approved :: MIT License",
21
+ "Operating System :: OS Independent",
22
+ "Programming Language :: Python :: 3",
23
+ "Programming Language :: Python :: 3 :: Only",
24
+ "Programming Language :: Python :: 3.9",
25
+ "Programming Language :: Python :: 3.10",
26
+ "Programming Language :: Python :: 3.11",
27
+ "Programming Language :: Python :: 3.12",
28
+ "Programming Language :: Python :: 3.13",
29
+ "Programming Language :: Python :: 3.14",
30
+ "Topic :: Scientific/Engineering",
31
+ "Topic :: Software Development :: Libraries :: Python Modules"
32
+ ]
33
+ dependencies = [
34
+ "numpy>=1.24",
35
+ "pandas>=2.0",
36
+ "requests>=2.31",
37
+ "urllib3>=2.0"
38
+ ]
39
+
40
+ [project.optional-dependencies]
41
+ dev = [
42
+ "build>=1.2",
43
+ "pytest>=8.0",
44
+ "twine>=5.0"
45
+ ]
46
+
47
+ [project.urls]
48
+ Homepage = "https://sustax.earth"
49
+ Documentation = "https://sustax.earth/docs/workflows-and-pipelines-how-to-pass-sustax-data-to-different-interpreters-2/"
50
+ Source = "https://gitlab.com/joan.saladich/sustax-client"
51
+ Issues = "https://gitlab.com/joan.saladich/sustax-client/-/issues"
52
+
53
+ [tool.setuptools]
54
+ package-dir = {"" = "src"}
55
+ include-package-data = false
56
+
57
+ [tool.setuptools.packages.find]
58
+ where = ["src"]
59
+
60
+ [tool.pytest.ini_options]
61
+ minversion = "8.0"
62
+ addopts = "-q"
63
+ testpaths = ["tests"]
@@ -0,0 +1,4 @@
1
+ [egg_info]
2
+ tag_build =
3
+ tag_date = 0
4
+
@@ -0,0 +1,11 @@
1
+ """sustax-client: Python package for the Sustax User API and CSV parsing."""
2
+
3
+ from .client import SustaxClient
4
+ from .parser import load_sustax_file
5
+
6
+ __all__ = [
7
+ "SustaxClient",
8
+ "load_sustax_file",
9
+ ]
10
+
11
+ __version__ = "0.1.1"