glam-processing 0.2.0__py3-none-any.whl
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.
- glam_processing/__init__.py +0 -0
- glam_processing/cli.py +51 -0
- glam_processing/config/__init__.py +0 -0
- glam_processing/config/clms.py +39 -0
- glam_processing/config/settings.py +1 -0
- glam_processing/download.py +654 -0
- glam_processing/earthdata.py +733 -0
- glam_processing/exceptions.py +47 -0
- glam_processing/spectral.py +110 -0
- glam_processing-0.2.0.dist-info/METADATA +23 -0
- glam_processing-0.2.0.dist-info/RECORD +13 -0
- glam_processing-0.2.0.dist-info/WHEEL +4 -0
- glam_processing-0.2.0.dist-info/entry_points.txt +3 -0
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
class BadInputError(Exception):
|
|
2
|
+
def __init__(self, data):
|
|
3
|
+
self.data = data
|
|
4
|
+
|
|
5
|
+
def __str__(self):
|
|
6
|
+
return repr(self.data)
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
class UnavailableError(Exception):
|
|
10
|
+
"""
|
|
11
|
+
Error class indicating that a requested
|
|
12
|
+
file does not exist on the LADS DAAC.
|
|
13
|
+
"""
|
|
14
|
+
|
|
15
|
+
def __init__(self, data):
|
|
16
|
+
self.data = data
|
|
17
|
+
|
|
18
|
+
def __str__(self):
|
|
19
|
+
return repr(self.data)
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
class FileTypeError(TypeError):
|
|
23
|
+
"""
|
|
24
|
+
Error class indicating that there is
|
|
25
|
+
a problem with a raster file. The file format
|
|
26
|
+
may be incorrect, a requested subdataset may
|
|
27
|
+
not exist, or there may be another problem.
|
|
28
|
+
"""
|
|
29
|
+
|
|
30
|
+
def __init__(self, data):
|
|
31
|
+
self.data = data
|
|
32
|
+
|
|
33
|
+
def __str__(self):
|
|
34
|
+
return repr(self.data)
|
|
35
|
+
|
|
36
|
+
|
|
37
|
+
class UnsupportedError(Exception):
|
|
38
|
+
"""
|
|
39
|
+
Error class indicating that a dataset
|
|
40
|
+
is not currently supported.
|
|
41
|
+
"""
|
|
42
|
+
|
|
43
|
+
def __init__(self, data):
|
|
44
|
+
self.data = data
|
|
45
|
+
|
|
46
|
+
def __str__(self):
|
|
47
|
+
return repr(self.data)
|
|
@@ -0,0 +1,110 @@
|
|
|
1
|
+
import os
|
|
2
|
+
import logging
|
|
3
|
+
|
|
4
|
+
import numpy as np
|
|
5
|
+
|
|
6
|
+
logging.basicConfig(
|
|
7
|
+
format="%(asctime)s - %(message)s",
|
|
8
|
+
datefmt="%d-%b-%y %H:%M:%S",
|
|
9
|
+
level=logging.INFO,
|
|
10
|
+
)
|
|
11
|
+
log = logging.getLogger(__name__)
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
def calc_ndvi(red_array, nir_array) -> np.array:
|
|
15
|
+
"""
|
|
16
|
+
A function to robustly build an NDVI array from two
|
|
17
|
+
arrays (red and NIR) of the same shape.
|
|
18
|
+
|
|
19
|
+
Resulting array is scaled by 10000, with values stored
|
|
20
|
+
as integers. Nodata value is -3000.
|
|
21
|
+
|
|
22
|
+
...
|
|
23
|
+
|
|
24
|
+
Parameters
|
|
25
|
+
----------
|
|
26
|
+
|
|
27
|
+
red_array: numpy.array
|
|
28
|
+
Array of red reflectances
|
|
29
|
+
nir_array: numpy.array
|
|
30
|
+
Array of near-infrared reflectances
|
|
31
|
+
|
|
32
|
+
"""
|
|
33
|
+
|
|
34
|
+
# perform NDVI generation
|
|
35
|
+
ndvi = np.divide((nir_array - red_array), (nir_array + red_array))
|
|
36
|
+
|
|
37
|
+
# rescale and replace infinities
|
|
38
|
+
ndvi = ndvi * 10000
|
|
39
|
+
ndvi[ndvi == np.inf] = -3000
|
|
40
|
+
ndvi[ndvi == -np.inf] = -3000
|
|
41
|
+
ndvi = ndvi.astype(int)
|
|
42
|
+
|
|
43
|
+
# return array
|
|
44
|
+
return ndvi
|
|
45
|
+
|
|
46
|
+
|
|
47
|
+
def calcGcvi(green_array, nir_array) -> np.array:
|
|
48
|
+
"""
|
|
49
|
+
A function to robustly build a GCVI array from two
|
|
50
|
+
arrays (green and NIR) of the same shape.
|
|
51
|
+
|
|
52
|
+
Resulting array is scaled by 10000, with values stored
|
|
53
|
+
as integers. Nodata value is -3000.
|
|
54
|
+
|
|
55
|
+
...
|
|
56
|
+
|
|
57
|
+
Parameters
|
|
58
|
+
----------
|
|
59
|
+
|
|
60
|
+
green_array: numpy.array
|
|
61
|
+
Array of green reflectances
|
|
62
|
+
nir_array: numpy.array
|
|
63
|
+
Array of near-infrared reflectances
|
|
64
|
+
|
|
65
|
+
"""
|
|
66
|
+
|
|
67
|
+
# perform NDVI generation
|
|
68
|
+
gcvi = np.divide(nir_array, green_array) - 1
|
|
69
|
+
|
|
70
|
+
# rescale and replace infinities
|
|
71
|
+
gcvi = gcvi * 10000
|
|
72
|
+
gcvi[gcvi == np.inf] = -3000
|
|
73
|
+
gcvi[gcvi == -np.inf] = -3000
|
|
74
|
+
gcvi = gcvi.astype(int)
|
|
75
|
+
|
|
76
|
+
# return array
|
|
77
|
+
return gcvi
|
|
78
|
+
|
|
79
|
+
|
|
80
|
+
def calc_ndwi(nir_array, swir_array) -> np.array:
|
|
81
|
+
"""
|
|
82
|
+
A function to robustly build an NDWI array from two
|
|
83
|
+
arrays (SWIR and NIR) of the same shape.
|
|
84
|
+
|
|
85
|
+
Resulting array is scaled by 10000, with values stored
|
|
86
|
+
as integers. Nodata value is -3000.
|
|
87
|
+
|
|
88
|
+
...
|
|
89
|
+
|
|
90
|
+
Parameters
|
|
91
|
+
----------
|
|
92
|
+
|
|
93
|
+
nir_array: numpy.array
|
|
94
|
+
Array of near-infrared reflectances
|
|
95
|
+
swir_array: numpy.array
|
|
96
|
+
Array of shortwave infrared reflectances
|
|
97
|
+
|
|
98
|
+
"""
|
|
99
|
+
|
|
100
|
+
# perform NDVI generation
|
|
101
|
+
ndwi = np.divide((nir_array - swir_array), (nir_array + swir_array))
|
|
102
|
+
|
|
103
|
+
# rescale and replace infinities
|
|
104
|
+
ndwi = ndwi * 10000
|
|
105
|
+
ndwi[ndwi == np.inf] = -3000
|
|
106
|
+
ndwi[ndwi == -np.inf] = -3000
|
|
107
|
+
ndwi = ndwi.astype(int)
|
|
108
|
+
|
|
109
|
+
# return array
|
|
110
|
+
return ndwi
|
|
@@ -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,13 @@
|
|
|
1
|
+
glam_processing/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
2
|
+
glam_processing/cli.py,sha256=nMtCZd3GLaLaYbzo8pb-xP-vw5Vy0OG0VhYLGTQj6xY,1292
|
|
3
|
+
glam_processing/config/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
4
|
+
glam_processing/config/clms.py,sha256=kzLYyXeV_BQ8Hjv1uu1PHqYqXVquB4EmisY75pSwyts,1034
|
|
5
|
+
glam_processing/config/settings.py,sha256=AbpHGcgLb-kRsJGnwFEktk7uzpZOCcBY74-YBdrKVGs,1
|
|
6
|
+
glam_processing/download.py,sha256=Fu-apmeXULcm5XVe-26P6rzaEVbfFg_KQxtnEm3ajqM,22194
|
|
7
|
+
glam_processing/earthdata.py,sha256=Dx1RnzNsfpdEcY7Gh40fwsxbyMLbFsOBwcflOBkqZj8,25603
|
|
8
|
+
glam_processing/exceptions.py,sha256=C2gPReRS2ksTkH6-jZ0vbXk0zMW02Jjwq8yiceK4MeM,979
|
|
9
|
+
glam_processing/spectral.py,sha256=rKzxlkcJMmt_BT5DlttQ6g3b4hfPu9Q7QsrfhJ6qq4k,2436
|
|
10
|
+
glam_processing-0.2.0.dist-info/METADATA,sha256=LADF8jzcfk8IKgCnhQk6YTxYcURL2mt2yLKjrPLWYII,768
|
|
11
|
+
glam_processing-0.2.0.dist-info/WHEEL,sha256=sP946D7jFCHeNz5Iq4fL4Lu-PrWrFsgfLXbbkciIZwg,88
|
|
12
|
+
glam_processing-0.2.0.dist-info/entry_points.txt,sha256=JNynmpzaVwSF-603cvddgM2-rwmXF4inaynR2i0H1S8,48
|
|
13
|
+
glam_processing-0.2.0.dist-info/RECORD,,
|