Skip to content

armgit / camel

Public Imported from GitHub
0

🐫 CAMEL: The first and the best multi-agent framework. Finding the Scaling Law of Agents. https://www.camel-ai.org

enhance: Add EarthScienceToolkit (about 100 specific earth science to… (#3583)

Wendong-Fanc67fe43593bb
diff --git a/camel/toolkits/earth_science_toolkit.py b/camel/toolkits/earth_science_toolkit.py
index 8b0e60fc6..72e62a0de 100644
--- a/camel/toolkits/earth_science_toolkit.py
+++ b/camel/toolkits/earth_science_toolkit.py
@@ -1,53 +1,57 @@
-import warnings
-from typing import List, Optional, Any
-from camel.toolkits.base import BaseToolkit
-from camel.toolkits.function_tool import FunctionTool
-from camel.utils import MCPServer
-import os
+# ========= Copyright 2023-2025 @ CAMEL-AI.org. All Rights Reserved. =========
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+# ========= Copyright 2023-2025 @ CAMEL-AI.org. All Rights Reserved. =========
import math
+import os
import re
-import cv2
-import rasterio
-import numpy as np
-import pandas as pd
-import ruptures as rpt
from pathlib import Path
-from osgeo import gdal
-from skimage.morphology import skeletonize
-from statsmodels.tsa.seasonal import STL
-from statsmodels.tsa.stattools import acf
-from scipy.ndimage import convolve
-from scipy.stats import skew
-from scipy.stats import kurtosis
-from scipy.ndimage import zoom
-from scipy.stats import linregress
-from scipy.stats import norm
-import matplotlib.cm as cm
+from typing import Any, List, cast
+
+from camel.logger import get_logger
+from camel.toolkits.base import BaseToolkit
+from camel.toolkits.function_tool import FunctionTool
+from camel.utils import MCPServer
+
+logger = get_logger(__name__)
+
TEMP_DIR = Path('/tmp/earth_science')
TEMP_DIR.mkdir(parents=True, exist_ok=True)
@MCPServer()
class EarthScienceToolkit(BaseToolkit):
- """A class representing a toolkit for earth obseravation science.
+ r"""A class representing a toolkit for earth observation science.
- This class provides 104 basic methods for earth observation problem solutions which can be divided into
- Index(12 functions), Inversion(18 functions), Perception(15 functions), Analysis(10 functions), and Statistics(49 functions).
+ This class provides 104 basic methods for earth observation solutions:
+ Index (12), Inversion (18), Perception (15), Analysis (10), Statistics
+ (49).
"""
def calculate_ndvi(self, input_nir_path, input_red_path, output_path):
- """
- Calculate the Normalized Difference Vegetation Index (NDVI) from input raster files
- and save the result to a specified output path.
+ r"""Calculate NDVI from NIR and Red band rasters.
- Parameters:
- input_nir_path (str): Path to the Near-Infrared (NIR) band raster file.
- input_red_path (str): Path to the Red band raster file.
- output_path (str): relative path for the output raster file, e.g. "question17/ndvi_2022-01-16.tif"
+ Args:
+ input_nir_path (str): Path to Near-Infrared (NIR) band raster.
+ input_red_path (str): Path to Red band raster file.
+ output_path (str): Relative output path, e.g.
+ "question17/ndvi_2022-01-16.tif"
Returns:
str: Path to the saved NDVI file.
"""
+ import numpy as np
+ import rasterio
+
with rasterio.open(input_nir_path) as nir_src:
nir_band = nir_src.read(1)
nir_profile = nir_src.profile
@@ -58,43 +62,52 @@ class EarthScienceToolkit(BaseToolkit):
denominator = nir_band + red_band + 1e-06
ndvi = (nir_band - red_band) / denominator
ndvi_profile = nir_profile.copy()
- ndvi_profile.update(dtype=rasterio.float32, nodata=-9999, compress=
- 'lzw')
+ ndvi_profile.update(
+ dtype=rasterio.float32, nodata=-9999, compress='lzw'
+ )
os.makedirs((TEMP_DIR / output_path).parent, exist_ok=True)
with rasterio.open(TEMP_DIR / output_path, 'w', **ndvi_profile) as dst:
dst.write(ndvi.astype(rasterio.float32), 1)
return f'Result save at {TEMP_DIR / output_path}'
- def calculate_batch_ndvi(self, input_nir_paths: list[str],
- input_red_paths: list[str], output_paths: list[str]) ->list[str]:
- """
- Batch-calculate NDVI from multiple pairs of NIR/Red rasters.
+ def calculate_batch_ndvi(
+ self,
+ input_nir_paths: list[str],
+ input_red_paths: list[str],
+ output_paths: list[str],
+ ) -> list[str]:
+ r"""Batch-calculate NDVI from multiple pairs of NIR/Red rasters.
- Parameters:
+ Args:
input_nir_paths (list[str]): Paths to NIR band rasters.
input_red_paths (list[str]): Paths to Red band rasters.
- output_paths (list[str]): Relative output paths (e.g., "question17/ndvi_2022-01-16.tif").
+ output_paths (list[str]): Relative output paths.
Returns:
list[str]: A list of result messages (e.g., saved file paths).
"""
- return [self.calculate_ndvi(nir_path, red_path, out_path) for
- nir_path, red_path, out_path in zip(input_nir_paths,
- input_red_paths, output_paths)]
+ return [
+ self.calculate_ndvi(nir_path, red_path, out_path)
+ for nir_path, red_path, out_path in zip(
+ input_nir_paths, input_red_paths, output_paths
+ )
+ ]
def calculate_ndwi(self, input_nir_path, input_swir_path, output_path):
- """
- Calculate the Normalized Difference Water Index (NDWI) from input raster files
- and save the result to a specified output path.
+ r"""Calculate NDWI from NIR and SWIR band rasters.
- Parameters:
- input_nir_path (str): Path to the Near-Infrared (NIR) band raster file.
- input_swir_path (str): Path to the Short-Wave Infrared (SWIR) band raster file.
- output_path (str): relative path for the output raster file, e.g. "question17/ndwi_2022-01-16.tif"
+ Args:
+ input_nir_path (str): Path to Near-Infrared (NIR) band raster.
+ input_swir_path (str): Path to Short-Wave Infrared (SWIR) raster.
+ output_path (str): Relative output path, e.g.
+ "question17/ndwi_2022-01-16.tif"
Returns:
str: Path to the saved NDWI file.
"""
+ import numpy as np
+ import rasterio
+
with rasterio.open(input_nir_path) as nir_src:
nir_band = nir_src.read(1)
nir_profile = nir_src.profile
@@ -105,43 +118,52 @@ class EarthScienceToolkit(BaseToolkit):
denominator = nir_band + swir_band + 1e-06
ndwi = (nir_band - swir_band) / denominator
ndwi_profile = nir_profile.copy()
- ndwi_profile.update(dtype=rasterio.float32, nodata=-9999, compress=
- 'lzw')
+ ndwi_profile.update(
+ dtype=rasterio.float32, nodata=-9999, compress='lzw'
+ )
os.makedirs((TEMP_DIR / output_path).parent, exist_ok=True)
with rasterio.open(TEMP_DIR / output_path, 'w', **ndwi_profile) as dst:
dst.write(ndwi.astype(rasterio.float32), 1)
return f'Result save at {TEMP_DIR / output_path}'
- def calculate_batch_ndwi(self, input_nir_paths: list[str],
- input_swir_paths: list[str], output_paths: list[str]) ->list[str]:
- """
- Batch-calculate NDWI from multiple pairs of NIR/SWIR rasters.
+ def calculate_batch_ndwi(
+ self,
+ input_nir_paths: list[str],
+ input_swir_paths: list[str],
+ output_paths: list[str],
+ ) -> list[str]:
+ r"""Batch-calculate NDWI from multiple pairs of NIR/SWIR rasters.
- Parameters:
+ Args:
input_nir_paths (list[str]): Paths to NIR band rasters.
input_swir_paths (list[str]): Paths to SWIR band rasters.
- output_paths (list[str]): Relative output paths (e.g., "question17/ndwi_2022-01-16.tif").
+ output_paths (list[str]): Relative output paths.
Returns:
list[str]: A list of result messages (e.g., saved file paths).
"""
- return [self.calculate_ndwi(nir_path, swir_path, out_path) for
- nir_path, swir_path, out_path in zip(input_nir_paths,
- input_swir_paths, output_paths)]
+ return [
+ self.calculate_ndwi(nir_path, swir_path, out_path)
+ for nir_path, swir_path, out_path in zip(
+ input_nir_paths, input_swir_paths, output_paths
+ )
+ ]
def calculate_ndbi(self, input_swir_path, input_nir_path, output_path):
- """
- Calculate the Normalized Difference Built-Up Index (NDBI) from input raster files
- and save the result to a specified output path.
+ r"""Calculate NDBI from SWIR and NIR band rasters.
- Parameters:
- input_swir_path (str): Path to the Short-Wave Infrared (SWIR) band raster file.
- input_nir_path (str): Path to the Near-Infrared (NIR) band raster file.
- output_path (str): relative path for the output raster file, e.g. "question17/ndbi_2022-01-16.tif"
+ Args:
+ input_swir_path (str): Path to Short-Wave Infrared (SWIR) raster.
+ input_nir_path (str): Path to Near-Infrared (NIR) band raster.
+ output_path (str): Relative output path, e.g.
+ "question17/ndbi_2022-01-16.tif"
Returns:
str: Path to the saved NDBI file.
"""
+ import numpy as np
+ import rasterio
+
with rasterio.open(input_swir_path) as swir_src:
swir_band = swir_src.read(1)
swir_profile = swir_src.profile
@@ -152,47 +174,64 @@ class EarthScienceToolkit(BaseToolkit):
denominator = swir_band + nir_band + 1e-06
ndbi = (swir_band - nir_band) / denominator
ndbi_profile = swir_profile.copy()
- ndbi_profile.update(dtype=rasterio.float32, nodata=-9999, compress=
- 'lzw')
+ ndbi_profile.update(
+ dtype=rasterio.float32, nodata=-9999, compress='lzw'
+ )
os.makedirs((TEMP_DIR / output_path).parent, exist_ok=True)
with rasterio.open(TEMP_DIR / output_path, 'w', **ndbi_profile) as dst:
dst.write(ndbi.astype(rasterio.float32), 1)
return f'Result save at {TEMP_DIR / output_path}'
- def calculate_batch_ndbi(self, input_swir_paths: list[str],
- input_nir_paths: list[str], output_paths: list[str]) ->list[str]:
- """
- Batch-calculate NDBI from multiple pairs of SWIR/NIR rasters.
+ def calculate_batch_ndbi(
+ self,
+ input_swir_paths: list[str],
+ input_nir_paths: list[str],
+ output_paths: list[str],
+ ) -> list[str]:
+ r"""Batch-calculate NDBI from multiple pairs of SWIR/NIR rasters.
- Parameters:
+ Args:
input_swir_paths (list[str]): Paths to SWIR band rasters.
input_nir_paths (list[str]): Paths to NIR band rasters.
- output_paths (list[str]): Relative output paths (e.g., "question17/ndbi_2022-01-16.tif").
+ output_paths (list[str]): Relative output paths.
Returns:
list[str]: A list of result messages (e.g., saved file paths).
"""
- return [self.calculate_ndbi(swir_path, nir_path, out_path) for
- swir_path, nir_path, out_path in zip(input_swir_paths,
- input_nir_paths, output_paths)]
-
- def calculate_evi(self, input_nir_path, input_red_path, input_blue_path,
- output_path, G: float=2.5, C1: float=6, C2: float=7.5, L: float=1):
- """
- Calculate the Enhanced Vegetation Index (EVI) from input raster files
- and save the result to a specified output path.
-
- Parameters:
- input_nir_path (str): Path to the Near-Infrared (NIR) band raster file.
- input_red_path (str): Path to the Red band raster file.
- input_blue_path (str): Path to the Blue band raster file.
- output_path (str): relative path for the output raster file, e.g. "question17/evi_2022-01-16.tif"
+ return [
+ self.calculate_ndbi(swir_path, nir_path, out_path)
+ for swir_path, nir_path, out_path in zip(
+ input_swir_paths, input_nir_paths, output_paths
+ )
+ ]
+
+ def calculate_evi(
+ self,
+ input_nir_path,
+ input_red_path,
+ input_blue_path,
+ output_path,
+ G: float = 2.5,
+ C1: float = 6,
+ C2: float = 7.5,
+ L: float = 1,
+ ):
+ r"""Calculate EVI from NIR, Red, and Blue band rasters.
+
+ Args:
+ input_nir_path (str): Path to Near-Infrared (NIR) band raster.
+ input_red_path (str): Path to Red band raster file.
+ input_blue_path (str): Path to Blue band raster file.
+ output_path (str): Relative output path, e.g.
+ "question17/evi_2022-01-16.tif"
G (float, optional): Gain factor. Defaults to 2.5.
C1 (float, optional): Coefficient 1. Defaults to 6.
C2 (float, optional): Coefficient 2. Defaults to 7.5.
L (float, optional): Adjustment factor. Defaults to 1.
-
"""
+ import numpy as np
+ import rasterio
+
with rasterio.open(input_nir_path) as nir_src:
nir_band = nir_src.read(1)
nir_profile = nir_src.profile
@@ -206,21 +245,28 @@ class EarthScienceToolkit(BaseToolkit):
denominator = nir_band + C1 * red_band - C2 * blue_band + L + 1e-06
evi = G * (nir_band - red_band) / denominator
evi_profile = nir_profile.copy()
- evi_profile.update(dtype=rasterio.float32, nodata=-9999, compress='lzw'
- )
+ evi_profile.update(
+ dtype=rasterio.float32, nodata=-9999, compress='lzw'
+ )
os.makedirs((TEMP_DIR / output_path).parent, exist_ok=True)
with rasterio.open(TEMP_DIR / output_path, 'w', **evi_profile) as dst:
dst.write(evi.astype(rasterio.float32), 1)
return f'Result save at {TEMP_DIR / output_path}'
- def calculate_batch_evi(self, input_nir_paths: list[str],
- input_red_paths: list[str], input_blue_paths: list[str],
- output_paths: list[str], G: float=2.5, C1: float=6, C2: float=7.5,
- L: float=1) ->list[str]:
- """
- Batch-calculate EVI from multiple sets of NIR/Red/Blue rasters.
-
- Parameters:
+ def calculate_batch_evi(
+ self,
+ input_nir_paths: list[str],
+ input_red_paths: list[str],
+ input_blue_paths: list[str],
+ output_paths: list[str],
+ G: float = 2.5,
+ C1: float = 6,
+ C2: float = 7.5,
+ L: float = 1,
+ ) -> list[str]:
+ r"""Batch-calculate EVI from multiple sets of NIR/Red/Blue rasters.
+
+ Args:
input_nir_paths (list[str]): Paths to NIR band rasters.
input_red_paths (list[str]): Paths to Red band rasters.
input_blue_paths (list[str]): Paths to Blue band rasters.
@@ -231,26 +277,30 @@ class EarthScienceToolkit(BaseToolkit):
list[str]: Result messages from each `calculate_evi` call.
"""
results: list[str] = []
- for nir_path, red_path, blue_path, out_path in zip(input_nir_paths,
- input_red_paths, input_blue_paths, output_paths):
- res = self.calculate_evi(nir_path, red_path, blue_path,
- out_path, G=G, C1=C1, C2=C2, L=L)
+ for nir_path, red_path, blue_path, out_path in zip(
+ input_nir_paths, input_red_paths, input_blue_paths, output_paths
+ ):
+ res = self.calculate_evi(
+ nir_path, red_path, blue_path, out_path, G=G, C1=C1, C2=C2, L=L
+ )
results.append(res)
return results
def calculate_nbr(self, input_nir_path, input_swir_path, output_path):
- """
- Calculate the Normalized Burn Ratio (NBR) from input raster files
- and save the result to a specified output path.
+ r"""Calculate NBR from NIR and SWIR band rasters.
- Parameters:
- input_nir_path (str): Path to the Near-Infrared (NIR) band raster file.
- input_swir_path (str): Path to the Short-Wave Infrared (SWIR) band raster file.
- output_path (str): relative path for the output raster file, e.g. "question17/nbr_2022-01-16.tif"
+ Args:
+ input_nir_path (str): Path to Near-Infrared (NIR) band raster.
+ input_swir_path (str): Path to Short-Wave Infrared (SWIR) raster.
+ output_path (str): Relative output path, e.g.
+ "question17/nbr_2022-01-16.tif"
Returns:
str: Path to the saved NBR file.
"""
+ import numpy as np
+ import rasterio
+
with rasterio.open(input_nir_path) as nir_src:
nir_band = nir_src.read(1)
nir_profile = nir_src.profile
@@ -261,49 +311,62 @@ class EarthScienceToolkit(BaseToolkit):
denominator = nir_band + swir_band + 1e-06
nbr = (nir_band - swir_band) / denominator
nbr_profile = nir_profile.copy()
- nbr_profile.update(dtype=rasterio.float32, nodata=-9999, compress='lzw'
- )
+ nbr_profile.update(
+ dtype=rasterio.float32, nodata=-9999, compress='lzw'
+ )
os.makedirs((TEMP_DIR / output_path).parent, exist_ok=True)
with rasterio.open(TEMP_DIR / output_path, 'w', **nbr_profile) as dst:
dst.write(nbr.astype(rasterio.float32), 1)
return f'Result save at {TEMP_DIR / output_path}'
- def calculate_batch_nbr(self, input_nir_paths: list[str],
- input_swir_paths: list[str], output_paths: list[str]) ->list[str]:
- """
- Batch-calculate NBR from multiple pairs of NIR/SWIR rasters.
+ def calculate_batch_nbr(
+ self,
+ input_nir_paths: list[str],
+ input_swir_paths: list[str],
+ output_paths: list[str],
+ ) -> list[str]:
+ r"""Batch-calculate NBR from multiple pairs of NIR/SWIR rasters.
- Parameters:
+ Args:
input_nir_paths (list[str]): Paths to NIR band rasters.
input_swir_paths (list[str]): Paths to SWIR band rasters.
- output_paths (list[str]): Relative output paths (e.g., "question17/nbr_2022-01-16.tif").
+ output_paths (list[str]): Relative output paths.
Returns:
list[str]: A list of result messages (e.g., saved file paths).
"""
results: list[str] = []
- for nir_path, swir_path, out_path in zip(input_nir_paths,
- input_swir_paths, output_paths):
+ for nir_path, swir_path, out_path in zip(
+ input_nir_paths, input_swir_paths, output_paths
+ ):
res = self.calculate_nbr(nir_path, swir_path, out_path)
results.append(res)
return results
- def calculate_fvc(self, input_nir_path, input_red_path, output_path,
- ndvi_min=0.1, ndvi_max=0.9):
- """
- Calculate the Fractional Vegetation Cover (FVC) from input raster files
- and save the result to a specified output path.
-
- Parameters:
- input_nir_path (str): Path to the Near-Infrared (NIR) band raster file.
- input_red_path (str): Path to the Red band raster file.
- output_path (str): relative path for the output raster file, e.g. "question17/fvc_2022-01-16.tif"
- ndvi_min (float): Minimum NDVI value for non-vegetated areas (default: 0.1).
- ndvi_max (float): Maximum NDVI value for fully vegetated areas (default: 0.9).
+ def calculate_fvc(
+ self,
+ input_nir_path,
+ input_red_path,
+ output_path,
+ ndvi_min=0.1,
+ ndvi_max=0.9,
+ ):
+ r"""Calculate FVC from NIR and Red band rasters.
+
+ Args:
+ input_nir_path (str): Path to Near-Infrared (NIR) band raster.
+ input_red_path (str): Path to Red band raster file.
+ output_path (str): Relative output path.
+ ndvi_min (float): Min NDVI for non-vegetated areas (default: 0.1).
+ ndvi_max (float): Max NDVI for fully vegetated areas (default: 0.
+ 9).
Returns:
str: Path to the saved FVC raster file.
"""
+ import numpy as np
+ import rasterio
+
with rasterio.open(input_nir_path) as nir_src:
nir_band = nir_src.read(1)
nir_profile = nir_src.profile
@@ -316,53 +379,71 @@ class EarthScienceToolkit(BaseToolkit):
fvc = (ndvi - ndvi_min) / (ndvi_max - ndvi_min) * 100
fvc = np.clip(fvc, 0, 100)
fvc_profile = nir_profile.copy()
- fvc_profile.update(dtype=rasterio.float32, nodata=-9999, compress='lzw'
- )
+ fvc_profile.update(
+ dtype=rasterio.float32, nodata=-9999, compress='lzw'
+ )
os.makedirs((TEMP_DIR / output_path).parent, exist_ok=True)
with rasterio.open(TEMP_DIR / output_path, 'w', **fvc_profile) as dst:
dst.write(fvc.astype(rasterio.float32), 1)
return f'Result save at {TEMP_DIR / output_path}'
- def calculate_batch_fvc(self, input_nir_paths: list[str],
- input_red_paths: list[str], output_paths: list[str], ndvi_min:
- float=0.1, ndvi_max: float=0.9) ->list[str]:
- """
- Batch-calculate FVC from multiple pairs of NIR/Red rasters.
-
- Parameters:
+ def calculate_batch_fvc(
+ self,
+ input_nir_paths: list[str],
+ input_red_paths: list[str],
+ output_paths: list[str],
+ ndvi_min: float = 0.1,
+ ndvi_max: float = 0.9,
+ ) -> list[str]:
+ r"""Batch-calculate FVC from multiple pairs of NIR/Red rasters.
+
+ Args:
input_nir_paths (list[str]): Paths to NIR band rasters.
input_red_paths (list[str]): Paths to Red band rasters.
- output_paths (list[str]): Relative output paths (e.g., "question17/fvc_2022-01-16.tif").
- ndvi_min (float, optional): Minimum NDVI value for non-vegetated areas. Defaults to 0.1.
- ndvi_max (float, optional): Maximum NDVI value for fully vegetated areas. Defaults to 0.9.
+ output_paths (list[str]): Relative output paths.
+ ndvi_min (float, optional): Min NDVI for non-vegetated areas.
+ ndvi_max (float, optional): Max NDVI for fully vegetated areas.
Returns:
list[str]: A list of result messages (e.g., saved file paths).
"""
results: list[str] = []
- for nir_path, red_path, out_path in zip(input_nir_paths,
- input_red_paths, output_paths):
- res = self.calculate_fvc(nir_path, red_path, out_path, ndvi_min
- =ndvi_min, ndvi_max=ndvi_max)
+ for nir_path, red_path, out_path in zip(
+ input_nir_paths, input_red_paths, output_paths
+ ):
+ res = self.calculate_fvc(
+ nir_path,
+ red_path,
+ out_path,
+ ndvi_min=ndvi_min,
+ ndvi_max=ndvi_max,
+ )
results.append(res)
return results
- def calculate_wri(self, input_green_path, input_red_path,
- input_nir_path, input_swir_path, output_path):
- """
- Calculate the Water Ratio Index (WRI) from input raster files
- and save the result to a specified output path.
-
- Parameters:
- input_green_path (str): Path to the Green band raster file.
- input_red_path (str): Path to the Red band raster file.
- input_nir_path (str): Path to the Near-Infrared (NIR) band raster file.
- input_swir_path (str): Path to the Short-Wave Infrared (SWIR) band raster file.
- output_path (str): relative path for the output raster file, e.g. "question17/wri_2022-01-16.tif"
+ def calculate_wri(
+ self,
+ input_green_path,
+ input_red_path,
+ input_nir_path,
+ input_swir_path,
+ output_path,
+ ):
+ r"""Calculate WRI from Green, Red, NIR, and SWIR band rasters.
+
+ Args:
+ input_green_path (str): Path to Green band raster file.
+ input_red_path (str): Path to Red band raster file.
+ input_nir_path (str): Path to Near-Infrared (NIR) band raster.
+ input_swir_path (str): Path to Short-Wave Infrared (SWIR) raster.
+ output_path (str): Relative output path.
Returns:
str: Path to the saved WRI raster file.
"""
+ import numpy as np
+ import rasterio
+
with rasterio.open(input_green_path) as green_src:
green_band = green_src.read(1)
green_profile = green_src.profile
@@ -379,51 +460,62 @@ class EarthScienceToolkit(BaseToolkit):
denominator = nir_band + swir_band + 1e-06
wri = (green_band + red_band) / denominator
wri_profile = green_profile.copy()
- wri_profile.update(dtype=rasterio.float32, nodata=-9999, compress='lzw'
- )
+ wri_profile.update(
+ dtype=rasterio.float32, nodata=-9999, compress='lzw'
+ )
os.makedirs((TEMP_DIR / output_path).parent, exist_ok=True)
with rasterio.open(TEMP_DIR / output_path, 'w', **wri_profile) as dst:
dst.write(wri.astype(rasterio.float32), 1)
return f'Result save at {TEMP_DIR / output_path}'
- def calculate_batch_wri(self, input_green_paths: list[str],
- input_red_paths: list[str], input_nir_paths: list[str],
- input_swir_paths: list[str], output_paths: list[str]) ->list[str]:
- """
- Batch-calculate WRI from multiple sets of Green/Red/NIR/SWIR rasters.
-
- Parameters:
+ def calculate_batch_wri(
+ self,
+ input_green_paths: list[str],
+ input_red_paths: list[str],
+ input_nir_paths: list[str],
+ input_swir_paths: list[str],
+ output_paths: list[str],
+ ) -> list[str]:
+ r"""Batch-calculate WRI from multiple raster sets.
+
+ Args:
input_green_paths (list[str]): Paths to Green band rasters.
input_red_paths (list[str]): Paths to Red band rasters.
input_nir_paths (list[str]): Paths to NIR band rasters.
input_swir_paths (list[str]): Paths to SWIR band rasters.
- output_paths (list[str]): Relative output paths (e.g., "question17/wri_2022-01-16.tif").
+ output_paths (list[str]): Relative output paths.
Returns:
list[str]: A list of result messages (e.g., saved file paths).
"""
results: list[str] = []
for green_path, red_path, nir_path, swir_path, out_path in zip(
- input_green_paths, input_red_paths, input_nir_paths,
- input_swir_paths, output_paths):
- res = self.calculate_wri(green_path, red_path, nir_path,
- swir_path, out_path)
+ input_green_paths,
+ input_red_paths,
+ input_nir_paths,
+ input_swir_paths,
+ output_paths,
+ ):
+ res = self.calculate_wri(
+ green_path, red_path, nir_path, swir_path, out_path
+ )
results.append(res)
return results
def calculate_ndti(self, input_red_path, input_green_path, output_path):
- """
- Calculate the Normalized Difference Turbidity Index (NDTI) from input raster files
- and save the result to a specified output path.
+ r"""Calculate NDTI from Red and Green band rasters.
- Parameters:
- input_red_path (str): Path to the Red band raster file.
- input_green_path (str): Path to the Green band raster file.
- output_path (str): relative path for the output raster file, e.g. "question17/ndti_2022-01-16.tif"
+ Args:
+ input_red_path (str): Path to Red band raster file.
+ input_green_path (str): Path to Green band raster file.
+ output_path (str): Relative output path.
Returns:
str: Path to the saved NDTI file.
"""
+ import numpy as np
+ import rasterio
+
with rasterio.open(input_red_path) as red_src:
red_band = red_src.read(1)
red_profile = red_src.profile
@@ -434,46 +526,56 @@ class EarthScienceToolkit(BaseToolkit):
denominator = red_band + green_band + 1e-06
ndti = (red_band - green_band) / denominator
ndti_profile = red_profile.copy()
- ndti_profile.update(dtype=rasterio.float32, nodata=-9999, compress=
- 'lzw')
+ ndti_profile.update(
+ dtype=rasterio.float32, nodata=-9999, compress='lzw'
+ )
os.makedirs((TEMP_DIR / output_path).parent, exist_ok=True)
with rasterio.open(TEMP_DIR / output_path, 'w', **ndti_profile) as dst:
dst.write(ndti.astype(rasterio.float32), 1)
return f'Result save at {TEMP_DIR / output_path}'
- def calculate_batch_ndti(self, input_red_paths: list[str],
- input_green_paths: list[str], output_paths: list[str]) ->list[str]:
- """
- Batch-calculate NDTI from multiple pairs of Red/Green rasters.
+ def calculate_batch_ndti(
+ self,
+ input_red_paths: list[str],
+ input_green_paths: list[str],
+ output_paths: list[str],
+ ) -> list[str]:
+ r"""Batch-calculate NDTI from multiple pairs of Red/Green rasters.
- Parameters:
+ Args:
input_red_paths (list[str]): Paths to Red band rasters.
input_green_paths (list[str]): Paths to Green band rasters.
- output_paths (list[str]): Relative output paths (e.g., "question17/ndti_2022-01-16.tif").
+ output_paths (list[str]): Relative output paths
+ (e.g., "question17/ndti_2022-01-16.tif").
Returns:
list[str]: A list of result messages (e.g., saved file paths).
"""
results: list[str] = []
- for red_path, green_path, out_path in zip(input_red_paths,
- input_green_paths, output_paths):
+ for red_path, green_path, out_path in zip(
+ input_red_paths, input_green_paths, output_paths
+ ):
res = self.calculate_ndti(red_path, green_path, out_path)
results.append(res)
return results
def calculate_frp(self, input_frp_path, output_path, fire_threshold=0):
- """
- Calculate Fire Radiative Power (FRP) statistics from input raster files
- and save the result to a specified output path.
+ r"""Calculate Fire Radiative Power (FRP) statistics from input raster
+ files and save the result to a specified output path.
- Parameters:
+ Args:
input_frp_path (str): Path to the FRP raster file.
- output_path (str): relative path for the output raster file, e.g. "question17/frp_2022-01-16.tif"
- fire_threshold (float): Minimum FRP value to be considered as fire (default: 0).
-
+ output_path (str): relative path for the output raster file,
+ e.g. "question17/frp_2022-01-16.tif"
+ fire_threshold (float): Minimum FRP value to be considered
+ as fire (default: 0).
+
Returns:
str: Path to the saved fire mask file.
"""
+ import numpy as np
+ import rasterio
+
with rasterio.open(input_frp_path) as frp_src:
frp_band = frp_src.read(1)
frp_profile = frp_src.profile
@@ -487,42 +589,53 @@ class EarthScienceToolkit(BaseToolkit):
dst.write(output_data, 1)
return f'Result save at {TEMP_DIR / output_path}'
- def calculate_batch_frp(self, input_frp_paths: list[str], output_paths:
- list[str], fire_threshold: float=0) ->list[str]:
- """
- Batch-calculate FRP fire masks from multiple raster files.
+ def calculate_batch_frp(
+ self,
+ input_frp_paths: list[str],
+ output_paths: list[str],
+ fire_threshold: float = 0,
+ ) -> list[str]:
+ r"""Batch-calculate FRP fire masks from multiple raster files.
- Parameters:
+ Args:
input_frp_paths (list[str]): Paths to FRP raster files.
- output_paths (list[str]): Relative output paths (e.g., "question17/frp_2022-01-16.tif").
- fire_threshold (float, optional): Minimum FRP value to be considered as fire. Defaults to 0.
+ output_paths (list[str]): Relative output paths
+ (e.g., "question17/frp_2022-01-16.tif").
+ fire_threshold (float, optional): Minimum FRP value to be
+ considered as fire. Defaults to 0.
Returns:
list[str]: A list of result messages (e.g., saved file paths).
"""
results: list[str] = []
for frp_path, out_path in zip(input_frp_paths, output_paths):
- res = self.calculate_frp(frp_path, out_path, fire_threshold=
- fire_threshold)
+ res = self.calculate_frp(
+ frp_path, out_path, fire_threshold=fire_threshold
+ )
results.append(res)
return results
- def calculate_ndsi(self, input_green_path: str, input_swir_path: str,
- output_path: str) ->str:
- """
- Calculate the Normalized Difference Snow Index (NDSI) from input raster files
- and save the result to a specified output path.
+ def calculate_ndsi(
+ self, input_green_path: str, input_swir_path: str, output_path: str
+ ) -> str:
+ r"""Calculate the Normalized Difference Snow Index (NDSI) from input
+ raster files and save the result to a specified output path.
NDSI = (Green - SWIR) / (Green + SWIR)
- Parameters:
+ Args:
input_green_path (str): Path to the Green band raster file.
input_swir_path (str): Path to the SWIR band raster file.
- output_path (str): relative path for the output raster file, e.g. "question17/ndsi_2022-01-16.tif"
+ output_path (str): relative path for the output raster file,
+ e.g. "question17/ndsi_2022-01-16.tif"
Returns:
str: Path to the output NDSI raster file.
"""
+ import numpy as np
+ import rasterio
+ from scipy.ndimage import zoom
+
with rasterio.open(input_green_path) as green_src:
green_band = green_src.read(1)
green_profile = green_src.profile
@@ -539,41 +652,65 @@ class EarthScienceToolkit(BaseToolkit):
target_width = min(green_band.shape[1], swir_band.shape[1])
target_shape = target_height, target_width
if green_band.shape != target_shape:
- zoom_factors = target_height / green_band.shape[0
- ], target_width / green_band.shape[1]
+ zoom_factors = (
+ target_height / green_band.shape[0],
+ target_width / green_band.shape[1],
+ )
green_band = zoom(green_band, zoom_factors, order=1)
if swir_band.shape != target_shape:
- zoom_factors = target_height / swir_band.shape[0
- ], target_width / swir_band.shape[1]
+ zoom_factors = (
+ target_height / swir_band.shape[0],
+ target_width / swir_band.shape[1],
+ )
swir_band = zoom(swir_band, zoom_factors, order=1)
- green_band = np.where((green_band < 0) | (green_band > 1), np.nan,
- green_band)
- swir_band = np.where((swir_band < 0) | (swir_band > 1), np.nan,
- swir_band)
+ green_band = np.where(
+ (green_band < 0) | (green_band > 1), np.nan, green_band
+ )
+ swir_band = np.where(
+ (swir_band < 0) | (swir_band > 1), np.nan, swir_band
+ )
denominator = green_band + swir_band + 1e-06
- denominator = np.where(np.isnan(green_band) | np.isnan(swir_band),
- np.nan, denominator)
+ denominator = np.where(
+ np.isnan(green_band) | np.isnan(swir_band), np.nan, denominator
+ )
ndsi = (green_band - swir_band) / denominator
ndsi = np.clip(ndsi, -1, 1)
- output_profile = swir_profile.copy() if swir_band.shape[0
- ] <= green_band.shape[0] else green_profile.copy()
- output_profile.update(dtype=rasterio.float32, nodata=-9999,
- compress='lzw', height=ndsi.shape[0], width=ndsi.shape[1])
+ output_profile = (
+ swir_profile.copy()
+ if swir_band.shape[0] <= green_band.shape[0]
+ else green_profile.copy()
+ )
+ output_profile.update(
+ dtype=rasterio.float32,
+ nodata=-9999,
+ compress='lzw',
+ height=ndsi.shape[0],
+ width=ndsi.shape[1],
+ )
os.makedirs((TEMP_DIR / output_path).parent, exist_ok=True)
- with rasterio.open(TEMP_DIR / output_path, 'w', **output_profile
- ) as dst:
+ with rasterio.open(
+ TEMP_DIR / output_path, 'w', **output_profile
+ ) as dst:
dst.write(ndsi.astype(rasterio.float32), 1)
return f'Result save at {TEMP_DIR / output_path}'
- def calculate_batch_ndsi(self, green_file_list: list[str],
- swir_file_list: list[str], output_path_list: list[str]) ->list[str]:
+ def calculate_batch_ndsi(
+ self,
+ green_file_list: list[str],
+ swir_file_list: list[str],
+ output_path_list: list[str],
+ ) -> list[str]:
"""
Calculate NDSI for multiple pairs of Green and SWIR band images.
- Parameters:
- green_file_list (list[str]): List of paths to Green band raster files.
- swir_file_list (list[str]): List of paths to SWIR band raster files.
- output_path_list (list[str]): relative path for the output raster file, e.g. ["question17/ndsi_2022-01-16.tif", "question17/ndsi_2022-01-16.tif"]
+ Args:
+ green_file_list (list[str]): List of paths to Green band raster
+ files.
+ swir_file_list (list[str]): List of paths to SWIR band raster
+ files.
+ output_path_list (list[str]): relative path for the output raster
+ file, e.g. ["question17/ndsi_2022-01-16.tif", "question17/
+ ndsi_2022-01-16.tif"]
Returns:
list[str]: List of paths to the output NDSI raster files.
@@ -581,32 +718,39 @@ class EarthScienceToolkit(BaseToolkit):
if len(green_file_list) != len(swir_file_list):
raise ValueError('Number of Green and SWIR files must be equal')
results = []
- for i, (green_path, swir_path) in enumerate(zip(green_file_list,
- swir_file_list)):
- result = self.calculate_ndsi(green_path, swir_path,
- output_path_list[i])
+ for i, (green_path, swir_path) in enumerate(
+ zip(green_file_list, swir_file_list)
+ ):
+ result = self.calculate_ndsi(
+ green_path, swir_path, output_path_list[i]
+ )
results.append(result)
return results
- def calc_extreme_snow_loss_percentage_from_binary_map(self,
- binary_map_path: str) ->float:
- """
- Calculate the percentage of extreme snow and ice loss areas from a binary map.
+ def calc_extreme_snow_loss_percentage_from_binary_map(
+ self, binary_map_path: str
+ ) -> float:
+ r"""Calculate the percentage of extreme snow and ice loss areas from a
+ binary map.
- Parameters:
+ Args:
binary_map_path (str):
- Path to the binary raster image where pixels with value 1.0
+ Path to the binary raster image where pixels with value 1.0
represent extreme snow/ice loss areas.
Returns:
float:
- The percentage of extreme snow/ice loss pixels relative to all valid pixels
- (range: 0.0–1.0).
+ The percentage of extreme snow/ice loss pixels relative to all
+ valid pixels
+ (range: 0.0-1.0).
Example:
- >>> calc_extreme_snow_loss_percentage_from_binary_map("snow_loss_binary.tif")
+ >>> calc_extreme_snow_loss_percentage_from_binary_map
+ ("snow_loss_binary.tif")
0.27
"""
+ import numpy as np
+
img = self.read_image(binary_map_path)
if img.size == 0:
raise ValueError('Input image is empty')
@@ -619,18 +763,25 @@ class EarthScienceToolkit(BaseToolkit):
extreme_loss_percentage = len(extreme_loss_pixels) / len(valid_pixels)
return float(extreme_loss_percentage)
- def compute_tvdi(self, ndvi_path: str, lst_path: str, output_path: str
- ) ->str:
- """
+ def compute_tvdi(
+ self, ndvi_path: str, lst_path: str, output_path: str
+ ) -> str:
+ r"""
Description:
- Compute the Temperature Vegetation Dryness Index (TVDI) based on NDVI and LST raster data.
- TVDI quantifies soil moisture conditions by analyzing the relationship between NDVI and LST
- through a trapezoidal space approach. The function fits linear regressions for LST maxima
- and minima per NDVI bin and normalizes per-pixel LST values accordingly.
-
- Parameters:
- ndvi_path (str): Path to the NDVI GeoTIFF file (e.g., MODIS NDVI scaled by 0.0001).
- lst_path (str): Path to the LST GeoTIFF file (e.g., MODIS LST scaled by 0.02).
+ Compute the Temperature Vegetation Dryness Index (TVDI) based on
+ NDVI and LST raster data.
+ TVDI quantifies soil moisture conditions by analyzing the
+ relationship between NDVI and LST
+ through a trapezoidal space approach. The function fits linear
+ regressions for LST maxima
+ and minima per NDVI bin and normalizes per-pixel LST values
+ accordingly.
+
+ Args:
+ ndvi_path (str): Path to the NDVI GeoTIFF file (e.g., MODIS NDVI
+ scaled by 0.0001).
+ lst_path (str): Path to the LST GeoTIFF file (e.g., MODIS LST
+ scaled by 0.02).
output_path (str): Relative path to save the computed TVDI raster
(e.g., "question17/tvdi_2022-01-16.tif").
@@ -645,6 +796,10 @@ class EarthScienceToolkit(BaseToolkit):
... )
'Result saved at question17/tvdi_2022-01-16.tif'
"""
+ import numpy as np
+ import rasterio
+ from scipy.stats import linregress
+
with rasterio.open(ndvi_path) as src_ndvi:
ndvi = src_ndvi.read(1).astype(np.float32) * 0.0001
profile = src_ndvi.profile
@@ -652,7 +807,7 @@ class EarthScienceToolkit(BaseToolkit):
lst = src_lst.read(1).astype(np.float32) * 0.02
valid_mask = (ndvi >= 0) & (ndvi <= 1) & (lst > 0)
if not np.any(valid_mask):
- print(f'Warning: No valid data points in {output_path}')
+ logger.info(f'Warning: No valid data points in {output_path}')
tvdi = np.full_like(ndvi, np.nan, dtype=np.float32)
profile.update(dtype=rasterio.float32, count=1, compress='lzw')
os.makedirs((TEMP_DIR / output_path).parent, exist_ok=True)
@@ -662,9 +817,10 @@ class EarthScienceToolkit(BaseToolkit):
ndvi_valid = ndvi[valid_mask]
lst_valid = lst[valid_mask]
if len(ndvi_valid) < 100:
- print(
- f'Warning: Too few valid data points ({len(ndvi_valid)}) in {output_path}'
- )
+ logger.info(
+ f'Warning: Too few valid data points '
+ f'({len(ndvi_valid)}) in {output_path}'
+ )
tvdi = np.full_like(ndvi, np.nan, dtype=np.float32)
profile.update(dtype=rasterio.float32, count=1, compress='lzw')
os.makedirs((TEMP_DIR / output_path).parent, exist_ok=True)
@@ -673,30 +829,35 @@ class EarthScienceToolkit(BaseToolkit):
return f'Result saved at {TEMP_DIR / output_path}'
n_bins = 100
bins = np.linspace(ndvi_valid.min(), ndvi_valid.max(), n_bins + 1)
- ndvi_bin_centers, lst_max_vals, lst_min_vals = [], [], []
+ ndvi_bin_centers_list: List[Any] = []
+ lst_max_vals_list: List[Any] = []
+ lst_min_vals_list: List[Any] = []
for i in range(n_bins):
bin_mask = (ndvi_valid >= bins[i]) & (ndvi_valid < bins[i + 1])
if np.any(bin_mask):
- ndvi_bin_centers.append((bins[i] + bins[i + 1]) / 2)
- lst_max_vals.append(np.max(lst_valid[bin_mask]))
- lst_min_vals.append(np.min(lst_valid[bin_mask]))
- if len(ndvi_bin_centers) < 2:
- print(
- f'Warning: Not enough data bins for regression in {output_path}'
- )
+ ndvi_bin_centers_list.append((bins[i] + bins[i + 1]) / 2)
+ lst_max_vals_list.append(np.max(lst_valid[bin_mask]))
+ lst_min_vals_list.append(np.min(lst_valid[bin_mask]))
+ if len(ndvi_bin_centers_list) < 2:
+ logger.info(
+ 'Warning: Not enough data bins for regression in '
+ '{output_path}'
+ )
tvdi = np.full_like(ndvi, np.nan, dtype=np.float32)
profile.update(dtype=rasterio.float32, count=1, compress='lzw')
os.makedirs((TEMP_DIR / output_path).parent, exist_ok=True)
with rasterio.open(TEMP_DIR / output_path, 'w', **profile) as dst:
dst.write(tvdi, 1)
return f'Result saved at {TEMP_DIR / output_path}'
- ndvi_bin_centers = np.array(ndvi_bin_centers)
- lst_max_vals = np.array(lst_max_vals)
- lst_min_vals = np.array(lst_min_vals)
- slope_max, intercept_max, _, _, _ = linregress(ndvi_bin_centers,
- lst_max_vals)
- slope_min, intercept_min, _, _, _ = linregress(ndvi_bin_centers,
- lst_min_vals)
+ ndvi_bin_centers = np.array(ndvi_bin_centers_list)
+ lst_max_vals = np.array(lst_max_vals_list)
+ lst_min_vals = np.array(lst_min_vals_list)
+ slope_max, intercept_max, _, _, _ = linregress(
+ ndvi_bin_centers, lst_max_vals
+ )
+ slope_min, intercept_min, _, _, _ = linregress(
+ ndvi_bin_centers, lst_min_vals
+ )
lst_max = ndvi * slope_max + intercept_max
lst_min = ndvi * slope_min + intercept_min
denominator = lst_max - lst_min
@@ -710,29 +871,44 @@ class EarthScienceToolkit(BaseToolkit):
dst.write(tvdi, 1)
return f'Result saved at {TEMP_DIR / output_path}'
- def band_ratio(self, sur_refl_b02_path: str, sur_refl_b05_path: str,
- sur_refl_b17_path: str, sur_refl_b18_path: str, sur_refl_b19_path:
- str, output_path: str) ->str:
- """
+ def band_ratio(
+ self,
+ sur_refl_b02_path: str,
+ sur_refl_b05_path: str,
+ sur_refl_b17_path: str,
+ sur_refl_b18_path: str,
+ sur_refl_b19_path: str,
+ output_path: str,
+ ) -> str:
+ r"""
Description:
- Compute a Precipitable Water Vapor (PWV) image from MODIS surface reflectance bands
- using the band ratio method.
- This method interpolates atmospheric window reflectance between 0.865 µm and 1.240 µm,
- computes transmittance in water vapor absorption bands (0.905, 0.936, 0.940 µm),
- and derives PWV in centimeters.
+ Compute a Precipitable Water Vapor (PWV) image from MODIS surface
+ reflectance bands
+ using the band ratio method.
+ This method interpolates atmospheric window reflectance between 0.
+ 865 µm and 1.240 µm,
+ computes transmittance in water vapor absorption bands (0.905, 0.
+ 936, 0.940 µm),
+ and derives PWV in centimeters.
The output GeoTIFF contains four bands:
1. PWV
2. T17 (transmittance at 0.905 µm)
3. T18 (transmittance at 0.936 µm)
4. T19 (transmittance at 0.940 µm)
- Parameters:
- sur_refl_b02_path (str): Path to MODIS surface reflectance band sur_refl_b02 (0.865 µm) GeoTIFF.
- sur_refl_b05_path (str): Path to MODIS surface reflectance band sur_refl_b05 (1.240 µm) GeoTIFF.
- sur_refl_b17_path (str): Path to MODIS surface reflectance band sur_refl_b17 (0.905 µm) GeoTIFF.
- sur_refl_b18_path (str): Path to MODIS surface reflectance band sur_refl_b18 (0.936 µm) GeoTIFF.
- sur_refl_b19_path (str): Path to MODIS surface reflectance band sur_refl_b19 (0.940 µm) GeoTIFF.
- output_path (str): Relative output path for the PWV GeoTIFF, e.g. "question17/pwv_2022-01-16.tif".
+ Args:
+ sur_refl_b02_path (str): Path to MODIS surface reflectance band
+ sur_refl_b02 (0.865 µm) GeoTIFF.
+ sur_refl_b05_path (str): Path to MODIS surface reflectance band
+ sur_refl_b05 (1.240 µm) GeoTIFF.
+ sur_refl_b17_path (str): Path to MODIS surface reflectance band
+ sur_refl_b17 (0.905 µm) GeoTIFF.
+ sur_refl_b18_path (str): Path to MODIS surface reflectance band
+ sur_refl_b18 (0.936 µm) GeoTIFF.
+ sur_refl_b19_path (str): Path to MODIS surface reflectance band
+ sur_refl_b19 (0.940 µm) GeoTIFF.
+ output_path (str): Relative output path for the PWV GeoTIFF, e.g.
+ "question17/pwv_2022-01-16.tif".
Return:
str: Full path to the saved PWV GeoTIFF.
@@ -746,13 +922,19 @@ class EarthScienceToolkit(BaseToolkit):
sur_refl_b19_path="data/MODIS_sur_refl_b19.tif",
output_path="question17/pwv_2022-01-16.tif"
)
- print(result)
+ logger.info(result)
# Output: "Result saved at TEMP_DIR/question17/pwv_2022-01-16.tif"
"""
- with rasterio.open(sur_refl_b02_path) as src02, rasterio.open(
- sur_refl_b05_path) as src05, rasterio.open(sur_refl_b17_path
- ) as src17, rasterio.open(sur_refl_b18_path
- ) as src18, rasterio.open(sur_refl_b19_path) as src19:
+ import numpy as np
+ import rasterio
+
+ with (
+ rasterio.open(sur_refl_b02_path) as src02,
+ rasterio.open(sur_refl_b05_path) as src05,
+ rasterio.open(sur_refl_b17_path) as src17,
+ rasterio.open(sur_refl_b18_path) as src18,
+ rasterio.open(sur_refl_b19_path) as src19,
+ ):
b02 = src02.read(1).astype(np.float32)
b05 = src05.read(1).astype(np.float32)
b17 = src17.read(1).astype(np.float32)
@@ -781,20 +963,27 @@ class EarthScienceToolkit(BaseToolkit):
dst.write(out_data)
return f'Result saved at {TEMP_DIR / output_path}'
- def lst_single_channel(self, bt_path: str, red_path: str, nir_path: str,
- output_path: str) ->str:
+ def lst_single_channel(
+ self, bt_path: str, red_path: str, nir_path: str, output_path: str
+ ) -> str:
"""
Description:
- Estimate Land Surface Temperature (LST) using the Single-Channel method.
- This approach calculates LST from thermal brightness temperature and adjusts
- for surface emissivity estimated using NDVI derived from RED and NIR bands.
- It is suitable for single thermal band sensors such as Landsat 8 TIRS.
-
- Parameters:
+ Estimate Land Surface Temperature (LST) using the Single-Channel
+ method.
+ This approach calculates LST from thermal brightness temperature
+ and adjusts
+ for surface emissivity estimated using NDVI derived from RED and
+ NIR bands.
+ It is suitable for single thermal band sensors such as Landsat 8
+ TIRS.
+
+ Args:
bt_path (str): Path to the Brightness Temperature GeoTIFF (Kelvin).
- red_path (str): Path to the RED band GeoTIFF (e.g., Landsat 8 Band 4).
- nir_path (str): Path to the NIR band GeoTIFF (e.g., Landsat 8 Band 5).
- output_path (str): Relative path for the output LST GeoTIFF,
+ red_path (str): Path to the RED band GeoTIFF (e.g., Landsat 8 Band
+ 4).
+ nir_path (str): Path to the NIR band GeoTIFF (e.g., Landsat 8 Band
+ 5).
+ output_path (str): Relative path for the output LST GeoTIFF,
e.g. "question17/lst_2022-01-16.tif".
Return:
@@ -807,22 +996,27 @@ class EarthScienceToolkit(BaseToolkit):
nir_path="data/Landsat8_B5.tif",
output_path="question17/lst_2022-01-16.tif"
)
- print(result)
+ logger.info(result)
# Output: "Result saved at TEMP_DIR/question17/lst_2022-01-16.tif"
"""
+ import numpy as np
+ import rasterio
+
def read_band(path):
with rasterio.open(path) as src:
band = src.read(1).astype(np.float32)
profile = src.profile
band[band < 0] = np.nan
return band, profile
+
bt, profile = read_band(bt_path)
red, _ = read_band(red_path)
nir, _ = read_band(nir_path)
ndvi = (nir - red) / (nir + red + 1e-06)
- emissivity = np.where(ndvi > 0.7, 0.99, np.where(ndvi < 0.2, 0.96,
- 0.97 + 0.003 * ndvi))
+ emissivity = np.where(
+ ndvi > 0.7, 0.99, np.where(ndvi < 0.2, 0.96, 0.97 + 0.003 * ndvi)
+ )
wavelength = 10.9
c2 = 14387.7
lst = bt / (1 + wavelength * bt / c2 * np.log(emissivity))
@@ -832,19 +1026,24 @@ class EarthScienceToolkit(BaseToolkit):
dst.write(lst.astype(np.float32), 1)
return f'Result saved at {TEMP_DIR / output_path}'
- def lst_multi_channel(self, band31_path: str, band32_path: str,
- output_path: str) ->str:
+ def lst_multi_channel(
+ self, band31_path: str, band32_path: str, output_path: str
+ ) -> str:
"""
Description:
- Estimate Land Surface Temperature (LST) using the multi-channel algorithm.
- This method combines two thermal infrared bands (typically at ~11 μm and ~12 μm)
+ Estimate Land Surface Temperature (LST) using the multi-channel
+ algorithm.
+ This method combines two thermal infrared bands (typically at ~11
+ μm and ~12 μm)
to reduce atmospheric effects and improve LST estimation accuracy.
- Parameters:
- band31_path (str): Path to local GeoTIFF file for thermal band 31 (~11 μm).
- band32_path (str): Path to local GeoTIFF file for thermal band 32 (~12 μm).
+ Args:
+ band31_path (str): Path to local GeoTIFF file for thermal band 31
+ (~11 μm).
+ band32_path (str): Path to local GeoTIFF file for thermal band 32
+ (~12 μm).
output_path (str): Relative path for the output LST GeoTIFF,
- e.g. "question17/lst_2022-01-16.tif".
+ e.g. "question17/lst_2022-01-16.tif".
Return:
str: Full path to the saved LST GeoTIFF.
@@ -855,9 +1054,12 @@ class EarthScienceToolkit(BaseToolkit):
band32_path="data/MODIS_Band32.tif",
output_path="question17/lst_2022-01-16.tif"
)
- print(result)
+ logger.info(result)
# Output: "Result saved at TEMP_DIR/question17/lst_2022-01-16.tif"
"""
+ import numpy as np
+ import rasterio
+
with rasterio.open(band31_path) as src31:
band31 = src31.read(1).astype(np.float32)
profile = src31.profile
@@ -873,30 +1075,38 @@ class EarthScienceToolkit(BaseToolkit):
dst.write(lst.astype(np.float32), 1)
return f'Result saved at {TEMP_DIR / output_path}'
- def split_window(self, band31_path: str, band32_path: str,
- emissivity31_path: str, emissivity32_path: str, parameter: str,
- output_path: str) ->str:
- """
- Description:
- Estimate **Land Surface Temperature (LST)** or **Precipitable Water Vapor (PWV)**
- using the split-window algorithm.
- The method leverages two thermal infrared bands (~11 μm and ~12 μm)
- and emissivity data to correct atmospheric effects and retrieve
- accurate surface or atmospheric parameters.
- Only one parameter is computed based on the user-selected `parameter`.
-
- Parameters:
+ def split_window(
+ self,
+ band31_path: str,
+ band32_path: str,
+ emissivity31_path: str,
+ emissivity32_path: str,
+ parameter: str,
+ output_path: str,
+ ) -> str:
+ r"""Description:
+ Estimate **Land Surface Temperature (LST)** or **Precipitable
+ Water Vapor (PWV)**
+ using the split-window algorithm.
+ The method leverages two thermal infrared bands (~11 μm and ~12 μm)
+ and emissivity data to correct atmospheric effects and retrieve
+ accurate surface or atmospheric Args.
+ Only one parameter is computed based on the user-selected
+ `parameter`.
+
+ Args:
band31_path (str): Path to thermal band 31 GeoTIFF (~11 μm).
band32_path (str): Path to thermal band 32 GeoTIFF (~12 μm).
emissivity31_path (str): Path to emissivity band 31 GeoTIFF.
emissivity32_path (str): Path to emissivity band 32 GeoTIFF.
- parameter (str): Specify either `"LST"` for Land Surface Temperature
- or `"PWV"` for Precipitable Water Vapor.
+ parameter (str): Specify either `"LST"` for Land Surface
+ Temperature or `"PWV"` for Precipitable Water Vapor.
output_path (str): Relative path for the output raster file,
- e.g. `"question17/lst_2022-01-16.tif"`.
+ e.g. `"question17/lst_2022-01-16.tif"`.
Return:
- str: Full path to the saved GeoTIFF containing the selected parameter.
+ str: Full path to the saved GeoTIFF containing the selected
+ parameter.
Example:
# Example 1: Retrieve LST
@@ -908,7 +1118,7 @@ class EarthScienceToolkit(BaseToolkit):
parameter="LST",
output_path="question17/lst_2022-01-16.tif"
)
- print(result)
+ logger.info(result)
# Output: "Result saved at TEMP_DIR/question17/lst_2022-01-16.tif"
# Example 2: Retrieve PWV
@@ -920,9 +1130,12 @@ class EarthScienceToolkit(BaseToolkit):
parameter="PWV",
output_path="question17/pwv_2022-01-16.tif"
)
- print(result)
+ logger.info(result)
# Output: "Result saved at TEMP_DIR/question17/pwv_2022-01-16.tif"
"""
+ import numpy as np
+ import rasterio
+
with rasterio.open(band31_path) as src31:
band31 = src31.read(1).astype(np.float32)
profile = src31.profile
@@ -930,41 +1143,48 @@ class EarthScienceToolkit(BaseToolkit):
band32 = src32.read(1).astype(np.float32)
with rasterio.open(emissivity31_path) as src_e31:
e31 = src_e31.read(1).astype(np.float32)
- print(
- f'Emissivity31 Original range: {np.nanmin(e31):.4f} to {np.nanmax(e31):.4f}'
- )
+ logger.info(
+ f'Emissivity31 Original range: '
+ f'{np.nanmin(e31):.4f} to {np.nanmax(e31):.4f}'
+ )
e31 = e31 * 0.002 + 0.49
- print(
- f'Emissivity31 Corrected range: {np.nanmin(e31):.4f} to {np.nanmax(e31):.4f}'
- )
+ logger.info(
+ f'Emissivity31 Corrected range: '
+ f'{np.nanmin(e31):.4f} to {np.nanmax(e31):.4f}'
+ )
with rasterio.open(emissivity32_path) as src_e32:
e32 = src_e32.read(1).astype(np.float32)
- print(
- f'Emissivity32 Original range: {np.nanmin(e32):.4f} to {np.nanmax(e32):.4f}'
- )
+ logger.info(
+ f'Emissivity32 Original range: '
+ f'{np.nanmin(e32):.4f} to {np.nanmax(e32):.4f}'
+ )
e32 = e32 * 0.002 + 0.49
- print(
- f'Emissivity32 Corrected range: {np.nanmin(e32):.4f} to {np.nanmax(e32):.4f}'
- )
- delta_T = band31 - band32
- print(
- f'Temperature difference ΔT range: {np.nanmin(delta_T):.4f} to {np.nanmax(delta_T):.4f}'
+ logger.info(
+ f'Emissivity32 Corrected range: '
+ f'{np.nanmin(e32):.4f} to {np.nanmax(e32):.4f}'
)
+ delta_T = band31 - band32
+ logger.info(
+ f'Temperature difference ΔT range: '
+ f'{np.nanmin(delta_T):.4f} to {np.nanmax(delta_T):.4f}'
+ )
eps_mean = (e31 + e32) / 2
- print(
- f'Mean emissivity range: {np.nanmin(eps_mean):.4f} to {np.nanmax(eps_mean):.4f}'
- )
+ logger.info(
+ f'Mean emissivity range: {np.nanmin(eps_mean):.4f} to '
+ f'{np.nanmax(eps_mean):.4f}'
+ )
delta_eps = e31 - e32
- print(
- f'Emissivity difference Δε range: {np.nanmin(delta_eps):.4f} to {np.nanmax(delta_eps):.4f}'
- )
+ logger.info(
+ f'Emissivity difference Δε range: {np.nanmin(delta_eps):.4f} '
+ f'to {np.nanmax(delta_eps):.4f}'
+ )
eps_mean = np.clip(eps_mean, 0.8, 1.0)
if parameter.upper() == 'LST':
C0, C1, C2, C3, C4 = 0.268, 1.378, 0.183, 54.3, -2.238
t31_c = band31 - 273.15
term1 = C0
term2 = C1 * t31_c
- term3 = C2 * t31_c ** 2 / 1000
+ term3 = C2 * t31_c**2 / 1000
term4 = (C3 + C4 * delta_T) * (1 - eps_mean)
term5 = (C3 + C4 * delta_T) * delta_eps
lst = term1 + term2 + term3 + term4 + term5
@@ -982,27 +1202,37 @@ class EarthScienceToolkit(BaseToolkit):
os.makedirs((TEMP_DIR / output_path).parent, exist_ok=True)
with rasterio.open(TEMP_DIR / output_path, 'w', **profile) as dst:
dst.write(output, 1)
- print(f'\nFinal {out_band_name} statistics:')
- print(f'Min: {np.nanmin(output):.2f}')
- print(f'Max: {np.nanmax(output):.2f}')
- print(f'Mean: {np.nanmean(output):.2f}')
- print(
- f'Valid data percent: {np.sum(~np.isnan(output)) / output.size * 100:.2f}%'
- )
+ logger.info(f'\nFinal {out_band_name} statistics:')
+ logger.info(f'Min: {np.nanmin(output):.2f}')
+ logger.info(f'Max: {np.nanmax(output):.2f}')
+ logger.info(f'Mean: {np.nanmean(output):.2f}')
+ logger.info(
+ f'Valid data percent: '
+ f'{np.sum(~np.isnan(output)) / output.size * 100:.2f}%'
+ )
return f'Result saved at {TEMP_DIR / output_path}'
- def temperature_emissivity_separation(self, tir_band_paths: list[str],
- representative_band_index: int, output_path: str) ->str:
+ def temperature_emissivity_separation(
+ self,
+ tir_band_paths: list[str],
+ representative_band_index: int,
+ output_path: str,
+ ) -> str:
"""
Description:
- Estimate Land Surface Temperature (LST) using the Temperature Emissivity Separation (TES)
- algorithm with empirical emissivity estimation. Outputs a multi-band raster containing LST,
+ Estimate Land Surface Temperature (LST) using the Temperature
+ Emissivity Separation (TES)
+ algorithm with empirical emissivity estimation. Outputs a
+ multi-band raster containing LST,
emissivity, and emissivity variation (Δε).
- Parameters:
- tir_band_paths (list[str]): List of paths to Thermal Infrared (TIR) GeoTIFFs (e.g., ASTER Bands 10–14).
- representative_band_index (int): Index of the TIR band used as the reference brightness temperature (e.g., 3 for Band 13).
- output_path (str): Relative path for saving the output raster file (e.g., "question17/lst_2022-01-16.tif").
+ Args:
+ tir_band_paths (list[str]): List of paths to Thermal Infrared
+ (TIR) GeoTIFFs (e.g., ASTER Bands 10-14).
+ representative_band_index (int): Index of the TIR band used as the
+ reference brightness temperature (e.g., 3 for Band 13).
+ output_path (str): Relative path for saving the output raster file
+ (e.g., "question17/lst_2022-01-16.tif").
Return:
str: Path to the saved GeoTIFF file containing:
@@ -1012,12 +1242,16 @@ class EarthScienceToolkit(BaseToolkit):
Example:
>>> temperature_emissivity_separation(
- ... ["ASTER_B10.tif", "ASTER_B11.tif", "ASTER_B12.tif", "ASTER_B13.tif", "ASTER_B14.tif"],
+ ... ["ASTER_B10.tif", "ASTER_B11.tif", "ASTER_B12.tif",
+ "ASTER_B13.tif", "ASTER_B14.tif"],
... representative_band_index=3,
... output_path="question17/lst_2022-01-16.tif"
... )
'Result saved at question17/lst_2022-01-16.tif'
"""
+ import numpy as np
+ import rasterio
+
c2 = 14387.7
wavelength = 10.6
with rasterio.open(tir_band_paths[representative_band_index]) as src:
@@ -1039,15 +1273,20 @@ class EarthScienceToolkit(BaseToolkit):
emissivity = np.clip(emissivity, 0.85, 0.999)
Tb = bands_stack[representative_band_index]
Tb[~valid_mask] = np.nan
- valid_calc = (Tb > 0) & (emissivity > 0) & ~np.isnan(Tb) & ~np.isnan(
- emissivity)
+ valid_calc = (
+ (Tb > 0) & (emissivity > 0) & ~np.isnan(Tb) & ~np.isnan(emissivity)
+ )
lst = np.full_like(Tb, np.nan)
- lst[valid_calc] = Tb[valid_calc] / (1 + wavelength * Tb[valid_calc] /
- c2 * np.log(emissivity[valid_calc]))
+ lst[valid_calc] = Tb[valid_calc] / (
+ 1
+ + wavelength * Tb[valid_calc] / c2 * np.log(emissivity[valid_calc])
+ )
out_stack = np.stack([lst, emissivity, delta_epsilon], axis=0).astype(
- np.float32)
- profile.update(dtype=rasterio.float32, count=3, compress='lzw',
- nodata=np.nan)
+ np.float32
+ )
+ profile.update(
+ dtype=rasterio.float32, count=3, compress='lzw', nodata=np.nan
+ )
out_full_path = TEMP_DIR / output_path
os.makedirs(out_full_path.parent, exist_ok=True)
with rasterio.open(out_full_path, 'w', **profile) as dst:
@@ -1057,21 +1296,34 @@ class EarthScienceToolkit(BaseToolkit):
dst.set_band_description(3, 'Emissivity Variation (Δε)')
return f'Result saved at {out_full_path}'
- def modis_day_night_lst(self, BT_day_path: str, BT_night_path: str,
- Emis_day_path: str, Emis_night_path: str, output_path: str) ->str:
+ def modis_day_night_lst(
+ self,
+ BT_day_path: str,
+ BT_night_path: str,
+ Emis_day_path: str,
+ Emis_night_path: str,
+ output_path: str,
+ ) -> str:
"""
Description:
- Estimate Land Surface Temperature (LST) from MODIS Day and Night brightness temperatures
- using a single-channel correction algorithm. Performs resampling, scaling, and filtering
- of emissivity and brightness temperature bands to output a six-band GeoTIFF.
-
- Parameters:
- BT_day_path (str): Path to local MODIS Brightness Temperature Day GeoTIFF.
- BT_night_path (str): Path to local MODIS Brightness Temperature Night GeoTIFF.
- Emis_day_path (str): Path to MODIS Emissivity Day GeoTIFF (scaled by 0.002, offset by 0.49).
- Emis_night_path (str): Path to MODIS Emissivity Night GeoTIFF (scaled by 0.002, offset by 0.49).
- output_path (str): Relative path for saving the output raster file
- (e.g., "question17/lst_2022-01-16.tif").
+ Estimate Land Surface Temperature (LST) from MODIS Day and Night
+ brightness temperatures
+ using a single-channel correction algorithm. Performs resampling,
+ scaling, and filtering
+ of emissivity and brightness temperature bands to output a
+ six-band GeoTIFF.
+
+ Args:
+ BT_day_path (str): Path to local MODIS Brightness Temperature Day
+ GeoTIFF.
+ BT_night_path (str): Path to local MODIS Brightness Temperature
+ Night GeoTIFF.
+ Emis_day_path (str): Path to MODIS Emissivity Day GeoTIFF (scaled
+ by 0.002, offset by 0.49).
+ Emis_night_path (str): Path to MODIS Emissivity Night GeoTIFF
+ (scaled by 0.002, offset by 0.49).
+ output_path (str): Relative path for saving the output raster file
+ (e.g., "question17/lst_2022-01-16.tif").
Return:
str: Path to the exported GeoTIFF with six bands:
@@ -1093,8 +1345,12 @@ class EarthScienceToolkit(BaseToolkit):
'Result saved at question17/lst_2022-01-16.tif'
"""
- def resample_to_reference(src_data: np.ndarray, src_profile: dict,
- ref_profile: dict) ->np.ndarray:
+ import numpy as np
+ import rasterio
+
+ def resample_to_reference(
+ src_data: np.ndarray, src_profile: dict, ref_profile: dict
+ ) -> np.ndarray:
src_height, src_width = src_data.shape
dst_height = ref_profile['height']
dst_width = ref_profile['width']
@@ -1107,43 +1363,57 @@ class EarthScienceToolkit(BaseToolkit):
src_j = min(int(j / scale_w), src_width - 1)
dst_data[i, j] = src_data[src_i, src_j]
return dst_data
+
MIN_TEMP = 270
MAX_TEMP = 325
with rasterio.open(BT_day_path) as src:
BT_day = src.read(1).astype(np.float32)
- BT_day = np.where((BT_day > MAX_TEMP) | (BT_day < MIN_TEMP), np
- .nan, BT_day)
+ BT_day = np.where(
+ (BT_day > MAX_TEMP) | (BT_day < MIN_TEMP), np.nan, BT_day
+ )
ref_profile = src.profile.copy()
with rasterio.open(BT_night_path) as src:
BT_night_raw = src.read(1).astype(np.float32)
- BT_night_raw = np.where((BT_night_raw > MAX_TEMP) | (
- BT_night_raw < MIN_TEMP), np.nan, BT_night_raw)
- BT_night = resample_to_reference(BT_night_raw, src.profile,
- ref_profile)
+ BT_night_raw = np.where(
+ (BT_night_raw > MAX_TEMP) | (BT_night_raw < MIN_TEMP),
+ np.nan,
+ BT_night_raw,
+ )
+ BT_night = resample_to_reference(
+ BT_night_raw, src.profile, ref_profile
+ )
with rasterio.open(Emis_day_path) as src:
Emis_day_raw = src.read(1).astype(np.float32)
Emis_day_raw = Emis_day_raw * 0.002 + 0.49
- Emis_day = resample_to_reference(Emis_day_raw, src.profile,
- ref_profile)
+ Emis_day = resample_to_reference(
+ Emis_day_raw, src.profile, ref_profile
+ )
with rasterio.open(Emis_night_path) as src:
Emis_night_raw = src.read(1).astype(np.float32)
Emis_night_raw = Emis_night_raw * 0.002 + 0.49
- Emis_night = resample_to_reference(Emis_night_raw, src.profile,
- ref_profile)
+ Emis_night = resample_to_reference(
+ Emis_night_raw, src.profile, ref_profile
+ )
Emis_day_clipped = np.clip(Emis_day, 0.5, 1.0)
Emis_night_clipped = np.clip(Emis_night, 0.5, 1.0)
wavelength = 11.0
c2 = 14387.7
- LST_day = BT_day / (1 + wavelength * BT_day / c2 * np.log(
- Emis_day_clipped))
- LST_night = BT_night / (1 + wavelength * BT_night / c2 * np.log(
- Emis_night_clipped))
- LST_day = np.where((LST_day > MAX_TEMP) | (LST_day < MIN_TEMP), np.
- nan, LST_day)
- LST_night = np.where((LST_night > MAX_TEMP) | (LST_night < MIN_TEMP
- ), np.nan, LST_night)
- out_stack = np.stack([LST_day, LST_night, BT_day, BT_night,
- Emis_day, Emis_night], axis=0).astype(np.float32)
+ LST_day = BT_day / (
+ 1 + wavelength * BT_day / c2 * np.log(Emis_day_clipped)
+ )
+ LST_night = BT_night / (
+ 1 + wavelength * BT_night / c2 * np.log(Emis_night_clipped)
+ )
+ LST_day = np.where(
+ (LST_day > MAX_TEMP) | (LST_day < MIN_TEMP), np.nan, LST_day
+ )
+ LST_night = np.where(
+ (LST_night > MAX_TEMP) | (LST_night < MIN_TEMP), np.nan, LST_night
+ )
+ out_stack = np.stack(
+ [LST_day, LST_night, BT_day, BT_night, Emis_day, Emis_night],
+ axis=0,
+ ).astype(np.float32)
profile = ref_profile.copy()
profile.update(count=6, dtype=rasterio.float32, compress='lzw')
os.makedirs((TEMP_DIR / output_path).parent, exist_ok=True)
@@ -1151,37 +1421,38 @@ class EarthScienceToolkit(BaseToolkit):
dst.write(out_stack)
return f'Result saved at {TEMP_DIR / output_path}'
- def ttm_lst(self, tir_band_paths: list[str], output_path: str,
- wavelengths: list[float]=[8.3, 8.65, 9.1]) ->str:
- """
- Description:
- Estimate Land Surface Temperature (LST) and surface emissivity using a simplified
- Three-Temperature Method (TTM). Reads three thermal infrared (TIR) bands, performs
- filtering, applies empirical atmospheric correction, and outputs a three-band
- GeoTIFF with LST and emissivity estimates.
-
- Parameters:
- tir_band_paths (list[str]): Paths to three thermal infrared band GeoTIFF files
- (e.g., ASTER B10, B11, B12).
- output_path (str): Relative path to save the output raster
- (e.g., "question17/lst_2022-01-16.tif").
- wavelengths (list[float], optional): Central wavelengths (in μm) for each band.
- Defaults to [8.3, 8.65, 9.1].
+ def ttm_lst(
+ self,
+ tir_band_paths: list[str],
+ output_path: str,
+ wavelengths: list[float] | None = None,
+ ) -> str:
+ """Estimate LST and emissivity using Three-Temperature Method.
+
+ Reads three thermal infrared (TIR) bands, performs filtering,
+ applies empirical atmospheric correction, and outputs a
+ three-band GeoTIFF with LST and emissivity estimates.
+
+ Args:
+ tir_band_paths (list[str]): Paths to three TIR band GeoTIFFs
+ (e.g., ASTER B10, B11, B12).
+ output_path (str): Relative path to save the output raster.
+ wavelengths (list[float], optional): Central wavelengths (μm)
+ for each band. Defaults to [8.3, 8.65, 9.1].
Return:
- str: Path to the exported GeoTIFF with three bands:
- - Band 1: LST (Kelvin)
- - Band 2: Emissivity estimate (Band 1)
- - Band 3: Emissivity estimate (Band 2)
+ str: Path to exported GeoTIFF with LST (K) and emissivity bands.
Example:
- >>> ttm_lst(
- ... tir_band_paths=["ASTER_B10.tif", "ASTER_B11.tif", "ASTER_B12.tif"],
- ... output_path="question17/lst_2022-01-16.tif"
- ... )
- 'Result saved at question17/lst_2022-01-16.tif'
+ >>> ttm_lst(["B10.tif", "B11.tif", "B12.tif"], "out/lst.tif")
+ 'Result saved at out/lst.tif'
"""
- print('Reading input bands...')
+ import numpy as np
+ import rasterio
+
+ if wavelengths is None:
+ wavelengths = [8.3, 8.65, 9.1]
+ logger.info('Reading input bands...')
bands_data = []
profile = None
for path in tir_band_paths:
@@ -1192,58 +1463,81 @@ class EarthScienceToolkit(BaseToolkit):
profile = src.profile.copy()
B1, B2, B3 = bands_data
shape = B1.shape
- print(f'Image size: {shape[1]} x {shape[0]}')
- valid_mask = (B1 > 240) & (B1 < 340) & (B2 > 240) & (B2 < 340) & (B3 >
- 240) & (B3 < 340)
+ logger.info(f'Image size: {shape[1]} x {shape[0]}')
+ valid_mask = (
+ (B1 > 240)
+ & (B1 < 340)
+ & (B2 > 240)
+ & (B2 < 340)
+ & (B3 > 240)
+ & (B3 < 340)
+ )
lst = np.full(shape, np.nan, dtype=np.float32)
eps1_arr = np.full(shape, np.nan, dtype=np.float32)
eps2_arr = np.full(shape, np.nan, dtype=np.float32)
valid_indices = np.where(valid_mask)
- print(f'Number of valid pixels: {len(valid_indices[0])}')
+ logger.info(f'Number of valid pixels: {len(valid_indices[0])}')
weights = np.array([0.3, 0.3, 0.4])
- lst_valid = B1[valid_mask] * weights[0] + B2[valid_mask] * weights[1
- ] + B3[valid_mask] * weights[2]
+ lst_valid = (
+ B1[valid_mask] * weights[0]
+ + B2[valid_mask] * weights[1]
+ + B3[valid_mask] * weights[2]
+ )
lst_valid += 2.0
lst[valid_mask] = lst_valid
eps_mean = 0.95
eps1_arr[valid_mask] = eps_mean
eps2_arr[valid_mask] = eps_mean
- print('Saving results...')
- profile.update(count=3, dtype=rasterio.float32, compress='lzw',
- nodata=np.nan)
+ logger.info('Saving results...')
+ if profile is None:
+ raise RuntimeError('Failed to read profile from input bands')
+ profile.update(
+ count=3, dtype=rasterio.float32, compress='lzw', nodata=np.nan
+ )
os.makedirs((TEMP_DIR / output_path).parent, exist_ok=True)
with rasterio.open(TEMP_DIR / output_path, 'w', **profile) as dst:
dst.write(lst, 1)
dst.write(eps1_arr, 2)
dst.write(eps2_arr, 3)
- print(
- f'Processing complete! Results saved to: {TEMP_DIR / output_path}')
+ logger.info(
+ f'Processing complete! Results saved to: {TEMP_DIR / output_path}'
+ )
valid_temps = lst[~np.isnan(lst)]
- print('\nTemperature Statistics:')
- print(f'Minimum: {np.min(valid_temps):.2f}K')
- print(f'Maximum: {np.max(valid_temps):.2f}K')
- print(f'Mean: {np.mean(valid_temps):.2f}K')
- print(f'Median: {np.median(valid_temps):.2f}K')
+ logger.info('\nTemperature Statistics:')
+ logger.info(f'Minimum: {np.min(valid_temps):.2f}K')
+ logger.info(f'Maximum: {np.max(valid_temps):.2f}K')
+ logger.info(f'Mean: {np.mean(valid_temps):.2f}K')
+ logger.info(f'Median: {np.median(valid_temps):.2f}K')
return f'Result saved at {TEMP_DIR / output_path}'
- def calculate_mean_lst_by_ndvi(self, red_paths: (str | list[str]),
- nir_paths: (str | list[str]), lst_paths: (str | list[str]),
- ndvi_threshold: float, mode: str='above') ->float:
+ def calculate_mean_lst_by_ndvi(
+ self,
+ red_paths: (str | list[str]),
+ nir_paths: (str | list[str]),
+ lst_paths: (str | list[str]),
+ ndvi_threshold: float,
+ mode: str = 'above',
+ ) -> float:
"""
- Calculate the average Land Surface Temperature (LST) across multiple images
- where NDVI is either above or below a given threshold.
+ Calculate the average Land Surface Temperature (LST) across multiple
+ images where NDVI is either above or below a given threshold.
- Parameters:
+ Args:
red_paths (str or list): Path(s) to red band image(s).
nir_paths (str or list): Path(s) to near-infrared (NIR) image(s).
- lst_paths (str or list): Path(s) to land surface temperature (LST) image(s).
+ lst_paths (str or list): Path(s) to land surface temperature (LST)
+ image(s).
ndvi_threshold (float): Threshold value for NDVI.
- mode (str): 'above' for NDVI >= threshold, 'below' for NDVI < threshold.
+ mode (str): 'above' for NDVI >= threshold, 'below' for NDVI <
+ threshold.
Returns:
- float: Mean of LST values over selected NDVI regions across all image sets.
- Returns np.nan if no valid pixels found.
+ float: Mean of LST values over selected NDVI regions across all
+ image sets. Returns np.nan if no valid pixels found.
"""
+ import numpy as np
+ import rasterio
+
if isinstance(red_paths, str):
red_paths = [red_paths]
if isinstance(nir_paths, str):
@@ -1252,14 +1546,19 @@ class EarthScienceToolkit(BaseToolkit):
lst_paths = [lst_paths]
if not len(red_paths) == len(nir_paths) == len(lst_paths):
raise ValueError(
- 'red_paths, nir_paths, and lst_paths must have the same length.'
- )
+ 'red_paths, nir_paths, and lst_paths must '
+ 'have the same length.'
+ )
all_selected_lst = []
- for red_path, nir_path, lst_path in zip(red_paths, nir_paths, lst_paths
- ):
+ for red_path, nir_path, lst_path in zip(
+ red_paths, nir_paths, lst_paths
+ ):
try:
- with rasterio.open(red_path) as red_src, rasterio.open(nir_path
- ) as nir_src, rasterio.open(lst_path) as lst_src:
+ with (
+ rasterio.open(red_path) as red_src,
+ rasterio.open(nir_path) as nir_src,
+ rasterio.open(lst_path) as lst_src,
+ ):
red = red_src.read(1).astype('float32')
nir = nir_src.read(1).astype('float32')
lst = lst_src.read(1).astype('float32')
@@ -1274,32 +1573,42 @@ class EarthScienceToolkit(BaseToolkit):
if selected_lst.size > 0:
all_selected_lst.append(selected_lst)
except Exception as e:
- print(
+ logger.info(
f'Error processing {red_path}, {nir_path}, {lst_path}: {e}'
- )
+ )
continue
if not all_selected_lst:
return float('nan')
combined_lst_values = np.concatenate(all_selected_lst)
return float(np.nanmean(combined_lst_values))
- def calculate_max_lst_by_ndvi(self, red_path, nir_path, lst_path,
- ndvi_threshold, mode='above'):
+ def calculate_max_lst_by_ndvi(
+ self, red_path, nir_path, lst_path, ndvi_threshold, mode='above'
+ ):
"""
- Calculate the maximum Land Surface Temperature (LST) in areas where NDVI is above or below a given threshold.
+ Calculate the maximum Land Surface Temperature (LST) in areas where
+ NDVI is above or below a given threshold.
- Parameters:
+ Args:
red_path (str): Path to the red band image.
nir_path (str): Path to the near-infrared (NIR) band image.
lst_path (str): Path to the land surface temperature (LST) image.
ndvi_threshold (float): Threshold value for NDVI.
- mode (str): 'above' to select NDVI >= threshold, 'below' for NDVI < threshold. Default is 'above'.
+ mode (str): 'above' to select NDVI >= threshold, 'below' for NDVI
+ < threshold. Default is 'above'.
Returns:
- float: Maximum LST value over the selected NDVI region. Returns np.nan if no valid data.
+ float: Maximum LST value over the selected NDVI region. Returns np.
+ nan if no valid data.
"""
- with rasterio.open(red_path) as red_src, rasterio.open(nir_path
- ) as nir_src, rasterio.open(lst_path) as lst_src:
+ import numpy as np
+ import rasterio
+
+ with (
+ rasterio.open(red_path) as red_src,
+ rasterio.open(nir_path) as nir_src,
+ rasterio.open(lst_path) as lst_src,
+ ):
red = red_src.read(1).astype('float32')
nir = nir_src.read(1).astype('float32')
lst = lst_src.read(1).astype('float32')
@@ -1314,22 +1623,32 @@ class EarthScienceToolkit(BaseToolkit):
max_lst = np.nanmax(selected_lst)
return float(max_lst)
- def calculate_ATI(self, day_temp_path: str, night_temp_path: str,
- albedo_path: str, output_path: str) ->str:
+ def calculate_ATI(
+ self,
+ day_temp_path: str,
+ night_temp_path: str,
+ albedo_path: str,
+ output_path: str,
+ ) -> str:
"""
Description:
- Estimate Apparent Thermal Inertia (ATI) using the Thermal Inertia Method.
- ATI is computed as (1 - Albedo) / (Daytime BT - Nighttime BT) and serves as a proxy for
- land surface heat retention and thermal stability over diurnal cycles.
- The function aligns all raster layers to the daytime brightness temperature
- raster's resolution and extent before calculation.
-
- Parameters:
- day_temp_path (str): Path to the daytime brightness temperature (BT) GeoTIFF.
- night_temp_path (str): Path to the nighttime brightness temperature (BT) GeoTIFF.
+ Estimate Apparent Thermal Inertia (ATI) using the Thermal Inertia
+ Method.
+ ATI is computed as (1 - Albedo) / (Daytime BT - Nighttime BT) and
+ serves as a proxy for
+ land surface heat retention and thermal stability over diurnal
+ cycles.
+ The function aligns all raster layers to the daytime brightness
+ temperature raster's resolution and extent before calculation.
+
+ Args:
+ day_temp_path (str): Path to the daytime brightness temperature
+ (BT) GeoTIFF.
+ night_temp_path (str): Path to the nighttime brightness
+ temperature (BT) GeoTIFF.
albedo_path (str): Path to the surface albedo GeoTIFF.
output_path (str): Relative path to save the ATI raster, e.g.
- "question17/thermal_inertia_2022-01-16.tif".
+ "question17/thermal_inertia_2022-01-16.tif".
Return:
str: Path to the saved Apparent Thermal Inertia GeoTIFF file.
@@ -1344,14 +1663,19 @@ class EarthScienceToolkit(BaseToolkit):
'Result saved at question17/thermal_inertia_2022-01-16.tif'
"""
- def resample_to_reference(src_data: np.ndarray, src_profile: dict,
- ref_profile: dict) ->np.ndarray:
+ import numpy as np
+ import rasterio
+ from osgeo import gdal
+
+ def resample_to_reference(
+ src_data: np.ndarray, src_profile: dict, ref_profile: dict
+ ) -> np.ndarray:
"""
Description:
- Resample a raster array to match the resolution and extent of a reference raster profile
- using GDAL bilinear resampling.
+ Resample a raster array to match the resolution and extent of
+ a reference raster profile using GDAL bilinear resampling.
- Parameters:
+ Args:
src_data (np.ndarray): Source raster data to be resampled.
src_profile (dict): Metadata profile of the source raster.
ref_profile (dict): Metadata profile of the reference raster.
@@ -1363,21 +1687,36 @@ class EarthScienceToolkit(BaseToolkit):
temp_dst = 'temp_dst.tif'
try:
driver = gdal.GetDriverByName('GTiff')
- dataset = driver.Create(temp_src, src_profile['width'],
- src_profile['height'], 1, gdal.GDT_Float32)
+ dataset = driver.Create(
+ temp_src,
+ src_profile['width'],
+ src_profile['height'],
+ 1,
+ gdal.GDT_Float32,
+ )
transform = src_profile['transform']
- geotransform = [transform[2], transform[0], transform[1],
- transform[5], transform[3], transform[4]]
+ geotransform = [
+ transform[2],
+ transform[0],
+ transform[1],
+ transform[5],
+ transform[3],
+ transform[4],
+ ]
dataset.SetGeoTransform(geotransform)
- if 'crs' in src_profile and src_profile['crs']:
+ if src_profile.get('crs'):
dataset.SetProjection(src_profile['crs'].to_wkt())
else:
dataset.SetProjection('EPSG:4326')
dataset.GetRasterBand(1).WriteArray(src_data)
dataset = None
- gdal.Warp(temp_dst, temp_src, width=ref_profile['width'],
- height=ref_profile['height'], resampleAlg=gdal.GRA_Bilinear
- )
+ gdal.Warp(
+ temp_dst,
+ temp_src,
+ width=ref_profile['width'],
+ height=ref_profile['height'],
+ resampleAlg=gdal.GRA_Bilinear,
+ )
dataset = gdal.Open(temp_dst)
resampled_data = dataset.GetRasterBand(1).ReadAsArray()
dataset = None
@@ -1387,6 +1726,7 @@ class EarthScienceToolkit(BaseToolkit):
os.remove(temp_src)
if os.path.exists(temp_dst):
os.remove(temp_dst)
+
with rasterio.open(day_temp_path) as src_day:
BT_day = src_day.read(1).astype(np.float32)
day_profile = src_day.profile
@@ -1409,32 +1749,54 @@ class EarthScienceToolkit(BaseToolkit):
dst.write(ATI, 1)
return f'Result saved at {out_path}'
- def dual_polarization_differential(self, pol1_path: str, pol2_path: str,
- parameter: str, output_path: str, a: float=0.3, b: float=0.1,
- input_unit: str='dB') ->str:
- """
- Dual-Polarization Differential Method (DPDM) for microwave remote sensing parameter inversion.
-
- Supports soil moisture and vegetation index estimation with improved data handling and flexible parameters.
-
- Parameters:
- pol1_path (str): File path for the first polarization band GeoTIFF (e.g., VV).
- pol2_path (str): File path for the second polarization band GeoTIFF (e.g., VH).
- parameter (str): Parameter to invert, options: "soil_moisture" or "vegetation_index".
- output_path (str): relative path for the output raster file, e.g. "question17/thermal_inertia_2022-01-16.tif"
- a (float, optional): Linear coefficient for soil moisture model. Default is 0.3.
- b (float, optional): Intercept for soil moisture model. Default is 0.1.
- input_unit (str, optional): Unit of input data, either "dB" or "linear". Default is "dB".
+ def dual_polarization_differential(
+ self,
+ pol1_path: str,
+ pol2_path: str,
+ parameter: str,
+ output_path: str,
+ a: float = 0.3,
+ b: float = 0.1,
+ input_unit: str = 'dB',
+ ) -> str:
+ """
+ Dual-Polarization Differential Method (DPDM) for microwave remote
+ sensing parameter inversion.
+
+ Supports soil moisture and vegetation index estimation with improved
+ data handling and flexible Args.
+
+ Args:
+ pol1_path (str): File path for the first polarization band GeoTIFF
+ (e.g., VV).
+ pol2_path (str): File path for the second polarization band
+ GeoTIFF (e.g., VH).
+ parameter (str): Parameter to invert, options: "soil_moisture" or
+ "vegetation_index".
+ output_path (str): relative path for the output raster file, e.g.
+ "question17/thermal_inertia_2022-01-16.tif"
+ a (float, optional): Linear coefficient for soil moisture model.
+ Default is 0.3.
+ b (float, optional): Intercept for soil moisture model. Default is
+ 0.1.
+ input_unit (str, optional): Unit of input data, either "dB" or
+ "linear". Default is "dB".
Returns:
str: Path to the exported parameter GeoTIFF.
"""
+ import numpy as np
+ import rasterio
+
def db2linear(db):
"""Convert decibel (dB) values to linear scale."""
return 10 ** (db / 10)
- with rasterio.open(pol1_path) as src1, rasterio.open(pol2_path
- ) as src2:
+
+ with (
+ rasterio.open(pol1_path) as src1,
+ rasterio.open(pol2_path) as src2,
+ ):
band1 = src1.read(1).astype(np.float32)
band2 = src2.read(1).astype(np.float32)
profile = src1.profile
@@ -1453,49 +1815,75 @@ class EarthScienceToolkit(BaseToolkit):
output[valid_mask] = diff[valid_mask] / sum_[valid_mask]
else:
raise ValueError(
- "Unsupported parameter. Choose 'soil_moisture' or 'vegetation_index'."
- )
+ "Unsupported parameter. "
+ "Choose 'soil_moisture' or 'vegetation_index'."
+ )
profile.update(dtype=rasterio.float32, count=1, compress='lzw')
os.makedirs((TEMP_DIR / output_path).parent, exist_ok=True)
with rasterio.open(TEMP_DIR / output_path, 'w', **profile) as dst:
dst.write(output, 1)
return f'Result saved at {TEMP_DIR / output_path}'
- def dual_frequency_diff(self, band1_path: str, band2_path: str,
- parameter: str, alpha: float, beta: float, output_path: str) ->str:
- """
- Dual-frequency Differential Method (DDM) for parameter inversion using local raster data.
+ def dual_frequency_diff(
+ self,
+ band1_path: str,
+ band2_path: str,
+ parameter: str,
+ alpha: float,
+ beta: float,
+ output_path: str,
+ ) -> str:
+ r"""Dual-frequency Differential Method (DDM) for parameter inversion.
- Supports inversion of multiple parameters via empirical linear models:
+ Uses local raster data for parameter inversion via empirical linear
+ models:
- Soil Moisture (SM): param = alpha*(band1 - band2) + beta
- Vegetation Index (VI): param = alpha*(band1 - band2) + beta
- Leaf Area Index (LAI): param = alpha*(band1 - band2) + beta
- Parameters:
- band1_path (str): File path for frequency 1 polarization band GeoTIFF.
- band2_path (str): File path for frequency 2 polarization band GeoTIFF.
- parameter (str): Parameter to invert. Options: 'SM', 'VI', 'LAI'. Default is 'SM'.
+ Args:
+ band1_path (str): File path for frequency 1 polarization band
+ GeoTIFF.
+ band2_path (str): File path for frequency 2 polarization band
+ GeoTIFF.
+ parameter (str): Parameter to invert. Options: 'SM', 'VI', 'LAI'.
+ Default is 'SM'.
alpha (float, optional): Slope coefficient to override default.
beta (float, optional): Intercept coefficient to override default.
- output_path (str): relative path for the output raster file, e.g. "question17/thermal_inertia_2022-01-16.tif"
+ output_path (str): Relative path for the output raster file,
+ e.g. "question17/thermal_inertia_2022-01-16.tif"
Returns:
- str: Path to the saved combined output GeoTIFF (difference and parameter).
+ str: Path to the saved combined output GeoTIFF (difference and
+ parameter).
"""
- param_models = {'SM': {'alpha': 0.7, 'beta': 0.1}, 'VI': {'alpha':
- 0.5, 'beta': 0.0}, 'LAI': {'alpha': 0.6, 'beta': 0.05}}
+ import numpy as np
+ import rasterio
+
+ param_models = {
+ 'SM': {'alpha': 0.7, 'beta': 0.1},
+ 'VI': {'alpha': 0.5, 'beta': 0.0},
+ 'LAI': {'alpha': 0.6, 'beta': 0.05},
+ }
parameter_upper = parameter.upper()
if parameter_upper not in param_models:
raise ValueError(
- f"Unsupported parameter '{parameter}'. Choose from {list(param_models.keys())}"
- )
- alpha_val = alpha if alpha is not None else param_models[
- parameter_upper]['alpha']
- beta_val = beta if beta is not None else param_models[parameter_upper][
- 'beta']
- with rasterio.open(band1_path) as src1, rasterio.open(band2_path
- ) as src2:
+ f"Unsupported parameter '{parameter}'. "
+ f"Choose from {list(param_models.keys())}"
+ )
+ alpha_val = (
+ alpha
+ if alpha is not None
+ else param_models[parameter_upper]['alpha']
+ )
+ beta_val = (
+ beta if beta is not None else param_models[parameter_upper]['beta']
+ )
+ with (
+ rasterio.open(band1_path) as src1,
+ rasterio.open(band2_path) as src2,
+ ):
band1 = src1.read(1).astype(np.float32)
band2 = src2.read(1).astype(np.float32)
profile = src1.profile
@@ -1518,36 +1906,53 @@ class EarthScienceToolkit(BaseToolkit):
dst.write(param_img, 2)
return f'Result saved at {TEMP_DIR / output_path}'
- def multi_freq_bt(self, bt_paths: list[str], diff_pairs: list[list[int]
- ], parameter: str, output_path: str) ->str:
- """
- Multi-frequency Brightness Temperature Method for parameter inversion using local raster data.
-
- Parameters:
- bt_paths (list[str]): List of local file paths for brightness temperature GeoTIFF bands
- (e.g., ["BT_10GHz.tif", "BT_19GHz.tif", "BT_37GHz.tif"]).
- diff_pairs (list[list[int]]): List of index pairs from bt_paths for difference calculation (e.g., [[0,1],[1,2]]).
+ def multi_freq_bt(
+ self,
+ bt_paths: list[str],
+ diff_pairs: list[list[int]],
+ parameter: str,
+ output_path: str,
+ ) -> str:
+ """Multi-frequency Brightness Temperature Method for inversion.
+
+ Uses local raster data for parameter inversion.
+
+ Args:
+ bt_paths (list[str]): List of local file paths for brightness
+ temperature GeoTIFF bands (e.g., ["BT_10GHz.tif",
+ "BT_19GHz.tif", "BT_37GHz.tif"]).
+ diff_pairs (list[list[int]]): List of index pairs from bt_paths
+ for difference calculation (e.g., [[0,1],[1,2]]).
parameter (str): Parameter to invert. Options: 'SM', 'VWC', 'LAI'.
- output_path (str): relative path for the output raster file, e.g. "question17/thermal_inertia_2022-01-16.tif"
+ output_path (str): Relative path for the output raster file,
+ e.g. "question17/thermal_inertia_2022-01-16.tif"
Returns:
str: Path to the saved inverted parameter GeoTIFF.
"""
- param_models = {'SM': {'alpha': [0.6, 0.4], 'beta': 0.05}, 'VWC': {
- 'alpha': [0.5, 0.5], 'beta': 0.1}, 'LAI': {'alpha': [0.7, 0.3],
- 'beta': 0.0}}
+ import numpy as np
+ import rasterio
+
+ param_models = {
+ 'SM': {'alpha': [0.6, 0.4], 'beta': 0.05},
+ 'VWC': {'alpha': [0.5, 0.5], 'beta': 0.1},
+ 'LAI': {'alpha': [0.7, 0.3], 'beta': 0.0},
+ }
param_key = parameter.upper()
if param_key not in param_models:
raise ValueError(
- f"Unsupported parameter '{parameter}'. Choose from {list(param_models.keys())}"
- )
+ f"Unsupported parameter '{parameter}'. "
+ f"Choose from {list(param_models.keys())}"
+ )
model = param_models[param_key]
- alpha_list = model['alpha']
+ alpha_list = cast(list[float], model['alpha'])
beta = model['beta']
- if len(alpha_list) != len(diff_pairs):
+ diff_pairs_list = list(diff_pairs)
+ if len(alpha_list) != len(diff_pairs_list):
raise ValueError(
- f'Length of alpha coefficients ({len(alpha_list)}) must match number of diff pairs ({len(diff_pairs)})'
- )
+ f'Length of alpha coefficients ({len(alpha_list)}) must match '
+ f'number of diff pairs ({len(diff_pairs_list)})'
+ )
bt_arrays = []
profile = None
mask = None
@@ -1566,52 +1971,77 @@ class EarthScienceToolkit(BaseToolkit):
for idx1, idx2 in diff_pairs:
if idx1 < 0 or idx1 >= n_bands or idx2 < 0 or idx2 >= n_bands:
raise IndexError(
- f'diff_pairs contains invalid band index: ({idx1},{idx2})')
+ f'diff_pairs contains invalid band index: ({idx1},{idx2})'
+ )
diff_images = []
- for idx1, idx2 in diff_pairs:
+ for idx1, idx2 in diff_pairs_list:
diff = bt_arrays[idx1] - bt_arrays[idx2]
diff_images.append(diff)
param_img = np.full_like(diff_images[0], beta, dtype=np.float32)
for alpha, diff in zip(alpha_list, diff_images):
param_img += alpha * diff
+ if mask is None:
+ raise RuntimeError('Failed to compute mask from input bands')
param_img = np.where(mask, param_img, np.nan)
param_img = np.clip(param_img, 0, 1)
os.makedirs((TEMP_DIR / output_path).parent, exist_ok=True)
- profile.update(dtype=rasterio.float32, count=1, compress='lzw',
- nodata=np.nan)
+ if profile is None:
+ raise RuntimeError('Failed to read profile from input bands')
+ profile.update(
+ dtype=rasterio.float32, count=1, compress='lzw', nodata=np.nan
+ )
with rasterio.open(TEMP_DIR / output_path, 'w', **profile) as dst:
dst.write(param_img.astype(np.float32), 1)
return f'Result saved at {TEMP_DIR / output_path}'
- def chang_single_param_inversion(self, bt_paths: list[str], diff_pairs:
- list[list[int]], parameter: str, output_path: str) ->str:
- """
- Chang algorithm for inversion of a single parameter using multi-frequency dual-polarized microwave brightness temperatures from local raster files.
-
- Parameters:
- bt_paths (list[str]): List of local GeoTIFF file paths for brightness temperature bands
- (e.g., ["BT_10V.tif", "BT_10H.tif", "BT_19V.tif", "BT_19H.tif"]).
- diff_pairs (list[list[int]]): List of index pairs for brightness temperature differences.
+ def chang_single_param_inversion(
+ self,
+ bt_paths: list[str],
+ diff_pairs: list[list[int]],
+ parameter: str,
+ output_path: str,
+ ) -> str:
+ """Chang algorithm for single parameter inversion.
+
+ Uses multi-frequency dual-polarized microwave brightness temperatures
+ from local raster files.
+
+ Args:
+ bt_paths (list[str]): List of local GeoTIFF file paths for
+ brightness temperature bands (e.g., ["BT_10V.tif",
+ "BT_10H.tif", "BT_19V.tif", "BT_19H.tif"]).
+ diff_pairs (list[list[int]]): List of index pairs for brightness
+ temperature differences.
parameter (str): Parameter to invert (e.g., "SM", "VWC").
- output_path (str): relative path for the output raster file, e.g. "question17/thermal_inertia_2022-01-16.tif"
+ output_path (str): Relative path for the output raster file,
+ e.g. "question17/thermal_inertia_2022-01-16.tif"
Returns:
str: File path to saved GeoTIFF with inverted parameter band.
"""
+ import numpy as np
+ import rasterio
+
parameter = parameter.upper()
- param_models = {'SM': {'alpha': [0.65, 0.3, 0.1], 'beta': 0.02},
- 'VWC': {'alpha': [0.5, 0.4, 0.2], 'beta': 0.05}}
+ param_models = {
+ 'SM': {'alpha': [0.65, 0.3, 0.1], 'beta': 0.02},
+ 'VWC': {'alpha': [0.5, 0.4, 0.2], 'beta': 0.05},
+ }
if parameter not in param_models:
raise ValueError(
- f"Unsupported parameter '{parameter}'. Supported: {list(param_models.keys())}"
- )
+ f"Unsupported parameter '{parameter}'. "
+ f"Supported: {list(param_models.keys())}"
+ )
model = param_models[parameter]
- alpha_list = model['alpha']
+ alpha_list = cast(list[float], model['alpha'])
beta = model['beta']
- if len(alpha_list) != len(diff_pairs):
+ diff_pairs_list = list(diff_pairs)
+ if len(alpha_list) != len(diff_pairs_list):
raise ValueError(
- f"Length of alpha coefficients ({len(alpha_list)}) must equal number of diff_pairs ({len(diff_pairs)}) for parameter '{parameter}'"
- )
+ f"Length of alpha coefficients ({len(alpha_list)}) must equal "
+ f"number of diff_pairs ({len(diff_pairs_list)}) for parameter "
+ f"'{parameter}'"
+ )
bt_arrays = []
mask = None
profile = None
@@ -1619,56 +2049,73 @@ class EarthScienceToolkit(BaseToolkit):
with rasterio.open(path) as src:
band = src.read(1).astype(np.float32)
nodata = src.nodata
- valid_mask = (band != nodata if nodata is not None else np.
- ones_like(band, dtype=bool))
+ valid_mask = (
+ band != nodata
+ if nodata is not None
+ else np.ones_like(band, dtype=bool)
+ )
mask = valid_mask if mask is None else mask & valid_mask
bt_arrays.append(band)
if profile is None:
profile = src.profile
n_bands = len(bt_arrays)
- for idx1, idx2 in diff_pairs:
+ for idx1, idx2 in diff_pairs_list:
if not 0 <= idx1 < n_bands or not 0 <= idx2 < n_bands:
raise IndexError(
- f'diff_pairs indices ({idx1},{idx2}) out of range for available bands (0-{n_bands - 1})'
- )
+ f'diff_pairs indices ({idx1},{idx2}) out of range for '
+ f'available bands (0-{n_bands - 1})'
+ )
diff_imgs = []
- for idx1, idx2 in diff_pairs:
+ for idx1, idx2 in diff_pairs_list:
diff_imgs.append(bt_arrays[idx1] - bt_arrays[idx2])
param_img = np.full_like(diff_imgs[0], beta, dtype=np.float32)
for alpha, diff in zip(alpha_list, diff_imgs):
param_img += alpha * diff
+ if mask is None:
+ raise RuntimeError('Failed to compute mask from input bands')
param_img = np.where(mask, param_img, np.nan)
param_img = np.clip(param_img, 0, 1)
os.makedirs((TEMP_DIR / output_path).parent, exist_ok=True)
- profile.update(dtype=rasterio.float32, count=1, compress='lzw',
- nodata=np.nan)
+ if profile is None:
+ raise RuntimeError('Failed to read profile from input bands')
+ profile.update(
+ dtype=rasterio.float32, count=1, compress='lzw', nodata=np.nan
+ )
with rasterio.open(TEMP_DIR / output_path, 'w', **profile) as dst:
dst.write(param_img.astype(np.float32), 1)
return f'Result saved at {TEMP_DIR / output_path}'
- def nasa_team_sea_ice_concentration(self, bt_paths: dict, output_path:
- str, nd_ice: float=50.0, nd_water: float=0.0, s1_ice: float=20.0,
- s1_water: float=0.0) ->str:
- """
- Estimate Sea Ice Concentration using NASA Team Algorithm from local passive microwave brightness temperature GeoTIFF files.
-
- Parameters:
- bt_paths (dict): Dictionary of local GeoTIFF file paths for required brightness temperature bands, e.g.,
- {
- "19V": "BT_19V.tif",
- "19H": "BT_19H.tif",
- "37V": "BT_37V.tif",
- "37H": "BT_37H.tif"
- }
- nd_ice (float): ND value for ice reference. Default 50.0.
- nd_water (float): ND value for water reference. Default 0.0.
- s1_ice (float): S1 value for ice reference. Default 20.0.
- s1_water (float): S1 value for water reference. Default 0.0.
- output_path (str): relative path for the output raster file, e.g. "question17/thermal_inertia_2022-01-16.tif"
+ def nasa_team_sea_ice_concentration(
+ self,
+ bt_paths: dict,
+ output_path: str,
+ nd_ice: float = 50.0,
+ nd_water: float = 0.0,
+ s1_ice: float = 20.0,
+ s1_water: float = 0.0,
+ ) -> str:
+ """Estimate Sea Ice Concentration using NASA Team Algorithm.
+
+ Uses local passive microwave brightness temperature GeoTIFF files.
+
+ Args:
+ bt_paths (dict): Dictionary of local GeoTIFF file paths for
+ required brightness temperature bands, e.g.,
+ {"19V": "BT_19V.tif", "19H": "BT_19H.tif",
+ "37V": "BT_37V.tif", "37H": "BT_37H.tif"}
+ nd_ice (float): ND value for ice reference. Default 50.0.
+ nd_water (float): ND value for water reference. Default 0.0.
+ s1_ice (float): S1 value for ice reference. Default 20.0.
+ s1_water (float): S1 value for water reference. Default 0.0.
+ output_path (str): Relative path for the output raster file,
+ e.g. "question17/thermal_inertia_2022-01-16.tif"
Returns:
str: Path to saved GeoTIFF with sea ice concentration band.
"""
+ import numpy as np
+ import rasterio
+
required_bands = ['19V', '19H', '37V', '37H']
for band in required_bands:
if band not in bt_paths:
@@ -1695,35 +2142,48 @@ class EarthScienceToolkit(BaseToolkit):
except Exception as e:
raise RuntimeError(f'Error processing data: {e}')
os.makedirs((TEMP_DIR / output_path).parent, exist_ok=True)
+ if profile is None:
+ raise RuntimeError('Failed to read profile from input bands')
profile.update(dtype=rasterio.float32, count=1, compress='lzw')
with rasterio.open(TEMP_DIR / output_path, 'w', **profile) as dst:
dst.write(Ci, 1)
return f'Result saved at {TEMP_DIR / output_path}'
- def dual_polarization_ratio(self, bt_paths: dict, parameter: str,
- output_path: str, coeffs: (dict | None)=None) ->str:
- """
- Estimate Vegetation Water Content (VWC) or Soil Moisture (SM) using Dual-Polarization Ratio Method (PRM) from local passive microwave brightness temperature GeoTIFF files.
+ def dual_polarization_ratio(
+ self,
+ bt_paths: dict,
+ parameter: str,
+ output_path: str,
+ coeffs: (dict | None) = None,
+ ) -> str:
+ """Estimate VWC or SM using Dual-Polarization Ratio Method (PRM).
- The polarization ratio is computed as: (V - H) / (V + H), where V and H are brightness temperatures of vertical and horizontal polarizations.
+ Uses local passive microwave brightness temperature GeoTIFF files.
+ The polarization ratio is computed as: (V - H) / (V + H), where V
+ and H are brightness temperatures of vertical and horizontal
+ polarizations.
Empirical models:
- VWC = a_vwc * PR + b_vwc
- SM = a_sm * PR + b_sm
- Parameters:
- bt_paths (dict): Dictionary of local GeoTIFF file paths for vertical and horizontal polarization bands, e.g.
- {
- "V": "BT_V.tif",
- "H": "BT_H.tif"
- }
- parameter (str): Parameter to invert, either "VWC" or "SM".
- output_path (str): relative path for the output raster file, e.g. "question17/thermal_inertia_2022-01-16.tif"
- coeffs (dict, optional): Empirical coefficients {"VWC": {"a":float, "b":float}, "SM": {...}}.
+ Args:
+ bt_paths (dict): Dictionary of local GeoTIFF file paths for
+ vertical and horizontal polarization bands, e.g.
+ {"V": "BT_V.tif", "H": "BT_H.tif"}
+ parameter (str): Parameter to invert, either "VWC" or "SM".
+ output_path (str): Relative path for the output raster file,
+ e.g. "question17/thermal_inertia_2022-01-16.tif"
+ coeffs (dict, optional): Empirical coefficients
+ {"VWC": {"a":float, "b":float}, "SM": {...}}.
Returns:
- str: File path of the saved GeoTIFF containing the inverted parameter and PR band.
+ str: File path of the saved GeoTIFF containing the inverted
+ parameter and PR band.
"""
+ import numpy as np
+ import rasterio
+
if 'V' not in bt_paths or 'H' not in bt_paths:
raise ValueError("bt_paths dict must contain keys 'V' and 'H'")
parameter = parameter.upper()
@@ -1731,11 +2191,14 @@ class EarthScienceToolkit(BaseToolkit):
coeffs = {'VWC': {'a': 15.0, 'b': 5.0}, 'SM': {'a': 0.4, 'b': 0.1}}
if parameter not in coeffs:
raise ValueError(
- f"Unsupported parameter '{parameter}'. Supported: {list(coeffs.keys())}"
- )
+ f"Unsupported parameter '{parameter}'. "
+ f"Supported: {list(coeffs.keys())}"
+ )
try:
- with rasterio.open(bt_paths['V']) as src_v, rasterio.open(bt_paths
- ['H']) as src_h:
+ with (
+ rasterio.open(bt_paths['V']) as src_v,
+ rasterio.open(bt_paths['H']) as src_h,
+ ):
V = src_v.read(1).astype(np.float32)
H = src_h.read(1).astype(np.float32)
profile = src_v.profile
@@ -1756,19 +2219,28 @@ class EarthScienceToolkit(BaseToolkit):
return f'Result saved at {TEMP_DIR / output_path}'
except Exception as e:
raise RuntimeError(
- f'Error processing dual polarization ratio parameter: {e}')
+ f'Error processing dual polarization ratio parameter: {e}'
+ )
- def calculate_water_turbidity_ntu(self, input_red_path: str,
- output_path: str, method: str='linear', a: float=1.0, b: float=0.0,
- n: float=1.0) ->str:
- """
- Calculate water turbidity in NTU (Nephelometric Turbidity Units) from red band raster file
- and save the result to a specified output path.
+ def calculate_water_turbidity_ntu(
+ self,
+ input_red_path: str,
+ output_path: str,
+ method: str = 'linear',
+ a: float = 1.0,
+ b: float = 0.0,
+ n: float = 1.0,
+ ) -> str:
+ """Calculate water turbidity in NTU from red band raster file.
- Parameters:
+ NTU = Nephelometric Turbidity Units. Saves result to output path.
+
+ Args:
input_red_path (str): Path to the Red band raster file.
- output_path (str): relative path for the output raster file, e.g. "benchmark/data/question17/turbidity_2022-01-16.tif"
- method (str): Calculation method - "linear" (a*Red+b), "power" (a*Red^n+b), or "log" (a*log(Red)+b).
+ output_path (str): Relative path for the output raster file,
+ e.g. "benchmark/data/question17/turbidity_2022-01-16.tif"
+ method (str): Calculation method - "linear" (a*Red+b),
+ "power" (a*Red^n+b), or "log" (a*log(Red)+b).
a (float): Coefficient parameter, default 1.0.
b (float): Offset parameter, default 0.0.
n (float): Power parameter for power method, default 1.0.
@@ -1776,6 +2248,9 @@ class EarthScienceToolkit(BaseToolkit):
Returns:
str: Path to the output NTU raster file.
"""
+ import numpy as np
+ import rasterio
+
with rasterio.open(input_red_path) as red_src:
red_band = red_src.read(1)
red_profile = red_src.profile
@@ -1784,7 +2259,7 @@ class EarthScienceToolkit(BaseToolkit):
ntu = a * red_band + b
elif method == 'power':
red_positive = np.maximum(red_band, 1e-06)
- ntu = a * red_positive ** n + b
+ ntu = a * red_positive**n + b
elif method == 'log':
red_positive = np.maximum(red_band, 1e-06)
ntu = a * np.log(red_positive) + b
@@ -1792,31 +2267,37 @@ class EarthScienceToolkit(BaseToolkit):
raise ValueError("Method must be 'linear', 'power', or 'log'")
ntu = np.maximum(ntu, 0)
ntu_profile = red_profile.copy()
- ntu_profile.update(dtype=rasterio.float32, nodata=-9999, compress='lzw'
- )
+ ntu_profile.update(
+ dtype=rasterio.float32, nodata=-9999, compress='lzw'
+ )
os.makedirs((TEMP_DIR / output_path).parent, exist_ok=True)
with rasterio.open(TEMP_DIR / output_path, 'w', **ntu_profile) as dst:
dst.write(ntu.astype(rasterio.float32), 1)
return f'Result saved at {TEMP_DIR / output_path}'
def threshold_segmentation(self, input_image_path, threshold, output_path):
- """
- Perform threshold-based segmentation on a single-band raster image.
-
- The function reads a raster image from the specified path, converts it to a binary mask
- by applying a fixed threshold, and writes the resulting binary image to a new file.
- Pixel values greater than the threshold are set to 255 (white), and values less than or
- equal to the threshold are set to 0 (black).
-
- Parameters:
- input_image_path (str): Path to the input raster image file (e.g., TIFF, PNG, JPG).
- threshold (float or int): Pixel intensity threshold used to generate the binary mask.
- output_path (str): Relative output path (under TEMP_DIR) where the result will be saved,
- e.g., "question17/threshold_segmentation_2022-01-16.tif".
+ """Perform threshold-based segmentation on a single-band raster image.
+
+ Reads a raster image, converts it to a binary mask by applying a fixed
+ threshold, and writes the resulting binary image to a new file. Pixel
+ values greater than threshold are set to 255 (white), and values less
+ than or equal to threshold are set to 0 (black).
+
+ Args:
+ input_image_path (str): Path to the input raster image file
+ (e.g., TIFF, PNG, JPG).
+ threshold (float or int): Pixel intensity threshold used to
+ generate the binary mask.
+ output_path (str): Relative output path (under TEMP_DIR) where
+ the result will be saved, e.g.,
+ "question17/threshold_segmentation_2022-01-16.tif".
Returns:
str: Message indicating the file path where the result is saved.
"""
+ import numpy as np
+ import rasterio
+
with rasterio.open(input_image_path) as src:
image = src.read(1)
meta = src.meta.copy()
@@ -1827,18 +2308,20 @@ class EarthScienceToolkit(BaseToolkit):
dst.write(binary_image, 1)
return f'Result save at {TEMP_DIR / output_path}'
- def bbox_expansion(self, bboxes: list[list[float]], radius: float, gsd:
- float):
- """
- Expands bounding boxes by a given radius and returns the expanded bounding boxes.
+ def bbox_expansion(
+ self, bboxes: list[list[float]], radius: float, gsd: float
+ ):
+ """Expand bounding boxes by a given radius.
- Parameters:
- bboxes (list[list[float]]): List of bounding boxes, each represented as [x1, y1, x2, y2].
+ Args:
+ bboxes (list[list[float]]): List of bounding boxes, each
+ represented as [x1, y1, x2, y2].
radius (float): Expansion radius in the same unit as the GSD.
- gsd (float): Ground Sampling Distance in the same unit as the radius.
+ gsd (float): Ground Sampling Distance in the same unit as radius.
Returns:
- list[list[float]]: List of expanded bounding boxes, each represented as [x1, y1, x2, y2].
+ list[list[float]]: List of expanded bounding boxes, each
+ represented as [x1, y1, x2, y2].
"""
expanded_bboxes = []
for bbox in bboxes:
@@ -1851,12 +2334,9 @@ class EarthScienceToolkit(BaseToolkit):
return expanded_bboxes
def count_above_threshold(self, file_path: str, threshold: float):
- """
- Description:
- Count the number of pixels in an image whose values are greater than
- the specified threshold.
+ """Count pixels in an image whose values exceed the threshold.
- Parameters:
+ Args:
file_path (str):
Path to the input image (GeoTIFF or raster format).
threshold (float):
@@ -1870,6 +2350,9 @@ class EarthScienceToolkit(BaseToolkit):
>>> count_above_threshold("sample_image.tif", 100)
2456
"""
+ import numpy as np
+ import rasterio
+
with rasterio.open(file_path) as src:
x = src.read(1)
x = np.asarray(x)
@@ -1877,12 +2360,12 @@ class EarthScienceToolkit(BaseToolkit):
return int(count)
def count_skeleton_contours(self, image_path):
- """
- Description:
- Read a binary image, apply erosion and skeletonization,
- then count the number of external contours in the skeletonized image.
+ """Count external contours in a skeletonized binary image.
+
+ Reads a binary image, applies erosion and skeletonization, then
+ counts the number of external contours.
- Parameters:
+ Args:
image_path (str):
Path to the input binary (black and white) image.
@@ -1894,6 +2377,10 @@ class EarthScienceToolkit(BaseToolkit):
>>> count_skeleton_contours("binary_mask.png")
12
"""
+ import cv2
+ import numpy as np
+ from skimage.morphology import skeletonize
+
img = cv2.imread(image_path, cv2.IMREAD_GRAYSCALE)
if img is None:
raise FileNotFoundError(f'Failed to read image: {image_path}')
@@ -1902,19 +2389,19 @@ class EarthScienceToolkit(BaseToolkit):
eroded = cv2.erode(binary, kernel, iterations=1)
skeleton = skeletonize(eroded > 0)
skeleton_uint8 = (skeleton * 255).astype(np.uint8)
- contours, _ = cv2.findContours(skeleton_uint8, cv2.RETR_EXTERNAL,
- cv2.CHAIN_APPROX_SIMPLE)
+ contours, _ = cv2.findContours(
+ skeleton_uint8, cv2.RETR_EXTERNAL, cv2.CHAIN_APPROX_SIMPLE
+ )
return len(contours)
def bboxes2centroids(self, bboxes):
- """
- Description:
- Convert bounding boxes from [x_min, y_min, x_max, y_max] format
- to centroid coordinates (x, y).
+ """Convert bounding boxes to centroid coordinates.
+
+ Converts from [x_min, y_min, x_max, y_max] format to (x, y) centroids.
- Parameters:
- bboxes (list[list[float]]):
- A list of bounding boxes, each defined as [x_min, y_min, x_max, y_max].
+ Args:
+ bboxes (list[list[float]]): A list of bounding boxes, each
+ defined as [x_min, y_min, x_max, y_max].
Returns:
centroids (list[tuple[float, float]]):
@@ -1927,12 +2414,12 @@ class EarthScienceToolkit(BaseToolkit):
return [((x1 + x2) / 2, (y1 + y2) / 2) for x1, y1, x2, y2 in bboxes]
def centroid_distance_extremes(self, centroids):
- """
- Description:
- Compute pairwise distances between centroids and return both the closest
- and farthest pairs with their indices and distances.
+ """Find closest and farthest centroid pairs.
+
+ Computes pairwise distances between centroids and returns both the
+ closest and farthest pairs with their indices and distances.
- Parameters:
+ Args:
centroids (list[tuple[float, float]] or np.ndarray):
A list or NumPy array of centroid coordinates in (x, y) format.
@@ -1949,36 +2436,36 @@ class EarthScienceToolkit(BaseToolkit):
>>> centroid_distance_extremes(centroids)
{'min': (0, 1, 5.0), 'max': (1, 2, 7.211102550927978)}
"""
+ import numpy as np
+
points = np.array(centroids)
diff = points[:, None, :] - points[None, :, :]
- dist_matrix = np.sqrt(np.sum(diff ** 2, axis=-1))
+ dist_matrix = np.sqrt(np.sum(diff**2, axis=-1))
np.fill_diagonal(dist_matrix, np.inf)
min_idx = np.unravel_index(np.argmin(dist_matrix), dist_matrix.shape)
min_dist = dist_matrix[min_idx]
np.fill_diagonal(dist_matrix, -np.inf)
max_idx = np.unravel_index(np.argmax(dist_matrix), dist_matrix.shape)
max_dist = dist_matrix[max_idx]
- return {'min': (int(min_idx[0]), int(min_idx[1]), float(min_dist)),
- 'max': (int(max_idx[0]), int(max_idx[1]), float(max_dist))}
+ return {
+ 'min': (int(min_idx[0]), int(min_idx[1]), float(min_dist)),
+ 'max': (int(max_idx[0]), int(max_idx[1]), float(max_dist)),
+ }
def calculate_bbox_area(self, bboxes, gsd=None):
- """
- Description:
- Calculate the total area of a list of bounding boxes in [x, y, w, h] format.
-
- Parameters:
- bboxes (list[list[float]]):
- A list of bounding boxes, where each box is defined as [x, y, w, h].
- - x, y → top-left corner coordinates
- - w, h → width and height of the box
- gsd (float, optional):
- Ground sample distance (meters per pixel).
- - If provided, the result is in square meters (m²).
- - If None, the result is in square pixels (pixel²). Default = None.
+ """Calculate the total area of bounding boxes in [x, y, w, h] format.
+
+ Args:
+ bboxes (list[list[float]]): A list of bounding boxes, each
+ defined as [x, y, w, h] where x,y is top-left corner and
+ w,h are width and height.
+ gsd (float, optional): Ground sample distance (meters per pixel).
+ If provided, result is in m². If None, result is in pixel².
+ Default = None.
Returns:
- total_area (float):
- The total area of all bounding boxes, in m² if gsd is provided, otherwise in pixel².
+ total_area (float): The total area of all bounding boxes, in m²
+ if gsd is provided, otherwise in pixel².
Example:
>>> calculate_bbox_area([[0, 0, 10, 20], [5, 5, 15, 10]])
@@ -1990,7 +2477,8 @@ class EarthScienceToolkit(BaseToolkit):
for bbox in bboxes:
if len(bbox) != 4:
raise ValueError(
- f'Invalid bbox format: {bbox}. Expected [x, y, w, h].')
+ f'Invalid bbox format: {bbox}. Expected [x, y, w, h].'
+ )
_, _, w, h = bbox
area = w * h
total_area += area
@@ -1998,40 +2486,33 @@ class EarthScienceToolkit(BaseToolkit):
total_area *= gsd * gsd
return total_area
- def compute_linear_trend(self, y: list, x: (list | None)=None):
- """
- Description
+ def compute_linear_trend(self, y: list, x: (list | None) = None):
+ r"""Compute linear trend (slope and intercept) of a time series.
- Computes the linear trend (slope and intercept) of a time series by fitting a line of the form:
+ Fits a line of the form y = a * x + b using least squares method.
- y = a \\\\cdot x + b
+ Args:
+ y (list): The dependent variable (time series data).
+ x (list): The independent variable (time indices). If not
+ provided, uses np.arange(len(y)) as default.
- using the least squares method.
-
- Parameters
- • y (list):
- The dependent variable — typically your time series data.
- • x (list):
- The independent variable — usually time indices. If not provided, the function will use np.arange(len(y)) as a default.
-
- Returns
- • slope (float):
- The coefficient a — represents the trend.
- • > 0: upward trend
- • < 0: downward trend
- • ≈ 0: no trend
- • intercept (float):
- The y-intercept b of the fitted line.
+ Returns:
+ tuple: (slope, intercept) where:
+ - slope (float): The coefficient a representing the trend.
+ > 0: upward, < 0: downward, ~0: no trend.
+ - intercept (float): The y-intercept b of the fitted line.
"""
- y = np.asarray(y)
+ import numpy as np
+
+ y_arr = np.asarray(y)
if x is None:
- x = np.arange(len(y))
+ x_arr = np.arange(len(y_arr))
else:
- x = np.asarray(x)
- if len(x) != len(y):
+ x_arr = np.asarray(x)
+ if len(x_arr) != len(y_arr):
raise ValueError('len(x) != len(y)')
- A = np.vstack([x, np.ones_like(x)]).T
- a, b = np.linalg.lstsq(A, y, rcond=None)[0]
+ A = np.vstack([x_arr, np.ones_like(x_arr)]).T
+ a, b = np.linalg.lstsq(A, y_arr, rcond=None)[0]
return float(a), float(b)
def mann_kendall_test(self, x: list):
@@ -2042,7 +2523,7 @@ class EarthScienceToolkit(BaseToolkit):
The test is non-parametric and does not assume normality.
Handles tied ranks with variance correction.
- Parameters:
+ Args:
x (list[float]):
The input time series data as a list of floats or ints.
Any missing values (NaN) should be removed beforehand.
@@ -2058,24 +2539,29 @@ class EarthScienceToolkit(BaseToolkit):
z (float):
Standard normal test statistic.
tau (float):
- Kendall’s Tau statistic (measure of rank correlation, range -1 to 1).
+ Kendall's Tau statistic (measure of rank correlation,
+ range -1 to 1).
Example:
>>> mann_kendall_test([1, 2, 3, 4, 5])
('increasing', 0.03, 2.12, 0.9)
"""
- x = np.asarray(x)
- n = len(x)
+ import numpy as np
+ from scipy.stats import norm
+
+ x_arr = np.asarray(x)
+ n = len(x_arr)
s = 0
for k in range(n - 1):
- s += np.sum(np.sign(x[k + 1:] - x[k]))
- unique_x, counts = np.unique(x, return_counts=True)
- g = len(counts)
- if n == len(np.unique(x)):
+ s += np.sum(np.sign(x_arr[k + 1 :] - x_arr[k]))
+ _, counts = np.unique(x_arr, return_counts=True)
+ if n == len(np.unique(x_arr)):
var_s = n * (n - 1) * (2 * n + 5) / 18
else:
- var_s = (n * (n - 1) * (2 * n + 5) - np.sum(counts * (counts -
- 1) * (2 * counts + 5))) / 18
+ var_s = (
+ n * (n - 1) * (2 * n + 5)
+ - np.sum(counts * (counts - 1) * (2 * counts + 5))
+ ) / 18
if s > 0:
z = (s - 1) / np.sqrt(var_s)
elif s < 0:
@@ -2094,19 +2580,19 @@ class EarthScienceToolkit(BaseToolkit):
def sens_slope(self, x: list):
"""
Description:
- Compute Sen’s Slope estimator for a univariate time series.
+ Compute Sen's Slope estimator for a univariate time series.
This robust non-parametric method calculates the median of
all pairwise slopes between observations, providing an estimate
of the overall monotonic trend magnitude.
- Parameters:
+ Args:
x (list[float]):
The input time series data as a list of floats or ints.
Must have at least two data points.
Returns:
slope (float):
- The Sen’s Slope estimate (median of all pairwise slopes).
+ The Sen's Slope estimate (median of all pairwise slopes).
slopes (list[float]):
List of all pairwise slopes, which can be used for
further distributional or variability analysis.
@@ -2115,68 +2601,63 @@ class EarthScienceToolkit(BaseToolkit):
>>> sens_slope([2, 4, 6, 8, 10])
(2.0, [2.0, 2.0, 2.0, 2.0, 2.0, 2.0, 2.0, 2.0, 2.0, 2.0])
"""
- x = np.asarray(x)
- n = len(x)
+ import numpy as np
+
+ x_arr = np.asarray(x)
+ n = len(x_arr)
if n < 2:
raise ValueError('At least two data points are required.')
- slopes = []
+ slopes_list: list = []
for i in range(n - 1):
for j in range(i + 1, n):
- slope_ij = (x[j] - x[i]) / (j - i)
- slopes.append(slope_ij)
- slopes = np.array(slopes)
- median_slope = np.median(slopes)
- return float(median_slope), [float(s) for s in slopes]
+ slope_ij = (x_arr[j] - x_arr[i]) / (j - i)
+ slopes_list.append(slope_ij)
+ slopes_arr = np.array(slopes_list)
+ median_slope = np.median(slopes_arr)
+ return float(median_slope), [float(s) for s in slopes_arr]
- def stl_decompose(self, x: list, period: int, robust: bool=True):
- """
- Description:
- Apply STL (Seasonal-Trend decomposition using LOESS) to a univariate time series.
- This method decomposes the input data into three additive components:
- - trend
- - seasonal
- - residual
+ def stl_decompose(self, x: list, period: int, robust: bool = True):
+ """Apply STL decomposition to a univariate time series.
- Parameters:
- x (list[float]):
- Input time series values. Will be internally converted to a pandas Series.
- period (int):
- The number of observations in one seasonal cycle.
+ Decomposes input data into three additive components: trend,
+ seasonal, and residual using LOESS.
+
+ Args:
+ x (list[float]): Input time series values.
+ period (int): Number of observations in one seasonal cycle.
Example: 12 for monthly data with yearly seasonality.
- robust (bool, default=True):
- If True, use the robust version of STL, which is less sensitive to outliers.
+ robust (bool, default=True): If True, use robust version of STL,
+ which is less sensitive to outliers.
Returns:
- dict:
- A dictionary containing three keys with list outputs:
- - "trend" (list[float]): Long-term trend component
- - "seasonal" (list[float]): Seasonal cycle component
- - "resid" (list[float]): Residual (noise) component
+ dict: Dictionary with keys "trend", "seasonal", "resid", each
+ containing list[float] of component values.
Example:
- >>> stl_decompose([10, 12, 15, 20, 18, 16, 14, 13, 11, 10, 9, 8], period=12)
- {
- "trend": [...],
- "seasonal": [...],
- "resid": [...]
- }
+ >>> stl_decompose([10, 12, 15, 20, 18, 16], period=12)
+ {"trend": [...], "seasonal": [...], "resid": [...]}
"""
+ import pandas as pd
+ from statsmodels.tsa.seasonal import STL
+
if not isinstance(x, pd.Series):
x = pd.Series(x)
stl = STL(x, period=period, robust=robust)
result = stl.fit()
- return {'trend': [float(x) for x in result.trend], 'seasonal': [
- float(x) for x in result.seasonal], 'resid': [float(x) for x in
- result.resid]}
+ return {
+ 'trend': [float(x) for x in result.trend],
+ 'seasonal': [float(x) for x in result.seasonal],
+ 'resid': [float(x) for x in result.resid],
+ }
def detect_change_points(self, signal, model='l2', penalty=10):
"""
Description:
- Detect change points in a one-dimensional time series using the
- PELT algorithm from the ruptures library. This identifies indices
+ Detect change points in a one-dimensional time series using the
+ PELT algorithm from the ruptures library. This identifies indices
where the statistical structure of the signal changes.
- Parameters:
+ Args:
signal (list[float]):
Input time series data.
model (str, default="l2"):
@@ -2195,83 +2676,81 @@ class EarthScienceToolkit(BaseToolkit):
The final index of the signal is always included.
Example:
- >>> detect_change_points([1, 1, 1, 10, 10, 10, 2, 2, 2], model="l2", penalty=5)
- [3, 6, 9]
+ >>> detect_change_points([1, 1, 1, 10, 10, 10], model="l2",
+ penalty=5)
+ [3, 6]
"""
+ import numpy as np
+ import ruptures as rpt
+
signal = np.asarray(signal)
algo = rpt.Pelt(model=model).fit(signal)
change_points = algo.predict(pen=penalty)
return [int(cp) for cp in change_points]
- def autocorrelation_function(self, x: list, nlags: int=20):
- """
- Description:
- Compute the Autocorrelation Function (ACF) of a univariate time series.
- The ACF describes the correlation between the series and its lagged values,
- and is commonly used to detect seasonality or serial dependence.
+ def autocorrelation_function(self, x: list, nlags: int = 20):
+ """Compute the Autocorrelation Function (ACF) of a time series.
- Parameters:
- x (list[float]):
- Input time series data as a list of floats or ints.
- nlags (int, default=20):
- The number of lags to compute autocorrelation for.
+ The ACF describes correlation between the series and its lagged values,
+ commonly used to detect seasonality or serial dependence.
+
+ Args:
+ x (list[float]): Input time series data.
+ nlags (int, default=20): Number of lags to compute.
Returns:
- acf (list[float]):
- List of autocorrelation values for lags 0 through `nlags`.
- - acf[0] = 1.0 (perfect correlation with itself)
- - acf[k] = correlation between series and series lagged by k steps
+ acf (list[float]): Autocorrelation values for lags 0 to nlags.
+ acf[0] = 1.0 (self-correlation), acf[k] = correlation at lag k.
Example:
>>> autocorrelation_function([1, 2, 3, 4, 5], nlags=3)
[1.0, 0.5, 0.0, -0.5]
"""
- x = np.asarray(x)
- x = x - np.mean(x)
- n = len(x)
+ import numpy as np
+
+ x_arr = np.asarray(x)
+ x_arr = x_arr - np.mean(x_arr)
+ n = len(x_arr)
acf = np.empty(nlags + 1)
- var = np.dot(x, x) / n
+ var = np.dot(x_arr, x_arr) / n
for lag in range(nlags + 1):
if lag == 0:
acf[lag] = 1.0
else:
- acf[lag] = np.dot(x[:-lag], x[lag:]) / (n - lag) / var
+ acf[lag] = np.dot(x_arr[:-lag], x_arr[lag:]) / (n - lag) / var
return [float(val) for val in acf]
- def detect_seasonality_acf(self, values: list, min_acf: float=0.3):
- """
- Description:
- Detect the dominant seasonality (cycle length) in a univariate time series
- using the Autocorrelation Function (ACF). A peak in the ACF beyond lag=1
- indicates potential periodicity.
+ def detect_seasonality_acf(self, values: list, min_acf: float = 0.3):
+ """Detect dominant seasonality in a time series using ACF.
+
+ A peak in the ACF beyond lag=1 indicates potential periodicity.
- Parameters:
- values (list[float]):
- Input time series data as a list of numeric values.
- min_acf (float, default=0.3):
- ACF threshold to consider a lag significant.
- Lags with autocorrelation above this value are considered candidates.
+ Args:
+ values (list[float]): Input time series data.
+ min_acf (float, default=0.3): ACF threshold to consider
+ significant.
Returns:
- result (int | str):
- - An integer representing the dominant period (lag) if detected.
- - "Data is not cyclical" if no significant seasonality is found.
+ result (int | str): Dominant period (lag) if detected, or
+ "Data is not cyclical" if no significant seasonality found.
Example:
>>> detect_seasonality_acf([1, 2, 1, 2, 1, 2], min_acf=0.3)
2
-
>>> detect_seasonality_acf([1, 2, 3, 4, 5], min_acf=0.3)
'Data is not cyclical'
"""
- values = np.asarray(values)
- n = len(values)
+ import numpy as np
+ from statsmodels.tsa.stattools import acf
+
+ values_arr = np.asarray(values)
+ n = len(values_arr)
nlags = min(n // 3, 40)
if nlags < 2:
return 'Data is not cyclical'
try:
- acf_values = acf(values, nlags=nlags, fft=True)
- except:
+ acf_values = acf(values_arr, nlags=nlags, fft=True)
+ except Exception:
return 'Data is not cyclical'
max_acf = 0
best_lag = None
@@ -2284,40 +2763,32 @@ class EarthScienceToolkit(BaseToolkit):
else:
return best_lag
- def getis_ord_gi_star(self, image_path: str, weight_matrix: list,
- output_path: str) ->str:
- """
- Description:
- Compute the Getis-Ord Gi* statistic for a single-band raster image
- to identify local spatial autocorrelation.
- Positive Gi* values indicate hot spots (clusters of high values),
- while negative values indicate cold spots (clusters of low values).
+ def getis_ord_gi_star(
+ self, image_path: str, weight_matrix: list, output_path: str
+ ) -> str:
+ """Compute Getis-Ord Gi* statistic for local spatial autocorrelation.
- Parameters:
- image_path (str):
- Path to the input single-band raster image (GeoTIFF).
- weight_matrix (list[list[float]]):
- 2D list representing the spatial weight kernel
- (e.g., 3x3 or 5x5 neighborhood weights).
- The sum of weights must not be zero.
- output_path (str):
- Relative file path to save the Gi* statistic result as GeoTIFF
- (e.g., "question17/cloud_mask_2022-01-16.tif").
+ Positive Gi* values indicate hot spots (clusters of high values),
+ negative values indicate cold spots (clusters of low values).
+
+ Args:
+ image_path (str): Path to input single-band raster (GeoTIFF).
+ weight_matrix (list[list[float]]): 2D spatial weight kernel
+ (e.g., 3x3 or 5x5). Sum of weights must not be zero.
+ output_path (str): Relative path to save the Gi* result GeoTIFF.
Returns:
- str:
- Path to the saved GeoTIFF image containing computed Gi* statistics.
- - Output is float32 raster.
- - Preserves georeference and projection metadata from the input if available.
+ str: Path to saved GeoTIFF with Gi* statistics (float32 raster).
+ Preserves georeference and projection from input if available.
Example:
- >>> getis_ord_gi_star(
- ... image_path="ndvi_2022-01-16.tif",
- ... weight_matrix=[[1,1,1],[1,0,1],[1,1,1]],
- ... output_path="outputs/gi_star_ndvi.tif"
- ... )
- 'Result save at outputs/gi_star_ndvi.tif'
+ >>> getis_ord_gi_star("ndvi.tif", [[1,1,1],[1,0,1],[1,1,1]], "out.
+ tif") 'Result save at out.tif'
"""
+ import numpy as np
+ from osgeo import gdal
+ from scipy.ndimage import convolve
+
ds = gdal.Open(image_path)
if ds is None:
raise RuntimeError(f'Failed to open image: {image_path}')
@@ -2331,14 +2802,19 @@ class EarthScienceToolkit(BaseToolkit):
s = np.std(img)
n = img.size
numerator = convolve(img, W, mode='constant', cval=0)
- W_sq_sum = np.sum(W ** 2)
- denom_part = (n * W_sq_sum - W_sum ** 2) / (n - 1)
+ W_sq_sum = np.sum(W**2)
+ denom_part = (n * W_sq_sum - W_sum**2) / (n - 1)
denominator = s * np.sqrt(denom_part)
gi_star = (numerator - x_bar * W_sum) / denominator
(TEMP_DIR / output_path).parent.mkdir(parents=True, exist_ok=True)
driver = gdal.GetDriverByName('GTiff')
- out_ds = driver.Create(TEMP_DIR / output_path, xsize=gi_star.shape[
- 1], ysize=gi_star.shape[0], bands=1, eType=gdal.GDT_Float32)
+ out_ds = driver.Create(
+ TEMP_DIR / output_path,
+ xsize=gi_star.shape[1],
+ ysize=gi_star.shape[0],
+ bands=1,
+ eType=gdal.GDT_Float32,
+ )
out_ds.GetRasterBand(1).WriteArray(gi_star.astype(np.float32))
if ds.GetGeoTransform():
out_ds.SetGeoTransform(ds.GetGeoTransform())
@@ -2348,28 +2824,28 @@ class EarthScienceToolkit(BaseToolkit):
out_ds = None
return f'Result save at {TEMP_DIR / output_path}'
- def analyze_hotspot_direction(self, hotspot_map_path: str) ->str:
- """
- Description:
- Analyze the dominant direction of hotspot concentration in a binary hotspot map.
- The function computes the relative location of hotspot pixels (value=1) with
- respect to the raster center and determines which cardinal direction
- (north, south, east, west) contains the majority of hotspots.
+ def analyze_hotspot_direction(self, hotspot_map_path: str) -> str:
+ """Analyze dominant direction of hotspot concentration.
+
+ Computes the relative location of hotspot pixels (value=1) with
+ respect to raster center and determines which cardinal direction
+ contains the majority of hotspots.
- Parameters:
- hotspot_map_path (str):
- Path to the binary hotspot map GeoTIFF file.
- Hotspot pixels should be encoded with value=1; all other values are ignored.
+ Args:
+ hotspot_map_path (str): Path to binary hotspot map GeoTIFF.
+ Hotspot pixels should be value=1; others are ignored.
Returns:
- str:
- - "north", "south", "east", or "west": The dominant hotspot direction.
- - "no hotspots found": Returned if the map contains no hotspot pixels.
+ str: "north", "south", "east", "west" for dominant direction,
+ or "no hotspots found" if no hotspot pixels exist.
Example:
>>> analyze_hotspot_direction("outputs/hotspot_map.tif")
'north'
"""
+ import numpy as np
+ import rasterio
+
with rasterio.open(hotspot_map_path) as src:
hotspot_data = src.read(1)
hotspot_indices = np.where(hotspot_data == 1)
@@ -2393,38 +2869,41 @@ class EarthScienceToolkit(BaseToolkit):
max_direction = max(directions.keys(), key=lambda x: directions[x])
return max_direction
- def count_spikes_from_values(self, values, spike_threshold=0.1, verbose
- =True):
+ def count_spikes_from_values(
+ self, values, spike_threshold=0.1, verbose=True
+ ):
"""
Count the number of upward spikes in a sequence of numerical values.
A spike is defined as a positive difference between consecutive valid
values greater than the given threshold.
- Parameters:
+ Args:
values (list of float):
Input sequence of values (can include None or NaN).
spike_threshold (float):
Minimum positive change required to count as a spike.
verbose (bool):
- If True, prints details for each detected spike.
+ If True, logger.infos details for each detected spike.
Returns:
int:
Number of detected upward spikes.
Example:
- >>> count_spikes_from_values([0.1, 0.15, 0.5, 0.55], spike_threshold=0.2)
+ >>> count_spikes_from_values([0.1, 0.15, 0.5], spike_threshold=0.2)
1
"""
+ import numpy as np
+
values = np.array(values, dtype=np.float32)
valid_indices = ~np.isnan(values)
valid_values = values[valid_indices]
if len(valid_values) < 2:
if verbose:
- print(
- 'Warning: Insufficient valid data points for spike analysis'
- )
+ logger.info(
+ 'Warning: Insufficient valid data for spike analysis'
+ )
return 0
spike_count = 0
for i in range(1, len(valid_values)):
@@ -2432,21 +2911,22 @@ class EarthScienceToolkit(BaseToolkit):
if diff > spike_threshold:
spike_count += 1
if verbose:
- print(
- f'Spike detected: {valid_values[i - 1]:.4f} -> {valid_values[i]:.4f}, Δ = {diff:.4f}'
- )
+ logger.info(
+ f'Spike detected: {valid_values[i - 1]:.4f} -> '
+ f'{valid_values[i]:.4f}, Δ = {diff:.4f}'
+ )
if verbose:
- print(f'\nTotal number of spikes detected: {spike_count}')
+ logger.info(f'\nTotal number of spikes detected: {spike_count}')
return spike_count
- def coefficient_of_variation(self, x: list, ddof: int=1):
+ def coefficient_of_variation(self, x: list, ddof: int = 1):
"""
Description:
Compute the Coefficient of Variation (CV) for a dataset.
CV is defined as the ratio of the standard deviation to the mean:
CV = std(x) / mean(x)
- Parameters:
+ Args:
x (list[float]):
Input dataset values (numeric).
ddof (int, default=1):
@@ -2463,34 +2943,28 @@ class EarthScienceToolkit(BaseToolkit):
>>> coefficient_of_variation([10, 12, 8, 9, 11])
0.14586499149789456
"""
- x = np.asarray(x)
- mean = np.mean(x)
- std = np.std(x, ddof=ddof)
+ import numpy as np
+
+ x_arr = np.asarray(x)
+ mean = np.mean(x_arr)
+ std = np.std(x_arr, ddof=ddof)
if mean == 0:
return float('nan')
return float(std / mean)
- def skewness(self, x: list, bias: bool=True):
- """
- Description:
- Compute the skewness of a dataset, which quantifies the asymmetry of its
- probability distribution around the mean.
+ def skewness(self, x: list, bias: bool = True):
+ """Compute skewness of a dataset (distribution asymmetry).
- - Positive skew → distribution has a longer right tail
- - Negative skew → distribution has a longer left tail
- - Zero skew → approximately symmetric distribution
+ Positive skew = longer right tail, negative = longer left tail,
+ zero = approximately symmetric.
- Parameters:
- x (list[float]):
- Input dataset values (numeric).
- bias (bool, default=True):
- If False, applies bias correction (Fisher-Pearson method)
- to compute the unbiased estimator of skewness.
+ Args:
+ x (list[float]): Input dataset values (numeric).
+ bias (bool, default=True): If False, applies bias correction
+ (Fisher-Pearson method) for unbiased estimator.
Returns:
- skew (float):
- The skewness of the dataset.
- Returns 0.0 if all values are identical (no variation).
+ skew (float): Skewness value. Returns 0.0 if no variation.
Example:
>>> skewness([1, 2, 3, 4, 5])
@@ -2498,41 +2972,34 @@ class EarthScienceToolkit(BaseToolkit):
>>> skewness([1, 1, 2, 5, 10])
1.446915
"""
- x = np.asarray(x)
- n = len(x)
- mean = np.mean(x)
- std = np.std(x, ddof=0 if bias else 1)
+ import numpy as np
+
+ x_arr = np.asarray(x)
+ n = len(x_arr)
+ mean = np.mean(x_arr)
+ std = np.std(x_arr, ddof=0 if bias else 1)
if std == 0:
return 0.0
- m3 = np.mean((x - mean) ** 3)
- skew = m3 / std ** 3
+ m3 = np.mean((x_arr - mean) ** 3)
+ skew = m3 / std**3
if not bias and n > 2:
skew *= np.sqrt(n * (n - 1)) / (n - 2)
return float(skew)
- def kurtosis(self, x: list, bias: bool=True, fisher: bool=True):
- """
- Description:
- Compute the kurtosis of a dataset, which quantifies the tailedness
- (extreme values relative to a normal distribution).
+ def kurtosis(self, x: list, bias: bool = True, fisher: bool = True):
+ """Compute kurtosis of a dataset (tailedness measure).
- - Positive kurtosis → distribution has heavier tails than normal.
- - Negative kurtosis → distribution has lighter tails than normal.
- - Zero kurtosis → distribution has similar tails to normal (when fisher=True).
+ Positive kurtosis = heavier tails than normal, negative = lighter.
+ Zero kurtosis = similar tails to normal (when fisher=True).
- Parameters:
- x (list[float]):
- Input dataset values (numeric).
- bias (bool, default=True):
- If False, applies bias correction to compute the unbiased estimator.
- fisher (bool, default=True):
- - If True, returns "excess kurtosis" (normal distribution → 0).
- - If False, returns regular kurtosis (normal distribution → 3).
+ Args:
+ x (list[float]): Input dataset values (numeric).
+ bias (bool, default=True): If False, applies bias correction.
+ fisher (bool, default=True): If True, returns "excess kurtosis"
+ (normal=0). If False, returns regular kurtosis (normal=3).
Returns:
- kurt (float):
- The kurtosis value of the dataset.
- Returns 0.0 if all values are identical (no variation).
+ kurt (float): Kurtosis value. Returns 0.0 if no variation.
Example:
>>> kurtosis([1, 2, 3, 4, 5])
@@ -2542,17 +3009,19 @@ class EarthScienceToolkit(BaseToolkit):
>>> kurtosis([1, 2, 2, 2, 100], fisher=False)
5.12
"""
- x = np.asarray(x)
- n = len(x)
- mean = np.mean(x)
- std = np.std(x, ddof=0 if bias else 1)
+ import numpy as np
+
+ x_arr = np.asarray(x)
+ n = len(x_arr)
+ mean = np.mean(x_arr)
+ std = np.std(x_arr, ddof=0 if bias else 1)
if std == 0:
return 0.0
- m4 = np.mean((x - mean) ** 4)
- kurt = m4 / std ** 4
+ m4 = np.mean((x_arr - mean) ** 4)
+ kurt = m4 / std**4
if not bias and n > 3:
- numerator = n * (n + 1) * ((x - mean) ** 4).sum()
- denominator = (n - 1) * (n - 2) * (n - 3) * std ** 4
+ numerator = n * (n + 1) * ((x_arr - mean) ** 4).sum()
+ denominator = (n - 1) * (n - 2) * (n - 3) * std**4
adjustment = numerator / denominator
excess = 3 * (n - 1) ** 2 / ((n - 2) * (n - 3))
kurt = adjustment - excess
@@ -2560,17 +3029,20 @@ class EarthScienceToolkit(BaseToolkit):
kurt -= 3
return float(kurt)
- def calc_single_image_mean(self, file_path: str, uint8: bool=False
- ) ->float:
+ def calc_single_image_mean(
+ self, file_path: str, uint8: bool = False
+ ) -> float:
"""
Compute mean value of an image.
- Parameters:
+ Args:
file_path (str): Path to input image.
Returns:
mean (float): Mean pixel value
"""
+ import numpy as np
+
if uint8:
img = self.read_image_uint8(file_path)
else:
@@ -2581,30 +3053,37 @@ class EarthScienceToolkit(BaseToolkit):
flat = np.where(np.isinf(flat), np.nan, flat)
return float(np.nanmean(flat))
- def calc_batch_image_mean(self, file_list: list[str], uint8: bool=False
- ) ->list[float]:
+ def calc_batch_image_mean(
+ self, file_list: list[str], uint8: bool = False
+ ) -> list[float]:
"""
Compute mean value of an batch of images.
- Parameters:
+ Args:
file_list (list(str)): Paths to input images.
Returns:
mean (list(float)): Mean pixel value
"""
- return [float(self.calc_single_image_mean(file_path, uint8)) for
- file_path in file_list]
+ return [
+ float(self.calc_single_image_mean(file_path, uint8))
+ for file_path in file_list
+ ]
- def calc_single_image_std(self, file_path: str, uint8: bool=False) ->float:
+ def calc_single_image_std(
+ self, file_path: str, uint8: bool = False
+ ) -> float:
"""
Compute standard deviation value of an image.
- Parameters:
+ Args:
file_path (str): Path to input image.
Returns:
std (float): Standard deviation
"""
+ import numpy as np
+
if uint8:
img = self.read_image_uint8(file_path)
else:
@@ -2615,33 +3094,38 @@ class EarthScienceToolkit(BaseToolkit):
flat = np.where(np.isinf(flat), np.nan, flat)
return float(np.nanstd(flat, ddof=1))
- def calc_batch_image_std(self, file_list: list[str], uint8: bool=False
- ) ->list[float]:
- """
- Description:
- Compute the standard deviation (spread of pixel values) for a batch of images.
+ def calc_batch_image_std(
+ self, file_list: list[str], uint8: bool = False
+ ) -> list[float]:
+ """Compute standard deviation for a batch of images.
- Parameters:
- - file_list (list[str]): List of input image file paths.
- - uint8 (bool, optional): Whether to convert images to uint8 format before computation. Default = False.
+ Args:
+ file_list (list[str]): List of input image file paths.
+ uint8 (bool, optional): Whether to convert to uint8 first.
+ Default = False.
Returns:
- - std (list[float]): List of standard deviation values, one for each input image.
+ list[float]: Standard deviation values, one per input image.
"""
- return [float(self.calc_single_image_std(file_path, uint8)) for
- file_path in file_list]
+ return [
+ float(self.calc_single_image_std(file_path, uint8))
+ for file_path in file_list
+ ]
- def calc_single_image_median(self, file_path: str, uint8: bool=False
- ) ->float:
+ def calc_single_image_median(
+ self, file_path: str, uint8: bool = False
+ ) -> float:
"""
Compute median value of an image.
- Parameters:
+ Args:
file_path (str): Path to input image.
Returns:
median (float): Median pixel value
"""
+ import numpy as np
+
if uint8:
img = self.read_image_uint8(file_path)
else:
@@ -2652,32 +3136,38 @@ class EarthScienceToolkit(BaseToolkit):
flat = np.where(np.isinf(flat), np.nan, flat)
return float(np.nanmedian(flat))
- def calc_batch_image_median(self, file_list: list[str], uint8: bool=False
- ) ->list[float]:
- """
- Description:
- Compute the median pixel value for a batch of images.
+ def calc_batch_image_median(
+ self, file_list: list[str], uint8: bool = False
+ ) -> list[float]:
+ """Compute median pixel value for a batch of images.
- Parameters:
- - file_list (list[str]): List of input image file paths.
- - uint8 (bool, optional): Whether to convert images to uint8 format before computation. Default = False.
+ Args:
+ file_list (list[str]): List of input image file paths.
+ uint8 (bool, optional): Whether to convert to uint8 first.
+ Default = False.
Returns:
- - median (list[float]): List of median pixel values, one for each input image.
+ list[float]: Median pixel values, one per input image.
"""
- return [float(self.calc_single_image_median(file_path, uint8)) for
- file_path in file_list]
+ return [
+ float(self.calc_single_image_median(file_path, uint8))
+ for file_path in file_list
+ ]
- def calc_single_image_min(self, file_path: str, uint8: bool=False) ->float:
+ def calc_single_image_min(
+ self, file_path: str, uint8: bool = False
+ ) -> float:
"""
Compute min value of an image.
- Parameters:
+ Args:
file_path (str): Path to input image.
Returns:
- min (flaot): Minimum pixel value
+ min (float): Minimum pixel value
"""
+ import numpy as np
+
if uint8:
img = self.read_image_uint8(file_path)
else:
@@ -2688,32 +3178,38 @@ class EarthScienceToolkit(BaseToolkit):
flat = np.where(np.isinf(flat), np.nan, flat)
return float(np.nanmin(flat))
- def calc_batch_image_min(self, file_list: list[str], uint8: bool=False
- ) ->list[float]:
- """
- Description:
- Compute the minimum pixel value for a batch of images.
+ def calc_batch_image_min(
+ self, file_list: list[str], uint8: bool = False
+ ) -> list[float]:
+ """Compute minimum pixel value for a batch of images.
- Parameters:
- - file_list (list[str]): List of input image file paths.
- - uint8 (bool, optional): Whether to convert images to uint8 format before computation. Default = False.
+ Args:
+ file_list (list[str]): List of input image file paths.
+ uint8 (bool, optional): Whether to convert to uint8 first.
+ Default = False.
Returns:
- - min (list[float]): List of minimum pixel values, one for each input image.
+ list[float]: Minimum pixel values, one per input image.
"""
- return [float(self.calc_single_image_min(file_path, uint8)) for
- file_path in file_list]
+ return [
+ float(self.calc_single_image_min(file_path, uint8))
+ for file_path in file_list
+ ]
- def calc_single_image_max(self, file_path: str, uint8: bool=False) ->float:
+ def calc_single_image_max(
+ self, file_path: str, uint8: bool = False
+ ) -> float:
"""
Compute max value of an image.
- Parameters:
+ Args:
file_path (str): Path to input image.
Returns:
max (float): Maximum pixel value
"""
+ import numpy as np
+
if uint8:
img = self.read_image_uint8(file_path)
else:
@@ -2724,33 +3220,39 @@ class EarthScienceToolkit(BaseToolkit):
flat = np.where(np.isinf(flat), np.nan, flat)
return float(np.nanmax(flat))
- def calc_batch_image_max(self, file_list: list[str], uint8: bool=False
- ) ->list[float]:
- """
- Description:
- Compute the maximum pixel value for a batch of images.
+ def calc_batch_image_max(
+ self, file_list: list[str], uint8: bool = False
+ ) -> list[float]:
+ """Compute maximum pixel value for a batch of images.
- Parameters:
- - file_list (list[str]): List of input image file paths.
- - uint8 (bool, optional): Whether to convert images to uint8 format before computation. Default = False.
+ Args:
+ file_list (list[str]): List of input image file paths.
+ uint8 (bool, optional): Whether to convert to uint8 first.
+ Default = False.
Returns:
- - max (list[float]): List of maximum pixel values, one for each input image.
+ list[float]: Maximum pixel values, one per input image.
"""
- return [float(self.calc_single_image_max(file_path, uint8)) for
- file_path in file_list]
+ return [
+ float(self.calc_single_image_max(file_path, uint8))
+ for file_path in file_list
+ ]
- def calc_single_image_skewness(self, file_path: str, uint8: bool=False
- ) ->float:
+ def calc_single_image_skewness(
+ self, file_path: str, uint8: bool = False
+ ) -> float:
"""
Compute skewness value of an image.
- Parameters:
+ Args:
file_path (str): Path to input image.
Returns:
skewness: Skewness of pixel value distribution
"""
+ import numpy as np
+ from scipy.stats import skew
+
if uint8:
img = self.read_image_uint8(file_path)
else:
@@ -2761,37 +3263,42 @@ class EarthScienceToolkit(BaseToolkit):
flat = np.where(np.isinf(flat), np.nan, flat)
return float(skew(flat, bias=False))
- def calc_batch_image_skewness(self, file_list: list[str], uint8: bool=False
- ) ->list[float]:
- """
- Description:
- Compute the skewness of pixel value distributions for a batch of images.
- Skewness quantifies the asymmetry of the distribution:
- - Positive skew → longer right tail
- - Negative skew → longer left tail
- - Zero skew → symmetric distribution
+ def calc_batch_image_skewness(
+ self, file_list: list[str], uint8: bool = False
+ ) -> list[float]:
+ """Compute skewness of pixel distributions for a batch of images.
- Parameters:
- - file_list (list[str]): List of input image file paths.
- - uint8 (bool, optional): Whether to convert images to uint8 format before computation. Default = False.
+ Positive skew = longer right tail, negative = longer left tail,
+ zero = symmetric distribution.
+
+ Args:
+ file_list (list[str]): List of input image file paths.
+ uint8 (bool, optional): Whether to convert to uint8 first.
+ Default = False.
Returns:
- - skewness (list[float]): List of skewness values, one for each input image.
+ list[float]: Skewness values, one per input image.
"""
- return [float(self.calc_single_image_skewness(file_path, uint8)) for
- file_path in file_list]
+ return [
+ float(self.calc_single_image_skewness(file_path, uint8))
+ for file_path in file_list
+ ]
- def calc_single_image_kurtosis(self, file_path: str, uint8: bool=False
- ) ->float:
+ def calc_single_image_kurtosis(
+ self, file_path: str, uint8: bool = False
+ ) -> float:
"""
Compute kurtosis value of an image.
- Parameters:
+ Args:
file_path (str): Path to input image.
Returns:
kurtosis: Kurtosis of pixel value distribution (excess kurtosis)
"""
+ import numpy as np
+ from scipy.stats import kurtosis
+
if uint8:
img = self.read_image_uint8(file_path)
else:
@@ -2805,37 +3312,42 @@ class EarthScienceToolkit(BaseToolkit):
raise ValueError('No valid data points for kurtosis calculation')
return float(kurtosis(flat_clean, fisher=False))
- def calc_batch_image_kurtosis(self, file_list: list[str], uint8: bool=False
- ) ->list[float]:
- """
- Description:
- Compute the kurtosis of pixel value distributions for a batch of images.
- Kurtosis measures the "tailedness" of the distribution relative to a normal distribution.
+ def calc_batch_image_kurtosis(
+ self, file_list: list[str], uint8: bool = False
+ ) -> list[float]:
+ """Compute kurtosis of pixel distributions for a batch of images.
- Parameters:
- - file_list (list[str]): List of input image file paths.
- - uint8 (bool, optional): Whether to convert images to uint8 format before computation. Default = False.
+ Kurtosis measures "tailedness" relative to normal distribution.
+ Normal = 3, higher = heavier tails, lower = lighter tails.
+
+ Args:
+ file_list (list[str]): List of input image file paths.
+ uint8 (bool, optional): Whether to convert to uint8 first.
+ Default = False.
Returns:
- - kurtosis (list[float]): List of kurtosis values, one for each input image.
- * Normal distribution → kurtosis ≈ 3
- * Higher values → heavier tails
- * Lower values → lighter tails
+ list[float]: Kurtosis values, one per input image.
"""
- return [float(self.calc_single_image_kurtosis(file_path, uint8)) for
- file_path in file_list]
+ return [
+ float(self.calc_single_image_kurtosis(file_path, uint8))
+ for file_path in file_list
+ ]
- def calc_single_image_sum(self, file_path: str, uint8: bool=False) ->float:
+ def calc_single_image_sum(
+ self, file_path: str, uint8: bool = False
+ ) -> float:
"""
Compute sum value of an image.
- Parameters:
+ Args:
file_path (str): Path to input image.
uint8 (bool): Whether to use uint8 format.
Returns:
sum (float): Sum pixel value
"""
+ import numpy as np
+
if uint8:
img = self.read_image_uint8(file_path)
else:
@@ -2846,28 +3358,33 @@ class EarthScienceToolkit(BaseToolkit):
flat = np.where(np.isinf(flat), np.nan, flat)
return float(np.nansum(flat))
- def calc_batch_image_sum(self, file_list: list[str], uint8: bool=False
- ) ->list[float]:
+ def calc_batch_image_sum(
+ self, file_list: list[str], uint8: bool = False
+ ) -> list[float]:
"""
Description:
Compute the sum of pixel values for a batch of images.
- Parameters:
+ Args:
- file_list (list[str]): List of input image file paths.
- - uint8 (bool, optional): Whether to convert images to uint8 format before computation. Default = False.
+ - uint8 (bool, optional): Whether to convert images to uint8 format
+ before computation. Default = False.
Returns:
- - sum (list[float]): List of pixel sum values, one for each input image.
+ - sum (list[float]): List of pixel sum values, one for each image.
"""
- return [float(self.calc_single_image_sum(file_path, uint8)) for
- file_path in file_list]
+ return [
+ float(self.calc_single_image_sum(file_path, uint8))
+ for file_path in file_list
+ ]
- def calc_single_image_hotspot_percentage(self, file_path: str,
- threshold: float, uint8: bool=False) ->float:
+ def calc_single_image_hotspot_percentage(
+ self, file_path: str, threshold: float, uint8: bool = False
+ ) -> float:
"""
Compute hotspot percentage of an image.
- Parameters:
+ Args:
file_path (str): Path to input image.
threshold (float): Threshold value for hotspot detection.
uint8 (bool): Whether to use uint8 format.
@@ -2875,6 +3392,8 @@ class EarthScienceToolkit(BaseToolkit):
Returns:
percentage (float): Hotspot area percentage (0.0 to 1.0).
"""
+ import numpy as np
+
if uint8:
img = self.read_image_uint8(file_path)
else:
@@ -2890,37 +3409,58 @@ class EarthScienceToolkit(BaseToolkit):
hotspot_percentage = len(hotspot_pixels) / len(valid_pixels)
return float(hotspot_percentage)
- def calc_batch_image_hotspot_percentage(self, file_list: list[str],
- threshold: float, uint8: bool=False) ->list[float]:
+ def calc_batch_image_hotspot_percentage(
+ self, file_list: list[str], threshold: float, uint8: bool = False
+ ) -> list[float]:
"""
Description:
- Compute the hotspot percentage (fraction of pixels above a threshold) for a batch of images.
+ Compute the hotspot percentage (fraction of pixels above a threshold)
+ for a batch of images.
- Parameters:
+ Args:
- file_list (list[str]): List of input image file paths.
- - threshold (float): Threshold value for hotspot detection. Pixels with values greater than this threshold are counted as hotspots.
- - uint8 (bool, optional): Whether to convert images to uint8 format before computation. Default = False.
+ - threshold (float): Threshold value for hotspot detection. Pixels with
+ values greater than this threshold are counted as hotspots.
+ - uint8 (bool, optional): Whether to convert images to uint8 format
+ before computation. Default = False.
Returns:
- - percentage (list[float]): List of hotspot area percentages (0.0–1.0), one for each input image.
+ - percentage (list[float]): List of hotspot area percentages (0.0-1.0),
+ one for each input image.
"""
- return [float(self.calc_single_image_hotspot_percentage(file_path,
- threshold, uint8)) for file_path in file_list]
+ return [
+ float(
+ self.calc_single_image_hotspot_percentage(
+ file_path, threshold, uint8
+ )
+ )
+ for file_path in file_list
+ ]
- def calc_single_image_hotspot_tif(self, file_path: str, threshold:
- float, output_path: str, uint8: bool=False) ->str:
+ def calc_single_image_hotspot_tif(
+ self,
+ file_path: str,
+ threshold: float,
+ output_path: str,
+ uint8: bool = False,
+ ) -> str:
"""
- Create a binary map highlighting areas below the threshold and save as GeoTIFF.
+ Create a binary map highlighting areas below the threshold and save
+ as GeoTIFF.
- Parameters:
+ Args:
file_path (str): Path to input image.
threshold (float): Threshold value for detection.
uint8 (bool): Whether to use uint8 format.
- output_path (str, optional): relative path for the output raster file, e.g. "question17/hotspot_2022-01-16.tif"
+ output_path (str, optional): relative path for the output raster
+ file, e.g. "question17/hotspot_2022-01-16.tif"
Returns:
str: Path to the saved GeoTIFF image containing the binary map.
"""
+ import numpy as np
+ from osgeo import gdal
+
ds = gdal.Open(file_path)
if ds is None:
raise RuntimeError(f'Failed to open image: {file_path}')
@@ -2935,11 +3475,16 @@ class EarthScienceToolkit(BaseToolkit):
mask[img < threshold] = 1.0
mask[img >= threshold] = 0.0
mask[np.isnan(img)] = np.nan
- output_path = TEMP_DIR / output_path
- os.makedirs(output_path.parent, exist_ok=True)
+ output_path_full = TEMP_DIR / output_path
+ os.makedirs(output_path_full.parent, exist_ok=True)
driver = gdal.GetDriverByName('GTiff')
- out_ds = driver.Create(str(output_path), xsize=mask.shape[1], ysize
- =mask.shape[0], bands=1, eType=gdal.GDT_Float32)
+ out_ds = driver.Create(
+ str(output_path_full),
+ xsize=mask.shape[1],
+ ysize=mask.shape[0],
+ bands=1,
+ eType=gdal.GDT_Float32,
+ )
out_ds.GetRasterBand(1).WriteArray(mask)
out_ds.GetRasterBand(1).SetNoDataValue(np.nan)
if ds.GetGeoTransform():
@@ -2949,35 +3494,48 @@ class EarthScienceToolkit(BaseToolkit):
out_ds.FlushCache()
out_ds = None
ds = None
- return f'Result save at {TEMP_DIR / output_path}'
+ return f'Result save at {output_path_full}'
- def calc_batch_image_hotspot_tif(self, file_list: list[str], threshold:
- float, output_path_list: list[str], uint8: bool=False) ->list[str]:
+ def calc_batch_image_hotspot_tif(
+ self,
+ file_list: list[str],
+ threshold: float,
+ output_path_list: list[str],
+ uint8: bool = False,
+ ) -> list[str]:
"""
Description:
- Create binary hotspot maps for a batch of images, where pixels below a specified
- threshold are set to 1 (hotspot) and others set to 0. The output is saved as
- GeoTIFF files, preserving georeference metadata from the input images.
+ Create binary hotspot maps for a batch of images, where pixels below
+ a specified threshold are set to 1 (hotspot) and others set to 0.
+ The output is saved as GeoTIFF files, preserving georeference metadata
+ from the input images.
- Parameters:
+ Args:
- file_list (list[str]): List of input image file paths.
- - threshold (float): Threshold value for hotspot detection. Pixels below this threshold are marked as hotspots.
- - output_path_list (list[str]): List of output file paths for the generated GeoTIFF hotspot maps.
- - uint8 (bool, optional): Whether to convert images to uint8 format before computation. Default = False.
+ - threshold (float): Threshold value for hotspot detection. Pixels
+ below this threshold are marked as hotspots.
+ - output_path_list (list[str]): List of output file paths for the
+ generated GeoTIFF hotspot maps.
+ - uint8 (bool, optional): Whether to convert images to uint8 format
+ before computation. Default = False.
Returns:
- - list[str]: Paths to the saved GeoTIFF images containing the binary hotspot maps.
+ - list[str]: Paths to the saved GeoTIFF images containing the binary
+ hotspot maps.
"""
- return [self.calc_single_image_hotspot_tif(file_path, threshold,
- output_path, uint8) for file_path, output_path in zip(file_list,
- output_path_list)]
+ return [
+ self.calc_single_image_hotspot_tif(
+ file_path, threshold, output_path, uint8
+ )
+ for file_path, output_path in zip(file_list, output_path_list)
+ ]
def difference(self, a: float, b: float):
"""
Description:
Compute the absolute difference between two numbers.
- Parameters:
+ Args:
- a (float): The first number.
- b (float): The second number.
@@ -2992,7 +3550,7 @@ class EarthScienceToolkit(BaseToolkit):
Description:
Perform division between two numbers.
- Parameters:
+ Args:
- a (float): The divisor (denominator).
- b (float): The dividend (numerator).
@@ -3007,15 +3565,17 @@ class EarthScienceToolkit(BaseToolkit):
def percentage_change(self, a: float, b: float):
"""
Description:
- Calculate the percentage change between two numbers, useful for comparing relative growth or decline.
+ Calculate the percentage change between two numbers, useful for
+ comparing relative growth or decline.
- Parameters:
+ Args:
- a (float): The original value (denominator).
- b (float): The new value (numerator).
Returns:
- - percent (float): The percentage change, computed as ((b - a) / a) * 100.
- Positive values indicate increase, negative values indicate decrease.
+ - percent (float): The percentage change, computed as
+ ((b - a) / a) * 100. Positive values indicate increase,
+ negative values indicate decrease.
"""
percent = (b - a) / a * 100
return float(percent)
@@ -3025,11 +3585,12 @@ class EarthScienceToolkit(BaseToolkit):
Description:
Convert temperature from Kelvin to Celsius.
- Parameters:
+ Args:
- kelvin (float): Temperature in Kelvin.
Returns:
- - celsius (float): Temperature in Celsius, computed as (Kelvin - 273.15).
+ - celsius (float): Temperature in Celsius, computed as
+ (Kelvin - 273.15).
"""
celsius = kelvin - 273.15
return celsius
@@ -3039,7 +3600,7 @@ class EarthScienceToolkit(BaseToolkit):
Description:
Convert temperature from Celsius to Kelvin.
- Parameters:
+ Args:
celsius (float):
Temperature in Celsius.
@@ -3060,9 +3621,10 @@ class EarthScienceToolkit(BaseToolkit):
def max_value_and_index(self, x: list):
"""
Description:
- Find the maximum value in a list and return both the maximum value and its index.
+ Find the maximum value in a list and return both the maximum value
+ and its index.
- Parameters:
+ Args:
- x (list[float]): Input data list.
Returns:
@@ -3070,17 +3632,20 @@ class EarthScienceToolkit(BaseToolkit):
* max_value (float): The maximum value in the list.
* max_index (int): The index of the maximum value.
"""
- x = np.asarray(x)
- max_index = np.argmax(x)
- max_value = x[max_index]
+ import numpy as np
+
+ x_arr = np.asarray(x)
+ max_index = np.argmax(x_arr)
+ max_value = x_arr[max_index]
return float(max_value), int(max_index)
def min_value_and_index(self, x: list):
"""
Description:
- Find the minimum value in a list and return both the minimum value and its index.
+ Find the minimum value in a list and return both the minimum value
+ and its index.
- Parameters:
+ Args:
- x (list[float]): Input data list.
Returns:
@@ -3088,9 +3653,11 @@ class EarthScienceToolkit(BaseToolkit):
* min_value (float): The minimum value in the list.
* min_index (int): The index of the minimum value.
"""
- x = np.asarray(x)
- min_index = np.argmin(x)
- min_value = x[min_index]
+ import numpy as np
+
+ x_arr = np.asarray(x)
+ min_index = np.argmin(x_arr)
+ min_value = x_arr[min_index]
return float(min_value), int(min_index)
def multiply(self, a, b):
@@ -3098,7 +3665,7 @@ class EarthScienceToolkit(BaseToolkit):
Description:
Multiply two numbers and return their product.
- Parameters:
+ Args:
a (float or int):
First number.
b (float or int):
@@ -3121,7 +3688,7 @@ class EarthScienceToolkit(BaseToolkit):
Description:
Return the ceiling (rounded up integer) of a given number.
- Parameters:
+ Args:
n (float):
A numeric value.
@@ -3142,11 +3709,12 @@ class EarthScienceToolkit(BaseToolkit):
Description:
Retrieve elements from a list using a list or tuple of indices.
- Parameters:
+ Args:
input_list (list):
The source list from which elements will be extracted.
indexes (list[int] or tuple[int]):
- A sequence of indices specifying the positions of elements to retrieve.
+ A sequence of indices specifying the positions of elements
+ to retrieve.
Returns:
result (list):
@@ -3163,7 +3731,7 @@ class EarthScienceToolkit(BaseToolkit):
Description:
Compute the arithmetic mean (average) of a dataset.
- Parameters:
+ Args:
x (list[float]):
Input data array.
@@ -3175,17 +3743,23 @@ class EarthScienceToolkit(BaseToolkit):
>>> mean([1, 2, 3, 4, 5])
3.0
"""
- x = np.asarray(x)
- return float(np.mean(x))
+ import numpy as np
- def calculate_threshold_ratio(self, image_paths: (str | list[str]),
- threshold: float=0.75, band_index: int=0) ->float:
+ x_arr = np.asarray(x)
+ return float(np.mean(x_arr))
+
+ def calculate_threshold_ratio(
+ self,
+ image_paths: (str | list[str]),
+ threshold: float = 0.75,
+ band_index: int = 0,
+ ) -> float:
"""
Description:
- Calculate the average percentage of pixels above a given threshold for
- one or more images and a specified band.
+ Calculate the average percentage of pixels above a given threshold
+ for one or more images and a specified band.
- Parameters:
+ Args:
image_paths (str or list[str]):
Path or list of image file paths.
threshold (float, optional):
@@ -3195,14 +3769,19 @@ class EarthScienceToolkit(BaseToolkit):
Returns:
percentage (float):
- Average percentage of pixels above the threshold across all images.
+ Average percentage of pixels above the threshold across all
+ images.
Example:
>>> calculate_threshold_ratio("image1.tif", threshold=0.5)
42.37
- >>> calculate_threshold_ratio(["img1.tif", "img2.tif"], threshold=0.8, band_index=1)
+ >>> calculate_threshold_ratio(
+ ... ["img1.tif", "img2.tif"], threshold=0.8, band_index=1
+ ... )
33.12
"""
+ import numpy as np
+
if isinstance(image_paths, str):
image_paths = [image_paths]
ratios = []
@@ -3225,31 +3804,37 @@ class EarthScienceToolkit(BaseToolkit):
ratios.append(float(percentage))
return float(np.mean(ratios)) if ratios else 0.0
- def calc_single_image_fire_pixels(self, file_path: str, fire_threshold:
- float=0) ->int:
+ def calc_single_image_fire_pixels(
+ self, file_path: str, fire_threshold: float = 0
+ ) -> int:
"""
Compute the number of fire pixels (MaxFRP > threshold) in an image.
- Parameters:
+ Args:
file_path (str): Path to input image.
- fire_threshold (float): Minimum FRP value to be considered as fire (default: 0).
+ fire_threshold (float): Minimum FRP value to be considered as fire
+ (default: 0).
Returns:
fire_pixels (int): Number of fire pixels
"""
+ import numpy as np
+
img = self.read_image(file_path)
if img.size == 0:
raise ValueError('Input image is empty')
fire_pixels = np.sum(img > fire_threshold)
return int(fire_pixels)
- def calc_batch_fire_pixels(self, file_list: list[str], fire_threshold:
- float=0) ->list[int]:
+ def calc_batch_fire_pixels(
+ self, file_list: list[str], fire_threshold: float = 0
+ ) -> list[int]:
"""
Description:
- Compute the number of fire pixels (FRP > threshold) for a batch of images.
+ Compute the number of fire pixels (FRP > threshold) for a batch of
+ images.
- Parameters:
+ Args:
file_list (list[str]):
Paths to input images.
fire_threshold (float, optional):
@@ -3260,23 +3845,29 @@ class EarthScienceToolkit(BaseToolkit):
A list of fire pixel counts, one per input image.
Example:
- >>> calc_batch_fire_pixels(["img1.tif", "img2.tif"], fire_threshold=50)
+ >>> calc_batch_fire_pixels(
+ ... ["img1.tif", "img2.tif"], fire_threshold=50
+ ... )
[123, 89]
"""
- return [self.calc_single_image_fire_pixels(file_path,
- fire_threshold) for file_path in file_list]
+ return [
+ self.calc_single_image_fire_pixels(file_path, fire_threshold)
+ for file_path in file_list
+ ]
- def create_fire_increase_map(self, change_image_path: str, output_path:
- str, threshold: float=20.0) ->str:
+ def create_fire_increase_map(
+ self, change_image_path: str, output_path: str, threshold: float = 20.0
+ ) -> str:
"""
Description:
- Create a binary map highlighting areas where fire increase exceeds a specified threshold.
+ Create a binary map highlighting areas where fire increase exceeds
+ a specified threshold.
- Parameters:
+ Args:
change_image_path (str):
Path to the fire change image.
output_path (str):
- Relative path for the output raster file
+ Relative path for the output raster file
(e.g., "question17/hotspot_2022-01-16.tif").
threshold (float, optional):
Threshold value in MW. Default = 20.0.
@@ -3286,9 +3877,15 @@ class EarthScienceToolkit(BaseToolkit):
Path to the saved GeoTIFF fire increase map.
Example:
- >>> create_fire_increase_map("fire_change.tif", "output/fire_increase.tif", threshold=25.0)
+ >>> create_fire_increase_map(
+ ... "fire_change.tif", "output/fire_increase.tif",
+ ... threshold=25.0
+ ... )
'Result save at /tmp/output/fire_increase.tif'
"""
+ import numpy as np
+ import rasterio
+
change_img = self.read_image(change_image_path)
fire_increase_map = (change_img >= threshold).astype(np.uint8)
with rasterio.open(change_image_path) as src:
@@ -3299,22 +3896,30 @@ class EarthScienceToolkit(BaseToolkit):
dst.write(fire_increase_map, 1)
return f'Result save at {TEMP_DIR / output_path}'
- def identify_fire_prone_areas(self, file_path: str, output_path: str,
- threshold_percentile: float=75, uint8: bool=False) ->tuple[str, float]:
+ def identify_fire_prone_areas(
+ self,
+ file_path: str,
+ output_path: str,
+ threshold_percentile: float = 75,
+ uint8: bool = False,
+ ) -> tuple[str, float]:
"""
Description:
- Identify fire-prone areas from a hotspot map based on a given percentile threshold.
+ Identify fire-prone areas from a hotspot map based on a given
+ percentile threshold.
- Parameters:
+ Args:
file_path (str):
Path to the input hotspot map file.
output_path (str):
- Relative path for the output raster file
+ Relative path for the output raster file
(e.g., "question17/hotspot_2022-01-16.tif").
threshold_percentile (float, optional):
- Percentile threshold for identifying fire-prone areas. Default = 75.
+ Percentile threshold for identifying fire-prone areas.
+ Default = 75.
uint8 (bool, optional):
- Whether to use uint8 format when reading the input. Default = False.
+ Whether to use uint8 format when reading the input.
+ Default = False.
Returns:
result (tuple[str, float]):
@@ -3323,9 +3928,14 @@ class EarthScienceToolkit(BaseToolkit):
- Threshold value used for classification.
Example:
- >>> identify_fire_prone_areas("hotspot_map.tif", "output/fire_prone.tif", 80)
+ >>> identify_fire_prone_areas(
+ ... "hotspot_map.tif", "output/fire_prone.tif", 80
+ ... )
('Result save at /tmp/output/fire_prone.tif', 123.45)
"""
+ import numpy as np
+ import rasterio
+
if uint8:
hotspot_map = self.read_image_uint8(file_path)
else:
@@ -3338,41 +3948,49 @@ class EarthScienceToolkit(BaseToolkit):
fire_prone_areas = np.zeros_like(hotspot_map, dtype=np.uint8)
else:
threshold_value = np.percentile(valid_pixels, threshold_percentile)
- fire_prone_areas = (hotspot_map >= threshold_value).astype(np.uint8
- )
+ fire_prone_areas = (hotspot_map >= threshold_value).astype(
+ np.uint8
+ )
os.makedirs((TEMP_DIR / output_path).parent, exist_ok=True)
with rasterio.open(file_path) as src:
output_profile = src.profile.copy()
- output_profile.update(dtype=rasterio.uint8, compress='lzw',
- nodata=255)
- with rasterio.open(TEMP_DIR / output_path, 'w', **output_profile
- ) as dst:
+ output_profile.update(
+ dtype=rasterio.uint8, compress='lzw', nodata=255
+ )
+ with rasterio.open(
+ TEMP_DIR / output_path, 'w', **output_profile
+ ) as dst:
dst.write(fire_prone_areas, 1)
return f'Result save at {TEMP_DIR / output_path}', float(
- threshold_value)
+ threshold_value
+ )
def get_percentile_value_from_image(self, image_path, percentile):
"""
Description:
- Calculate the N-th percentile value of pixel values in a raster image,
- and return it as a native Python type matching the image's data type.
+ Calculate the N-th percentile value of pixel values in a raster
+ image, and return it as a native Python type matching the image's
+ data type.
- Parameters:
+ Args:
image_path (str):
Path to the input raster (.tif) file.
percentile (int or float):
- Percentile to calculate (range 1–100).
+ Percentile to calculate (range 1-100).
Returns:
value (int or float):
The pixel value corresponding to the specified percentile,
- cast to the appropriate native Python type (int for integer rasters,
- float for floating-point rasters).
+ cast to the appropriate native Python type (int for integer
+ rasters, float for floating-point rasters).
Example:
>>> get_percentile_value_from_image("fire_map.tif", 90)
235
"""
+ import numpy as np
+ import rasterio
+
if not 1 <= percentile <= 100:
raise ValueError('Percentile must be between 1 and 100.')
with rasterio.open(image_path) as src:
@@ -3390,22 +4008,27 @@ class EarthScienceToolkit(BaseToolkit):
else:
raise TypeError(f'Unsupported raster data type: {dtype}')
- def image_division_mean(self, image_path1, image_path2=None, band1=1,
- band2=2):
+ def image_division_mean(
+ self, image_path1, image_path2=None, band1=1, band2=2
+ ):
"""
Description:
- Calculate the mean of pixel-wise division between two images
+ Calculate the mean of pixel-wise division between two images
or between two bands of the same image.
- Parameters:
+ Args:
image_path1 (str):
- Path to the first image (or the only image if comparing two bands).
+ Path to the first image (or the only image if comparing two
+ bands).
image_path2 (str, optional):
- Path to the second image. If None, band1 and band2 of image_path1 will be used.
+ Path to the second image. If None, band1 and band2 of
+ image_path1 will be used.
band1 (int, optional):
- Band index for numerator when using a multi-band image. Default = 1.
+ Band index for numerator when using a multi-band image.
+ Default = 1.
band2 (int, optional):
- Band index for denominator when using a multi-band image. Default = 2.
+ Band index for denominator when using a multi-band image.
+ Default = 2.
Returns:
result (float):
@@ -3418,13 +4041,18 @@ class EarthScienceToolkit(BaseToolkit):
>>> image_division_mean("image1.tif", "image2.tif")
0.876
"""
+ import numpy as np
+ import rasterio
+
if image_path2 is None:
with rasterio.open(image_path1) as src:
array1 = src.read(band1).astype(np.float32)
array2 = src.read(band2).astype(np.float32)
else:
- with rasterio.open(image_path1) as src1, rasterio.open(image_path2
- ) as src2:
+ with (
+ rasterio.open(image_path1) as src1,
+ rasterio.open(image_path2) as src2,
+ ):
array1 = src1.read(1).astype(np.float32)
array2 = src2.read(1).astype(np.float32)
mask = (array2 != 0) & ~np.isnan(array1) & ~np.isnan(array2)
@@ -3432,14 +4060,15 @@ class EarthScienceToolkit(BaseToolkit):
ratio[mask] = array1[mask] / array2[mask]
return float(np.nanmean(ratio))
- def calculate_intersection_percentage(self, path1, threshold1, path2,
- threshold2):
+ def calculate_intersection_percentage(
+ self, path1, threshold1, path2, threshold2
+ ):
"""
Description:
- Calculate the percentage of pixels that simultaneously satisfy
+ Calculate the percentage of pixels that simultaneously satisfy
threshold conditions in two raster images.
- Parameters:
+ Args:
path1 (str):
Path to the first raster image (e.g., NDVI).
threshold1 (float):
@@ -3451,13 +4080,18 @@ class EarthScienceToolkit(BaseToolkit):
Returns:
percentage (float):
- Percentage of pixels that satisfy both conditions
+ Percentage of pixels that satisfy both conditions
over the total valid pixels.
Example:
- >>> calculate_intersection_percentage("ndvi.tif", 0.3, "tvdi.tif", 0.7)
+ >>> calculate_intersection_percentage(
+ ... "ndvi.tif", 0.3, "tvdi.tif", 0.7
+ ... )
12.54
"""
+ import numpy as np
+ import rasterio
+
with rasterio.open(path1) as src1:
data1 = src1.read(1).astype(np.float32)
mask1 = src1.read_masks(1) > 0
@@ -3470,25 +4104,28 @@ class EarthScienceToolkit(BaseToolkit):
condition1 = valid_data1 > threshold1
condition2 = valid_data2 > threshold2
intersection_mask = condition1 & condition2
- total_valid_pixels = np.count_nonzero(~np.isnan(valid_data1) & ~np.
- isnan(valid_data2))
+ total_valid_pixels = np.count_nonzero(
+ ~np.isnan(valid_data1) & ~np.isnan(valid_data2)
+ )
intersection_pixels = np.count_nonzero(intersection_mask)
if total_valid_pixels == 0:
return 0.0
percentage = intersection_pixels / total_valid_pixels * 100
return percentage
- def calc_batch_image_mean_mean(self, file_list: list[str], uint8: bool=
- False) ->float:
+ def calc_batch_image_mean_mean(
+ self, file_list: list[str], uint8: bool = False
+ ) -> float:
"""
Description:
Compute the average of mean pixel values across a batch of images.
- Parameters:
+ Args:
file_list (list[str]):
List of image file paths.
uint8 (bool, optional):
- Whether to convert images to uint8 format (0–255). Default = False.
+ Whether to convert images to uint8 format (0-255).
+ Default = False.
Returns:
mean_of_means (float):
@@ -3498,21 +4135,28 @@ class EarthScienceToolkit(BaseToolkit):
>>> calc_batch_image_mean_mean(["img1.tif", "img2.tif"])
105.67
"""
- means = [float(self.calc_single_image_mean(file_path, uint8)) for
- file_path in file_list]
+ import numpy as np
+
+ means = [
+ float(self.calc_single_image_mean(file_path, uint8))
+ for file_path in file_list
+ ]
return float(np.mean(means))
- def calc_batch_image_mean_max(self, file_list: list[str], uint8: bool=False
- ) ->float:
+ def calc_batch_image_mean_max(
+ self, file_list: list[str], uint8: bool = False
+ ) -> float:
"""
Description:
- Compute the mean pixel values of a batch of images and return the maximum mean.
+ Compute the mean pixel values of a batch of images and return the
+ maximum mean.
- Parameters:
+ Args:
file_list (list[str]):
Paths to input images.
uint8 (bool, optional):
- Whether to treat image as uint8 (0–255 normalization). Default = False.
+ Whether to treat image as uint8 (0-255 normalization).
+ Default = False.
Returns:
max_mean (float):
@@ -3522,24 +4166,29 @@ class EarthScienceToolkit(BaseToolkit):
>>> calc_batch_image_mean_max(["img1.tif", "img2.tif"])
145.32
"""
- means = [float(self.calc_single_image_mean(file_path, uint8)) for
- file_path in file_list]
+ means = [
+ float(self.calc_single_image_mean(file_path, uint8))
+ for file_path in file_list
+ ]
return max(means)
- def calc_batch_image_mean_max_min(self, file_list: list[str], uint8:
- bool=False) ->tuple[float, float, float]:
+ def calc_batch_image_mean_max_min(
+ self, file_list: list[str], uint8: bool = False
+ ) -> tuple[float, float, float]:
"""
Description:
- Compute the batch-wise statistics across multiple images, including:
+ Compute the batch-wise statistics across multiple images,
+ including:
- Mean of mean values
- Maximum of maximum values
- Minimum of minimum values
- Parameters:
+ Args:
file_list (list[str]):
List of image file paths.
uint8 (bool, optional):
- Whether to convert the data to uint8 range (0–255). Default = False.
+ Whether to convert the data to uint8 range (0-255).
+ Default = False.
Returns:
result (tuple[float, float, float]):
@@ -3550,6 +4199,9 @@ class EarthScienceToolkit(BaseToolkit):
>>> calc_batch_image_mean_max_min(["img1.tif", "img2.tif"])
(110.5, 243.0, 5.0)
"""
+ import numpy as np
+ import rasterio
+
means = []
maxs = []
mins = []
@@ -3564,47 +4216,59 @@ class EarthScienceToolkit(BaseToolkit):
mins.append(np.min(img))
return float(np.mean(means)), float(np.max(maxs)), float(np.min(mins))
- def calc_batch_image_mean_threshold(self, file_list: list[str],
- threshold: float, above: bool=True, uint8: bool=False, band_index:
- int=0, return_type: str='ratio') ->(float | int):
+ def calc_batch_image_mean_threshold(
+ self,
+ file_list: list[str],
+ threshold: float,
+ above: bool = True,
+ uint8: bool = False,
+ band_index: int = 0,
+ return_type: str = 'ratio',
+ ) -> float | int:
"""
Description:
- Calculate the percentage or count of images whose mean pixel values
+ Calculate the percentage or count of images whose mean pixel values
(in a specified band) are above or below a given threshold.
- Parameters:
+ Args:
file_list (list[str]):
List of image file paths.
threshold (float):
Threshold value for comparison.
above (bool, optional):
- If True, count images with mean > threshold; if False, mean < threshold.
- Default = True.
+ If True, count images with mean > threshold; if False,
+ mean < threshold. Default = True.
uint8 (bool, optional):
- If True, rescale image data to 0–255 range. Default = False.
+ If True, rescale image data to 0-255 range. Default = False.
band_index (int, optional):
Index of the band to read (0-based). Default = 0.
return_type (str, optional):
- - "ratio": return percentage (float, 0–100).
- - "count": return number of images (int).
+ - "ratio": return percentage (float, 0-100).
+ - "count": return number of images (int).
Default = "ratio".
Returns:
float | int:
- Percentage (0–100) or count of images satisfying the condition.
+ Percentage (0-100) or count of images satisfying the condition.
Example:
- >>> calc_batch_image_mean_threshold(["img1.tif", "img2.tif"], threshold=100, above=True)
+ >>> calc_batch_image_mean_threshold(
+ ... ["img1.tif", "img2.tif"], threshold=100, above=True
+ ... )
50.0
"""
+ import numpy as np
+ import rasterio
+
valid_means = []
for file_path in file_list:
try:
with rasterio.open(file_path) as src:
if band_index >= src.count:
- print(
- f'Warning: {file_path} does not contain band {band_index + 1}. Skipped.'
- )
+ logger.info(
+ f'Warning: {file_path} does not contain '
+ f'band {band_index + 1}. Skipped.'
+ )
continue
data = src.read(band_index + 1).astype(np.float32)
data = np.where(data == src.nodata, np.nan, data)
@@ -3618,33 +4282,36 @@ class EarthScienceToolkit(BaseToolkit):
if not np.isnan(mean_val):
valid_means.append(mean_val)
except Exception as e:
- print(f'Error processing {file_path}: {e}')
+ logger.info(f'Error processing {file_path}: {e}')
continue
if not valid_means:
return 0 if return_type == 'count' else 0.0
- valid_means = np.array(valid_means)
+ valid_means_arr = np.array(valid_means)
if above:
- count = np.sum(valid_means > threshold)
+ count = np.sum(valid_means_arr > threshold)
else:
- count = np.sum(valid_means < threshold)
+ count = np.sum(valid_means_arr < threshold)
if return_type == 'count':
return int(count)
elif return_type == 'ratio':
- return float(count / len(valid_means) * 100.0)
+ return float(count / len(valid_means_arr) * 100.0)
else:
raise ValueError("return_type must be 'ratio' or 'count'")
- def calculate_multi_band_threshold_ratio(self, image_path: str,
- band_conditions: list) ->float:
+ def calculate_multi_band_threshold_ratio(
+ self, image_path: str, band_conditions: list
+ ) -> float:
"""
Description:
- Calculate the percentage of pixels that simultaneously satisfy multiple band threshold conditions.
+ Calculate the percentage of pixels that simultaneously satisfy
+ multiple band threshold conditions.
- Parameters:
+ Args:
image_path (str):
Path to the multi-band image file.
band_conditions (list[tuple[int, float, str]]):
- A list of conditions in the form (band_index, threshold_value, compare_type):
+ A list of conditions in the form
+ (band_index, threshold_value, compare_type):
- band_index (int): Zero-based band index.
- threshold_value (float): Threshold to apply.
- compare_type (str): "above" or "below".
@@ -3660,6 +4327,9 @@ class EarthScienceToolkit(BaseToolkit):
... )
42.5
"""
+ import numpy as np
+ import rasterio
+
with rasterio.open(image_path) as src:
bands = []
for band_index, _, _ in band_conditions:
@@ -3667,8 +4337,7 @@ class EarthScienceToolkit(BaseToolkit):
band[band == src.nodata] = np.nan
bands.append(band)
combined_mask = np.ones_like(bands[0], dtype=bool)
- for band, (band_index, threshold, compare_type) in zip(bands,
- band_conditions):
+ for band, (_, threshold, compare_type) in zip(bands, band_conditions):
valid = ~np.isnan(band)
if compare_type.lower() == 'above':
mask = (band > threshold) & valid
@@ -3676,8 +4345,9 @@ class EarthScienceToolkit(BaseToolkit):
mask = (band < threshold) & valid
else:
raise ValueError(
- f"Invalid compare_type '{compare_type}', must be 'above' or 'below'"
- )
+ f"Invalid compare_type '{compare_type}', "
+ "must be 'above' or 'below'"
+ )
combined_mask &= mask
total_valid_pixels = float(np.sum(~np.isnan(bands[0])))
satisfying_pixels = float(np.sum(combined_mask))
@@ -3686,24 +4356,28 @@ class EarthScienceToolkit(BaseToolkit):
else:
return satisfying_pixels / total_valid_pixels * 100
- def count_pixels_satisfying_conditions(self, image_path: str,
- band_conditions: list) ->int:
+ def count_pixels_satisfying_conditions(
+ self, image_path: str, band_conditions: list
+ ) -> int:
"""
Description:
- Count the number of pixels that simultaneously satisfy multiple band threshold conditions.
+ Count the number of pixels that simultaneously satisfy multiple
+ band threshold conditions.
- Parameters:
+ Args:
image_path (str):
Path to the multi-band image file.
band_conditions (list[tuple[int, float, str]]):
- A list of conditions in the form (band_index, threshold_value, compare_type):
+ A list of conditions in the form
+ (band_index, threshold_value, compare_type):
- band_index (int): Zero-based band index.
- threshold_value (float): Threshold to apply.
- compare_type (str): "above" or "below".
Returns:
int:
- Number of pixels satisfying all threshold conditions (intersection).
+ Number of pixels satisfying all threshold conditions
+ (intersection).
Example:
>>> count_pixels_satisfying_conditions(
@@ -3712,6 +4386,9 @@ class EarthScienceToolkit(BaseToolkit):
... )
1250
"""
+ import numpy as np
+ import rasterio
+
with rasterio.open(image_path) as src:
bands = []
for band_index, _, _ in band_conditions:
@@ -3721,8 +4398,7 @@ class EarthScienceToolkit(BaseToolkit):
band[band == nodata] = np.nan
bands.append(band)
combined_mask = np.ones_like(bands[0], dtype=bool)
- for band, (band_index, threshold, compare_type) in zip(bands,
- band_conditions):
+ for band, (_, threshold, compare_type) in zip(bands, band_conditions):
valid = ~np.isnan(band)
if compare_type.lower() == 'above':
mask = (band > threshold) & valid
@@ -3730,19 +4406,25 @@ class EarthScienceToolkit(BaseToolkit):
mask = (band < threshold) & valid
else:
raise ValueError(
- f"Invalid compare_type '{compare_type}', must be 'above' or 'below'"
- )
+ f"Invalid compare_type '{compare_type}', "
+ "must be 'above' or 'below'"
+ )
combined_mask &= mask
return int(np.sum(combined_mask))
- def count_images_exceeding_threshold_ratio(self, image_paths: (str |
- list[str]), value_threshold: float=0.7, ratio_threshold: float=20.0,
- mode: str='above', verbose: bool=True) ->int:
+ def count_images_exceeding_threshold_ratio(
+ self,
+ image_paths: (str | list[str]),
+ value_threshold: float = 0.7,
+ ratio_threshold: float = 20.0,
+ mode: str = 'above',
+ verbose: bool = True,
+ ) -> int:
"""
- Count how many images have a percentage of pixels above or below a threshold
- that exceeds a specified ratio.
+ Count how many images have a percentage of pixels above or below a
+ threshold that exceeds a specified ratio.
- Parameters:
+ Args:
image_paths (str or list):
Path(s) to image file(s).
value_threshold (float):
@@ -3754,7 +4436,7 @@ class EarthScienceToolkit(BaseToolkit):
- 'below': pixels < value_threshold
Default is 'above'.
verbose (bool):
- If True, prints detailed ratio results per image.
+ If True, logger.infos detailed ratio results per image.
Returns:
int:
@@ -3769,6 +4451,9 @@ class EarthScienceToolkit(BaseToolkit):
... )
1
"""
+ import numpy as np
+ import rasterio
+
if isinstance(image_paths, str):
image_paths = [image_paths]
count_exceeding = 0
@@ -3794,36 +4479,45 @@ class EarthScienceToolkit(BaseToolkit):
else:
status = 'wrong'
if verbose:
- print(
- f"{path}: {ratio:.2f}% {'<' if mode == 'below' else '>'} {value_threshold} → {status} (threshold: {ratio_threshold}%)"
- )
- if verbose:
- print(
- f"""
-Total images exceeding threshold ratio: {count_exceeding} / {len(image_paths)}"""
+ op = '<' if mode == 'below' else '>'
+ logger.info(
+ f"{path}: {ratio:.2f}% {op} {value_threshold} -> "
+ f"{status} (threshold: {ratio_threshold}%)"
)
+ if verbose:
+ logger.info(
+ f"\nTotal images exceeding threshold ratio: "
+ f"{count_exceeding} / {len(image_paths)}"
+ )
return count_exceeding
- def average_ratio_exceeding_threshold(self, image_paths: (str | list[
- str]), value_threshold: float=0.7, ratio_threshold: float=20.0,
- mode: str='above', verbose: bool=True) ->float:
+ def average_ratio_exceeding_threshold(
+ self,
+ image_paths: (str | list[str]),
+ value_threshold: float = 0.7,
+ ratio_threshold: float = 20.0,
+ mode: str = 'above',
+ verbose: bool = True,
+ ) -> float:
"""
Calculate the average percentage of pixels exceeding a value threshold,
- considering only images where the ratio is greater than a specified ratio threshold.
+ considering only images where the ratio is greater than a specified
+ ratio threshold.
- Parameters:
+ Args:
image_paths (str or list):
Path(s) to image file(s).
value_threshold (float):
Pixel value threshold (e.g., NDVI > 0.7).
ratio_threshold (float):
- Minimum percentage threshold for inclusion (e.g., 20.0 means 20%).
+ Minimum percentage threshold for inclusion
+ (e.g., 20.0 means 20%).
mode (str):
- 'above': pixels > value_threshold
- 'below': pixels < value_threshold
Default is 'above'.
verbose (bool):
- If True, prints detailed ratio results per image.
+ If True, logger.infos detailed ratio results per image.
Returns:
float:
@@ -3839,6 +4533,9 @@ Total images exceeding threshold ratio: {count_exceeding} / {len(image_paths)}""
... )
18.5
"""
+ import numpy as np
+ import rasterio
+
if isinstance(image_paths, str):
image_paths = [image_paths]
ratios = []
@@ -3851,7 +4548,7 @@ Total images exceeding threshold ratio: {count_exceeding} / {len(image_paths)}""
band[band == nodata] = np.nan
except Exception as e:
if verbose:
- print(f'Error processing {path}: {e}')
+ logger.info(f'Error processing {path}: {e}')
continue
valid_mask = ~np.isnan(band)
total_pixels = np.sum(valid_mask)
@@ -3869,38 +4566,47 @@ Total images exceeding threshold ratio: {count_exceeding} / {len(image_paths)}""
else:
status = 'wrong'
if verbose:
- print(
- f"{path}: {ratio:.2f}% {'<' if mode == 'below' else '>'} {value_threshold} → {status} (threshold: {ratio_threshold}%)"
- )
+ op = '<' if mode == 'below' else '>'
+ logger.info(
+ f"{path}: {ratio:.2f}% {op} {value_threshold} -> "
+ f"{status} (threshold: {ratio_threshold}%)"
+ )
if ratios:
avg = float(np.mean(ratios))
else:
avg = 0.0
if verbose:
- print(
- f"""
-Average ratio of qualifying images: {avg:.2f}% ({len(ratios)} out of {len(image_paths)} images)"""
- )
+ logger.info(
+ f"\nAverage ratio of qualifying images: {avg:.2f}% "
+ f"({len(ratios)} out of {len(image_paths)} images)"
+ )
return avg
- def count_images_exceeding_mean_multiplier(self, image_paths: (str |
- list[str]), mean_multiplier: float=1.1, mode: str='above', verbose:
- bool=True) ->int:
+ def count_images_exceeding_mean_multiplier(
+ self,
+ image_paths: (str | list[str]),
+ mean_multiplier: float = 1.1,
+ mode: str = 'above',
+ verbose: bool = True,
+ ) -> int:
"""
Count how many images have a mean pixel value above or below
a multiple of the overall mean pixel value across all images.
- Parameters:
+ Args:
image_paths (str or list):
Path(s) to image file(s).
mean_multiplier (float):
Multiplier applied to the overall mean (e.g., 1.1 means 110%).
mode (str):
- - 'above': count images with mean > mean_multiplier × overall_mean
- - 'below': count images with mean < mean_multiplier × overall_mean
+ - 'above': count images with mean > mean_multiplier *
+ overall_mean
+ - 'below': count images with mean < mean_multiplier *
+ overall_mean
Default is 'above'.
verbose (bool):
- If True, prints detailed mean and threshold comparisons per image.
+ If True, logger.infos detailed mean and threshold comparisons
+ per image.
Returns:
int:
@@ -3914,6 +4620,9 @@ Average ratio of qualifying images: {avg:.2f}% ({len(ratios)} out of {len(image_
... )
2
"""
+ import numpy as np
+ import rasterio
+
if isinstance(image_paths, str):
image_paths = [image_paths]
image_means = []
@@ -3928,8 +4637,12 @@ Average ratio of qualifying images: {avg:.2f}% ({len(ratios)} out of {len(image_
overall_mean = np.nanmean(image_means)
threshold = mean_multiplier * overall_mean
if verbose:
- print(f'\nOverall mean across all images: {overall_mean:.4f}')
- print(f'Threshold for comparison ({mode}): {threshold:.4f}\n')
+ logger.info(
+ f'\nOverall mean across all images: {overall_mean:.4f}'
+ )
+ logger.info(
+ f'Threshold for comparison ({mode}): {threshold:.4f}\n'
+ )
count = 0
for path, img_mean in zip(image_paths, image_means):
if mode == 'below':
@@ -3944,23 +4657,30 @@ Average ratio of qualifying images: {avg:.2f}% ({len(ratios)} out of {len(image_
else:
status = 'wrong'
if verbose:
- print(
- f'{path}: mean = {img_mean:.4f} {op} {threshold:.4f} → {status}'
- )
- if verbose:
- print(
- f'\nTotal images satisfying condition: {count} / {len(image_paths)}'
+ logger.info(
+ f'{path}: mean = {img_mean:.4f} {op} '
+ f'{threshold:.4f} -> {status}'
)
+ if verbose:
+ logger.info(
+ f'\nTotal images satisfying condition: '
+ f'{count} / {len(image_paths)}'
+ )
return count
- def calculate_band_mean_by_condition(self, image_path: str,
- condition_band_index: int, condition_threshold: float,
- condition_mode: str='above', target_band_index: int=0) ->float:
+ def calculate_band_mean_by_condition(
+ self,
+ image_path: str,
+ condition_band_index: int,
+ condition_threshold: float,
+ condition_mode: str = 'above',
+ target_band_index: int = 0,
+ ) -> float:
"""
- Calculate the mean value of a target band over pixels where a condition band
- satisfies a threshold.
+ Calculate the mean value of a target band over pixels where a
+ condition band satisfies a threshold.
- Parameters:
+ Args:
image_path (str):
Path to the multi-band raster image.
condition_band_index (int):
@@ -3987,51 +4707,83 @@ Average ratio of qualifying images: {avg:.2f}% ({len(ratios)} out of {len(image_
... )
0.5471
"""
+ import numpy as np
+ import rasterio
+
with rasterio.open(image_path) as src:
- condition_band = src.read(condition_band_index + 1).astype(np.
- float32)
+ condition_band = src.read(condition_band_index + 1).astype(
+ np.float32
+ )
target_band = src.read(target_band_index + 1).astype(np.float32)
nodata = src.nodata
if nodata is not None:
condition_band[condition_band == nodata] = np.nan
target_band[target_band == nodata] = np.nan
if condition_mode == 'below':
- mask = (condition_band < condition_threshold) & ~np.isnan(
- condition_band) & ~np.isnan(target_band)
+ mask = (
+ (condition_band < condition_threshold)
+ & ~np.isnan(condition_band)
+ & ~np.isnan(target_band)
+ )
else:
- mask = (condition_band >= condition_threshold) & ~np.isnan(
- condition_band) & ~np.isnan(target_band)
+ mask = (
+ (condition_band >= condition_threshold)
+ & ~np.isnan(condition_band)
+ & ~np.isnan(target_band)
+ )
selected_values = target_band[mask]
mean_value = np.nanmean(selected_values)
return float(mean_value)
- def calc_threshold_value_mean(self, path1: (str | list[str]), path2: (
- str | list[str]), threshold: float=300.0) ->float:
+ def calc_threshold_value_mean(
+ self,
+ path1: (str | list[str]),
+ path2: (str | list[str]),
+ threshold: float = 300.0,
+ ) -> float:
"""
- Calculate the mean value of corresponding raster pixels in path2
+ Calculate the mean value of corresponding raster pixels in path2
where the raster values in path1 exceed the given threshold.
- Parameters:
- path1 (Path or List[Path]): Path(s) to the first set of raster files (e.g., LST).
- path2 (Path or List[Path]): Path(s) to the second set of raster files (e.g., TVDI).
- threshold (float): Threshold for values in path1 (e.g., LST in Kelvin).
+ Args:
+ path1 (Path or List[Path]): Path(s) to the first set of raster
+ files (e.g., LST).
+ path2 (Path or List[Path]): Path(s) to the second set of raster
+ files (e.g., TVDI).
+ threshold (float): Threshold for values in path1 (e.g., LST in
+ Kelvin).
Returns:
- float: Mean value of path2 pixels that meet the threshold condition in path1.
- Returns np.nan if no valid data is found.
- """
- files1 = [Path(path1)] if isinstance(path1, (str, Path)) else [Path
- (p) for p in path1]
- files2 = [Path(path2)] if isinstance(path2, (str, Path)) else [Path
- (p) for p in path2]
+ float: Mean value of path2 pixels that meet the threshold
+ condition in path1. Returns np.nan if no valid data is found.
+ """
+ import numpy as np
+ import rasterio
+
+ files1 = (
+ [Path(path1)]
+ if isinstance(path1, (str, Path))
+ else [Path(p) for p in path1]
+ )
+ files2 = (
+ [Path(path2)]
+ if isinstance(path2, (str, Path))
+ else [Path(p) for p in path2]
+ )
pattern = re.compile('\\d{4}_\\d{2}_\\d{2}_\\d{4}')
- dict1 = {pattern.search(f.name).group(): f for f in files1 if
- pattern.search(f.name)}
- dict2 = {pattern.search(f.name).group(): f for f in files2 if
- pattern.search(f.name)}
+ dict1 = {}
+ for f in files1:
+ match = pattern.search(f.name)
+ if match:
+ dict1[match.group()] = f
+ dict2 = {}
+ for f in files2:
+ match = pattern.search(f.name)
+ if match:
+ dict2[match.group()] = f
matched_keys = set(dict1.keys()) & set(dict2.keys())
if not matched_keys:
- print('No matched file pairs found.')
+ logger.info('No matched file pairs found.')
return np.nan
all_vals = []
for key in sorted(matched_keys):
@@ -4040,30 +4792,40 @@ Average ratio of qualifying images: {avg:.2f}% ({len(ratios)} out of {len(image_
with rasterio.open(file1) as ds1, rasterio.open(file2) as ds2:
data1 = ds1.read(1).astype(np.float32)
data2 = ds2.read(1).astype(np.float32)
- mask = (data1 > threshold) & (data1 > 0) & (data2 >= 0) & (
- data2 <= 1)
+ mask = (
+ (data1 > threshold)
+ & (data1 > 0)
+ & (data2 >= 0)
+ & (data2 <= 1)
+ )
if np.any(mask):
all_vals.extend(data2[mask].flatten())
if not all_vals:
- print('No valid values found for path1 > threshold.')
+ logger.info('No valid values found for path1 > threshold.')
return np.nan
return float(np.mean(all_vals))
- def calculate_tif_average(self, file_list: list[str], output_path: str,
- uint8: bool=False) ->str:
+ def calculate_tif_average(
+ self, file_list: list[str], output_path: str, uint8: bool = False
+ ) -> str:
"""
- Calculate average of multiple tif files and save result to same directory.
+ Calculate average of multiple tif files and save result to same
+ directory.
- Parameters:
+ Args:
file_list (list[str]): List of tif file paths.
- output_path (str): relative path for the output raster file, e.g. "benchmark/data/question17/avg_result.tif"
+ output_path (str): relative path for the output raster file, e.g.
+ "benchmark/data/question17/avg_result.tif"
uint8 (bool): Convert to uint8 format, default False.
Returns:
output_path (str): Full path of output file.
"""
- output_path = TEMP_DIR / output_path
- os.makedirs(output_path.parent, exist_ok=True)
+ import numpy as np
+ from osgeo import gdal
+
+ output_path_full = TEMP_DIR / output_path
+ os.makedirs(output_path_full.parent, exist_ok=True)
ds = gdal.Open(file_list[0])
bands = ds.RasterCount
rows = ds.RasterYSize
@@ -4073,8 +4835,10 @@ Average ratio of qualifying images: {avg:.2f}% ({len(ratios)} out of {len(image_
if bands == 1:
first_img = ds.GetRasterBand(1).ReadAsArray()
else:
- first_img = np.stack([ds.GetRasterBand(i + 1).ReadAsArray() for
- i in range(bands)], axis=0)
+ first_img = np.stack(
+ [ds.GetRasterBand(i + 1).ReadAsArray() for i in range(bands)],
+ axis=0,
+ )
first_img = np.transpose(first_img, (1, 2, 0))
ds = None
sum_img = np.zeros_like(first_img, dtype=np.float64)
@@ -4085,8 +4849,13 @@ Average ratio of qualifying images: {avg:.2f}% ({len(ratios)} out of {len(image_
if bands == 1:
img = ds.GetRasterBand(1).ReadAsArray()
else:
- img = np.stack([ds.GetRasterBand(i + 1).ReadAsArray() for i in
- range(bands)], axis=0)
+ img = np.stack(
+ [
+ ds.GetRasterBand(i + 1).ReadAsArray()
+ for i in range(bands)
+ ],
+ axis=0,
+ )
img = np.transpose(img, (1, 2, 0))
ds = None
sum_img = sum_img + img
@@ -4102,41 +4871,56 @@ Average ratio of qualifying images: {avg:.2f}% ({len(ratios)} out of {len(image_
band_data = avg_img[:, :, band]
min_val = np.min(band_data)
max_val = np.max(band_data)
- band_data = (band_data - min_val) / (max_val - min_val
- ) * 255
+ band_data = (
+ (band_data - min_val) / (max_val - min_val) * 255
+ )
avg_img[:, :, band] = band_data.astype(np.uint8)
driver = gdal.GetDriverByName('GTiff')
data_type = gdal.GDT_Byte if uint8 else gdal.GDT_Float32
if len(avg_img.shape) == 2:
- out_ds = driver.Create(output_path, cols, rows, 1, data_type)
+ out_ds = driver.Create(
+ str(output_path_full), cols, rows, 1, data_type
+ )
out_ds.SetGeoTransform(geotransform)
out_ds.SetProjection(projection)
out_ds.GetRasterBand(1).WriteArray(avg_img)
else:
- out_ds = driver.Create(output_path, cols, rows, bands, data_type)
+ out_ds = driver.Create(
+ str(output_path_full), cols, rows, bands, data_type
+ )
out_ds.SetGeoTransform(geotransform)
out_ds.SetProjection(projection)
for i in range(bands):
out_ds.GetRasterBand(i + 1).WriteArray(avg_img[:, :, i])
out_ds = None
- return f'Result save at {output_path}'
+ return f'Result save at {output_path_full}'
- def calculate_tif_difference(self, image_a_path: str, image_b_path: str,
- output_path: str, uint8: bool=False) ->str:
+ def calculate_tif_difference(
+ self,
+ image_a_path: str,
+ image_b_path: str,
+ output_path: str,
+ uint8: bool = False,
+ ) -> str:
"""
- Calculate difference between two tif files (image_b - image_a) and save result.
+ Calculate difference between two tif files (image_b - image_a) and
+ save result.
- Parameters:
+ Args:
image_a_path (str): Path to first image (will be subtracted from).
image_b_path (str): Path to second image (will subtract from).
- output_path (str): relative path for the output raster file, e.g. "question17/difference_result.tif"
+ output_path (str): relative path for the output raster file, e.g.
+ "question17/difference_result.tif"
uint8 (bool): Convert to uint8 format, default False.
Returns:
output_path (str): Full path of output file.
"""
- output_path = TEMP_DIR / output_path
- os.makedirs(output_path.parent, exist_ok=True)
+ import numpy as np
+ from osgeo import gdal
+
+ output_path_full = TEMP_DIR / output_path
+ os.makedirs(output_path_full.parent, exist_ok=True)
ds_a = gdal.Open(image_a_path)
if ds_a is None:
raise RuntimeError(f'Failed to open {image_a_path}')
@@ -4148,8 +4932,13 @@ Average ratio of qualifying images: {avg:.2f}% ({len(ratios)} out of {len(image_
if bands_a == 1:
img_a = ds_a.GetRasterBand(1).ReadAsArray()
else:
- img_a = np.stack([ds_a.GetRasterBand(i + 1).ReadAsArray() for i in
- range(bands_a)], axis=0)
+ img_a = np.stack(
+ [
+ ds_a.GetRasterBand(i + 1).ReadAsArray()
+ for i in range(bands_a)
+ ],
+ axis=0,
+ )
img_a = np.transpose(img_a, (1, 2, 0))
ds_a = None
ds_b = gdal.Open(image_b_path)
@@ -4161,14 +4950,21 @@ Average ratio of qualifying images: {avg:.2f}% ({len(ratios)} out of {len(image_
if bands_b == 1:
img_b = ds_b.GetRasterBand(1).ReadAsArray()
else:
- img_b = np.stack([ds_b.GetRasterBand(i + 1).ReadAsArray() for i in
- range(bands_b)], axis=0)
+ img_b = np.stack(
+ [
+ ds_b.GetRasterBand(i + 1).ReadAsArray()
+ for i in range(bands_b)
+ ],
+ axis=0,
+ )
img_b = np.transpose(img_b, (1, 2, 0))
ds_b = None
if rows_a != rows_b or cols_a != cols_b or bands_a != bands_b:
raise ValueError(
- f'Images must have same dimensions. Image A: {rows_a}x{cols_a}x{bands_a}, Image B: {rows_b}x{cols_b}x{bands_b}'
- )
+ f'Images must have same dimensions. '
+ f'Image A: {rows_a}x{cols_a}x{bands_a}, '
+ f'Image B: {rows_b}x{cols_b}x{bands_b}'
+ )
diff_img = img_b.astype(np.float64) - img_a.astype(np.float64)
if uint8:
if len(diff_img.shape) == 2:
@@ -4185,80 +4981,107 @@ Average ratio of qualifying images: {avg:.2f}% ({len(ratios)} out of {len(image_
min_val = np.min(band_data)
max_val = np.max(band_data)
if max_val > min_val:
- band_data = (band_data - min_val) / (max_val - min_val
- ) * 255
+ band_data = (
+ (band_data - min_val) / (max_val - min_val) * 255
+ )
diff_img[:, :, band] = band_data.astype(np.uint8)
else:
diff_img[:, :, band] = 0
driver = gdal.GetDriverByName('GTiff')
data_type = gdal.GDT_Byte if uint8 else gdal.GDT_Float32
if len(diff_img.shape) == 2:
- out_ds = driver.Create(output_path, cols_a, rows_a, 1, data_type)
+ out_ds = driver.Create(
+ str(output_path_full), cols_a, rows_a, 1, data_type
+ )
out_ds.SetGeoTransform(geotransform)
out_ds.SetProjection(projection)
out_ds.GetRasterBand(1).WriteArray(diff_img)
else:
- out_ds = driver.Create(output_path, cols_a, rows_a, bands_a,
- data_type)
+ out_ds = driver.Create(
+ str(output_path_full), cols_a, rows_a, bands_a, data_type
+ )
out_ds.SetGeoTransform(geotransform)
out_ds.SetProjection(projection)
for i in range(bands_a):
out_ds.GetRasterBand(i + 1).WriteArray(diff_img[:, :, i])
out_ds = None
- return f'Result save at {TEMP_DIR / output_path}'
+ return f'Result save at {output_path_full}'
- def subtract(self, img1_path: str, img2_path: str, output_path: str) ->str:
+ def subtract(
+ self, img1_path: str, img2_path: str, output_path: str
+ ) -> str:
"""
Subtract two images and save result.
-
- Parameters:
+
+ Args:
img1_path (str): Path to first image.
img2_path (str): Path to second image.
- output_path (str): relative path for the output raster file, e.g. "question17/difference_result.tif"
-
+ output_path (str): relative path for the output raster file, e.g.
+ "question17/difference_result.tif"
+
Returns:
str: Path to output file.
"""
+ import numpy as np
+ import rasterio
+
img1 = self.read_image(img1_path)
img2 = self.read_image(img2_path)
result = img1.astype(np.float32) - img2.astype(np.float32)
- output_path = TEMP_DIR / output_path
- os.makedirs(output_path.parent, exist_ok=True)
+ output_path_full = TEMP_DIR / output_path
+ os.makedirs(output_path_full.parent, exist_ok=True)
with rasterio.open(img1_path) as src:
profile = src.profile
profile.update(dtype=rasterio.float32, compress='lzw')
- with rasterio.open(output_path, 'w', **profile) as dst:
+ with rasterio.open(output_path_full, 'w', **profile) as dst:
dst.write(result, 1)
- return f'Result save at {TEMP_DIR / output_path}'
+ return f'Result save at {output_path_full}'
def calculate_area(self, input_image_path, gsd):
"""
Description:
- This function calculates the area of non-zero pixels in the input image and returns the result.
-
- Parameters:
- input_image_path (str): Path to the input image file (TIFF, PNG, JPG, etc.).
- gsd (float): Ground sample distance in meters per pixel, if None, the function will return the number of non-zero pixels.
+ This function calculates the area of non-zero pixels in the input
+ image and returns the result.
+
+ Args:
+ input_image_path (str): Path to the input image file (TIFF, PNG,
+ JPG, etc.).
+ gsd (float): Ground sample distance in meters per pixel, if None,
+ the function will return the number of non-zero pixels.
Returns:
area (int): The area of non-zero pixels in the input image.
"""
+ import numpy as np
+
image = self.read_image(input_image_path)
if gsd is None:
return float(np.sum(image != 0))
else:
return float(np.sum(image != 0) * gsd * gsd)
- def grayscale_to_colormap(self, image_path: str, save_name: str,
- cmap_name: str='viridis', preserve_geo: bool=False):
+ def grayscale_to_colormap(
+ self,
+ image_path: str,
+ save_name: str,
+ cmap_name: str = 'viridis',
+ preserve_geo: bool = False,
+ ):
"""
Apply a colormap to a grayscale image and save as a color image.
-
- Parameters:
+
+ Args:
image_path (str): Path to input grayscale image (e.g. .tif).
- save_name (str): Filename for save color image (.png, .jpg, or .tif).
- cmap_name (str): Name of a matplotlib colormap, e.g. 'viridis', 'RdBu', etc.
+ save_name (str): Filename for save color image (.png, .jpg, or
+ .tif).
+ cmap_name (str): Name of a matplotlib colormap, e.g. 'viridis',
+ 'RdBu', etc.
preserve_geo (bool): If True, preserves georeferencing.
"""
+ import cv2
+ import matplotlib.cm as cm
+ import numpy as np
+ from osgeo import gdal
+
ds = gdal.Open(image_path)
if ds is None:
raise RuntimeError(f'Failed to open image: {image_path}')
@@ -4271,12 +5094,17 @@ Average ratio of qualifying images: {avg:.2f}% ({len(ratios)} out of {len(image_
save_path = TEMP_DIR / save_name
if preserve_geo:
driver = gdal.GetDriverByName('GTiff')
- out_ds = driver.Create(os.path.splitext(save_path)[0] + '.tif',
- xsize=color_img_uint8.shape[1], ysize=color_img_uint8.shape
- [0], bands=3, eType=gdal.GDT_Byte)
+ out_ds = driver.Create(
+ str(save_path.with_suffix('.tif')),
+ xsize=color_img_uint8.shape[1],
+ ysize=color_img_uint8.shape[0],
+ bands=3,
+ eType=gdal.GDT_Byte,
+ )
for i in range(3):
- out_ds.GetRasterBand(i + 1).WriteArray(color_img_uint8[:, :, i]
- )
+ out_ds.GetRasterBand(i + 1).WriteArray(
+ color_img_uint8[:, :, i]
+ )
gt = ds.GetGeoTransform()
prj = ds.GetProjection()
if gt:
@@ -4287,33 +5115,38 @@ Average ratio of qualifying images: {avg:.2f}% ({len(ratios)} out of {len(image_
out_ds = None
else:
bgr_img = cv2.cvtColor(color_img_uint8, cv2.COLOR_RGB2BGR)
- cv2.imwrite(save_path, bgr_img)
+ cv2.imwrite(str(save_path), bgr_img)
return f'Result save at {save_path}'
def get_filelist(self, dir_path: str):
"""
Returns a list of files in the specified directory.
- Parameters:
+ Args:
dir_path (str): Path to the directory.
Returns:
list: List of file names in the directory.
"""
- return sorted([_ for _ in os.listdir(dir_path) if not _.startswith(
- '.')])
+ return sorted(
+ [_ for _ in os.listdir(dir_path) if not _.startswith('.')]
+ )
def radiometric_correction_sr(self, input_band_path, output_path):
"""
Apply Landsat 8 surface reflectance (SR_B*) radiometric correction.
- Parameters:
+ Args:
input_band_path (str): Path to the input reflectance band file.
- output_path (str): relative path for the output raster file, e.g. "question17/radiometric_correction_2022-01-16.tif"
+ output_path (str): relative path for the output raster file, e.g.
+ "question17/radiometric_correction_2022-01-16.tif"
Returns:
str: Path to the saved corrected reflectance file.
"""
+ import numpy as np
+ import rasterio
+
with rasterio.open(input_band_path) as band_src:
band_array = band_src.read(1)
band_profile = band_src.profile
@@ -4322,23 +5155,30 @@ Average ratio of qualifying images: {avg:.2f}% ({len(ratios)} out of {len(image_
corrected_profile = band_profile.copy()
corrected_profile.update(dtype=rasterio.float32, nodata=np.nan)
os.makedirs((TEMP_DIR / output_path).parent, exist_ok=True)
- with rasterio.open(TEMP_DIR / output_path, 'w', **corrected_profile
- ) as dst:
+ with rasterio.open(
+ TEMP_DIR / output_path, 'w', **corrected_profile
+ ) as dst:
dst.write(corrected_band.astype(rasterio.float32), 1)
return f'Result saved at {TEMP_DIR / output_path}'
def apply_cloud_mask(self, sr_band_path, qa_pixel_path, output_path):
"""
- Apply cloud/shadow mask to a single Landsat 8 surface reflectance band using QA_PIXEL band.
+ Apply cloud/shadow mask to a single Landsat 8 surface reflectance band
+ using QA_PIXEL band.
- Parameters:
- sr_band_path (str): Path to surface reflectance band (e.g., SR_B3 or SR_B5).
+ Args:
+ sr_band_path (str): Path to surface reflectance band (e.g., SR_B3
+ or SR_B5).
qa_pixel_path (str): Path to QA_PIXEL band.
- output_path (str): relative path for the output raster file, e.g. "question17/cloud_mask_2022-01-16.tif"
+ output_path (str): relative path for the output raster file, e.g.
+ "question17/cloud_mask_2022-01-16.tif"
Returns:
str: Path to the saved masked raster file.
"""
+ import numpy as np
+ import rasterio
+
cloud_mask_bits = 1 + 2 + 4 + 8 + 16
os.makedirs((TEMP_DIR / output_path).parent, exist_ok=True)
with rasterio.open(sr_band_path) as band_src:
@@ -4350,12 +5190,16 @@ Average ratio of qualifying images: {avg:.2f}% ({len(ratios)} out of {len(image_
band[~mask] = np.nan
output_profile = profile.copy()
output_profile.update(dtype=rasterio.float32, nodata=np.nan)
- with rasterio.open(TEMP_DIR / output_path, 'w', **output_profile
- ) as dst:
+ with rasterio.open(
+ TEMP_DIR / output_path, 'w', **output_profile
+ ) as dst:
dst.write(band.astype(rasterio.float32), 1)
return f'Result saved at {TEMP_DIR / output_path}'
- def read_image(self, file_path: str) ->np.ndarray:
+ def read_image(self, file_path: str) -> Any:
+ import numpy as np
+ from osgeo import gdal
+
ds = gdal.Open(file_path)
if ds is None:
raise RuntimeError(f'Failed to open {file_path}')
@@ -4363,13 +5207,18 @@ Average ratio of qualifying images: {avg:.2f}% ({len(ratios)} out of {len(image_
if bands == 1:
img = ds.GetRasterBand(1).ReadAsArray()
else:
- img = np.stack([ds.GetRasterBand(i + 1).ReadAsArray() for i in
- range(bands)], axis=0)
+ img = np.stack(
+ [ds.GetRasterBand(i + 1).ReadAsArray() for i in range(bands)],
+ axis=0,
+ )
img = np.transpose(img, (1, 2, 0))
ds = None
return img
- def read_image_uint8(self, file_path: str) ->np.ndarray:
+ def read_image_uint8(self, file_path: str) -> Any:
+ import numpy as np
+ from osgeo import gdal
+
ds = gdal.Open(file_path)
if ds is None:
raise RuntimeError(f'Failed to open {file_path}')
@@ -4377,8 +5226,10 @@ Average ratio of qualifying images: {avg:.2f}% ({len(ratios)} out of {len(image_
if bands == 1:
img = ds.GetRasterBand(1).ReadAsArray()
else:
- img = np.stack([ds.GetRasterBand(i + 1).ReadAsArray() for i in
- range(bands)], axis=0)
+ img = np.stack(
+ [ds.GetRasterBand(i + 1).ReadAsArray() for i in range(bands)],
+ axis=0,
+ )
img = np.transpose(img, (1, 2, 0))
ds = None
img = img.astype(np.float32)
@@ -4390,7 +5241,9 @@ Average ratio of qualifying images: {avg:.2f}% ({len(ratios)} out of {len(image_
img = np.zeros_like(img)
return img.astype(np.uint8)
- def get_geotransform(self, file_path) ->tuple:
+ def get_geotransform(self, file_path) -> tuple:
+ from osgeo import gdal
+
ds = gdal.Open(file_path)
if ds is None:
raise RuntimeError(f'Failed to open {file_path}')
@@ -4402,7 +5255,7 @@ Average ratio of qualifying images: {avg:.2f}% ({len(ratios)} out of {len(image_
else:
return geo, proj
- def get_tools(self) ->List[FunctionTool]:
+ def get_tools(self) -> List[FunctionTool]:
"""Returns a list of FunctionTool objects representing the
functions in the toolkit.
@@ -4410,99 +5263,103 @@ Average ratio of qualifying images: {avg:.2f}% ({len(ratios)} out of {len(image_
List[FunctionTool]: A list of FunctionTool objects
representing the functions in the toolkit.
"""
- return [FunctionTool(self.calculate_batch_ndvi),
- FunctionTool(self.calculate_batch_ndwi),
+ return [
+ FunctionTool(self.calculate_batch_ndvi),
+ FunctionTool(self.calculate_batch_ndwi),
FunctionTool(self.calculate_batch_ndbi),
- FunctionTool(self.calculate_batch_evi),
- FunctionTool(self.calculate_batch_nbr),
+ FunctionTool(self.calculate_batch_evi),
+ FunctionTool(self.calculate_batch_nbr),
FunctionTool(self.calculate_batch_fvc),
- FunctionTool(self.calculate_batch_wri),
- FunctionTool(self.calculate_batch_ndti),
+ FunctionTool(self.calculate_batch_wri),
+ FunctionTool(self.calculate_batch_ndti),
FunctionTool(self.calculate_batch_frp),
- FunctionTool(self.calculate_batch_ndsi),
- FunctionTool(self.calc_extreme_snow_loss_percentage_from_binary_map),
- FunctionTool(self.compute_tvdi),
+ FunctionTool(self.calculate_batch_ndsi),
+ FunctionTool(
+ self.calc_extreme_snow_loss_percentage_from_binary_map
+ ),
+ FunctionTool(self.compute_tvdi),
FunctionTool(self.band_ratio),
- FunctionTool(self.lst_single_channel),
- FunctionTool(self.lst_multi_channel),
+ FunctionTool(self.lst_single_channel),
+ FunctionTool(self.lst_multi_channel),
FunctionTool(self.split_window),
FunctionTool(self.temperature_emissivity_separation),
- FunctionTool(self.modis_day_night_lst),
- FunctionTool(self.ttm_lst),
+ FunctionTool(self.modis_day_night_lst),
+ FunctionTool(self.ttm_lst),
FunctionTool(self.calculate_mean_lst_by_ndvi),
- FunctionTool(self.calculate_max_lst_by_ndvi),
- FunctionTool(self.calculate_ATI),
- FunctionTool(self.dual_polarization_differential),
- FunctionTool(self.dual_frequency_diff),
+ FunctionTool(self.calculate_max_lst_by_ndvi),
+ FunctionTool(self.calculate_ATI),
+ FunctionTool(self.dual_polarization_differential),
+ FunctionTool(self.dual_frequency_diff),
FunctionTool(self.multi_freq_bt),
- FunctionTool(self.chang_single_param_inversion),
- FunctionTool(self.nasa_team_sea_ice_concentration),
- FunctionTool(self.dual_polarization_ratio),
- FunctionTool(self.calculate_water_turbidity_ntu),
- FunctionTool(self.coefficient_of_variation),
+ FunctionTool(self.chang_single_param_inversion),
+ FunctionTool(self.nasa_team_sea_ice_concentration),
+ FunctionTool(self.dual_polarization_ratio),
+ FunctionTool(self.calculate_water_turbidity_ntu),
+ FunctionTool(self.coefficient_of_variation),
FunctionTool(self.skewness),
- FunctionTool(self.kurtosis),
- FunctionTool(self.calc_batch_image_mean),
+ FunctionTool(self.kurtosis),
+ FunctionTool(self.calc_batch_image_mean),
FunctionTool(self.calc_batch_image_std),
- FunctionTool(self.calc_batch_image_median),
- FunctionTool(self.calc_batch_image_min),
+ FunctionTool(self.calc_batch_image_median),
+ FunctionTool(self.calc_batch_image_min),
FunctionTool(self.calc_batch_image_max),
- FunctionTool(self.calc_batch_image_skewness),
- FunctionTool(self.calc_batch_image_kurtosis),
- FunctionTool(self.calc_batch_image_sum),
- FunctionTool(self.calc_batch_image_hotspot_percentage),
- FunctionTool(self.calc_batch_image_hotspot_tif),
+ FunctionTool(self.calc_batch_image_skewness),
+ FunctionTool(self.calc_batch_image_kurtosis),
+ FunctionTool(self.calc_batch_image_sum),
+ FunctionTool(self.calc_batch_image_hotspot_percentage),
+ FunctionTool(self.calc_batch_image_hotspot_tif),
FunctionTool(self.difference),
FunctionTool(self.division),
- FunctionTool(self.percentage_change),
+ FunctionTool(self.percentage_change),
FunctionTool(self.kelvin_to_celsius),
- FunctionTool(self.celsius_to_kelvin),
- FunctionTool(self.max_value_and_index),
+ FunctionTool(self.celsius_to_kelvin),
+ FunctionTool(self.max_value_and_index),
FunctionTool(self.min_value_and_index),
- FunctionTool(self.multiply),
+ FunctionTool(self.multiply),
FunctionTool(self.ceil_number),
- FunctionTool(self.get_list_object_via_indexes),
- FunctionTool(self.mean),
+ FunctionTool(self.get_list_object_via_indexes),
+ FunctionTool(self.mean),
FunctionTool(self.calculate_threshold_ratio),
- FunctionTool(self.calc_batch_fire_pixels),
- FunctionTool(self.create_fire_increase_map),
- FunctionTool(self.identify_fire_prone_areas),
- FunctionTool(self.get_percentile_value_from_image),
- FunctionTool(self.image_division_mean),
- FunctionTool(self.calculate_intersection_percentage),
- FunctionTool(self.calc_batch_image_mean_mean),
- FunctionTool(self.calc_batch_image_mean_max),
- FunctionTool(self.calc_batch_image_mean_max_min),
- FunctionTool(self.calc_batch_image_mean_threshold),
+ FunctionTool(self.calc_batch_fire_pixels),
+ FunctionTool(self.create_fire_increase_map),
+ FunctionTool(self.identify_fire_prone_areas),
+ FunctionTool(self.get_percentile_value_from_image),
+ FunctionTool(self.image_division_mean),
+ FunctionTool(self.calculate_intersection_percentage),
+ FunctionTool(self.calc_batch_image_mean_mean),
+ FunctionTool(self.calc_batch_image_mean_max),
+ FunctionTool(self.calc_batch_image_mean_max_min),
+ FunctionTool(self.calc_batch_image_mean_threshold),
FunctionTool(self.calculate_multi_band_threshold_ratio),
- FunctionTool(self.count_pixels_satisfying_conditions),
- FunctionTool(self.count_images_exceeding_threshold_ratio),
- FunctionTool(self.average_ratio_exceeding_threshold),
- FunctionTool(self.count_images_exceeding_mean_multiplier),
- FunctionTool(self.calculate_band_mean_by_condition),
- FunctionTool(self.calc_threshold_value_mean),
- FunctionTool(self.calculate_tif_average),
- FunctionTool(self.calculate_tif_difference),
+ FunctionTool(self.count_pixels_satisfying_conditions),
+ FunctionTool(self.count_images_exceeding_threshold_ratio),
+ FunctionTool(self.average_ratio_exceeding_threshold),
+ FunctionTool(self.count_images_exceeding_mean_multiplier),
+ FunctionTool(self.calculate_band_mean_by_condition),
+ FunctionTool(self.calc_threshold_value_mean),
+ FunctionTool(self.calculate_tif_average),
+ FunctionTool(self.calculate_tif_difference),
FunctionTool(self.subtract),
- FunctionTool(self.calculate_area),
- FunctionTool(self.grayscale_to_colormap),
+ FunctionTool(self.calculate_area),
+ FunctionTool(self.grayscale_to_colormap),
FunctionTool(self.get_filelist),
- FunctionTool(self.radiometric_correction_sr),
- FunctionTool(self.apply_cloud_mask),
+ FunctionTool(self.radiometric_correction_sr),
+ FunctionTool(self.apply_cloud_mask),
FunctionTool(self.compute_linear_trend),
- FunctionTool(self.mann_kendall_test),
- FunctionTool(self.sens_slope),
- FunctionTool(self.stl_decompose),
- FunctionTool(self.detect_change_points),
- FunctionTool(self.autocorrelation_function),
- FunctionTool(self.detect_seasonality_acf),
+ FunctionTool(self.mann_kendall_test),
+ FunctionTool(self.sens_slope),
+ FunctionTool(self.stl_decompose),
+ FunctionTool(self.detect_change_points),
+ FunctionTool(self.autocorrelation_function),
+ FunctionTool(self.detect_seasonality_acf),
FunctionTool(self.getis_ord_gi_star),
- FunctionTool(self.analyze_hotspot_direction),
- FunctionTool(self.count_spikes_from_values),
- FunctionTool(self.threshold_segmentation),
+ FunctionTool(self.analyze_hotspot_direction),
+ FunctionTool(self.count_spikes_from_values),
+ FunctionTool(self.threshold_segmentation),
FunctionTool(self.bbox_expansion),
- FunctionTool(self.count_above_threshold),
- FunctionTool(self.count_skeleton_contours),
+ FunctionTool(self.count_above_threshold),
+ FunctionTool(self.count_skeleton_contours),
FunctionTool(self.bboxes2centroids),
- FunctionTool(self.centroid_distance_extremes),
- FunctionTool(self.calculate_bbox_area)]
\ No newline at end of file
+ FunctionTool(self.centroid_distance_extremes),
+ FunctionTool(self.calculate_bbox_area),
+ ]
diff --git a/pyproject.toml b/pyproject.toml
index 3349ba930..0b578a992 100644
--- a/pyproject.toml
+++ b/pyproject.toml
@@ -440,6 +440,26 @@ all = [
"google-cloud-aiplatform>=1.111.0",
"httplib2>=0.31.0",
"duckdb>=1.4.3",
+ "opencv-python>=4.11.0.86",
+ "rasterio>=1.4.4",
+ "ruptures>=1.1.10",
+ "scikit-image>=0.25.2",
+ "scipy>=1.15.3",
+ "statsmodels>=0.14.6",
+]
+earth-science = [
+ "numpy>=1.2,<=2.2",
+ "pandas>=2",
+ "matplotlib>=3.10.7",
+ "opencv-python>=4.11.0.86",
+ "rasterio>=1.4.4",
+ "ruptures>=1.1.10",
+ "scikit-image>=0.25.2",
+ "scipy>=1.15.3",
+ "statsmodels>=0.14.6",
+ # Note: GDAL/osgeo requires system-level installation
+ # Install via: brew install gdal (macOS) or apt-get install gdal-bin libgdal-dev (Linux)
+ # Then: pip install gdal==$(gdal-config --version)
]
[project.urls]
@@ -655,6 +675,15 @@ module = [
"outlines.*",
"torch.*",
"cv2",
+ "matplotlib.*",
+ "rasterio",
+ "rasterio.*",
+ "ruptures",
+ "osgeo",
+ "osgeo.*",
+ "scipy.*",
+ "skimage.*",
+ "statsmodels.*",
"rlcard.*",
"pytesseract",
"psycopg.*",
@@ -679,4 +708,4 @@ skip = '.git*,*.pdf,*.svg,*.lock,*.css,examples/toolkits/semantic_scholar_toolki
check-hidden = true
# Ignore long lines as usually some kind of base64 encodings e.g. in ipynb
ignore-regex = '^\s*"image/\S+": ".*|^.{300,}|\b(NotIn|Unsupport)\b'
-ignore-words-list = 'ans,datas,rouge,doubleClick,OCE,ACI,aci,Pinter,SoM,checkin,'
+ignore-words-list = 'ans,datas,rouge,doubleClick,OCE,ACI,aci,Pinter,SoM,checkin,ND,'
diff --git a/uv.lock b/uv.lock
index 9cf255812..43fb52a85 100644
--- a/uv.lock
+++ b/uv.lock
@@ -7,11 +7,17 @@ resolution-markers = [
"python_full_version == '3.13.*' and sys_platform == 'win32'",
"python_full_version == '3.13.*' and sys_platform != 'win32'",
"python_full_version == '3.12.*' and sys_platform == 'win32'",
- "python_full_version == '3.12.*' and sys_platform != 'win32'",
+ "python_full_version == '3.12.*' and sys_platform == 'darwin'",
+ "python_full_version == '3.12.*' and platform_machine == 'aarch64' and sys_platform == 'linux'",
+ "(python_full_version == '3.12.*' and platform_machine != 'aarch64' and sys_platform == 'linux') or (python_full_version == '3.12.*' and sys_platform != 'darwin' and sys_platform != 'linux' and sys_platform != 'win32')",
"python_full_version == '3.11.*' and sys_platform == 'win32'",
- "python_full_version == '3.11.*' and sys_platform != 'win32'",
+ "python_full_version == '3.11.*' and sys_platform == 'darwin'",
+ "python_full_version == '3.11.*' and platform_machine == 'aarch64' and sys_platform == 'linux'",
+ "(python_full_version == '3.11.*' and platform_machine != 'aarch64' and sys_platform == 'linux') or (python_full_version == '3.11.*' and sys_platform != 'darwin' and sys_platform != 'linux' and sys_platform != 'win32')",
"python_full_version < '3.11' and sys_platform == 'win32'",
- "python_full_version < '3.11' and sys_platform != 'win32'",
+ "python_full_version < '3.11' and sys_platform == 'darwin'",
+ "python_full_version < '3.11' and platform_machine == 'aarch64' and sys_platform == 'linux'",
+ "(python_full_version < '3.11' and platform_machine != 'aarch64' and sys_platform == 'linux') or (python_full_version < '3.11' and sys_platform != 'darwin' and sys_platform != 'linux' and sys_platform != 'win32')",
]
[[package]]
@@ -42,6 +48,15 @@ wheels = [
{ url = "https://files.pythonhosted.org/packages/c4/9a/a86493374cc1a4c0f1e55db9a2962dfb8ee6f1f149cf4f6d84d60cabd30d/aci_sdk-1.0.0b4-py3-none-any.whl", hash = "sha256:7b644bdb91558ada198ec38f5835a9f6dd9a6e2db4b9d7cb0a25c51c4ec9deab", size = 32526, upload-time = "2025-08-20T16:45:50.195Z" },
]
+[[package]]
+name = "affine"
+version = "2.4.0"
+source = { registry = "https://pypi.org/simple" }
+sdist = { url = "https://files.pythonhosted.org/packages/69/98/d2f0bb06385069e799fc7d2870d9e078cfa0fa396dc8a2b81227d0da08b9/affine-2.4.0.tar.gz", hash = "sha256:a24d818d6a836c131976d22f8c27b8d3ca32d0af64c1d8d29deb7bafa4da1eea", size = 17132, upload-time = "2023-01-19T23:44:30.696Z" }
+wheels = [
+ { url = "https://files.pythonhosted.org/packages/0b/f7/85273299ab57117850cc0a936c64151171fac4da49bc6fba0dad984a7c5f/affine-2.4.0-py3-none-any.whl", hash = "sha256:8a3df80e2b2378aef598a83c1392efd47967afec4242021a0b06b4c7cbc61a92", size = 15662, upload-time = "2023-01-19T23:44:28.833Z" },
+]
+
[[package]]
name = "agentops"
version = "0.3.26"
@@ -846,7 +861,7 @@ name = "build"
version = "1.3.0"
source = { registry = "https://pypi.org/simple" }
dependencies = [
- { name = "colorama", marker = "os_name == 'nt'" },
+ { name = "colorama", marker = "(python_full_version >= '3.13' and os_name == 'nt' and sys_platform == 'darwin') or (python_full_version >= '3.13' and os_name == 'nt' and sys_platform == 'linux') or (os_name == 'nt' and platform_machine != 'aarch64' and sys_platform == 'linux') or (os_name == 'nt' and sys_platform != 'darwin' and sys_platform != 'linux')" },
{ name = "importlib-metadata", marker = "python_full_version < '3.10.2'" },
{ name = "packaging" },
{ name = "pyproject-hooks" },
@@ -959,6 +974,8 @@ all = [
{ name = "numpy", version = "2.2.0", source = { registry = "https://pypi.org/simple" }, marker = "python_full_version >= '3.13'" },
{ name = "onnxruntime" },
{ name = "openapi-spec-validator" },
+ { name = "opencv-python", version = "4.11.0.86", source = { registry = "https://pypi.org/simple" }, marker = "python_full_version < '3.13'" },
+ { name = "opencv-python", version = "4.12.0.88", source = { registry = "https://pypi.org/simple" }, marker = "python_full_version >= '3.13'" },
{ name = "openpyxl" },
{ name = "pandas" },
{ name = "pgvector" },
@@ -985,6 +1002,7 @@ all = [
{ name = "pytidb" },
{ name = "qdrant-client" },
{ name = "rank-bm25" },
+ { name = "rasterio" },
{ name = "redis" },
{ name = "reka-api" },
{ name = "reportlab" },
@@ -992,13 +1010,18 @@ all = [
{ name = "resend" },
{ name = "rlcard" },
{ name = "rouge" },
+ { name = "ruptures" },
{ name = "scenedetect" },
{ name = "scholarly", extra = ["tor"] },
+ { name = "scikit-image" },
+ { name = "scipy", version = "1.15.3", source = { registry = "https://pypi.org/simple" }, marker = "python_full_version < '3.11'" },
+ { name = "scipy", version = "1.16.3", source = { registry = "https://pypi.org/simple" }, marker = "python_full_version >= '3.11'" },
{ name = "scrapegraph-py" },
{ name = "sentencepiece" },
{ name = "slack-bolt" },
{ name = "slack-sdk" },
{ name = "soundfile" },
+ { name = "statsmodels" },
{ name = "stripe" },
{ name = "surrealdb" },
{ name = "sympy" },
@@ -1110,6 +1133,20 @@ document-tools = [
{ name = "unstructured", marker = "python_full_version < '3.13'" },
{ name = "xls2xlsx" },
]
+earth-science = [
+ { name = "matplotlib" },
+ { name = "numpy", version = "1.26.4", source = { registry = "https://pypi.org/simple" }, marker = "python_full_version < '3.13'" },
+ { name = "numpy", version = "2.2.0", source = { registry = "https://pypi.org/simple" }, marker = "python_full_version >= '3.13'" },
+ { name = "opencv-python", version = "4.11.0.86", source = { registry = "https://pypi.org/simple" }, marker = "python_full_version < '3.13'" },
+ { name = "opencv-python", version = "4.12.0.88", source = { registry = "https://pypi.org/simple" }, marker = "python_full_version >= '3.13'" },
+ { name = "pandas" },
+ { name = "rasterio" },
+ { name = "ruptures" },
+ { name = "scikit-image" },
+ { name = "scipy", version = "1.15.3", source = { registry = "https://pypi.org/simple" }, marker = "python_full_version < '3.11'" },
+ { name = "scipy", version = "1.16.3", source = { registry = "https://pypi.org/simple" }, marker = "python_full_version >= '3.11'" },
+ { name = "statsmodels" },
+]
eigent = [
{ name = "anthropic" },
{ name = "datasets" },
@@ -1449,6 +1486,7 @@ requires-dist = [
{ name = "markitdown", extras = ["all"], marker = "python_full_version < '3.13' and extra == 'eigent'", specifier = ">=0.1.1" },
{ name = "math-verify", marker = "extra == 'all'", specifier = ">=0.7.0,<0.8" },
{ name = "math-verify", marker = "extra == 'data-tools'", specifier = ">=0.7.0,<0.8" },
+ { name = "matplotlib", marker = "extra == 'earth-science'", specifier = ">=3.10.7" },
{ name = "mcp", specifier = ">=1.3.0" },
{ name = "mcp", marker = "extra == 'all'", specifier = ">=1.3.0" },
{ name = "mcp", marker = "extra == 'dev-tools'", specifier = ">=1.3.0" },
@@ -1481,6 +1519,7 @@ requires-dist = [
{ name = "numpy", marker = "extra == 'all'", specifier = ">=1.2,<=2.2" },
{ name = "numpy", marker = "extra == 'data-tools'", specifier = ">=1.2,<=2.2" },
{ name = "numpy", marker = "extra == 'document-tools'", specifier = ">=1.2,<=2.2" },
+ { name = "numpy", marker = "extra == 'earth-science'", specifier = ">=1.2,<=2.2" },
{ name = "numpy", marker = "extra == 'eigent'", specifier = ">=1.2,<=2.2" },
{ name = "numpy", marker = "extra == 'owl'", specifier = ">=1.2,<=2.2" },
{ name = "numpy", marker = "extra == 'rag'", specifier = ">=1.2,<=2.2" },
@@ -1492,12 +1531,15 @@ requires-dist = [
{ name = "openapi-spec-validator", marker = "extra == 'all'", specifier = ">=0.7.1,<0.8" },
{ name = "openapi-spec-validator", marker = "extra == 'document-tools'", specifier = ">=0.7.1,<0.8" },
{ name = "openapi-spec-validator", marker = "extra == 'owl'", specifier = ">=0.7.1,<0.8" },
+ { name = "opencv-python", marker = "extra == 'all'", specifier = ">=4.11.0.86" },
+ { name = "opencv-python", marker = "extra == 'earth-science'", specifier = ">=4.11.0.86" },
{ name = "openpyxl", marker = "extra == 'all'", specifier = ">=3.1.5" },
{ name = "openpyxl", marker = "extra == 'document-tools'", specifier = ">=3.1.5" },
{ name = "openpyxl", marker = "extra == 'eigent'", specifier = ">=3.1.5" },
{ name = "openpyxl", marker = "extra == 'owl'", specifier = ">=3.1.5" },
{ name = "pandas", marker = "extra == 'all'", specifier = ">=2" },
{ name = "pandas", marker = "extra == 'data-tools'", specifier = ">=2" },
+ { name = "pandas", marker = "extra == 'earth-science'", specifier = ">=2" },
{ name = "pandas", marker = "extra == 'eigent'", specifier = ">=2" },
{ name = "pandas", marker = "extra == 'owl'", specifier = ">=2" },
{ name = "pgvector", marker = "extra == 'all'", specifier = ">=0.2.4,<0.3" },
@@ -1569,6 +1611,8 @@ requires-dist = [
{ name = "qdrant-client", marker = "extra == 'storage'", specifier = ">=1.9.0,<2" },
{ name = "rank-bm25", marker = "extra == 'all'", specifier = ">=0.2.2,<0.3" },
{ name = "rank-bm25", marker = "extra == 'rag'", specifier = ">=0.2.2,<0.3" },
+ { name = "rasterio", marker = "extra == 'all'", specifier = ">=1.4.4" },
+ { name = "rasterio", marker = "extra == 'earth-science'", specifier = ">=1.4.4" },
{ name = "redis", marker = "extra == 'all'", specifier = ">=5.0.6,<6" },
{ name = "redis", marker = "extra == 'storage'", specifier = ">=5.0.6,<6" },
{ name = "reka-api", marker = "extra == 'all'", specifier = ">=3.0.8,<4" },
@@ -1588,12 +1632,18 @@ requires-dist = [
{ name = "rouge", marker = "extra == 'data-tools'", specifier = ">=1.0.1,<2" },
{ name = "rouge", marker = "extra == 'owl'", specifier = ">=1.0.1,<2" },
{ name = "ruff", marker = "extra == 'dev'", specifier = ">=0.7,<0.8" },
+ { name = "ruptures", marker = "extra == 'all'", specifier = ">=1.1.10" },
+ { name = "ruptures", marker = "extra == 'earth-science'", specifier = ">=1.1.10" },
{ name = "scenedetect", marker = "extra == 'all'", specifier = ">=0.6.5.2" },
{ name = "scenedetect", marker = "extra == 'eigent'", specifier = ">=0.6.5.2" },
{ name = "scenedetect", marker = "extra == 'media-tools'", specifier = ">=0.6.5.2" },
{ name = "scenedetect", marker = "extra == 'owl'", specifier = ">=0.6.5.2" },
{ name = "scholarly", extras = ["tor"], marker = "extra == 'all'", specifier = "==1.7.11" },
{ name = "scholarly", extras = ["tor"], marker = "extra == 'research-tools'", specifier = "==1.7.11" },
+ { name = "scikit-image", marker = "extra == 'all'", specifier = ">=0.25.2" },
+ { name = "scikit-image", marker = "extra == 'earth-science'", specifier = ">=0.25.2" },
+ { name = "scipy", marker = "extra == 'all'", specifier = ">=1.15.3" },
+ { name = "scipy", marker = "extra == 'earth-science'", specifier = ">=1.15.3" },
{ name = "scrapegraph-py", marker = "extra == 'all'", specifier = ">=1.12.0,<2" },
{ name = "scrapegraph-py", marker = "extra == 'owl'", specifier = ">=1.12.0,<2" },
{ name = "scrapegraph-py", marker = "extra == 'web-tools'", specifier = ">=1.12.0,<2" },
@@ -1611,6 +1661,8 @@ requires-dist = [
{ name = "sphinx", marker = "extra == 'docs'", specifier = ">=7,<8" },
{ name = "sphinx-book-theme", marker = "extra == 'docs'" },
{ name = "sphinxext-rediraffe", marker = "extra == 'docs'", specifier = ">=0.2.7,<0.3" },
+ { name = "statsmodels", marker = "extra == 'all'", specifier = ">=0.14.6" },
+ { name = "statsmodels", marker = "extra == 'earth-science'", specifier = ">=0.14.6" },
{ name = "stripe", marker = "extra == 'all'", specifier = ">=11.3.0,<12" },
{ name = "stripe", marker = "extra == 'data-tools'", specifier = ">=11.3.0,<12" },
{ name = "surrealdb", marker = "extra == 'all'", specifier = ">=1.0.6" },
@@ -1679,7 +1731,7 @@ requires-dist = [
{ name = "yt-dlp", marker = "extra == 'media-tools'", specifier = ">=2024.11.4,<2025" },
{ name = "yt-dlp", marker = "extra == 'owl'", specifier = ">=2024.11.4,<2025" },
]
-provides-extras = ["dev", "docs", "rag", "web-tools", "document-tools", "media-tools", "communication-tools", "data-tools", "research-tools", "dev-tools", "model-platforms", "huggingface", "storage", "owl", "eigent", "all"]
+provides-extras = ["dev", "docs", "rag", "web-tools", "document-tools", "media-tools", "communication-tools", "data-tools", "research-tools", "dev-tools", "model-platforms", "huggingface", "storage", "owl", "eigent", "all", "earth-science"]
[[package]]
name = "cerberus"
@@ -1972,14 +2024,38 @@ wheels = [
[[package]]
name = "click"
-version = "8.2.1"
+version = "8.1.8"
source = { registry = "https://pypi.org/simple" }
dependencies = [
{ name = "colorama", marker = "sys_platform == 'win32'" },
]
-sdist = { url = "https://files.pythonhosted.org/packages/60/6c/8ca2efa64cf75a977a0d7fac081354553ebe483345c734fb6b6515d96bbc/click-8.2.1.tar.gz", hash = "sha256:27c491cc05d968d271d5a1db13e3b5a184636d9d930f148c50b038f0d0646202", size = 286342, upload-time = "2025-05-20T23:19:49.832Z" }
+sdist = { url = "https://files.pythonhosted.org/packages/b9/2e/0090cbf739cee7d23781ad4b89a9894a41538e4fcf4c31dcdd705b78eb8b/click-8.1.8.tar.gz", hash = "sha256:ed53c9d8990d83c2a27deae68e4ee337473f6330c040a31d4225c9574d16096a", size = 226593, upload-time = "2024-12-21T18:38:44.339Z" }
+wheels = [
+ { url = "https://files.pythonhosted.org/packages/7e/d4/7ebdbd03970677812aac39c869717059dbb71a4cfc033ca6e5221787892c/click-8.1.8-py3-none-any.whl", hash = "sha256:63c132bbbed01578a06712a2d1f497bb62d9c1c0d329b7903a866228027263b2", size = 98188, upload-time = "2024-12-21T18:38:41.666Z" },
+]
+
+[[package]]
+name = "click-plugins"
+version = "1.1.1.2"
+source = { registry = "https://pypi.org/simple" }
+dependencies = [
+ { name = "click" },
+]
+sdist = { url = "https://files.pythonhosted.org/packages/c3/a4/34847b59150da33690a36da3681d6bbc2ec14ee9a846bc30a6746e5984e4/click_plugins-1.1.1.2.tar.gz", hash = "sha256:d7af3984a99d243c131aa1a828331e7630f4a88a9741fd05c927b204bcf92261", size = 8343, upload-time = "2025-06-25T00:47:37.555Z" }
wheels = [
- { url = "https://files.pythonhosted.org/packages/85/32/10bb5764d90a8eee674e9dc6f4db6a0ab47c8c4d0d83c27f7c39ac415a4d/click-8.2.1-py3-none-any.whl", hash = "sha256:61a3265b914e850b85317d0b3109c7f8cd35a670f963866005d6ef1d5175a12b", size = 102215, upload-time = "2025-05-20T23:19:47.796Z" },
+ { url = "https://files.pythonhosted.org/packages/3d/9a/2abecb28ae875e39c8cad711eb1186d8d14eab564705325e77e4e6ab9ae5/click_plugins-1.1.1.2-py2.py3-none-any.whl", hash = "sha256:008d65743833ffc1f5417bf0e78e8d2c23aab04d9745ba817bd3e71b0feb6aa6", size = 11051, upload-time = "2025-06-25T00:47:36.731Z" },
+]
+
+[[package]]
+name = "cligj"
+version = "0.7.2"
+source = { registry = "https://pypi.org/simple" }
+dependencies = [
+ { name = "click" },
+]
+sdist = { url = "https://files.pythonhosted.org/packages/ea/0d/837dbd5d8430fd0f01ed72c4cfb2f548180f4c68c635df84ce87956cff32/cligj-0.7.2.tar.gz", hash = "sha256:a4bc13d623356b373c2c27c53dbd9c68cae5d526270bfa71f6c6fa69669c6b27", size = 9803, upload-time = "2021-05-28T21:23:27.935Z" }
+wheels = [
+ { url = "https://files.pythonhosted.org/packages/73/86/43fa9f15c5b9fb6e82620428827cd3c284aa933431405d1bcf5231ae3d3e/cligj-0.7.2-py3-none-any.whl", hash = "sha256:c1ca117dbce1fe20a5809dc96f01e1c2840f6dcc939b3ddbb1111bf330ba82df", size = 7069, upload-time = "2021-05-28T21:23:26.877Z" },
]
[[package]]
@@ -2047,7 +2123,9 @@ version = "1.3.2"
source = { registry = "https://pypi.org/simple" }
resolution-markers = [
"python_full_version < '3.11' and sys_platform == 'win32'",
- "python_full_version < '3.11' and sys_platform != 'win32'",
+ "python_full_version < '3.11' and sys_platform == 'darwin'",
+ "python_full_version < '3.11' and platform_machine == 'aarch64' and sys_platform == 'linux'",
+ "(python_full_version < '3.11' and platform_machine != 'aarch64' and sys_platform == 'linux') or (python_full_version < '3.11' and sys_platform != 'darwin' and sys_platform != 'linux' and sys_platform != 'win32')",
]
dependencies = [
{ name = "numpy", version = "1.26.4", source = { registry = "https://pypi.org/simple" }, marker = "python_full_version < '3.11'" },
@@ -2122,9 +2200,13 @@ resolution-markers = [
"python_full_version == '3.13.*' and sys_platform == 'win32'",
"python_full_version == '3.13.*' and sys_platform != 'win32'",
"python_full_version == '3.12.*' and sys_platform == 'win32'",
- "python_full_version == '3.12.*' and sys_platform != 'win32'",
+ "python_full_version == '3.12.*' and sys_platform == 'darwin'",
+ "python_full_version == '3.12.*' and platform_machine == 'aarch64' and sys_platform == 'linux'",
+ "(python_full_version == '3.12.*' and platform_machine != 'aarch64' and sys_platform == 'linux') or (python_full_version == '3.12.*' and sys_platform != 'darwin' and sys_platform != 'linux' and sys_platform != 'win32')",
"python_full_version == '3.11.*' and sys_platform == 'win32'",
- "python_full_version == '3.11.*' and sys_platform != 'win32'",
+ "python_full_version == '3.11.*' and sys_platform == 'darwin'",
+ "python_full_version == '3.11.*' and platform_machine == 'aarch64' and sys_platform == 'linux'",
+ "(python_full_version == '3.11.*' and platform_machine != 'aarch64' and sys_platform == 'linux') or (python_full_version == '3.11.*' and sys_platform != 'darwin' and sys_platform != 'linux' and sys_platform != 'win32')",
]
dependencies = [
{ name = "numpy", version = "1.26.4", source = { registry = "https://pypi.org/simple" }, marker = "python_full_version >= '3.11' and python_full_version < '3.13'" },
@@ -4208,7 +4290,9 @@ version = "1.3.42"
source = { registry = "https://pypi.org/simple" }
resolution-markers = [
"python_full_version < '3.11' and sys_platform == 'win32'",
- "python_full_version < '3.11' and sys_platform != 'win32'",
+ "python_full_version < '3.11' and sys_platform == 'darwin'",
+ "python_full_version < '3.11' and platform_machine == 'aarch64' and sys_platform == 'linux'",
+ "(python_full_version < '3.11' and platform_machine != 'aarch64' and sys_platform == 'linux') or (python_full_version < '3.11' and sys_platform != 'darwin' and sys_platform != 'linux' and sys_platform != 'win32')",
]
dependencies = [
{ name = "cachetools", marker = "python_full_version < '3.11'" },
@@ -4237,9 +4321,13 @@ resolution-markers = [
"python_full_version == '3.13.*' and sys_platform == 'win32'",
"python_full_version == '3.13.*' and sys_platform != 'win32'",
"python_full_version == '3.12.*' and sys_platform == 'win32'",
- "python_full_version == '3.12.*' and sys_platform != 'win32'",
+ "python_full_version == '3.12.*' and sys_platform == 'darwin'",
+ "python_full_version == '3.12.*' and platform_machine == 'aarch64' and sys_platform == 'linux'",
+ "(python_full_version == '3.12.*' and platform_machine != 'aarch64' and sys_platform == 'linux') or (python_full_version == '3.12.*' and sys_platform != 'darwin' and sys_platform != 'linux' and sys_platform != 'win32')",
"python_full_version == '3.11.*' and sys_platform == 'win32'",
- "python_full_version == '3.11.*' and sys_platform != 'win32'",
+ "python_full_version == '3.11.*' and sys_platform == 'darwin'",
+ "python_full_version == '3.11.*' and platform_machine == 'aarch64' and sys_platform == 'linux'",
+ "(python_full_version == '3.11.*' and platform_machine != 'aarch64' and sys_platform == 'linux') or (python_full_version == '3.11.*' and sys_platform != 'darwin' and sys_platform != 'linux' and sys_platform != 'win32')",
]
dependencies = [
{ name = "cachetools", marker = "python_full_version >= '3.11'" },
@@ -4374,7 +4462,9 @@ version = "8.37.0"
source = { registry = "https://pypi.org/simple" }
resolution-markers = [
"python_full_version < '3.11' and sys_platform == 'win32'",
- "python_full_version < '3.11' and sys_platform != 'win32'",
+ "python_full_version < '3.11' and sys_platform == 'darwin'",
+ "python_full_version < '3.11' and platform_machine == 'aarch64' and sys_platform == 'linux'",
+ "(python_full_version < '3.11' and platform_machine != 'aarch64' and sys_platform == 'linux') or (python_full_version < '3.11' and sys_platform != 'darwin' and sys_platform != 'linux' and sys_platform != 'win32')",
]
dependencies = [
{ name = "colorama", marker = "python_full_version < '3.11' and sys_platform == 'win32'" },
@@ -4404,9 +4494,13 @@ resolution-markers = [
"python_full_version == '3.13.*' and sys_platform == 'win32'",
"python_full_version == '3.13.*' and sys_platform != 'win32'",
"python_full_version == '3.12.*' and sys_platform == 'win32'",
- "python_full_version == '3.12.*' and sys_platform != 'win32'",
+ "python_full_version == '3.12.*' and sys_platform == 'darwin'",
+ "python_full_version == '3.12.*' and platform_machine == 'aarch64' and sys_platform == 'linux'",
+ "(python_full_version == '3.12.*' and platform_machine != 'aarch64' and sys_platform == 'linux') or (python_full_version == '3.12.*' and sys_platform != 'darwin' and sys_platform != 'linux' and sys_platform != 'win32')",
"python_full_version == '3.11.*' and sys_platform == 'win32'",
- "python_full_version == '3.11.*' and sys_platform != 'win32'",
+ "python_full_version == '3.11.*' and sys_platform == 'darwin'",
+ "python_full_version == '3.11.*' and platform_machine == 'aarch64' and sys_platform == 'linux'",
+ "(python_full_version == '3.11.*' and platform_machine != 'aarch64' and sys_platform == 'linux') or (python_full_version == '3.11.*' and sys_platform != 'darwin' and sys_platform != 'linux' and sys_platform != 'win32')",
]
dependencies = [
{ name = "colorama", marker = "python_full_version >= '3.11' and sys_platform == 'win32'" },
@@ -4860,6 +4954,18 @@ wheels = [
{ url = "https://files.pythonhosted.org/packages/6d/eb/a5e8b06b924b4149cf498e1598116bad1e91ab23046c2dfc2c498154d393/latex2sympy2_extended-1.10.1-py3-none-any.whl", hash = "sha256:917a23e8f3b6edea88a56978fbbe87ed9fca4197f8277646be57b4660710347c", size = 207460, upload-time = "2025-02-27T16:02:45.941Z" },
]
+[[package]]
+name = "lazy-loader"
+version = "0.4"
+source = { registry = "https://pypi.org/simple" }
+dependencies = [
+ { name = "packaging" },
+]
+sdist = { url = "https://files.pythonhosted.org/packages/6f/6b/c875b30a1ba490860c93da4cabf479e03f584eba06fe5963f6f6644653d8/lazy_loader-0.4.tar.gz", hash = "sha256:47c75182589b91a4e1a85a136c074285a5ad4d9f39c63e0d7fb76391c4574cd1", size = 15431, upload-time = "2024-04-05T13:03:12.261Z" }
+wheels = [
+ { url = "https://files.pythonhosted.org/packages/83/60/d497a310bde3f01cb805196ac61b7ad6dc5dcf8dce66634dc34364b20b4f/lazy_loader-0.4-py3-none-any.whl", hash = "sha256:342aa8e14d543a154047afb4ba8ef17f5563baad3fc610d7b15b213b0f119efc", size = 12097, upload-time = "2024-04-05T13:03:10.514Z" },
+]
+
[[package]]
name = "lazy-object-proxy"
version = "1.12.0"
@@ -5237,11 +5343,17 @@ version = "3.26.1"
source = { registry = "https://pypi.org/simple" }
resolution-markers = [
"python_full_version == '3.12.*' and sys_platform == 'win32'",
- "python_full_version == '3.12.*' and sys_platform != 'win32'",
+ "python_full_version == '3.12.*' and sys_platform == 'darwin'",
+ "python_full_version == '3.12.*' and platform_machine == 'aarch64' and sys_platform == 'linux'",
+ "(python_full_version == '3.12.*' and platform_machine != 'aarch64' and sys_platform == 'linux') or (python_full_version == '3.12.*' and sys_platform != 'darwin' and sys_platform != 'linux' and sys_platform != 'win32')",
"python_full_version == '3.11.*' and sys_platform == 'win32'",
- "python_full_version == '3.11.*' and sys_platform != 'win32'",
+ "python_full_version == '3.11.*' and sys_platform == 'darwin'",
+ "python_full_version == '3.11.*' and platform_machine == 'aarch64' and sys_platform == 'linux'",
+ "(python_full_version == '3.11.*' and platform_machine != 'aarch64' and sys_platform == 'linux') or (python_full_version == '3.11.*' and sys_platform != 'darwin' and sys_platform != 'linux' and sys_platform != 'win32')",
"python_full_version < '3.11' and sys_platform == 'win32'",
- "python_full_version < '3.11' and sys_platform != 'win32'",
+ "python_full_version < '3.11' and sys_platform == 'darwin'",
+ "python_full_version < '3.11' and platform_machine == 'aarch64' and sys_platform == 'linux'",
+ "(python_full_version < '3.11' and platform_machine != 'aarch64' and sys_platform == 'linux') or (python_full_version < '3.11' and sys_platform != 'darwin' and sys_platform != 'linux' and sys_platform != 'win32')",
]
dependencies = [
{ name = "packaging", marker = "python_full_version < '3.13'" },
@@ -6040,7 +6152,9 @@ version = "3.4.2"
source = { registry = "https://pypi.org/simple" }
resolution-markers = [
"python_full_version < '3.11' and sys_platform == 'win32'",
- "python_full_version < '3.11' and sys_platform != 'win32'",
+ "python_full_version < '3.11' and sys_platform == 'darwin'",
+ "python_full_version < '3.11' and platform_machine == 'aarch64' and sys_platform == 'linux'",
+ "(python_full_version < '3.11' and platform_machine != 'aarch64' and sys_platform == 'linux') or (python_full_version < '3.11' and sys_platform != 'darwin' and sys_platform != 'linux' and sys_platform != 'win32')",
]
sdist = { url = "https://files.pythonhosted.org/packages/fd/1d/06475e1cd5264c0b870ea2cc6fdb3e37177c1e565c43f56ff17a10e3937f/networkx-3.4.2.tar.gz", hash = "sha256:307c3669428c5362aab27c8a1260aa8f47c4e91d3891f48be0141738d8d053e1", size = 2151368, upload-time = "2024-10-21T12:39:38.695Z" }
wheels = [
@@ -6057,9 +6171,13 @@ resolution-markers = [
"python_full_version == '3.13.*' and sys_platform == 'win32'",
"python_full_version == '3.13.*' and sys_platform != 'win32'",
"python_full_version == '3.12.*' and sys_platform == 'win32'",
- "python_full_version == '3.12.*' and sys_platform != 'win32'",
+ "python_full_version == '3.12.*' and sys_platform == 'darwin'",
+ "python_full_version == '3.12.*' and platform_machine == 'aarch64' and sys_platform == 'linux'",
+ "(python_full_version == '3.12.*' and platform_machine != 'aarch64' and sys_platform == 'linux') or (python_full_version == '3.12.*' and sys_platform != 'darwin' and sys_platform != 'linux' and sys_platform != 'win32')",
"python_full_version == '3.11.*' and sys_platform == 'win32'",
- "python_full_version == '3.11.*' and sys_platform != 'win32'",
+ "python_full_version == '3.11.*' and sys_platform == 'darwin'",
+ "python_full_version == '3.11.*' and platform_machine == 'aarch64' and sys_platform == 'linux'",
+ "(python_full_version == '3.11.*' and platform_machine != 'aarch64' and sys_platform == 'linux') or (python_full_version == '3.11.*' and sys_platform != 'darwin' and sys_platform != 'linux' and sys_platform != 'win32')",
]
sdist = { url = "https://files.pythonhosted.org/packages/e8/fc/7b6fd4d22c8c4dc5704430140d8b3f520531d4fe7328b8f8d03f5a7950e8/networkx-3.6.tar.gz", hash = "sha256:285276002ad1f7f7da0f7b42f004bcba70d381e936559166363707fdad3d72ad", size = 2511464, upload-time = "2025-11-24T03:03:47.158Z" }
wheels = [
@@ -6108,11 +6226,17 @@ version = "1.26.4"
source = { registry = "https://pypi.org/simple" }
resolution-markers = [
"python_full_version == '3.12.*' and sys_platform == 'win32'",
- "python_full_version == '3.12.*' and sys_platform != 'win32'",
+ "python_full_version == '3.12.*' and sys_platform == 'darwin'",
+ "python_full_version == '3.12.*' and platform_machine == 'aarch64' and sys_platform == 'linux'",
+ "(python_full_version == '3.12.*' and platform_machine != 'aarch64' and sys_platform == 'linux') or (python_full_version == '3.12.*' and sys_platform != 'darwin' and sys_platform != 'linux' and sys_platform != 'win32')",
"python_full_version == '3.11.*' and sys_platform == 'win32'",
- "python_full_version == '3.11.*' and sys_platform != 'win32'",
+ "python_full_version == '3.11.*' and sys_platform == 'darwin'",
+ "python_full_version == '3.11.*' and platform_machine == 'aarch64' and sys_platform == 'linux'",
+ "(python_full_version == '3.11.*' and platform_machine != 'aarch64' and sys_platform == 'linux') or (python_full_version == '3.11.*' and sys_platform != 'darwin' and sys_platform != 'linux' and sys_platform != 'win32')",
"python_full_version < '3.11' and sys_platform == 'win32'",
- "python_full_version < '3.11' and sys_platform != 'win32'",
+ "python_full_version < '3.11' and sys_platform == 'darwin'",
+ "python_full_version < '3.11' and platform_machine == 'aarch64' and sys_platform == 'linux'",
+ "(python_full_version < '3.11' and platform_machine != 'aarch64' and sys_platform == 'linux') or (python_full_version < '3.11' and sys_platform != 'darwin' and sys_platform != 'linux' and sys_platform != 'win32')",
]
sdist = { url = "https://files.pythonhosted.org/packages/65/6e/09db70a523a96d25e115e71cc56a6f9031e7b8cd166c1ac8438307c14058/numpy-1.26.4.tar.gz", hash = "sha256:2a02aba9ed12e4ac4eb3ea9421c420301a0c6460d9830d74a9df87efa4912010", size = 15786129, upload-time = "2024-02-06T00:26:44.495Z" }
wheels = [
@@ -6381,6 +6505,60 @@ wheels = [
{ url = "https://files.pythonhosted.org/packages/27/dd/b3fd642260cb17532f66cc1e8250f3507d1e580483e209dc1e9d13bd980d/openapi_spec_validator-0.7.2-py3-none-any.whl", hash = "sha256:4bbdc0894ec85f1d1bea1d6d9c8b2c3c8d7ccaa13577ef40da9c006c9fd0eb60", size = 39713, upload-time = "2025-06-07T14:48:54.077Z" },
]
+[[package]]
+name = "opencv-python"
+version = "4.11.0.86"
+source = { registry = "https://pypi.org/simple" }
+resolution-markers = [
+ "python_full_version == '3.12.*' and sys_platform == 'win32'",
+ "python_full_version == '3.12.*' and sys_platform == 'darwin'",
+ "python_full_version == '3.12.*' and platform_machine == 'aarch64' and sys_platform == 'linux'",
+ "(python_full_version == '3.12.*' and platform_machine != 'aarch64' and sys_platform == 'linux') or (python_full_version == '3.12.*' and sys_platform != 'darwin' and sys_platform != 'linux' and sys_platform != 'win32')",
+ "python_full_version == '3.11.*' and sys_platform == 'win32'",
+ "python_full_version == '3.11.*' and sys_platform == 'darwin'",
+ "python_full_version == '3.11.*' and platform_machine == 'aarch64' and sys_platform == 'linux'",
+ "(python_full_version == '3.11.*' and platform_machine != 'aarch64' and sys_platform == 'linux') or (python_full_version == '3.11.*' and sys_platform != 'darwin' and sys_platform != 'linux' and sys_platform != 'win32')",
+ "python_full_version < '3.11' and sys_platform == 'win32'",
+ "python_full_version < '3.11' and sys_platform == 'darwin'",
+ "python_full_version < '3.11' and platform_machine == 'aarch64' and sys_platform == 'linux'",
+ "(python_full_version < '3.11' and platform_machine != 'aarch64' and sys_platform == 'linux') or (python_full_version < '3.11' and sys_platform != 'darwin' and sys_platform != 'linux' and sys_platform != 'win32')",
+]
+dependencies = [
+ { name = "numpy", version = "1.26.4", source = { registry = "https://pypi.org/simple" }, marker = "python_full_version < '3.13'" },
+]
+sdist = { url = "https://files.pythonhosted.org/packages/17/06/68c27a523103dad5837dc5b87e71285280c4f098c60e4fe8a8db6486ab09/opencv-python-4.11.0.86.tar.gz", hash = "sha256:03d60ccae62304860d232272e4a4fda93c39d595780cb40b161b310244b736a4", size = 95171956, upload-time = "2025-01-16T13:52:24.737Z" }
+wheels = [
+ { url = "https://files.pythonhosted.org/packages/05/4d/53b30a2a3ac1f75f65a59eb29cf2ee7207ce64867db47036ad61743d5a23/opencv_python-4.11.0.86-cp37-abi3-macosx_13_0_arm64.whl", hash = "sha256:432f67c223f1dc2824f5e73cdfcd9db0efc8710647d4e813012195dc9122a52a", size = 37326322, upload-time = "2025-01-16T13:52:25.887Z" },
+ { url = "https://files.pythonhosted.org/packages/3b/84/0a67490741867eacdfa37bc18df96e08a9d579583b419010d7f3da8ff503/opencv_python-4.11.0.86-cp37-abi3-macosx_13_0_x86_64.whl", hash = "sha256:9d05ef13d23fe97f575153558653e2d6e87103995d54e6a35db3f282fe1f9c66", size = 56723197, upload-time = "2025-01-16T13:55:21.222Z" },
+ { url = "https://files.pythonhosted.org/packages/f3/bd/29c126788da65c1fb2b5fb621b7fed0ed5f9122aa22a0868c5e2c15c6d23/opencv_python-4.11.0.86-cp37-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:1b92ae2c8852208817e6776ba1ea0d6b1e0a1b5431e971a2a0ddd2a8cc398202", size = 42230439, upload-time = "2025-01-16T13:51:35.822Z" },
+ { url = "https://files.pythonhosted.org/packages/2c/8b/90eb44a40476fa0e71e05a0283947cfd74a5d36121a11d926ad6f3193cc4/opencv_python-4.11.0.86-cp37-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:6b02611523803495003bd87362db3e1d2a0454a6a63025dc6658a9830570aa0d", size = 62986597, upload-time = "2025-01-16T13:52:08.836Z" },
+ { url = "https://files.pythonhosted.org/packages/fb/d7/1d5941a9dde095468b288d989ff6539dd69cd429dbf1b9e839013d21b6f0/opencv_python-4.11.0.86-cp37-abi3-win32.whl", hash = "sha256:810549cb2a4aedaa84ad9a1c92fbfdfc14090e2749cedf2c1589ad8359aa169b", size = 29384337, upload-time = "2025-01-16T13:52:13.549Z" },
+ { url = "https://files.pythonhosted.org/packages/a4/7d/f1c30a92854540bf789e9cd5dde7ef49bbe63f855b85a2e6b3db8135c591/opencv_python-4.11.0.86-cp37-abi3-win_amd64.whl", hash = "sha256:085ad9b77c18853ea66283e98affefe2de8cc4c1f43eda4c100cf9b2721142ec", size = 39488044, upload-time = "2025-01-16T13:52:21.928Z" },
+]
+
+[[package]]
+name = "opencv-python"
+version = "4.12.0.88"
+source = { registry = "https://pypi.org/simple" }
+resolution-markers = [
+ "python_full_version >= '3.14' and sys_platform == 'win32'",
+ "python_full_version >= '3.14' and sys_platform != 'win32'",
+ "python_full_version == '3.13.*' and sys_platform == 'win32'",
+ "python_full_version == '3.13.*' and sys_platform != 'win32'",
+]
+dependencies = [
+ { name = "numpy", version = "2.2.0", source = { registry = "https://pypi.org/simple" }, marker = "python_full_version >= '3.13'" },
+]
+sdist = { url = "https://files.pythonhosted.org/packages/ac/71/25c98e634b6bdeca4727c7f6d6927b056080668c5008ad3c8fc9e7f8f6ec/opencv-python-4.12.0.88.tar.gz", hash = "sha256:8b738389cede219405f6f3880b851efa3415ccd674752219377353f017d2994d", size = 95373294, upload-time = "2025-07-07T09:20:52.389Z" }
+wheels = [
+ { url = "https://files.pythonhosted.org/packages/85/68/3da40142e7c21e9b1d4e7ddd6c58738feb013203e6e4b803d62cdd9eb96b/opencv_python-4.12.0.88-cp37-abi3-macosx_13_0_arm64.whl", hash = "sha256:f9a1f08883257b95a5764bf517a32d75aec325319c8ed0f89739a57fae9e92a5", size = 37877727, upload-time = "2025-07-07T09:13:31.47Z" },
+ { url = "https://files.pythonhosted.org/packages/33/7c/042abe49f58d6ee7e1028eefc3334d98ca69b030e3b567fe245a2b28ea6f/opencv_python-4.12.0.88-cp37-abi3-macosx_13_0_x86_64.whl", hash = "sha256:812eb116ad2b4de43ee116fcd8991c3a687f099ada0b04e68f64899c09448e81", size = 57326471, upload-time = "2025-07-07T09:13:41.26Z" },
+ { url = "https://files.pythonhosted.org/packages/62/3a/440bd64736cf8116f01f3b7f9f2e111afb2e02beb2ccc08a6458114a6b5d/opencv_python-4.12.0.88-cp37-abi3-manylinux2014_aarch64.manylinux_2_17_aarch64.whl", hash = "sha256:51fd981c7df6af3e8f70b1556696b05224c4e6b6777bdd2a46b3d4fb09de1a92", size = 45887139, upload-time = "2025-07-07T09:13:50.761Z" },
+ { url = "https://files.pythonhosted.org/packages/68/1f/795e7f4aa2eacc59afa4fb61a2e35e510d06414dd5a802b51a012d691b37/opencv_python-4.12.0.88-cp37-abi3-manylinux2014_x86_64.manylinux_2_17_x86_64.whl", hash = "sha256:092c16da4c5a163a818f120c22c5e4a2f96e0db4f24e659c701f1fe629a690f9", size = 67041680, upload-time = "2025-07-07T09:14:01.995Z" },
+ { url = "https://files.pythonhosted.org/packages/02/96/213fea371d3cb2f1d537612a105792aa0a6659fb2665b22cad709a75bd94/opencv_python-4.12.0.88-cp37-abi3-win32.whl", hash = "sha256:ff554d3f725b39878ac6a2e1fa232ec509c36130927afc18a1719ebf4fbf4357", size = 30284131, upload-time = "2025-07-07T09:14:08.819Z" },
+ { url = "https://files.pythonhosted.org/packages/fa/80/eb88edc2e2b11cd2dd2e56f1c80b5784d11d6e6b7f04a1145df64df40065/opencv_python-4.12.0.88-cp37-abi3-win_amd64.whl", hash = "sha256:d98edb20aa932fd8ebd276a72627dad9dc097695b3d435a4257557bbb49a79d2", size = 39000307, upload-time = "2025-07-07T09:14:16.641Z" },
+]
+
[[package]]
name = "openpyxl"
version = "3.1.5"
@@ -6809,6 +6987,19 @@ wheels = [
{ url = "https://files.pythonhosted.org/packages/cc/20/ff623b09d963f88bfde16306a54e12ee5ea43e9b597108672ff3a408aad6/pathspec-0.12.1-py3-none-any.whl", hash = "sha256:a0d503e138a4c123b27490a4f7beda6a01c6f288df0e4a8b79c7eb0dc7b4cc08", size = 31191, upload-time = "2023-12-10T22:30:43.14Z" },
]
+[[package]]
+name = "patsy"
+version = "1.0.2"
+source = { registry = "https://pypi.org/simple" }
+dependencies = [
+ { name = "numpy", version = "1.26.4", source = { registry = "https://pypi.org/simple" }, marker = "python_full_version < '3.13'" },
+ { name = "numpy", version = "2.2.0", source = { registry = "https://pypi.org/simple" }, marker = "python_full_version >= '3.13'" },
+]
+sdist = { url = "https://files.pythonhosted.org/packages/be/44/ed13eccdd0519eff265f44b670d46fbb0ec813e2274932dc1c0e48520f7d/patsy-1.0.2.tar.gz", hash = "sha256:cdc995455f6233e90e22de72c37fcadb344e7586fb83f06696f54d92f8ce74c0", size = 399942, upload-time = "2025-10-20T16:17:37.535Z" }
+wheels = [
+ { url = "https://files.pythonhosted.org/packages/f1/70/ba4b949bdc0490ab78d545459acd7702b211dfccf7eb89bbc1060f52818d/patsy-1.0.2-py2.py3-none-any.whl", hash = "sha256:37bfddbc58fcf0362febb5f54f10743f8b21dd2aa73dec7e7ef59d1b02ae668a", size = 233301, upload-time = "2025-10-20T16:17:36.563Z" },
+]
+
[[package]]
name = "pdfminer-six"
version = "20251107"
@@ -7789,7 +7980,7 @@ name = "pyobjc-framework-cocoa"
version = "12.1"
source = { registry = "https://pypi.org/simple" }
dependencies = [
- { name = "pyobjc-core", marker = "sys_platform != 'win32'" },
+ { name = "pyobjc-core", marker = "(python_full_version >= '3.13' and sys_platform != 'win32') or sys_platform == 'darwin'" },
]
sdist = { url = "https://files.pythonhosted.org/packages/02/a3/16ca9a15e77c061a9250afbae2eae26f2e1579eb8ca9462ae2d2c71e1169/pyobjc_framework_cocoa-12.1.tar.gz", hash = "sha256:5556c87db95711b985d5efdaaf01c917ddd41d148b1e52a0c66b1a2e2c5c1640", size = 2772191, upload-time = "2025-11-14T10:13:02.069Z" }
wheels = [
@@ -7807,8 +7998,8 @@ name = "pyobjc-framework-quartz"
version = "12.1"
source = { registry = "https://pypi.org/simple" }
dependencies = [
- { name = "pyobjc-core", marker = "sys_platform != 'win32'" },
- { name = "pyobjc-framework-cocoa", marker = "sys_platform != 'win32'" },
+ { name = "pyobjc-core", marker = "(python_full_version >= '3.13' and sys_platform != 'win32') or sys_platform == 'darwin'" },
+ { name = "pyobjc-framework-cocoa", marker = "(python_full_version >= '3.13' and sys_platform != 'win32') or sys_platform == 'darwin'" },
]
sdist = { url = "https://files.pythonhosted.org/packages/94/18/cc59f3d4355c9456fc945eae7fe8797003c4da99212dd531ad1b0de8a0c6/pyobjc_framework_quartz-12.1.tar.gz", hash = "sha256:27f782f3513ac88ec9b6c82d9767eef95a5cf4175ce88a1e5a65875fee799608", size = 3159099, upload-time = "2025-11-14T10:21:24.31Z" }
wheels = [
@@ -8414,6 +8605,66 @@ wheels = [
{ url = "https://files.pythonhosted.org/packages/b1/ad/fa2d3e5c29a04ead7eaa731c7cd1f30f9ec3c77b3a578fdf90280797cbcb/rapidfuzz-3.14.3-pp311-pypy311_pp73-win_amd64.whl", hash = "sha256:56fefb4382bb12250f164250240b9dd7772e41c5c8ae976fd598a32292449cc5", size = 1511361, upload-time = "2025-11-01T11:54:49.057Z" },
]
+[[package]]
+name = "rasterio"
+version = "1.4.4"
+source = { registry = "https://pypi.org/simple" }
+dependencies = [
+ { name = "affine" },
+ { name = "attrs" },
+ { name = "certifi" },
+ { name = "click" },
+ { name = "click-plugins" },
+ { name = "cligj" },
+ { name = "numpy", version = "1.26.4", source = { registry = "https://pypi.org/simple" }, marker = "python_full_version < '3.13'" },
+ { name = "numpy", version = "2.2.0", source = { registry = "https://pypi.org/simple" }, marker = "python_full_version >= '3.13'" },
+ { name = "pyparsing" },
+]
+sdist = { url = "https://files.pythonhosted.org/packages/ec/fa/fce8dc9f09e5bc6520b6fc1b4ecfa510af9ca06eb42ad7bdff9c9b8989d0/rasterio-1.4.4.tar.gz", hash = "sha256:c95424e2c7f009b8f7df1095d645c52895cd332c0c2e1b4c2e073ea28b930320", size = 445004, upload-time = "2025-12-12T18:01:08.971Z" }
+wheels = [
+ { url = "https://files.pythonhosted.org/packages/7e/24/eedb9dfed1706c696b4f43ba9b85e830ce332f4f57ffcb7b6a4c4e66ade9/rasterio-1.4.4-cp310-cp310-macosx_14_0_arm64.whl", hash = "sha256:35401e84d4d0b239bd62b33d4ee68d7bb13b47c3b41078f4aad7ad7964e61c73", size = 21127567, upload-time = "2025-12-12T17:58:42.664Z" },
+ { url = "https://files.pythonhosted.org/packages/67/5f/482a24bf75bcd48236cd223d037f22abc6c08da6961e390e6a35249a9f58/rasterio-1.4.4-cp310-cp310-macosx_15_0_x86_64.whl", hash = "sha256:1f17fc9608b6b6666894a04e0118d3329e831a6347bc3650584d247a9d476fdd", size = 25735929, upload-time = "2025-12-12T17:58:46.503Z" },
+ { url = "https://files.pythonhosted.org/packages/b0/da/b988ffb1bb37cc4cb8a028447ab654a16dbac0b339d977fb9c8adc5bd995/rasterio-1.4.4-cp310-cp310-manylinux_2_28_aarch64.whl", hash = "sha256:1f0edb8cb30ff8f5be341583f69c115b7c36ad52bbbe7582345d32af115bc6b3", size = 34040467, upload-time = "2025-12-12T17:58:50.109Z" },
+ { url = "https://files.pythonhosted.org/packages/e0/0a/2eace22e990203d47a8fed4b174b87be50281bf3f5b2509cf3700036cbcc/rasterio-1.4.4-cp310-cp310-manylinux_2_28_x86_64.whl", hash = "sha256:5197da0e3dd09907bdb343717a49e8fb5229ffdbff0e583b874959ec41fa9558", size = 35339947, upload-time = "2025-12-12T17:58:53.269Z" },
+ { url = "https://files.pythonhosted.org/packages/40/e5/16acecbbaedd820c5d71f99f3bab73c00455078a414b511f6854364d3e1e/rasterio-1.4.4-cp310-cp310-win_amd64.whl", hash = "sha256:15109134c7b4770e6aeb8d45dc52c2603824805ba734323268a44f5a81756a7a", size = 25708679, upload-time = "2025-12-12T17:58:56.661Z" },
+ { url = "https://files.pythonhosted.org/packages/c6/0d/d3859e49ab94464de2623fec82c6798d8d7c8bea2473cd2696fc5e09f717/rasterio-1.4.4-cp311-cp311-macosx_14_0_arm64.whl", hash = "sha256:b8eea428b5f0c78a963f6003a19b60777df83a0aba8c28231d65431e32ac160e", size = 21144125, upload-time = "2025-12-12T17:58:59.511Z" },
+ { url = "https://files.pythonhosted.org/packages/aa/3c/97ba4b146309cdc0e36f289b02ac69465b026a21afc828e4e4e1dc39466a/rasterio-1.4.4-cp311-cp311-macosx_15_0_x86_64.whl", hash = "sha256:1cc0ea5aa0d22f5f349aa221674481de689b7b3a99607ce6bb58a29e5be54d17", size = 25746406, upload-time = "2025-12-12T17:59:02.902Z" },
+ { url = "https://files.pythonhosted.org/packages/ce/33/75f81bd837ac2336b24456fdb249597a4b9af2a212b7151f64d09022be36/rasterio-1.4.4-cp311-cp311-manylinux_2_28_aarch64.whl", hash = "sha256:7eb25b23666b29dadfc49a59206cead62c99190584b61771bba0e95f7da06801", size = 34587242, upload-time = "2025-12-12T17:59:05.848Z" },
+ { url = "https://files.pythonhosted.org/packages/f9/77/3869a426f6e752dde13f3868cdf16253ca0214f92107db79c1583c9aa07b/rasterio-1.4.4-cp311-cp311-manylinux_2_28_x86_64.whl", hash = "sha256:e24b7b8c2df801dde2a1dffb44c58902bd76b5cab740dc11de4ff9963992a71a", size = 35881871, upload-time = "2025-12-12T17:59:09.779Z" },
+ { url = "https://files.pythonhosted.org/packages/66/d0/3818859ddbd3750d0ef5a6580a3272e81764286d943c689dd41e49b8b786/rasterio-1.4.4-cp311-cp311-win_amd64.whl", hash = "sha256:0718630f607be2f5742d8e4b34b434746fd788a192d77eefc9bb924399fea802", size = 25716477, upload-time = "2025-12-12T17:59:13.519Z" },
+ { url = "https://files.pythonhosted.org/packages/4b/02/039eb4970c93aaef4c9eb1ee159abad18e6e7f932c2eed575c95f78d94f6/rasterio-1.4.4-cp311-cp311-win_arm64.whl", hash = "sha256:0308ff4762ae9eb40a991f12d758626b59af4376b13675480391dd7295d17bbf", size = 24075993, upload-time = "2025-12-12T17:59:16.407Z" },
+ { url = "https://files.pythonhosted.org/packages/4c/fc/63d89ddfcb4643730553683ee322566b9b15fe56d026e4c21c4f4f5d9d26/rasterio-1.4.4-cp312-cp312-macosx_14_0_arm64.whl", hash = "sha256:f3c4f0cbd188f893011f2a0a6dc2852b3892799b3a0d79eddf92f2b115ec7ed7", size = 21120715, upload-time = "2025-12-12T17:59:19.35Z" },
+ { url = "https://files.pythonhosted.org/packages/43/70/2c003f76a23dbb078fdee35c8e2ec490d2ad8982f4dc956ba08b56027b87/rasterio-1.4.4-cp312-cp312-macosx_15_0_x86_64.whl", hash = "sha256:6fce26090b9f509eab337228420145947c491a13628965410f25bc3e6e05cf75", size = 25732944, upload-time = "2025-12-12T17:59:22.533Z" },
+ { url = "https://files.pythonhosted.org/packages/f6/cc/4a8e92362c0ff496dd1007c3dcba66e9ededf1a45eca8ad1db302b071c49/rasterio-1.4.4-cp312-cp312-manylinux_2_28_aarch64.whl", hash = "sha256:c1c722da390dc264aeccdc0dc200ca37923875d910ca4cd5bec0fec351bb818e", size = 34295209, upload-time = "2025-12-12T17:59:26.035Z" },
+ { url = "https://files.pythonhosted.org/packages/e6/6d/717d2dec47fbefad33ca0d27bd5f0d543b1d1bc9fcab5ef82a13adaaf38d/rasterio-1.4.4-cp312-cp312-manylinux_2_28_x86_64.whl", hash = "sha256:98b6dfb8282b2a54b9d75c3dc8d2520a69bbc66916c7d43de8e0bbf6e0240ca1", size = 35661866, upload-time = "2025-12-12T17:59:29.928Z" },
+ { url = "https://files.pythonhosted.org/packages/ed/60/ae3351fba2726ec0976974ce2eb030c159edd3363b8771e832b8db571c24/rasterio-1.4.4-cp312-cp312-win_amd64.whl", hash = "sha256:9513f4c7a6d93b45098f8dff2421fa9516604e3bfbf35aa144484a88d36a321f", size = 25682853, upload-time = "2025-12-12T17:59:35.869Z" },
+ { url = "https://files.pythonhosted.org/packages/38/ee/35387296bbacfc5cbbb4273228b1b959793d3ce38b0402a07f11a248420b/rasterio-1.4.4-cp312-cp312-win_arm64.whl", hash = "sha256:60b49a482e0f12f12ce9d2cc3090add02f89f3d422e85f2cffaa9207adb83c04", size = 24043249, upload-time = "2025-12-12T17:59:39.915Z" },
+ { url = "https://files.pythonhosted.org/packages/c1/fe/e3e37041c49956f4f4cbe473c3fe290aaba96ed20e9c07da304e0cad2015/rasterio-1.4.4-cp313-cp313-macosx_14_0_arm64.whl", hash = "sha256:df26c96aa81ffbd0b33189680859211eadf9950123c21579f84de73bb0f91d81", size = 21107336, upload-time = "2025-12-12T17:59:43.585Z" },
+ { url = "https://files.pythonhosted.org/packages/f3/02/c217fdcc8e80a4b7d1b1bc4529d78f98452816e9add53ff8742049a77ae7/rasterio-1.4.4-cp313-cp313-macosx_15_0_x86_64.whl", hash = "sha256:b3af0ecc922a80f3755516629f7948e37bade9077b5f5c12a3869a5e7f01619b", size = 25719929, upload-time = "2025-12-12T17:59:47.64Z" },
+ { url = "https://files.pythonhosted.org/packages/c0/d0/7f177f37bc9595d809dabb0073abd0c42358469f6b10875192b46331c652/rasterio-1.4.4-cp313-cp313-manylinux_2_28_aarch64.whl", hash = "sha256:7ce3b0f9a22e95a27790087908753973644d7c3877d495ec9bd6e04a25233ca4", size = 34198845, upload-time = "2025-12-12T17:59:52.405Z" },
+ { url = "https://files.pythonhosted.org/packages/7b/84/66c0d9cca2a09074ec2ce6fffa87709ca51b0d197ae742d835e841bac660/rasterio-1.4.4-cp313-cp313-manylinux_2_28_x86_64.whl", hash = "sha256:c072450caa96428b1218b030500bb908fd6f09bc013a88969ff81a124b6a112a", size = 35576074, upload-time = "2025-12-12T17:59:56.392Z" },
+ { url = "https://files.pythonhosted.org/packages/32/68/f7df5478458ace2fa50be43e9fab1a39957a0e71afaa3e6147ec289e0fc8/rasterio-1.4.4-cp313-cp313-win_amd64.whl", hash = "sha256:16ee92ef10c0ba89f45f9c2b40fca9f971f357385f04ee9b716fb09cbd9ce20c", size = 25680573, upload-time = "2025-12-12T18:00:00.45Z" },
+ { url = "https://files.pythonhosted.org/packages/34/e5/1bdaccb658430dfd391ad4a63d206546f36639d7e4130bf31f125c6525b4/rasterio-1.4.4-cp313-cp313-win_arm64.whl", hash = "sha256:65c10afe64b5e488185aaff0b659e08eda22c89285b54a3e433b80e6c6621770", size = 24040367, upload-time = "2025-12-12T18:00:04.443Z" },
+ { url = "https://files.pythonhosted.org/packages/32/76/54643a7d1d650fd7f1acea9093c298603e4c01bba6f90be2254310b48507/rasterio-1.4.4-cp313-cp313t-macosx_14_0_arm64.whl", hash = "sha256:18c2c1130e789dc2771d0aa5ec4b56d5b8a0097c648ccb94882d5ff3ab55c928", size = 21247203, upload-time = "2025-12-12T18:00:07.547Z" },
+ { url = "https://files.pythonhosted.org/packages/76/ef/434b4849ccd6a3e03a0b1ac37c963c1771564945745613d15c5d96ce768d/rasterio-1.4.4-cp313-cp313t-macosx_15_0_x86_64.whl", hash = "sha256:2d1654b7ffa6f3dde42c5fd27159ae45148c11e352de26f12fe7313a3236aeed", size = 25822050, upload-time = "2025-12-12T18:00:11.081Z" },
+ { url = "https://files.pythonhosted.org/packages/2d/fa/fe9a478aa0cde246da58baeb0df3248c7ca174e4d9c9b27e81b504e40a76/rasterio-1.4.4-cp313-cp313t-manylinux_2_28_aarch64.whl", hash = "sha256:c4022cbddb659856e120603b12233cec8913ae760fff220657ce888c3c6b9f9d", size = 34833783, upload-time = "2025-12-12T18:00:14.525Z" },
+ { url = "https://files.pythonhosted.org/packages/04/cd/ed4716590dbcd4b8ae633417d758564e510bee4d6aaac5050a0f6d5179c5/rasterio-1.4.4-cp313-cp313t-manylinux_2_28_x86_64.whl", hash = "sha256:96b88880551a07b7a3b50439483cefbd9af91a09e19ff2b736815994e5671314", size = 35738114, upload-time = "2025-12-12T18:00:17.96Z" },
+ { url = "https://files.pythonhosted.org/packages/7e/29/da7050d11ba1d041e0333ac14768e6e9ca1aa2b9fa8416f317d2650ed276/rasterio-1.4.4-cp313-cp313t-win_amd64.whl", hash = "sha256:def75d486d0ab8f306f918a913c425ed57159495518c54efe8e18d5164d37d90", size = 25896835, upload-time = "2025-12-12T18:00:21.411Z" },
+ { url = "https://files.pythonhosted.org/packages/88/80/304dbe5434c4aa8dfaf90480c16d770161796a6a61fa88e72e8a402153df/rasterio-1.4.4-cp313-cp313t-win_arm64.whl", hash = "sha256:770b7e86f6c565e6f9cf30f6fa4479a5a2bab4e10ff44fe7acfd518ca4a71d1b", size = 24128074, upload-time = "2025-12-12T18:00:24.653Z" },
+ { url = "https://files.pythonhosted.org/packages/03/01/d5a3dc51cd5fef62b76ecc77d33c1ca20de305fed7e16c71bcdf4858e466/rasterio-1.4.4-cp314-cp314-macosx_14_0_arm64.whl", hash = "sha256:019693f14a83ae9225cb57c16e466901d0e6284962dcf13a9f4bb1175b979011", size = 21120237, upload-time = "2025-12-12T18:00:27.723Z" },
+ { url = "https://files.pythonhosted.org/packages/50/da/db18362602b17327c0e00c9e9c0847c1c4ac657c1a289169ca06a26faccb/rasterio-1.4.4-cp314-cp314-macosx_15_0_x86_64.whl", hash = "sha256:87d7c3e97e3b40c9041d1602e2dcb4fc2d88abe6c645fccb4939dec297a91cf8", size = 25720506, upload-time = "2025-12-12T18:00:30.592Z" },
+ { url = "https://files.pythonhosted.org/packages/5a/8f/a15d66c9c05bffb176c9707ef1f2bfcf9c0b835272937c80ac7207a20b5c/rasterio-1.4.4-cp314-cp314-manylinux_2_28_aarch64.whl", hash = "sha256:a2401e4c43a31c7382154d4042b60a63b9bca5886802983c5c9362cdc5b09548", size = 34153931, upload-time = "2025-12-12T18:00:33.852Z" },
+ { url = "https://files.pythonhosted.org/packages/05/2d/cd778286b910db7a3f0bc1743ca362173f1fbb7365137e4982ca857b6d26/rasterio-1.4.4-cp314-cp314-manylinux_2_28_x86_64.whl", hash = "sha256:6c4287d8934d953f7870b8e2a1df1096fbf47eba39ad0f777a31ea500f4e5010", size = 35421139, upload-time = "2025-12-12T18:00:37.482Z" },
+ { url = "https://files.pythonhosted.org/packages/70/97/13a2e33aede8d7a42178c696a6a93868d1f9560f73de05033a1675f0806a/rasterio-1.4.4-cp314-cp314-win_amd64.whl", hash = "sha256:c3ba1871549221140661227dd4fa1f9a472ded4a6d2f2c2e367b0648bb15b99d", size = 26419132, upload-time = "2025-12-12T18:00:40.871Z" },
+ { url = "https://files.pythonhosted.org/packages/27/d8/2dcfcb362d6a2fd07c14cfb803a345a7926d4d9fb6243e196df105671e97/rasterio-1.4.4-cp314-cp314-win_arm64.whl", hash = "sha256:7c9d7dc824cb8d222808be153643cd4e65ea3e1f66019ada1ccd630221edfe30", size = 24800998, upload-time = "2025-12-12T18:00:45.332Z" },
+ { url = "https://files.pythonhosted.org/packages/13/f8/16e9b648e7f16cadb41df7c0116dbab26b4a2ba02c85cbe3f744065bdf56/rasterio-1.4.4-cp314-cp314t-macosx_14_0_arm64.whl", hash = "sha256:98e17bded830a59992d9f8f8d9f227ce1c4be0694930afcc4360358f5cb1a5db", size = 21247046, upload-time = "2025-12-12T18:00:49.429Z" },
+ { url = "https://files.pythonhosted.org/packages/a8/ea/f3dc3a25d7591821d488f5c5eb89f6abcd1f5c8e2ef4bd2792f965cbc9c8/rasterio-1.4.4-cp314-cp314t-macosx_15_0_x86_64.whl", hash = "sha256:56134ca203f952855e60774b06672033cf65057eb9810fcc5c1a75f1921053a3", size = 25821677, upload-time = "2025-12-12T18:00:52.458Z" },
+ { url = "https://files.pythonhosted.org/packages/2e/d3/1e038350218e852f904c8dc4ab751aa023a2e82e68998767b7b42e33832c/rasterio-1.4.4-cp314-cp314t-manylinux_2_28_aarch64.whl", hash = "sha256:52edde65515b33fe4314c8a44a9ee2fc00b550deed6d56e1a8d085d42bbca3e6", size = 34829572, upload-time = "2025-12-12T18:00:56.294Z" },
+ { url = "https://files.pythonhosted.org/packages/0b/ce/28abf7a5f5d9cb014c2e14cc396bebe953b3deefbf604d49f4322e73fa35/rasterio-1.4.4-cp314-cp314t-manylinux_2_28_x86_64.whl", hash = "sha256:d61d3f2c171c64050bd75e54a5d964ff7f165b3f5d2b92c9ee09b9716aa1b8bf", size = 35735171, upload-time = "2025-12-12T18:00:59.531Z" },
+ { url = "https://files.pythonhosted.org/packages/54/91/1ce35cfda2d56dacd6395faf20a5290268bd9009c53393ac42b5f9bb2c4c/rasterio-1.4.4-cp314-cp314t-win_amd64.whl", hash = "sha256:40137fe512c0d6e96c0167a0ae4e56d82c488f244163c45494b7392e51c844de", size = 26700712, upload-time = "2025-12-12T18:01:03.023Z" },
+ { url = "https://files.pythonhosted.org/packages/3b/33/4d13f48a8f01d782ffc1eece20821586518f3f515dca7cf152bca9fd22d4/rasterio-1.4.4-cp314-cp314t-win_arm64.whl", hash = "sha256:29ec3a794454b5bb255c9c0374cc380030a8a1e295c81eee7feb036802d2a9e3", size = 24875933, upload-time = "2025-12-12T18:01:06.134Z" },
+]
+
[[package]]
name = "readabilipy"
version = "0.3.0"
@@ -8938,6 +9189,40 @@ wheels = [
{ url = "https://files.pythonhosted.org/packages/aa/70/f8724f31abc0b329ca98b33d73c14020168babcf71b0cba3cded5d9d0e66/ruff-0.7.4-py3-none-win_arm64.whl", hash = "sha256:11bff065102c3ae9d3ea4dc9ecdfe5a5171349cdd0787c1fc64761212fc9cf1f", size = 8851590, upload-time = "2024-11-15T11:33:09.664Z" },
]
+[[package]]
+name = "ruptures"
+version = "1.1.10"
+source = { registry = "https://pypi.org/simple" }
+dependencies = [
+ { name = "numpy", version = "1.26.4", source = { registry = "https://pypi.org/simple" }, marker = "python_full_version < '3.13'" },
+ { name = "numpy", version = "2.2.0", source = { registry = "https://pypi.org/simple" }, marker = "python_full_version >= '3.13'" },
+ { name = "scipy", version = "1.15.3", source = { registry = "https://pypi.org/simple" }, marker = "python_full_version < '3.11'" },
+ { name = "scipy", version = "1.16.3", source = { registry = "https://pypi.org/simple" }, marker = "python_full_version >= '3.11'" },
+]
+sdist = { url = "https://files.pythonhosted.org/packages/64/32/3bcf5a62479b4d83187f872fc68b918b59285f560bee4f37c5d49b1d957a/ruptures-1.1.10.tar.gz", hash = "sha256:76b998f10709045e91a5f44173dc574bf98a106fd3bf22ec3c63b298a02df031", size = 320689, upload-time = "2025-09-10T09:48:02.917Z" }
+wheels = [
+ { url = "https://files.pythonhosted.org/packages/f3/6b/fbd0f47c95c2e55bfe21447fb5f3878692f1a3686e2f65e70bc7dbbea15b/ruptures-1.1.10-cp310-cp310-macosx_10_9_x86_64.whl", hash = "sha256:d2dae4173db1ffab6cf1eead44825b360e354b3c37f7316b7a827dea6a34b577", size = 497431, upload-time = "2025-09-10T09:47:30.729Z" },
+ { url = "https://files.pythonhosted.org/packages/e1/6e/3fbe3d105bc9100535682dcae147a6f93bde7ebc29af7795236204b7952e/ruptures-1.1.10-cp310-cp310-macosx_11_0_arm64.whl", hash = "sha256:20ea4ce1e7503bef60aa879196343acea660905f85692c9612d1a1f787e21da6", size = 495403, upload-time = "2025-09-10T09:47:32.478Z" },
+ { url = "https://files.pythonhosted.org/packages/f0/61/e0015e0a95a310edfcf1dc3413ccb4afad1905e33511b78768b32647e14f/ruptures-1.1.10-cp310-cp310-manylinux2014_aarch64.manylinux_2_17_aarch64.manylinux_2_28_aarch64.whl", hash = "sha256:8810f3c9f71262fa5d4866ea0a8f2d0ea4e15a9d28d868c97043d260c8c87bc8", size = 1282302, upload-time = "2025-09-10T09:47:33.817Z" },
+ { url = "https://files.pythonhosted.org/packages/48/8f/36bf50751f11a2b2e81b24b502fbc386c7ae2033a3faf3f7b4502dbdd7fd/ruptures-1.1.10-cp310-cp310-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl", hash = "sha256:e1a62f024d3714facca48e8859ba2602367af0c7ca1680cffded1cbff7cf264f", size = 1289697, upload-time = "2025-09-10T09:47:35.229Z" },
+ { url = "https://files.pythonhosted.org/packages/7e/d3/eb3fb911c23019ac6fdce873a959c63c344780a391ca55355c6fdb088912/ruptures-1.1.10-cp310-cp310-win_amd64.whl", hash = "sha256:171fe4f61044a0520e1cd4e429f69242570939700aa4990b3401bf9a8d61aebe", size = 476077, upload-time = "2025-09-10T09:47:36.417Z" },
+ { url = "https://files.pythonhosted.org/packages/ae/ea/b561e98a69e412c29a808cdb25acff73005b26d0313632b7ec29a5846f8c/ruptures-1.1.10-cp311-cp311-macosx_10_9_x86_64.whl", hash = "sha256:4038c09d8148bde4c3689adc3570dd3728163326a0b7baa82474641b8276f53e", size = 496985, upload-time = "2025-09-10T09:47:37.754Z" },
+ { url = "https://files.pythonhosted.org/packages/c6/7a/0026c5a85c11d6eb0202e828b5fa8dc829615f6bb61155463827ba1d2e5d/ruptures-1.1.10-cp311-cp311-macosx_11_0_arm64.whl", hash = "sha256:ef2f26424b267a3da46b05b6d78322249ab1325754c61cafd9580d4eef0011ea", size = 494748, upload-time = "2025-09-10T09:47:38.798Z" },
+ { url = "https://files.pythonhosted.org/packages/85/81/06be598b7dedbcd63683296ebae683dbdab62bb0134fc8a6fd05a4b74e03/ruptures-1.1.10-cp311-cp311-manylinux2014_aarch64.manylinux_2_17_aarch64.manylinux_2_28_aarch64.whl", hash = "sha256:728ec63779ebb94341caaca70c57d01eb6a22cb98d7e3079935a73a43febcb30", size = 1335652, upload-time = "2025-09-10T09:47:40.118Z" },
+ { url = "https://files.pythonhosted.org/packages/98/c0/0d211972132f2161c594a67552fd0eb30697750c13e7351ab9dc0bb1f2a5/ruptures-1.1.10-cp311-cp311-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl", hash = "sha256:14860e1b1bbb439837320147dcd71ad31fc76a35988de94b5aa90bb0d22b1022", size = 1341581, upload-time = "2025-09-10T09:47:41.208Z" },
+ { url = "https://files.pythonhosted.org/packages/d8/a9/14aa9d2413ad7c29ab9c983cf5f6ce65202c1a63af56a56d1ab075bcf91d/ruptures-1.1.10-cp311-cp311-win_amd64.whl", hash = "sha256:733adb020910dbcfc6fdbca7295db28295177a927a70002c7080f2a4bfbf1840", size = 475907, upload-time = "2025-09-10T09:47:42.727Z" },
+ { url = "https://files.pythonhosted.org/packages/c6/18/2b93d310a3a96393d48ee06363db860c576dcff3f925c8873a0ca7be219f/ruptures-1.1.10-cp312-cp312-macosx_10_13_x86_64.whl", hash = "sha256:7a7f614c63f2cecd76d7b5f9f79ff34712234d274a41867428ace4a3a45757c8", size = 499197, upload-time = "2025-09-10T09:47:43.707Z" },
+ { url = "https://files.pythonhosted.org/packages/67/28/a25c5eecf1b9df53d27482c953c573515ab0056e64b0e9173312344fc169/ruptures-1.1.10-cp312-cp312-macosx_11_0_arm64.whl", hash = "sha256:14e3aa451220a05c6a7782a3b31fdd4fc578d39b77404dc94649bcae5eebd1db", size = 496449, upload-time = "2025-09-10T09:47:45.206Z" },
+ { url = "https://files.pythonhosted.org/packages/00/68/e54eba1861ab1be8d63fe019ce57632422ae8d0e8979b897d3f2fb4ca33d/ruptures-1.1.10-cp312-cp312-manylinux2014_aarch64.manylinux_2_17_aarch64.manylinux_2_28_aarch64.whl", hash = "sha256:01fb8847a58cbb158103c1810022ea29e3fa3291d6531631bc6134f636ea2fc1", size = 1327050, upload-time = "2025-09-10T09:47:46.228Z" },
+ { url = "https://files.pythonhosted.org/packages/78/57/5d00e8500b4d906809b86a23390c035e40460f2ff90acd134a6198320428/ruptures-1.1.10-cp312-cp312-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl", hash = "sha256:0930cecc7ec1c9af0b1a7da6fb769d298691e077c6cba8daad6ebaef49ed8e80", size = 1346678, upload-time = "2025-09-10T09:47:47.634Z" },
+ { url = "https://files.pythonhosted.org/packages/a1/0a/df3f6843d4715e571b1bf4c075802c1cd002d1e462a1fc54faeda79a3b21/ruptures-1.1.10-cp312-cp312-win_amd64.whl", hash = "sha256:4be700aa3fee9057667062343a2fa728e25765f457ea54dac116fd2f4b7f49c9", size = 477643, upload-time = "2025-09-10T09:47:48.799Z" },
+ { url = "https://files.pythonhosted.org/packages/29/40/087c4deede27066eb9f075c3768749366030bb24fd2c490fb1affe0b8a3f/ruptures-1.1.10-cp313-cp313-macosx_10_13_x86_64.whl", hash = "sha256:29038a863f52c026d950066a62d23719304273e2cef41159259422a055f04fc0", size = 497249, upload-time = "2025-09-10T09:47:50.204Z" },
+ { url = "https://files.pythonhosted.org/packages/c6/84/f5fe5ded842d1c57ecd53db71f1e9c099ce14d7d2c2cc997f0351ef6f0cb/ruptures-1.1.10-cp313-cp313-macosx_11_0_arm64.whl", hash = "sha256:bfaf4dbf51ae74a4f8893ba36be98912cd4bd7f2a94a79a5ff0d2edca65c21f5", size = 494490, upload-time = "2025-09-10T09:47:51.584Z" },
+ { url = "https://files.pythonhosted.org/packages/0f/26/29499f16b62220ce3b0bb75a8f8de921814e55c223e3263df7f2733eb5a7/ruptures-1.1.10-cp313-cp313-manylinux2014_aarch64.manylinux_2_17_aarch64.manylinux_2_28_aarch64.whl", hash = "sha256:fea4d0049051530e73babc2f44e75e6ba520bb90fe5bfa60d59c4d054180893e", size = 1311189, upload-time = "2025-09-10T09:47:52.701Z" },
+ { url = "https://files.pythonhosted.org/packages/f3/dc/f0a268190b233c4d4b9fa50cd7078bbc536bf319d724218087b2cb4a1138/ruptures-1.1.10-cp313-cp313-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl", hash = "sha256:fada68f6617e26138151a1ce6f73932e84ae01119e48be005773a40363454e51", size = 1330363, upload-time = "2025-09-10T09:47:53.999Z" },
+ { url = "https://files.pythonhosted.org/packages/bd/29/1fe6a1b1811f64bdd35b61300e9d57f68d630d271c92423553a30072d5c5/ruptures-1.1.10-cp313-cp313-win_amd64.whl", hash = "sha256:39f3ece91327440fbebca84155b39435970ccc0f52bd3e33878aaff157d04e01", size = 477215, upload-time = "2025-09-10T09:47:55.027Z" },
+]
+
[[package]]
name = "safetensors"
version = "0.7.0"
@@ -9008,6 +9293,49 @@ tor = [
{ name = "stem" },
]
+[[package]]
+name = "scikit-image"
+version = "0.25.2"
+source = { registry = "https://pypi.org/simple" }
+dependencies = [
+ { name = "imageio" },
+ { name = "lazy-loader" },
+ { name = "networkx", version = "3.4.2", source = { registry = "https://pypi.org/simple" }, marker = "python_full_version < '3.11'" },
+ { name = "networkx", version = "3.6", source = { registry = "https://pypi.org/simple" }, marker = "python_full_version >= '3.11'" },
+ { name = "numpy", version = "1.26.4", source = { registry = "https://pypi.org/simple" }, marker = "python_full_version < '3.13'" },
+ { name = "numpy", version = "2.2.0", source = { registry = "https://pypi.org/simple" }, marker = "python_full_version >= '3.13'" },
+ { name = "packaging" },
+ { name = "pillow" },
+ { name = "scipy", version = "1.15.3", source = { registry = "https://pypi.org/simple" }, marker = "python_full_version < '3.11'" },
+ { name = "scipy", version = "1.16.3", source = { registry = "https://pypi.org/simple" }, marker = "python_full_version >= '3.11'" },
+ { name = "tifffile", version = "2025.5.10", source = { registry = "https://pypi.org/simple" }, marker = "python_full_version < '3.11'" },
+ { name = "tifffile", version = "2025.12.12", source = { registry = "https://pypi.org/simple" }, marker = "python_full_version >= '3.11'" },
+]
+sdist = { url = "https://files.pythonhosted.org/packages/c7/a8/3c0f256012b93dd2cb6fda9245e9f4bff7dc0486880b248005f15ea2255e/scikit_image-0.25.2.tar.gz", hash = "sha256:e5a37e6cd4d0c018a7a55b9d601357e3382826d3888c10d0213fc63bff977dde", size = 22693594, upload-time = "2025-02-18T18:05:24.538Z" }
+wheels = [
+ { url = "https://files.pythonhosted.org/packages/11/cb/016c63f16065c2d333c8ed0337e18a5cdf9bc32d402e4f26b0db362eb0e2/scikit_image-0.25.2-cp310-cp310-macosx_10_9_x86_64.whl", hash = "sha256:d3278f586793176599df6a4cf48cb6beadae35c31e58dc01a98023af3dc31c78", size = 13988922, upload-time = "2025-02-18T18:04:11.069Z" },
+ { url = "https://files.pythonhosted.org/packages/30/ca/ff4731289cbed63c94a0c9a5b672976603118de78ed21910d9060c82e859/scikit_image-0.25.2-cp310-cp310-macosx_12_0_arm64.whl", hash = "sha256:5c311069899ce757d7dbf1d03e32acb38bb06153236ae77fcd820fd62044c063", size = 13192698, upload-time = "2025-02-18T18:04:15.362Z" },
+ { url = "https://files.pythonhosted.org/packages/39/6d/a2aadb1be6d8e149199bb9b540ccde9e9622826e1ab42fe01de4c35ab918/scikit_image-0.25.2-cp310-cp310-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:be455aa7039a6afa54e84f9e38293733a2622b8c2fb3362b822d459cc5605e99", size = 14153634, upload-time = "2025-02-18T18:04:18.496Z" },
+ { url = "https://files.pythonhosted.org/packages/96/08/916e7d9ee4721031b2f625db54b11d8379bd51707afaa3e5a29aecf10bc4/scikit_image-0.25.2-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:a4c464b90e978d137330be433df4e76d92ad3c5f46a22f159520ce0fdbea8a09", size = 14767545, upload-time = "2025-02-18T18:04:22.556Z" },
+ { url = "https://files.pythonhosted.org/packages/5f/ee/c53a009e3997dda9d285402f19226fbd17b5b3cb215da391c4ed084a1424/scikit_image-0.25.2-cp310-cp310-win_amd64.whl", hash = "sha256:60516257c5a2d2f74387c502aa2f15a0ef3498fbeaa749f730ab18f0a40fd054", size = 12812908, upload-time = "2025-02-18T18:04:26.364Z" },
+ { url = "https://files.pythonhosted.org/packages/c4/97/3051c68b782ee3f1fb7f8f5bb7d535cf8cb92e8aae18fa9c1cdf7e15150d/scikit_image-0.25.2-cp311-cp311-macosx_10_9_x86_64.whl", hash = "sha256:f4bac9196fb80d37567316581c6060763b0f4893d3aca34a9ede3825bc035b17", size = 14003057, upload-time = "2025-02-18T18:04:30.395Z" },
+ { url = "https://files.pythonhosted.org/packages/19/23/257fc696c562639826065514d551b7b9b969520bd902c3a8e2fcff5b9e17/scikit_image-0.25.2-cp311-cp311-macosx_12_0_arm64.whl", hash = "sha256:d989d64ff92e0c6c0f2018c7495a5b20e2451839299a018e0e5108b2680f71e0", size = 13180335, upload-time = "2025-02-18T18:04:33.449Z" },
+ { url = "https://files.pythonhosted.org/packages/ef/14/0c4a02cb27ca8b1e836886b9ec7c9149de03053650e9e2ed0625f248dd92/scikit_image-0.25.2-cp311-cp311-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:b2cfc96b27afe9a05bc92f8c6235321d3a66499995675b27415e0d0c76625173", size = 14144783, upload-time = "2025-02-18T18:04:36.594Z" },
+ { url = "https://files.pythonhosted.org/packages/dd/9b/9fb556463a34d9842491d72a421942c8baff4281025859c84fcdb5e7e602/scikit_image-0.25.2-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:24cc986e1f4187a12aa319f777b36008764e856e5013666a4a83f8df083c2641", size = 14785376, upload-time = "2025-02-18T18:04:39.856Z" },
+ { url = "https://files.pythonhosted.org/packages/de/ec/b57c500ee85885df5f2188f8bb70398481393a69de44a00d6f1d055f103c/scikit_image-0.25.2-cp311-cp311-win_amd64.whl", hash = "sha256:b4f6b61fc2db6340696afe3db6b26e0356911529f5f6aee8c322aa5157490c9b", size = 12791698, upload-time = "2025-02-18T18:04:42.868Z" },
+ { url = "https://files.pythonhosted.org/packages/35/8c/5df82881284459f6eec796a5ac2a0a304bb3384eec2e73f35cfdfcfbf20c/scikit_image-0.25.2-cp312-cp312-macosx_10_13_x86_64.whl", hash = "sha256:8db8dd03663112783221bf01ccfc9512d1cc50ac9b5b0fe8f4023967564719fb", size = 13986000, upload-time = "2025-02-18T18:04:47.156Z" },
+ { url = "https://files.pythonhosted.org/packages/ce/e6/93bebe1abcdce9513ffec01d8af02528b4c41fb3c1e46336d70b9ed4ef0d/scikit_image-0.25.2-cp312-cp312-macosx_12_0_arm64.whl", hash = "sha256:483bd8cc10c3d8a7a37fae36dfa5b21e239bd4ee121d91cad1f81bba10cfb0ed", size = 13235893, upload-time = "2025-02-18T18:04:51.049Z" },
+ { url = "https://files.pythonhosted.org/packages/53/4b/eda616e33f67129e5979a9eb33c710013caa3aa8a921991e6cc0b22cea33/scikit_image-0.25.2-cp312-cp312-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:9d1e80107bcf2bf1291acfc0bf0425dceb8890abe9f38d8e94e23497cbf7ee0d", size = 14178389, upload-time = "2025-02-18T18:04:54.245Z" },
+ { url = "https://files.pythonhosted.org/packages/6b/b5/b75527c0f9532dd8a93e8e7cd8e62e547b9f207d4c11e24f0006e8646b36/scikit_image-0.25.2-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:a17e17eb8562660cc0d31bb55643a4da996a81944b82c54805c91b3fe66f4824", size = 15003435, upload-time = "2025-02-18T18:04:57.586Z" },
+ { url = "https://files.pythonhosted.org/packages/34/e3/49beb08ebccda3c21e871b607c1cb2f258c3fa0d2f609fed0a5ba741b92d/scikit_image-0.25.2-cp312-cp312-win_amd64.whl", hash = "sha256:bdd2b8c1de0849964dbc54037f36b4e9420157e67e45a8709a80d727f52c7da2", size = 12899474, upload-time = "2025-02-18T18:05:01.166Z" },
+ { url = "https://files.pythonhosted.org/packages/e6/7c/9814dd1c637f7a0e44342985a76f95a55dd04be60154247679fd96c7169f/scikit_image-0.25.2-cp313-cp313-macosx_10_13_x86_64.whl", hash = "sha256:7efa888130f6c548ec0439b1a7ed7295bc10105458a421e9bf739b457730b6da", size = 13921841, upload-time = "2025-02-18T18:05:03.963Z" },
+ { url = "https://files.pythonhosted.org/packages/84/06/66a2e7661d6f526740c309e9717d3bd07b473661d5cdddef4dd978edab25/scikit_image-0.25.2-cp313-cp313-macosx_12_0_arm64.whl", hash = "sha256:dd8011efe69c3641920614d550f5505f83658fe33581e49bed86feab43a180fc", size = 13196862, upload-time = "2025-02-18T18:05:06.986Z" },
+ { url = "https://files.pythonhosted.org/packages/4e/63/3368902ed79305f74c2ca8c297dfeb4307269cbe6402412668e322837143/scikit_image-0.25.2-cp313-cp313-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:28182a9d3e2ce3c2e251383bdda68f8d88d9fff1a3ebe1eb61206595c9773341", size = 14117785, upload-time = "2025-02-18T18:05:10.69Z" },
+ { url = "https://files.pythonhosted.org/packages/cd/9b/c3da56a145f52cd61a68b8465d6a29d9503bc45bc993bb45e84371c97d94/scikit_image-0.25.2-cp313-cp313-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:b8abd3c805ce6944b941cfed0406d88faeb19bab3ed3d4b50187af55cf24d147", size = 14977119, upload-time = "2025-02-18T18:05:13.871Z" },
+ { url = "https://files.pythonhosted.org/packages/8a/97/5fcf332e1753831abb99a2525180d3fb0d70918d461ebda9873f66dcc12f/scikit_image-0.25.2-cp313-cp313-win_amd64.whl", hash = "sha256:64785a8acefee460ec49a354706db0b09d1f325674107d7fa3eadb663fb56d6f", size = 12885116, upload-time = "2025-02-18T18:05:17.844Z" },
+ { url = "https://files.pythonhosted.org/packages/10/cc/75e9f17e3670b5ed93c32456fda823333c6279b144cd93e2c03aa06aa472/scikit_image-0.25.2-cp313-cp313t-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:330d061bd107d12f8d68f1d611ae27b3b813b8cdb0300a71d07b1379178dd4cd", size = 13862801, upload-time = "2025-02-18T18:05:20.783Z" },
+]
+
[[package]]
name = "scikit-learn"
version = "1.7.2"
@@ -9060,7 +9388,9 @@ version = "1.15.3"
source = { registry = "https://pypi.org/simple" }
resolution-markers = [
"python_full_version < '3.11' and sys_platform == 'win32'",
- "python_full_version < '3.11' and sys_platform != 'win32'",
+ "python_full_version < '3.11' and sys_platform == 'darwin'",
+ "python_full_version < '3.11' and platform_machine == 'aarch64' and sys_platform == 'linux'",
+ "(python_full_version < '3.11' and platform_machine != 'aarch64' and sys_platform == 'linux') or (python_full_version < '3.11' and sys_platform != 'darwin' and sys_platform != 'linux' and sys_platform != 'win32')",
]
dependencies = [
{ name = "numpy", version = "1.26.4", source = { registry = "https://pypi.org/simple" }, marker = "python_full_version < '3.11'" },
@@ -9124,9 +9454,13 @@ resolution-markers = [
"python_full_version == '3.13.*' and sys_platform == 'win32'",
"python_full_version == '3.13.*' and sys_platform != 'win32'",
"python_full_version == '3.12.*' and sys_platform == 'win32'",
- "python_full_version == '3.12.*' and sys_platform != 'win32'",
+ "python_full_version == '3.12.*' and sys_platform == 'darwin'",
+ "python_full_version == '3.12.*' and platform_machine == 'aarch64' and sys_platform == 'linux'",
+ "(python_full_version == '3.12.*' and platform_machine != 'aarch64' and sys_platform == 'linux') or (python_full_version == '3.12.*' and sys_platform != 'darwin' and sys_platform != 'linux' and sys_platform != 'win32')",
"python_full_version == '3.11.*' and sys_platform == 'win32'",
- "python_full_version == '3.11.*' and sys_platform != 'win32'",
+ "python_full_version == '3.11.*' and sys_platform == 'darwin'",
+ "python_full_version == '3.11.*' and platform_machine == 'aarch64' and sys_platform == 'linux'",
+ "(python_full_version == '3.11.*' and platform_machine != 'aarch64' and sys_platform == 'linux') or (python_full_version == '3.11.*' and sys_platform != 'darwin' and sys_platform != 'linux' and sys_platform != 'win32')",
]
dependencies = [
{ name = "numpy", version = "1.26.4", source = { registry = "https://pypi.org/simple" }, marker = "python_full_version >= '3.11' and python_full_version < '3.13'" },
@@ -9730,6 +10064,53 @@ wheels = [
{ url = "https://files.pythonhosted.org/packages/d9/52/1064f510b141bd54025f9b55105e26d1fa970b9be67ad766380a3c9b74b0/starlette-0.50.0-py3-none-any.whl", hash = "sha256:9e5391843ec9b6e472eed1365a78c8098cfceb7a74bfd4d6b1c0c0095efb3bca", size = 74033, upload-time = "2025-11-01T15:25:25.461Z" },
]
+[[package]]
+name = "statsmodels"
+version = "0.14.6"
+source = { registry = "https://pypi.org/simple" }
+dependencies = [
+ { name = "numpy", version = "1.26.4", source = { registry = "https://pypi.org/simple" }, marker = "python_full_version < '3.13'" },
+ { name = "numpy", version = "2.2.0", source = { registry = "https://pypi.org/simple" }, marker = "python_full_version >= '3.13'" },
+ { name = "packaging" },
+ { name = "pandas" },
+ { name = "patsy" },
+ { name = "scipy", version = "1.15.3", source = { registry = "https://pypi.org/simple" }, marker = "python_full_version < '3.11'" },
+ { name = "scipy", version = "1.16.3", source = { registry = "https://pypi.org/simple" }, marker = "python_full_version >= '3.11'" },
+]
+sdist = { url = "https://files.pythonhosted.org/packages/0d/81/e8d74b34f85285f7335d30c5e3c2d7c0346997af9f3debf9a0a9a63de184/statsmodels-0.14.6.tar.gz", hash = "sha256:4d17873d3e607d398b85126cd4ed7aad89e4e9d89fc744cdab1af3189a996c2a", size = 20689085, upload-time = "2025-12-05T23:08:39.522Z" }
+wheels = [
+ { url = "https://files.pythonhosted.org/packages/b5/6d/9ec309a175956f88eb8420ac564297f37cf9b1f73f89db74da861052dc29/statsmodels-0.14.6-cp310-cp310-macosx_10_9_x86_64.whl", hash = "sha256:f4ff0649a2df674c7ffb6fa1a06bffdb82a6adf09a48e90e000a15a6aaa734b0", size = 10142419, upload-time = "2025-12-05T19:27:35.625Z" },
+ { url = "https://files.pythonhosted.org/packages/86/8f/338c5568315ec5bf3ac7cd4b71e34b98cb3b0f834919c0c04a0762f878a1/statsmodels-0.14.6-cp310-cp310-macosx_11_0_arm64.whl", hash = "sha256:109012088b3e370080846ab053c76d125268631410142daad2f8c10770e8e8d9", size = 10022819, upload-time = "2025-12-05T19:27:49.385Z" },
+ { url = "https://files.pythonhosted.org/packages/b0/77/5fc4cbc2d608f9b483b0675f82704a8bcd672962c379fe4d82100d388dbf/statsmodels-0.14.6-cp310-cp310-manylinux2014_aarch64.manylinux_2_17_aarch64.manylinux_2_28_aarch64.whl", hash = "sha256:e93bd5d220f3cb6fc5fc1bffd5b094966cab8ee99f6c57c02e95710513d6ac3f", size = 10118927, upload-time = "2025-12-05T23:07:51.256Z" },
+ { url = "https://files.pythonhosted.org/packages/94/55/b86c861c32186403fe121d9ab27bc16d05839b170d92a978beb33abb995e/statsmodels-0.14.6-cp310-cp310-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl", hash = "sha256:06eec42d682fdb09fe5d70a05930857efb141754ec5a5056a03304c1b5e32fd9", size = 10413015, upload-time = "2025-12-05T23:08:53.95Z" },
+ { url = "https://files.pythonhosted.org/packages/f9/be/daf0dba729ccdc4176605f4a0fd5cfe71cdda671749dca10e74a732b8b1c/statsmodels-0.14.6-cp310-cp310-musllinux_1_2_x86_64.whl", hash = "sha256:0444e88557df735eda7db330806fe09d51c9f888bb1f5906cb3a61fb1a3ed4a8", size = 10441248, upload-time = "2025-12-05T23:09:09.353Z" },
+ { url = "https://files.pythonhosted.org/packages/9a/1c/2e10b7c7cc44fa418272996bf0427b8016718fd62f995d9c1f7ab37adf35/statsmodels-0.14.6-cp310-cp310-win_amd64.whl", hash = "sha256:e83a9abe653835da3b37fb6ae04b45480c1de11b3134bd40b09717192a1456ea", size = 9583410, upload-time = "2025-12-05T19:28:02.086Z" },
+ { url = "https://files.pythonhosted.org/packages/a9/4d/df4dd089b406accfc3bb5ee53ba29bb3bdf5ae61643f86f8f604baa57656/statsmodels-0.14.6-cp311-cp311-macosx_10_9_x86_64.whl", hash = "sha256:6ad5c2810fc6c684254a7792bf1cbaf1606cdee2a253f8bd259c43135d87cfb4", size = 10121514, upload-time = "2025-12-05T19:28:16.521Z" },
+ { url = "https://files.pythonhosted.org/packages/82/af/ec48daa7f861f993b91a0dcc791d66e1cf56510a235c5cbd2ab991a31d5c/statsmodels-0.14.6-cp311-cp311-macosx_11_0_arm64.whl", hash = "sha256:341fa68a7403e10a95c7b6e41134b0da3a7b835ecff1eb266294408535a06eb6", size = 10003346, upload-time = "2025-12-05T19:28:29.568Z" },
+ { url = "https://files.pythonhosted.org/packages/a9/2c/c8f7aa24cd729970728f3f98822fb45149adc216f445a9301e441f7ac760/statsmodels-0.14.6-cp311-cp311-manylinux2014_aarch64.manylinux_2_17_aarch64.manylinux_2_28_aarch64.whl", hash = "sha256:bdf1dfe2a3ca56f5529118baf33a13efed2783c528f4a36409b46bbd2d9d48eb", size = 10129872, upload-time = "2025-12-05T23:09:25.724Z" },
+ { url = "https://files.pythonhosted.org/packages/40/c6/9ae8e9b0721e9b6eb5f340c3a0ce8cd7cce4f66e03dd81f80d60f111987f/statsmodels-0.14.6-cp311-cp311-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl", hash = "sha256:a3764ba8195c9baf0925a96da0743ff218067a269f01d155ca3558deed2658ca", size = 10381964, upload-time = "2025-12-05T23:09:41.326Z" },
+ { url = "https://files.pythonhosted.org/packages/28/8c/cf3d30c8c2da78e2ad1f50ade8b7fabec3ff4cdfc56fbc02e097c4577f90/statsmodels-0.14.6-cp311-cp311-musllinux_1_2_x86_64.whl", hash = "sha256:9e8d2e519852adb1b420e018f5ac6e6684b2b877478adf7fda2cfdb58f5acb5d", size = 10409611, upload-time = "2025-12-05T23:09:57.131Z" },
+ { url = "https://files.pythonhosted.org/packages/bf/cc/018f14ecb58c6cb89de9d52695740b7d1f5a982aa9ea312483ea3c3d5f77/statsmodels-0.14.6-cp311-cp311-win_amd64.whl", hash = "sha256:2738a00fca51196f5a7d44b06970ace6b8b30289839e4808d656f8a98e35faa7", size = 9580385, upload-time = "2025-12-05T19:28:42.778Z" },
+ { url = "https://files.pythonhosted.org/packages/25/ce/308e5e5da57515dd7cab3ec37ea2d5b8ff50bef1fcc8e6d31456f9fae08e/statsmodels-0.14.6-cp312-cp312-macosx_10_13_x86_64.whl", hash = "sha256:fe76140ae7adc5ff0e60a3f0d56f4fffef484efa803c3efebf2fcd734d72ecb5", size = 10091932, upload-time = "2025-12-05T19:28:55.446Z" },
+ { url = "https://files.pythonhosted.org/packages/05/30/affbabf3c27fb501ec7b5808230c619d4d1a4525c07301074eb4bda92fa9/statsmodels-0.14.6-cp312-cp312-macosx_11_0_arm64.whl", hash = "sha256:26d4f0ed3b31f3c86f83a92f5c1f5cbe63fc992cd8915daf28ca49be14463a1c", size = 9997345, upload-time = "2025-12-05T19:29:10.278Z" },
+ { url = "https://files.pythonhosted.org/packages/48/f5/3a73b51e6450c31652c53a8e12e24eac64e3824be816c0c2316e7dbdcb7d/statsmodels-0.14.6-cp312-cp312-manylinux2014_aarch64.manylinux_2_17_aarch64.manylinux_2_28_aarch64.whl", hash = "sha256:d8c00a42863e4f4733ac9d078bbfad816249c01451740e6f5053ecc7db6d6368", size = 10058649, upload-time = "2025-12-05T23:10:12.775Z" },
+ { url = "https://files.pythonhosted.org/packages/81/68/dddd76117df2ef14c943c6bbb6618be5c9401280046f4ddfc9fb4596a1b8/statsmodels-0.14.6-cp312-cp312-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl", hash = "sha256:19b58cf7474aa9e7e3b0771a66537148b2df9b5884fbf156096c0e6c1ff0469d", size = 10339446, upload-time = "2025-12-05T23:10:28.503Z" },
+ { url = "https://files.pythonhosted.org/packages/56/4a/dce451c74c4050535fac1ec0c14b80706d8fc134c9da22db3c8a0ec62c33/statsmodels-0.14.6-cp312-cp312-musllinux_1_2_x86_64.whl", hash = "sha256:81e7dcc5e9587f2567e52deaff5220b175bf2f648951549eae5fc9383b62bc37", size = 10368705, upload-time = "2025-12-05T23:10:44.339Z" },
+ { url = "https://files.pythonhosted.org/packages/60/15/3daba2df40be8b8a9a027d7f54c8dedf24f0d81b96e54b52293f5f7e3418/statsmodels-0.14.6-cp312-cp312-win_amd64.whl", hash = "sha256:b5eb07acd115aa6208b4058211138393a7e6c2cf12b6f213ede10f658f6a714f", size = 9543991, upload-time = "2025-12-05T23:10:58.536Z" },
+ { url = "https://files.pythonhosted.org/packages/81/59/a5aad5b0cc266f5be013db8cde563ac5d2a025e7efc0c328d83b50c72992/statsmodels-0.14.6-cp313-cp313-macosx_10_13_x86_64.whl", hash = "sha256:47ee7af083623d2091954fa71c7549b8443168f41b7c5dce66510274c50fd73e", size = 10072009, upload-time = "2025-12-05T23:11:14.021Z" },
+ { url = "https://files.pythonhosted.org/packages/53/dd/d8cfa7922fc6dc3c56fa6c59b348ea7de829a94cd73208c6f8202dd33f17/statsmodels-0.14.6-cp313-cp313-macosx_11_0_arm64.whl", hash = "sha256:aa60d82e29fcd0a736e86feb63a11d2380322d77a9369a54be8b0965a3985f71", size = 9980018, upload-time = "2025-12-05T23:11:30.907Z" },
+ { url = "https://files.pythonhosted.org/packages/ee/77/0ec96803eba444efd75dba32f2ef88765ae3e8f567d276805391ec2c98c6/statsmodels-0.14.6-cp313-cp313-manylinux2014_aarch64.manylinux_2_17_aarch64.manylinux_2_28_aarch64.whl", hash = "sha256:89ee7d595f5939cc20bf946faedcb5137d975f03ae080f300ebb4398f16a5bd4", size = 10060269, upload-time = "2025-12-05T23:11:46.338Z" },
+ { url = "https://files.pythonhosted.org/packages/10/b9/fd41f1f6af13a1a1212a06bb377b17762feaa6d656947bf666f76300fc05/statsmodels-0.14.6-cp313-cp313-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl", hash = "sha256:730f3297b26749b216a06e4327fe0be59b8d05f7d594fb6caff4287b69654589", size = 10324155, upload-time = "2025-12-05T23:12:01.805Z" },
+ { url = "https://files.pythonhosted.org/packages/ee/0f/a6900e220abd2c69cd0a07e3ad26c71984be6061415a60e0f17b152ecf08/statsmodels-0.14.6-cp313-cp313-musllinux_1_2_x86_64.whl", hash = "sha256:f1c08befa85e93acc992b72a390ddb7bd876190f1360e61d10cf43833463bc9c", size = 10349765, upload-time = "2025-12-05T23:12:18.018Z" },
+ { url = "https://files.pythonhosted.org/packages/98/08/b79f0c614f38e566eebbdcff90c0bcacf3c6ba7a5bbb12183c09c29ca400/statsmodels-0.14.6-cp313-cp313-win_amd64.whl", hash = "sha256:8021271a79f35b842c02a1794465a651a9d06ec2080f76ebc3b7adce77d08233", size = 9540043, upload-time = "2025-12-05T23:12:33.887Z" },
+ { url = "https://files.pythonhosted.org/packages/71/de/09540e870318e0c7b58316561d417be45eff731263b4234fdd2eee3511a8/statsmodels-0.14.6-cp314-cp314-macosx_10_15_x86_64.whl", hash = "sha256:00781869991f8f02ad3610da6627fd26ebe262210287beb59761982a8fa88cae", size = 10069403, upload-time = "2025-12-05T23:12:48.424Z" },
+ { url = "https://files.pythonhosted.org/packages/ab/f0/63c1bfda75dc53cee858006e1f46bd6d6f883853bea1b97949d0087766ca/statsmodels-0.14.6-cp314-cp314-macosx_11_0_arm64.whl", hash = "sha256:73f305fbf31607b35ce919fae636ab8b80d175328ed38fdc6f354e813b86ee37", size = 9989253, upload-time = "2025-12-05T23:13:05.274Z" },
+ { url = "https://files.pythonhosted.org/packages/c1/98/b0dfb4f542b2033a3341aa5f1bdd97024230a4ad3670c5b0839d54e3dcab/statsmodels-0.14.6-cp314-cp314-manylinux2014_aarch64.manylinux_2_17_aarch64.manylinux_2_28_aarch64.whl", hash = "sha256:e443e7077a6e2d3faeea72f5a92c9f12c63722686eb80bb40a0f04e4a7e267ad", size = 10090802, upload-time = "2025-12-05T23:13:20.653Z" },
+ { url = "https://files.pythonhosted.org/packages/34/0e/2408735aca9e764643196212f9069912100151414dd617d39ffc72d77eee/statsmodels-0.14.6-cp314-cp314-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl", hash = "sha256:3414e40c073d725007a6603a18247ab7af3467e1af4a5e5a24e4c27bc26673b4", size = 10337587, upload-time = "2025-12-05T23:13:37.597Z" },
+ { url = "https://files.pythonhosted.org/packages/0f/36/4d44f7035ab3c0b2b6a4c4ebb98dedf36246ccbc1b3e2f51ebcd7ac83abb/statsmodels-0.14.6-cp314-cp314-musllinux_1_2_x86_64.whl", hash = "sha256:a518d3f9889ef920116f9fa56d0338069e110f823926356946dae83bc9e33e19", size = 10363350, upload-time = "2025-12-05T23:13:53.08Z" },
+ { url = "https://files.pythonhosted.org/packages/26/33/f1652d0c59fa51de18492ee2345b65372550501ad061daa38f950be390b6/statsmodels-0.14.6-cp314-cp314-win_amd64.whl", hash = "sha256:151b73e29f01fe619dbce7f66d61a356e9d1fe5e906529b78807df9189c37721", size = 9588010, upload-time = "2025-12-05T23:14:07.28Z" },
+]
+
[[package]]
name = "stem"
version = "1.8.2"
@@ -9852,6 +10233,51 @@ wheels = [
{ url = "https://files.pythonhosted.org/packages/32/d5/f9a850d79b0851d1d4ef6456097579a9005b31fea68726a4ae5f2d82ddd9/threadpoolctl-3.6.0-py3-none-any.whl", hash = "sha256:43a0b8fd5a2928500110039e43a5eed8480b918967083ea48dc3ab9f13c4a7fb", size = 18638, upload-time = "2025-03-13T13:49:21.846Z" },
]
+[[package]]
+name = "tifffile"
+version = "2025.5.10"
+source = { registry = "https://pypi.org/simple" }
+resolution-markers = [
+ "python_full_version < '3.11' and sys_platform == 'win32'",
+ "python_full_version < '3.11' and sys_platform == 'darwin'",
+ "python_full_version < '3.11' and platform_machine == 'aarch64' and sys_platform == 'linux'",
+ "(python_full_version < '3.11' and platform_machine != 'aarch64' and sys_platform == 'linux') or (python_full_version < '3.11' and sys_platform != 'darwin' and sys_platform != 'linux' and sys_platform != 'win32')",
+]
+dependencies = [
+ { name = "numpy", version = "1.26.4", source = { registry = "https://pypi.org/simple" }, marker = "python_full_version < '3.11'" },
+]
+sdist = { url = "https://files.pythonhosted.org/packages/44/d0/18fed0fc0916578a4463f775b0fbd9c5fed2392152d039df2fb533bfdd5d/tifffile-2025.5.10.tar.gz", hash = "sha256:018335d34283aa3fd8c263bae5c3c2b661ebc45548fde31504016fcae7bf1103", size = 365290, upload-time = "2025-05-10T19:22:34.386Z" }
+wheels = [
+ { url = "https://files.pythonhosted.org/packages/5d/06/bd0a6097da704a7a7c34a94cfd771c3ea3c2f405dd214e790d22c93f6be1/tifffile-2025.5.10-py3-none-any.whl", hash = "sha256:e37147123c0542d67bc37ba5cdd67e12ea6fbe6e86c52bee037a9eb6a064e5ad", size = 226533, upload-time = "2025-05-10T19:22:27.279Z" },
+]
+
+[[package]]
+name = "tifffile"
+version = "2025.12.12"
+source = { registry = "https://pypi.org/simple" }
+resolution-markers = [
+ "python_full_version >= '3.14' and sys_platform == 'win32'",
+ "python_full_version >= '3.14' and sys_platform != 'win32'",
+ "python_full_version == '3.13.*' and sys_platform == 'win32'",
+ "python_full_version == '3.13.*' and sys_platform != 'win32'",
+ "python_full_version == '3.12.*' and sys_platform == 'win32'",
+ "python_full_version == '3.12.*' and sys_platform == 'darwin'",
+ "python_full_version == '3.12.*' and platform_machine == 'aarch64' and sys_platform == 'linux'",
+ "(python_full_version == '3.12.*' and platform_machine != 'aarch64' and sys_platform == 'linux') or (python_full_version == '3.12.*' and sys_platform != 'darwin' and sys_platform != 'linux' and sys_platform != 'win32')",
+ "python_full_version == '3.11.*' and sys_platform == 'win32'",
+ "python_full_version == '3.11.*' and sys_platform == 'darwin'",
+ "python_full_version == '3.11.*' and platform_machine == 'aarch64' and sys_platform == 'linux'",
+ "(python_full_version == '3.11.*' and platform_machine != 'aarch64' and sys_platform == 'linux') or (python_full_version == '3.11.*' and sys_platform != 'darwin' and sys_platform != 'linux' and sys_platform != 'win32')",
+]
+dependencies = [
+ { name = "numpy", version = "1.26.4", source = { registry = "https://pypi.org/simple" }, marker = "python_full_version >= '3.11' and python_full_version < '3.13'" },
+ { name = "numpy", version = "2.2.0", source = { registry = "https://pypi.org/simple" }, marker = "python_full_version >= '3.13'" },
+]
+sdist = { url = "https://files.pythonhosted.org/packages/31/b9/4253513a66f0a836ec3a5104266cf73f7812bfbbcda9d87d8c0e93b28293/tifffile-2025.12.12.tar.gz", hash = "sha256:97e11fd6b1d8dc971896a098c841d9cd4e6eb958ac040dd6fb8b332c3f7288b6", size = 373597, upload-time = "2025-12-13T03:42:53.765Z" }
+wheels = [
+ { url = "https://files.pythonhosted.org/packages/d5/5c/e444e1b024a519e488326525f0c154396c6b16baff17e00623f2c21dfc42/tifffile-2025.12.12-py3-none-any.whl", hash = "sha256:e3e3f1290ec6741ca248a5b5a997125209b5c2962f6bd9aef01ea9352c25d0ee", size = 232132, upload-time = "2025-12-13T03:42:52.072Z" },
+]
+
[[package]]
name = "tiktoken"
version = "0.7.0"
@@ -10103,7 +10529,7 @@ version = "0.32.0"
source = { registry = "https://pypi.org/simple" }
dependencies = [
{ name = "attrs" },
- { name = "cffi", marker = "implementation_name != 'pypy' and os_name == 'nt'" },
+ { name = "cffi", marker = "(python_full_version >= '3.13' and implementation_name != 'pypy' and os_name == 'nt' and sys_platform == 'darwin') or (python_full_version >= '3.13' and implementation_name != 'pypy' and os_name == 'nt' and sys_platform == 'linux') or (implementation_name != 'pypy' and os_name == 'nt' and platform_machine != 'aarch64' and sys_platform == 'linux') or (implementation_name != 'pypy' and os_name == 'nt' and sys_platform != 'darwin' and sys_platform != 'linux')" },
{ name = "exceptiongroup", marker = "python_full_version < '3.11'" },
{ name = "idna" },
{ name = "outcome" },