glam-processing 0.2.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.
@@ -0,0 +1,23 @@
1
+ Metadata-Version: 2.1
2
+ Name: glam-processing
3
+ Version: 0.2.0
4
+ Summary:
5
+ Author: John Keniston
6
+ Author-email: jfkeniston@gmail.com
7
+ Requires-Python: >=3.11,<4.0
8
+ Classifier: Programming Language :: Python :: 3
9
+ Classifier: Programming Language :: Python :: 3.11
10
+ Classifier: Programming Language :: Python :: 3.12
11
+ Requires-Dist: cryptography (>=43.0.0,<44.0.0)
12
+ Requires-Dist: earthaccess (>=0.10.0,<0.11.0)
13
+ Requires-Dist: h5py (>=3.11.0,<4.0.0)
14
+ Requires-Dist: pyjwt (>=2.9.0,<3.0.0)
15
+ Requires-Dist: rasterio (>=1.3.10,<2.0.0)
16
+ Requires-Dist: rio-cogeo (>=5.3.3,<6.0.0)
17
+ Requires-Dist: rioxarray (>=0.17.0,<0.18.0)
18
+ Description-Content-Type: text/markdown
19
+
20
+ # GLAM Processing Toolkit
21
+
22
+ A Python library to download and process imagery used in the Harvest GLAM API & Web Application.
23
+
@@ -0,0 +1,3 @@
1
+ # GLAM Processing Toolkit
2
+
3
+ A Python library to download and process imagery used in the Harvest GLAM API & Web Application.
File without changes
@@ -0,0 +1,51 @@
1
+ import sys
2
+
3
+ import click
4
+
5
+
6
+ @click.group()
7
+ def cli():
8
+ """Glam Processing Tools"""
9
+ pass
10
+
11
+
12
+ @cli.command()
13
+ @click.option("-s", "--strategy", default="interactive", type=str)
14
+ @click.option("-p", "--persist", default=True, type=bool)
15
+ def auth(strategy, persist):
16
+ """Authenticate earthaccess with NASA Earthdata credentials"""
17
+ from .earthdata import authenticate
18
+
19
+ authenticated = authenticate()
20
+
21
+ click.echo(
22
+ "Successfully authenticated!" if authenticated else "Failed to authenticate"
23
+ )
24
+
25
+
26
+ @cli.command()
27
+ def list():
28
+ """List supported products"""
29
+ from .download import SUPPORTED_DATASETS
30
+
31
+ click.echo(f"Supported product datasets: {SUPPORTED_DATASETS}")
32
+
33
+
34
+ @cli.command()
35
+ @click.argument("dataset-id", type=str)
36
+ def info(dataset_id):
37
+ """Get info on supported products"""
38
+ from .download import Downloader, SUPPORTED_DATASETS, EARTHDATA_DATASETS
39
+
40
+ if dataset_id in SUPPORTED_DATASETS:
41
+ if dataset_id in EARTHDATA_DATASETS:
42
+ downloader = Downloader(dataset_id)
43
+ click.echo(downloader.info())
44
+ else:
45
+ click.echo(f"Summary information for {dataset_id} not available")
46
+ else:
47
+ click.echo(f"Dataset {dataset_id} not found in list of supported datasets")
48
+
49
+
50
+ if __name__ == "__main__":
51
+ cli()
@@ -0,0 +1,39 @@
1
+ import os
2
+ import json
3
+ import requests
4
+ import jwt
5
+ import time
6
+
7
+ CLMS_URL = "https://land.copernicus.eu"
8
+
9
+
10
+ def get_clms_token():
11
+ # Load saved key from filesystem
12
+
13
+ service_key_file = os.environ.get("CLMS_KEY_FILE", "clms-key.json")
14
+ service_key = json.load(open(service_key_file, "rb"))
15
+
16
+ private_key = service_key["private_key"].encode("utf-8")
17
+
18
+ claim_set = {
19
+ "iss": service_key["client_id"],
20
+ "sub": service_key["user_id"],
21
+ "aud": service_key["token_uri"],
22
+ "iat": int(time.time()),
23
+ "exp": int(time.time() + (60 * 60)),
24
+ }
25
+ grant = jwt.encode(claim_set, private_key, algorithm="RS256")
26
+
27
+ resp = requests.post(
28
+ f"{CLMS_URL}/@@oauth2-token",
29
+ headers={
30
+ "Accept": "application/json",
31
+ "Content-Type": "application/x-www-form-urlencoded",
32
+ },
33
+ data={
34
+ "grant_type": "urn:ietf:params:oauth:grant-type:jwt-bearer",
35
+ "assertion": grant,
36
+ },
37
+ )
38
+
39
+ return resp.json().get("access_token", None)