mapchete-eo 2025.8.0__tar.gz → 2025.8.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.
- {mapchete_eo-2025.8.0 → mapchete_eo-2025.8.2}/PKG-INFO +2 -3
- mapchete_eo-2025.8.2/mapchete_eo/__init__.py +1 -0
- {mapchete_eo-2025.8.0 → mapchete_eo-2025.8.2}/mapchete_eo/base.py +6 -0
- mapchete_eo-2025.8.2/mapchete_eo/image_operations/blend_modes/blending_functions.py +198 -0
- mapchete_eo-2025.8.2/mapchete_eo/image_operations/blend_modes/type_checks.py +99 -0
- {mapchete_eo-2025.8.0 → mapchete_eo-2025.8.2}/mapchete_eo/image_operations/compositing.py +18 -16
- {mapchete_eo-2025.8.0 → mapchete_eo-2025.8.2}/pyproject.toml +1 -2
- mapchete_eo-2025.8.0/mapchete_eo/__init__.py +0 -1
- {mapchete_eo-2025.8.0 → mapchete_eo-2025.8.2}/.gitignore +0 -0
- {mapchete_eo-2025.8.0 → mapchete_eo-2025.8.2}/LICENSE +0 -0
- {mapchete_eo-2025.8.0 → mapchete_eo-2025.8.2}/README.rst +0 -0
- {mapchete_eo-2025.8.0 → mapchete_eo-2025.8.2}/mapchete_eo/archives/__init__.py +0 -0
- {mapchete_eo-2025.8.0 → mapchete_eo-2025.8.2}/mapchete_eo/archives/base.py +0 -0
- {mapchete_eo-2025.8.0 → mapchete_eo-2025.8.2}/mapchete_eo/array/__init__.py +0 -0
- {mapchete_eo-2025.8.0 → mapchete_eo-2025.8.2}/mapchete_eo/array/buffer.py +0 -0
- {mapchete_eo-2025.8.0 → mapchete_eo-2025.8.2}/mapchete_eo/array/color.py +0 -0
- {mapchete_eo-2025.8.0 → mapchete_eo-2025.8.2}/mapchete_eo/array/convert.py +0 -0
- {mapchete_eo-2025.8.0 → mapchete_eo-2025.8.2}/mapchete_eo/blacklist.txt +0 -0
- {mapchete_eo-2025.8.0 → mapchete_eo-2025.8.2}/mapchete_eo/cli/__init__.py +0 -0
- {mapchete_eo-2025.8.0 → mapchete_eo-2025.8.2}/mapchete_eo/cli/bounds.py +0 -0
- {mapchete_eo-2025.8.0 → mapchete_eo-2025.8.2}/mapchete_eo/cli/options_arguments.py +0 -0
- {mapchete_eo-2025.8.0 → mapchete_eo-2025.8.2}/mapchete_eo/cli/s2_brdf.py +0 -0
- {mapchete_eo-2025.8.0 → mapchete_eo-2025.8.2}/mapchete_eo/cli/s2_cat_results.py +0 -0
- {mapchete_eo-2025.8.0 → mapchete_eo-2025.8.2}/mapchete_eo/cli/s2_find_broken_products.py +0 -0
- {mapchete_eo-2025.8.0 → mapchete_eo-2025.8.2}/mapchete_eo/cli/s2_jp2_static_catalog.py +0 -0
- {mapchete_eo-2025.8.0 → mapchete_eo-2025.8.2}/mapchete_eo/cli/s2_mask.py +0 -0
- {mapchete_eo-2025.8.0 → mapchete_eo-2025.8.2}/mapchete_eo/cli/s2_mgrs.py +0 -0
- {mapchete_eo-2025.8.0 → mapchete_eo-2025.8.2}/mapchete_eo/cli/s2_rgb.py +0 -0
- {mapchete_eo-2025.8.0 → mapchete_eo-2025.8.2}/mapchete_eo/cli/s2_verify.py +0 -0
- {mapchete_eo-2025.8.0 → mapchete_eo-2025.8.2}/mapchete_eo/cli/static_catalog.py +0 -0
- {mapchete_eo-2025.8.0 → mapchete_eo-2025.8.2}/mapchete_eo/eostac.py +0 -0
- {mapchete_eo-2025.8.0 → mapchete_eo-2025.8.2}/mapchete_eo/exceptions.py +0 -0
- {mapchete_eo-2025.8.0 → mapchete_eo-2025.8.2}/mapchete_eo/geometry.py +0 -0
- {mapchete_eo-2025.8.0 → mapchete_eo-2025.8.2}/mapchete_eo/image_operations/__init__.py +0 -0
- {mapchete_eo-2025.8.0 → mapchete_eo-2025.8.2}/mapchete_eo/image_operations/color_correction.py +0 -0
- {mapchete_eo-2025.8.0 → mapchete_eo-2025.8.2}/mapchete_eo/image_operations/dtype_scale.py +0 -0
- {mapchete_eo-2025.8.0 → mapchete_eo-2025.8.2}/mapchete_eo/image_operations/fillnodata.py +0 -0
- {mapchete_eo-2025.8.0 → mapchete_eo-2025.8.2}/mapchete_eo/image_operations/filters.py +0 -0
- {mapchete_eo-2025.8.0 → mapchete_eo-2025.8.2}/mapchete_eo/image_operations/linear_normalization.py +0 -0
- {mapchete_eo-2025.8.0 → mapchete_eo-2025.8.2}/mapchete_eo/image_operations/sigmoidal.py +0 -0
- {mapchete_eo-2025.8.0 → mapchete_eo-2025.8.2}/mapchete_eo/io/__init__.py +0 -0
- {mapchete_eo-2025.8.0 → mapchete_eo-2025.8.2}/mapchete_eo/io/assets.py +0 -0
- {mapchete_eo-2025.8.0 → mapchete_eo-2025.8.2}/mapchete_eo/io/items.py +0 -0
- {mapchete_eo-2025.8.0 → mapchete_eo-2025.8.2}/mapchete_eo/io/levelled_cubes.py +0 -0
- {mapchete_eo-2025.8.0 → mapchete_eo-2025.8.2}/mapchete_eo/io/path.py +0 -0
- {mapchete_eo-2025.8.0 → mapchete_eo-2025.8.2}/mapchete_eo/io/products.py +0 -0
- {mapchete_eo-2025.8.0 → mapchete_eo-2025.8.2}/mapchete_eo/io/profiles.py +0 -0
- {mapchete_eo-2025.8.0 → mapchete_eo-2025.8.2}/mapchete_eo/known_catalogs.py +0 -0
- {mapchete_eo-2025.8.0 → mapchete_eo-2025.8.2}/mapchete_eo/platforms/sentinel2/__init__.py +0 -0
- {mapchete_eo-2025.8.0 → mapchete_eo-2025.8.2}/mapchete_eo/platforms/sentinel2/archives.py +0 -0
- {mapchete_eo-2025.8.0 → mapchete_eo-2025.8.2}/mapchete_eo/platforms/sentinel2/bandpass_adjustment.py +0 -0
- {mapchete_eo-2025.8.0 → mapchete_eo-2025.8.2}/mapchete_eo/platforms/sentinel2/brdf/__init__.py +0 -0
- {mapchete_eo-2025.8.0 → mapchete_eo-2025.8.2}/mapchete_eo/platforms/sentinel2/brdf/config.py +0 -0
- {mapchete_eo-2025.8.0 → mapchete_eo-2025.8.2}/mapchete_eo/platforms/sentinel2/brdf/correction.py +0 -0
- {mapchete_eo-2025.8.0 → mapchete_eo-2025.8.2}/mapchete_eo/platforms/sentinel2/brdf/hls.py +0 -0
- {mapchete_eo-2025.8.0 → mapchete_eo-2025.8.2}/mapchete_eo/platforms/sentinel2/brdf/models.py +0 -0
- {mapchete_eo-2025.8.0 → mapchete_eo-2025.8.2}/mapchete_eo/platforms/sentinel2/brdf/protocols.py +0 -0
- {mapchete_eo-2025.8.0 → mapchete_eo-2025.8.2}/mapchete_eo/platforms/sentinel2/brdf/ross_thick.py +0 -0
- {mapchete_eo-2025.8.0 → mapchete_eo-2025.8.2}/mapchete_eo/platforms/sentinel2/brdf/sun_angle_arrays.py +0 -0
- {mapchete_eo-2025.8.0 → mapchete_eo-2025.8.2}/mapchete_eo/platforms/sentinel2/config.py +0 -0
- {mapchete_eo-2025.8.0 → mapchete_eo-2025.8.2}/mapchete_eo/platforms/sentinel2/driver.py +0 -0
- {mapchete_eo-2025.8.0 → mapchete_eo-2025.8.2}/mapchete_eo/platforms/sentinel2/masks.py +0 -0
- {mapchete_eo-2025.8.0 → mapchete_eo-2025.8.2}/mapchete_eo/platforms/sentinel2/metadata_parser.py +0 -0
- {mapchete_eo-2025.8.0 → mapchete_eo-2025.8.2}/mapchete_eo/platforms/sentinel2/path_mappers/__init__.py +0 -0
- {mapchete_eo-2025.8.0 → mapchete_eo-2025.8.2}/mapchete_eo/platforms/sentinel2/path_mappers/base.py +0 -0
- {mapchete_eo-2025.8.0 → mapchete_eo-2025.8.2}/mapchete_eo/platforms/sentinel2/path_mappers/earthsearch.py +0 -0
- {mapchete_eo-2025.8.0 → mapchete_eo-2025.8.2}/mapchete_eo/platforms/sentinel2/path_mappers/metadata_xml.py +0 -0
- {mapchete_eo-2025.8.0 → mapchete_eo-2025.8.2}/mapchete_eo/platforms/sentinel2/path_mappers/sinergise.py +0 -0
- {mapchete_eo-2025.8.0 → mapchete_eo-2025.8.2}/mapchete_eo/platforms/sentinel2/preprocessing_tasks.py +0 -0
- {mapchete_eo-2025.8.0 → mapchete_eo-2025.8.2}/mapchete_eo/platforms/sentinel2/processing_baseline.py +0 -0
- {mapchete_eo-2025.8.0 → mapchete_eo-2025.8.2}/mapchete_eo/platforms/sentinel2/product.py +0 -0
- {mapchete_eo-2025.8.0 → mapchete_eo-2025.8.2}/mapchete_eo/platforms/sentinel2/types.py +0 -0
- {mapchete_eo-2025.8.0 → mapchete_eo-2025.8.2}/mapchete_eo/processes/__init__.py +0 -0
- {mapchete_eo-2025.8.0 → mapchete_eo-2025.8.2}/mapchete_eo/processes/config.py +0 -0
- {mapchete_eo-2025.8.0 → mapchete_eo-2025.8.2}/mapchete_eo/processes/dtype_scale.py +0 -0
- {mapchete_eo-2025.8.0 → mapchete_eo-2025.8.2}/mapchete_eo/processes/eo_to_xarray.py +0 -0
- {mapchete_eo-2025.8.0 → mapchete_eo-2025.8.2}/mapchete_eo/processes/merge_rasters.py +0 -0
- {mapchete_eo-2025.8.0 → mapchete_eo-2025.8.2}/mapchete_eo/product.py +0 -0
- {mapchete_eo-2025.8.0 → mapchete_eo-2025.8.2}/mapchete_eo/protocols.py +0 -0
- {mapchete_eo-2025.8.0 → mapchete_eo-2025.8.2}/mapchete_eo/search/__init__.py +0 -0
- {mapchete_eo-2025.8.0 → mapchete_eo-2025.8.2}/mapchete_eo/search/base.py +0 -0
- {mapchete_eo-2025.8.0 → mapchete_eo-2025.8.2}/mapchete_eo/search/config.py +0 -0
- {mapchete_eo-2025.8.0 → mapchete_eo-2025.8.2}/mapchete_eo/search/s2_mgrs.py +0 -0
- {mapchete_eo-2025.8.0 → mapchete_eo-2025.8.2}/mapchete_eo/search/stac_search.py +0 -0
- {mapchete_eo-2025.8.0 → mapchete_eo-2025.8.2}/mapchete_eo/search/stac_static.py +0 -0
- {mapchete_eo-2025.8.0 → mapchete_eo-2025.8.2}/mapchete_eo/search/utm_search.py +0 -0
- {mapchete_eo-2025.8.0 → mapchete_eo-2025.8.2}/mapchete_eo/settings.py +0 -0
- {mapchete_eo-2025.8.0 → mapchete_eo-2025.8.2}/mapchete_eo/sort.py +0 -0
- {mapchete_eo-2025.8.0 → mapchete_eo-2025.8.2}/mapchete_eo/time.py +0 -0
- {mapchete_eo-2025.8.0 → mapchete_eo-2025.8.2}/mapchete_eo/types.py +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: mapchete-eo
|
|
3
|
-
Version: 2025.8.
|
|
3
|
+
Version: 2025.8.2
|
|
4
4
|
Summary: mapchete EO data reader
|
|
5
5
|
Project-URL: Homepage, https://gitlab.eox.at/maps/mapchete_eo
|
|
6
6
|
Author-email: Joachim Ungar <joachim.ungar@eox.at>, Petr Sevcik <petr.sevcik@eox.at>
|
|
@@ -13,12 +13,11 @@ Classifier: Programming Language :: Python :: 3.10
|
|
|
13
13
|
Classifier: Programming Language :: Python :: 3.11
|
|
14
14
|
Classifier: Programming Language :: Python :: 3.12
|
|
15
15
|
Classifier: Topic :: Scientific/Engineering :: GIS
|
|
16
|
-
Requires-Dist: blend-modes
|
|
17
16
|
Requires-Dist: click
|
|
18
17
|
Requires-Dist: croniter
|
|
19
18
|
Requires-Dist: lxml
|
|
20
19
|
Requires-Dist: mapchete[complete]>=2025.6.0
|
|
21
|
-
Requires-Dist: opencv-python
|
|
20
|
+
Requires-Dist: opencv-python-headless
|
|
22
21
|
Requires-Dist: pillow
|
|
23
22
|
Requires-Dist: pydantic
|
|
24
23
|
Requires-Dist: pystac-client>=0.7.5
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
__version__ = "2025.8.2"
|
|
@@ -91,6 +91,9 @@ class EODataCube(base.InputTile):
|
|
|
91
91
|
if not isinstance(item, CorruptedProductMetadata)
|
|
92
92
|
],
|
|
93
93
|
crs=self.tile.crs,
|
|
94
|
+
# by not using rtree, we avoid an edge case where products outside of process CRS bounds
|
|
95
|
+
# cause rtree to fail when indexing the products.
|
|
96
|
+
index=None,
|
|
94
97
|
)
|
|
95
98
|
|
|
96
99
|
# just return the prouducts as is
|
|
@@ -101,6 +104,9 @@ class EODataCube(base.InputTile):
|
|
|
101
104
|
if not isinstance(item, CorruptedProductMetadata)
|
|
102
105
|
],
|
|
103
106
|
crs=self.tile.crs,
|
|
107
|
+
# by not using rtree, we avoid an edge case where products outside of process CRS bounds
|
|
108
|
+
# cause rtree to fail when indexing the products.
|
|
109
|
+
index=None,
|
|
104
110
|
)
|
|
105
111
|
|
|
106
112
|
def read(
|
|
@@ -0,0 +1,198 @@
|
|
|
1
|
+
"""
|
|
2
|
+
|
|
3
|
+
Original LICENSE:
|
|
4
|
+
|
|
5
|
+
MIT License
|
|
6
|
+
|
|
7
|
+
Copyright (c) 2016 Florian Roscheck
|
|
8
|
+
|
|
9
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated
|
|
10
|
+
documentation files (the "Software"), to deal in the Software without restriction, including without limitation the
|
|
11
|
+
rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit
|
|
12
|
+
persons to whom the Software is furnished to do so, subject to the following conditions:
|
|
13
|
+
|
|
14
|
+
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the
|
|
15
|
+
Software.
|
|
16
|
+
|
|
17
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
|
|
18
|
+
INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
|
19
|
+
IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
|
|
20
|
+
WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE
|
|
21
|
+
OR OTHER DEALINGS IN THE SOFTWARE.
|
|
22
|
+
|
|
23
|
+
Overview
|
|
24
|
+
--------
|
|
25
|
+
|
|
26
|
+
.. currentmodule:: blend_modes.blending_functions
|
|
27
|
+
|
|
28
|
+
.. autosummary::
|
|
29
|
+
:nosignatures:
|
|
30
|
+
|
|
31
|
+
addition
|
|
32
|
+
darken_only
|
|
33
|
+
difference
|
|
34
|
+
divide
|
|
35
|
+
dodge
|
|
36
|
+
grain_extract
|
|
37
|
+
grain_merge
|
|
38
|
+
hard_light
|
|
39
|
+
lighten_only
|
|
40
|
+
multiply
|
|
41
|
+
normal
|
|
42
|
+
overlay
|
|
43
|
+
screen
|
|
44
|
+
soft_light
|
|
45
|
+
subtract
|
|
46
|
+
"""
|
|
47
|
+
|
|
48
|
+
import numpy as np
|
|
49
|
+
from typing import Callable
|
|
50
|
+
from mapchete_eo.image_operations.blend_modes.type_checks import (
|
|
51
|
+
assert_image_format,
|
|
52
|
+
assert_opacity,
|
|
53
|
+
)
|
|
54
|
+
|
|
55
|
+
|
|
56
|
+
class BlendBase:
|
|
57
|
+
def __init__(
|
|
58
|
+
self,
|
|
59
|
+
opacity=1.0,
|
|
60
|
+
disable_type_checks=False,
|
|
61
|
+
dtype=np.float16,
|
|
62
|
+
fcn_name="BlendBase",
|
|
63
|
+
):
|
|
64
|
+
self.opacity = opacity
|
|
65
|
+
self.disable_type_checks = disable_type_checks
|
|
66
|
+
self.dtype = dtype
|
|
67
|
+
self.fcn_name = fcn_name
|
|
68
|
+
|
|
69
|
+
def _prepare(self, src: np.ndarray, dst: np.ndarray):
|
|
70
|
+
if not self.disable_type_checks:
|
|
71
|
+
assert_image_format(src, fcn_name=self.fcn_name, arg_name="src")
|
|
72
|
+
assert_image_format(dst, fcn_name=self.fcn_name, arg_name="dst")
|
|
73
|
+
assert_opacity(self.opacity, fcn_name=self.fcn_name)
|
|
74
|
+
if src.dtype != self.dtype:
|
|
75
|
+
src = src.astype(self.dtype)
|
|
76
|
+
if dst.dtype != self.dtype:
|
|
77
|
+
dst = dst.astype(self.dtype)
|
|
78
|
+
return src, dst
|
|
79
|
+
|
|
80
|
+
def blend(self, src: np.ndarray, dst: np.ndarray, blend_func: Callable):
|
|
81
|
+
src, dst = self._prepare(src, dst)
|
|
82
|
+
blended = blend_func(src, dst)
|
|
83
|
+
result = (blended * self.opacity) + (dst * (1 - self.opacity))
|
|
84
|
+
return np.clip(result, 0, 1).astype(self.dtype)
|
|
85
|
+
|
|
86
|
+
|
|
87
|
+
def make_blend_function(blend_func: Callable):
|
|
88
|
+
# This function returns a wrapper that uses a shared BlendBase instance
|
|
89
|
+
base = BlendBase()
|
|
90
|
+
|
|
91
|
+
def func(
|
|
92
|
+
src: np.ndarray,
|
|
93
|
+
dst: np.ndarray,
|
|
94
|
+
opacity: float = 1.0,
|
|
95
|
+
disable_type_checks: bool = False,
|
|
96
|
+
dtype: np.dtype = np.float16,
|
|
97
|
+
) -> np.ndarray:
|
|
98
|
+
# If parameters differ from base, create new BlendBase (rare)
|
|
99
|
+
if (
|
|
100
|
+
opacity != base.opacity
|
|
101
|
+
or disable_type_checks != base.disable_type_checks
|
|
102
|
+
or dtype != base.dtype
|
|
103
|
+
):
|
|
104
|
+
base_local = BlendBase(opacity, disable_type_checks, dtype)
|
|
105
|
+
return base_local.blend(src, dst, blend_func)
|
|
106
|
+
return base.blend(src, dst, blend_func)
|
|
107
|
+
|
|
108
|
+
return func
|
|
109
|
+
|
|
110
|
+
|
|
111
|
+
normal = make_blend_function(lambda s, d: s)
|
|
112
|
+
multiply = make_blend_function(lambda s, d: s * d)
|
|
113
|
+
screen = make_blend_function(lambda s, d: 1 - (1 - s) * (1 - d))
|
|
114
|
+
darken_only = make_blend_function(lambda s, d: np.minimum(s, d))
|
|
115
|
+
lighten_only = make_blend_function(lambda s, d: np.maximum(s, d))
|
|
116
|
+
difference = make_blend_function(lambda s, d: np.abs(d - s))
|
|
117
|
+
subtract = make_blend_function(lambda s, d: np.clip(d - s, 0, 1))
|
|
118
|
+
|
|
119
|
+
|
|
120
|
+
def divide_blend(s: np.ndarray, d: np.ndarray) -> np.ndarray:
|
|
121
|
+
with np.errstate(divide="ignore", invalid="ignore"):
|
|
122
|
+
res = np.true_divide(d, s)
|
|
123
|
+
res[~np.isfinite(res)] = 0
|
|
124
|
+
return np.clip(res, 0, 1)
|
|
125
|
+
|
|
126
|
+
|
|
127
|
+
divide = make_blend_function(divide_blend)
|
|
128
|
+
|
|
129
|
+
|
|
130
|
+
def grain_extract_blend(s: np.ndarray, d: np.ndarray) -> np.ndarray:
|
|
131
|
+
return np.clip(d - s + 0.5, 0, 1)
|
|
132
|
+
|
|
133
|
+
|
|
134
|
+
grain_extract = make_blend_function(grain_extract_blend)
|
|
135
|
+
|
|
136
|
+
|
|
137
|
+
def grain_merge_blend(s: np.ndarray, d: np.ndarray) -> np.ndarray:
|
|
138
|
+
return np.clip(d + s - 0.5, 0, 1)
|
|
139
|
+
|
|
140
|
+
|
|
141
|
+
grain_merge = make_blend_function(grain_merge_blend)
|
|
142
|
+
|
|
143
|
+
|
|
144
|
+
def overlay_blend(s: np.ndarray, d: np.ndarray) -> np.ndarray:
|
|
145
|
+
mask = d <= 0.5
|
|
146
|
+
result = np.empty_like(d)
|
|
147
|
+
result[mask] = 2 * s[mask] * d[mask]
|
|
148
|
+
result[~mask] = 1 - 2 * (1 - s[~mask]) * (1 - d[~mask])
|
|
149
|
+
return np.clip(result, 0, 1)
|
|
150
|
+
|
|
151
|
+
|
|
152
|
+
overlay = make_blend_function(overlay_blend)
|
|
153
|
+
|
|
154
|
+
|
|
155
|
+
def hard_light_blend(s: np.ndarray, d: np.ndarray) -> np.ndarray:
|
|
156
|
+
mask = s <= 0.5
|
|
157
|
+
result = np.empty_like(d)
|
|
158
|
+
result[mask] = 2 * s[mask] * d[mask]
|
|
159
|
+
result[~mask] = 1 - 2 * (1 - s[~mask]) * (1 - d[~mask])
|
|
160
|
+
return np.clip(result, 0, 1)
|
|
161
|
+
|
|
162
|
+
|
|
163
|
+
hard_light = make_blend_function(hard_light_blend)
|
|
164
|
+
|
|
165
|
+
|
|
166
|
+
def soft_light_blend(s: np.ndarray, d: np.ndarray) -> np.ndarray:
|
|
167
|
+
result = (1 - 2 * s) * d**2 + 2 * s * d
|
|
168
|
+
return np.clip(result, 0, 1)
|
|
169
|
+
|
|
170
|
+
|
|
171
|
+
soft_light = make_blend_function(soft_light_blend)
|
|
172
|
+
|
|
173
|
+
|
|
174
|
+
def dodge_blend(s: np.ndarray, d: np.ndarray) -> np.ndarray:
|
|
175
|
+
with np.errstate(divide="ignore", invalid="ignore"):
|
|
176
|
+
res = np.true_divide(d, 1 - s)
|
|
177
|
+
res[~np.isfinite(res)] = 1
|
|
178
|
+
return np.clip(res, 0, 1)
|
|
179
|
+
|
|
180
|
+
|
|
181
|
+
dodge = make_blend_function(dodge_blend)
|
|
182
|
+
|
|
183
|
+
|
|
184
|
+
def burn_blend(s: np.ndarray, d: np.ndarray) -> np.ndarray:
|
|
185
|
+
with np.errstate(divide="ignore", invalid="ignore"):
|
|
186
|
+
res = 1 - np.true_divide(1 - d, s)
|
|
187
|
+
res[~np.isfinite(res)] = 0
|
|
188
|
+
return np.clip(res, 0, 1)
|
|
189
|
+
|
|
190
|
+
|
|
191
|
+
burn = make_blend_function(burn_blend)
|
|
192
|
+
|
|
193
|
+
|
|
194
|
+
def addition_blend(s: np.ndarray, d: np.ndarray) -> np.ndarray:
|
|
195
|
+
return np.clip(s + d, 0, 1)
|
|
196
|
+
|
|
197
|
+
|
|
198
|
+
addition = make_blend_function(addition_blend)
|
|
@@ -0,0 +1,99 @@
|
|
|
1
|
+
"""This module includes functions to check if variable types match expected formats."""
|
|
2
|
+
|
|
3
|
+
import numpy as np
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
def assert_image_format(image, fcn_name: str, arg_name: str, force_alpha: bool = True):
|
|
7
|
+
"""Assert if image arguments have the expected format.
|
|
8
|
+
|
|
9
|
+
Checks:
|
|
10
|
+
- Image is a numpy array
|
|
11
|
+
- Array is of floating-point type
|
|
12
|
+
- Array is 3D (height x width x channels)
|
|
13
|
+
- Array has the correct number of layers (3 or 4)
|
|
14
|
+
|
|
15
|
+
Args:
|
|
16
|
+
image: The image to be checked.
|
|
17
|
+
fcn_name (str): Calling function name for display in error messages.
|
|
18
|
+
arg_name (str): Relevant argument name for display in error messages.
|
|
19
|
+
force_alpha (bool): Whether the image must include an alpha layer.
|
|
20
|
+
|
|
21
|
+
Raises:
|
|
22
|
+
TypeError: If type or shape are incorrect.
|
|
23
|
+
"""
|
|
24
|
+
if not isinstance(image, np.ndarray):
|
|
25
|
+
raise TypeError(
|
|
26
|
+
f"\n[Invalid Type]\n"
|
|
27
|
+
f"Function: {fcn_name}\n"
|
|
28
|
+
f"Argument: {arg_name}\n"
|
|
29
|
+
f"Expected: numpy.ndarray\n"
|
|
30
|
+
f"Got: {type(image).__name__}\n"
|
|
31
|
+
f'Hint: Pass a numpy.ndarray for "{arg_name}".'
|
|
32
|
+
)
|
|
33
|
+
|
|
34
|
+
if image.dtype.kind != "f":
|
|
35
|
+
raise TypeError(
|
|
36
|
+
f"\n[Invalid Data Type]\n"
|
|
37
|
+
f"Function: {fcn_name}\n"
|
|
38
|
+
f"Argument: {arg_name}\n"
|
|
39
|
+
f'Expected dtype kind: "f" (floating-point)\n'
|
|
40
|
+
f'Got dtype kind: "{image.dtype.kind}"\n'
|
|
41
|
+
f"Hint: Convert the array to float, e.g., image.astype(float)."
|
|
42
|
+
)
|
|
43
|
+
|
|
44
|
+
if len(image.shape) != 3:
|
|
45
|
+
raise TypeError(
|
|
46
|
+
f"\n[Invalid Dimensions]\n"
|
|
47
|
+
f"Function: {fcn_name}\n"
|
|
48
|
+
f"Argument: {arg_name}\n"
|
|
49
|
+
f"Expected: 3D array (height x width x channels)\n"
|
|
50
|
+
f"Got: {len(image.shape)}D array\n"
|
|
51
|
+
f"Hint: Ensure the array has three dimensions."
|
|
52
|
+
)
|
|
53
|
+
|
|
54
|
+
if force_alpha and image.shape[2] != 4:
|
|
55
|
+
raise TypeError(
|
|
56
|
+
f"\n[Invalid Channel Count]\n"
|
|
57
|
+
f"Function: {fcn_name}\n"
|
|
58
|
+
f"Argument: {arg_name}\n"
|
|
59
|
+
f"Expected: 4 layers (R, G, B, Alpha)\n"
|
|
60
|
+
f"Got: {image.shape[2]} layers\n"
|
|
61
|
+
f"Hint: Include all four channels if force_alpha=True."
|
|
62
|
+
)
|
|
63
|
+
|
|
64
|
+
|
|
65
|
+
def assert_opacity(opacity, fcn_name: str, arg_name: str = "opacity"):
|
|
66
|
+
"""Assert if opacity has the expected format.
|
|
67
|
+
|
|
68
|
+
Checks:
|
|
69
|
+
- Opacity is float or int
|
|
70
|
+
- Opacity is within 0.0 <= x <= 1.0
|
|
71
|
+
|
|
72
|
+
Args:
|
|
73
|
+
opacity: The opacity value to be checked.
|
|
74
|
+
fcn_name (str): Calling function name for display in error messages.
|
|
75
|
+
arg_name (str): Argument name for display in error messages.
|
|
76
|
+
|
|
77
|
+
Raises:
|
|
78
|
+
TypeError: If type is not float or int.
|
|
79
|
+
ValueError: If opacity is out of range.
|
|
80
|
+
"""
|
|
81
|
+
if not isinstance(opacity, (float, int)):
|
|
82
|
+
raise TypeError(
|
|
83
|
+
f"\n[Invalid Type]\n"
|
|
84
|
+
f"Function: {fcn_name}\n"
|
|
85
|
+
f"Argument: {arg_name}\n"
|
|
86
|
+
f"Expected: float (or int)\n"
|
|
87
|
+
f"Got: {type(opacity).__name__}\n"
|
|
88
|
+
f"Hint: Pass a float between 0.0 and 1.0."
|
|
89
|
+
)
|
|
90
|
+
|
|
91
|
+
if not 0.0 <= opacity <= 1.0:
|
|
92
|
+
raise ValueError(
|
|
93
|
+
f"\n[Out of Range]\n"
|
|
94
|
+
f"Function: {fcn_name}\n"
|
|
95
|
+
f"Argument: {arg_name}\n"
|
|
96
|
+
f"Expected: value in range 0.0 <= x <= 1.0\n"
|
|
97
|
+
f"Got: {opacity}\n"
|
|
98
|
+
f"Hint: Clamp or normalize the value to the valid range."
|
|
99
|
+
)
|
|
@@ -2,13 +2,15 @@ import logging
|
|
|
2
2
|
from enum import Enum
|
|
3
3
|
from typing import Callable, Optional
|
|
4
4
|
|
|
5
|
-
import blend_modes
|
|
6
5
|
import cv2
|
|
7
6
|
import numpy as np
|
|
8
7
|
import numpy.ma as ma
|
|
9
8
|
from mapchete import Timer
|
|
10
9
|
from rasterio.plot import reshape_as_image, reshape_as_raster
|
|
11
10
|
|
|
11
|
+
from mapchete_eo.image_operations.blend_modes import blending_functions
|
|
12
|
+
|
|
13
|
+
|
|
12
14
|
logger = logging.getLogger(__name__)
|
|
13
15
|
|
|
14
16
|
|
|
@@ -68,63 +70,63 @@ def _blend_base(
|
|
|
68
70
|
|
|
69
71
|
|
|
70
72
|
def normal(bg: np.ndarray, fg: np.ndarray, opacity: float = 1) -> ma.MaskedArray:
|
|
71
|
-
return _blend_base(bg, fg, opacity,
|
|
73
|
+
return _blend_base(bg, fg, opacity, blending_functions.normal)
|
|
72
74
|
|
|
73
75
|
|
|
74
76
|
def soft_light(bg: np.ndarray, fg: np.ndarray, opacity: float = 1) -> ma.MaskedArray:
|
|
75
|
-
return _blend_base(bg, fg, opacity,
|
|
77
|
+
return _blend_base(bg, fg, opacity, blending_functions.soft_light)
|
|
76
78
|
|
|
77
79
|
|
|
78
80
|
def lighten_only(bg: np.ndarray, fg: np.ndarray, opacity: float = 1) -> ma.MaskedArray:
|
|
79
|
-
return _blend_base(bg, fg, opacity,
|
|
81
|
+
return _blend_base(bg, fg, opacity, blending_functions.lighten_only)
|
|
80
82
|
|
|
81
83
|
|
|
82
84
|
def screen(bg: np.ndarray, fg: np.ndarray, opacity: float = 1) -> ma.MaskedArray:
|
|
83
|
-
return _blend_base(bg, fg, opacity,
|
|
85
|
+
return _blend_base(bg, fg, opacity, blending_functions.screen)
|
|
84
86
|
|
|
85
87
|
|
|
86
88
|
def dodge(bg: np.ndarray, fg: np.ndarray, opacity: float = 1) -> ma.MaskedArray:
|
|
87
|
-
return _blend_base(bg, fg, opacity,
|
|
89
|
+
return _blend_base(bg, fg, opacity, blending_functions.dodge)
|
|
88
90
|
|
|
89
91
|
|
|
90
92
|
def addition(bg: np.ndarray, fg: np.ndarray, opacity: float = 1) -> ma.MaskedArray:
|
|
91
|
-
return _blend_base(bg, fg, opacity,
|
|
93
|
+
return _blend_base(bg, fg, opacity, blending_functions.addition)
|
|
92
94
|
|
|
93
95
|
|
|
94
96
|
def darken_only(bg: np.ndarray, fg: np.ndarray, opacity: float = 1) -> ma.MaskedArray:
|
|
95
|
-
return _blend_base(bg, fg, opacity,
|
|
97
|
+
return _blend_base(bg, fg, opacity, blending_functions.darken_only)
|
|
96
98
|
|
|
97
99
|
|
|
98
100
|
def multiply(bg: np.ndarray, fg: np.ndarray, opacity: float = 1) -> ma.MaskedArray:
|
|
99
|
-
return _blend_base(bg, fg, opacity,
|
|
101
|
+
return _blend_base(bg, fg, opacity, blending_functions.multiply)
|
|
100
102
|
|
|
101
103
|
|
|
102
104
|
def hard_light(bg: np.ndarray, fg: np.ndarray, opacity: float = 1) -> ma.MaskedArray:
|
|
103
|
-
return _blend_base(bg, fg, opacity,
|
|
105
|
+
return _blend_base(bg, fg, opacity, blending_functions.hard_light)
|
|
104
106
|
|
|
105
107
|
|
|
106
108
|
def difference(bg: np.ndarray, fg: np.ndarray, opacity: float = 1) -> ma.MaskedArray:
|
|
107
|
-
return _blend_base(bg, fg, opacity,
|
|
109
|
+
return _blend_base(bg, fg, opacity, blending_functions.difference)
|
|
108
110
|
|
|
109
111
|
|
|
110
112
|
def subtract(bg: np.ndarray, fg: np.ndarray, opacity: float = 1) -> ma.MaskedArray:
|
|
111
|
-
return _blend_base(bg, fg, opacity,
|
|
113
|
+
return _blend_base(bg, fg, opacity, blending_functions.subtract)
|
|
112
114
|
|
|
113
115
|
|
|
114
116
|
def grain_extract(bg: np.ndarray, fg: np.ndarray, opacity: float = 1) -> ma.MaskedArray:
|
|
115
|
-
return _blend_base(bg, fg, opacity,
|
|
117
|
+
return _blend_base(bg, fg, opacity, blending_functions.grain_extract)
|
|
116
118
|
|
|
117
119
|
|
|
118
120
|
def grain_merge(bg: np.ndarray, fg: np.ndarray, opacity: float = 1) -> ma.MaskedArray:
|
|
119
|
-
return _blend_base(bg, fg, opacity,
|
|
121
|
+
return _blend_base(bg, fg, opacity, blending_functions.grain_merge)
|
|
120
122
|
|
|
121
123
|
|
|
122
124
|
def divide(bg: np.ndarray, fg: np.ndarray, opacity: float = 1) -> ma.MaskedArray:
|
|
123
|
-
return _blend_base(bg, fg, opacity,
|
|
125
|
+
return _blend_base(bg, fg, opacity, blending_functions.divide)
|
|
124
126
|
|
|
125
127
|
|
|
126
128
|
def overlay(bg: np.ndarray, fg: np.ndarray, opacity: float = 1) -> ma.MaskedArray:
|
|
127
|
-
return _blend_base(bg, fg, opacity,
|
|
129
|
+
return _blend_base(bg, fg, opacity, blending_functions.overlay)
|
|
128
130
|
|
|
129
131
|
|
|
130
132
|
METHODS = {
|
|
@@ -22,12 +22,11 @@ classifiers = [
|
|
|
22
22
|
"Topic :: Scientific/Engineering :: GIS",
|
|
23
23
|
]
|
|
24
24
|
dependencies = [
|
|
25
|
-
"blend-modes",
|
|
26
25
|
"click",
|
|
27
26
|
"croniter",
|
|
28
27
|
"lxml",
|
|
29
28
|
"mapchete[complete]>=2025.6.0",
|
|
30
|
-
"opencv-python",
|
|
29
|
+
"opencv-python-headless",
|
|
31
30
|
"Pillow",
|
|
32
31
|
"pydantic",
|
|
33
32
|
"pystac[urllib3]>=1.12.2",
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
__version__ = "2025.8.0"
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{mapchete_eo-2025.8.0 → mapchete_eo-2025.8.2}/mapchete_eo/image_operations/color_correction.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{mapchete_eo-2025.8.0 → mapchete_eo-2025.8.2}/mapchete_eo/image_operations/linear_normalization.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{mapchete_eo-2025.8.0 → mapchete_eo-2025.8.2}/mapchete_eo/platforms/sentinel2/bandpass_adjustment.py
RENAMED
|
File without changes
|
{mapchete_eo-2025.8.0 → mapchete_eo-2025.8.2}/mapchete_eo/platforms/sentinel2/brdf/__init__.py
RENAMED
|
File without changes
|
{mapchete_eo-2025.8.0 → mapchete_eo-2025.8.2}/mapchete_eo/platforms/sentinel2/brdf/config.py
RENAMED
|
File without changes
|
{mapchete_eo-2025.8.0 → mapchete_eo-2025.8.2}/mapchete_eo/platforms/sentinel2/brdf/correction.py
RENAMED
|
File without changes
|
|
File without changes
|
{mapchete_eo-2025.8.0 → mapchete_eo-2025.8.2}/mapchete_eo/platforms/sentinel2/brdf/models.py
RENAMED
|
File without changes
|
{mapchete_eo-2025.8.0 → mapchete_eo-2025.8.2}/mapchete_eo/platforms/sentinel2/brdf/protocols.py
RENAMED
|
File without changes
|
{mapchete_eo-2025.8.0 → mapchete_eo-2025.8.2}/mapchete_eo/platforms/sentinel2/brdf/ross_thick.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{mapchete_eo-2025.8.0 → mapchete_eo-2025.8.2}/mapchete_eo/platforms/sentinel2/metadata_parser.py
RENAMED
|
File without changes
|
|
File without changes
|
{mapchete_eo-2025.8.0 → mapchete_eo-2025.8.2}/mapchete_eo/platforms/sentinel2/path_mappers/base.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{mapchete_eo-2025.8.0 → mapchete_eo-2025.8.2}/mapchete_eo/platforms/sentinel2/preprocessing_tasks.py
RENAMED
|
File without changes
|
{mapchete_eo-2025.8.0 → mapchete_eo-2025.8.2}/mapchete_eo/platforms/sentinel2/processing_baseline.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|