Skip to main content

EarthScienceToolkit

class EarthScienceToolkit(BaseToolkit):
A class representing a toolkit for earth observation science. This class provides 104 basic methods for earth observation solutions: Index (12), Inversion (18), Perception (15), Analysis (10), Statistics (49).

calculate_ndvi

def calculate_ndvi(
    self,
    input_nir_path,
    input_red_path,
    output_path
):
Calculate NDVI from NIR and Red band rasters. Parameters:
  • 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.

calculate_batch_ndvi

def calculate_batch_ndvi(
    self,
    input_nir_paths: list[str],
    input_red_paths: list[str],
    output_paths: list[str]
):
Batch-calculate NDVI from multiple pairs of NIR/Red rasters. Parameters:
  • 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.
Returns: list[str]: A list of result messages (e.g., saved file paths).

calculate_ndwi

def calculate_ndwi(
    self,
    input_nir_path,
    input_swir_path,
    output_path
):
Calculate NDWI from NIR and SWIR band rasters. Parameters:
  • 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.

calculate_batch_ndwi

def calculate_batch_ndwi(
    self,
    input_nir_paths: list[str],
    input_swir_paths: list[str],
    output_paths: list[str]
):
Batch-calculate NDWI from multiple pairs of NIR/SWIR rasters. Parameters:
  • 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.
Returns: list[str]: A list of result messages (e.g., saved file paths).

calculate_ndbi

def calculate_ndbi(
    self,
    input_swir_path,
    input_nir_path,
    output_path
):
Calculate NDBI from SWIR and NIR band rasters. Parameters:
  • 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.

calculate_batch_ndbi

def calculate_batch_ndbi(
    self,
    input_swir_paths: list[str],
    input_nir_paths: list[str],
    output_paths: list[str]
):
Batch-calculate NDBI from multiple pairs of SWIR/NIR rasters. Parameters:
  • 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.
Returns: list[str]: A list of result messages (e.g., saved file paths).

calculate_evi

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 EVI from NIR, Red, and Blue band rasters. Parameters:
  • 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. (default: 2)
  • C1 (float, optional): Coefficient 1. Defaults to 6. (default: 6)
  • C2 (float, optional): Coefficient 2. Defaults to 7.5. (default: 7)
  • L (float, optional): Adjustment factor. Defaults to 1. (default: 1)

calculate_batch_evi

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
):
Batch-calculate EVI from multiple sets of NIR/Red/Blue rasters. Parameters:
  • 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.
  • output_paths (list[str]): Relative output paths. G, C1, C2, L (float, optional): EVI coefficients.
Returns: list[str]: Result messages from each calculate_evi call.

calculate_nbr

def calculate_nbr(
    self,
    input_nir_path,
    input_swir_path,
    output_path
):
Calculate NBR from NIR and SWIR band rasters. Parameters:
  • 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.

calculate_batch_nbr

def calculate_batch_nbr(
    self,
    input_nir_paths: list[str],
    input_swir_paths: list[str],
    output_paths: list[str]
):
Batch-calculate NBR from multiple pairs of NIR/SWIR rasters. Parameters:
  • 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.
Returns: list[str]: A list of result messages (e.g., saved file paths).

calculate_fvc

def calculate_fvc(
    self,
    input_nir_path,
    input_red_path,
    output_path,
    ndvi_min = 0.1,
    ndvi_max = 0.9
):
Calculate FVC from NIR and Red band rasters. Parameters:
  • 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). (default: 0.1)
  • ndvi_max (float): Max NDVI for fully vegetated areas (default: 0. 9).
Returns: str: Path to the saved FVC raster file.

calculate_batch_fvc

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
):
Batch-calculate FVC from multiple pairs of NIR/Red rasters. Parameters:
  • 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.
  • 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).

calculate_wri

def calculate_wri(
    self,
    input_green_path,
    input_red_path,
    input_nir_path,
    input_swir_path,
    output_path
):
Calculate WRI from Green, Red, NIR, and SWIR band rasters. Parameters:
  • 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.

calculate_batch_wri

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]
):
Batch-calculate WRI from multiple raster sets. Parameters:
  • 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.
Returns: list[str]: A list of result messages (e.g., saved file paths).

calculate_ndti

def calculate_ndti(
    self,
    input_red_path,
    input_green_path,
    output_path
):
Calculate NDTI from Red and Green band rasters. Parameters:
  • 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.

calculate_batch_ndti

def calculate_batch_ndti(
    self,
    input_red_paths: list[str],
    input_green_paths: list[str],
    output_paths: list[str]
):
Batch-calculate NDTI from multiple pairs of Red/Green rasters. Parameters:
  • 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”).
Returns: list[str]: A list of result messages (e.g., saved file paths).

calculate_frp

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. Parameters:
  • 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).
Returns: str: Path to the saved fire mask file.

calculate_batch_frp

def calculate_batch_frp(
    self,
    input_frp_paths: list[str],
    output_paths: list[str],
    fire_threshold: float = 0
):
Batch-calculate FRP fire masks from multiple raster files. Parameters:
  • 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.
Returns: list[str]: A list of result messages (e.g., saved file paths).

calculate_ndsi

def calculate_ndsi(
    self,
    input_green_path: str,
    input_swir_path: str,
    output_path: str
):
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:
  • 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”
Returns: str: Path to the output NDSI raster file.

calculate_batch_ndsi

def calculate_batch_ndsi(
    self,
    green_file_list: list[str],
    swir_file_list: list[str],
    output_path_list: 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”]
Returns: list[str]: List of paths to the output NDSI raster files.

calc_extreme_snow_loss_percentage_from_binary_map

def calc_extreme_snow_loss_percentage_from_binary_map(self, binary_map_path: str):
Calculate the percentage of extreme snow and ice loss areas from a binary map. Parameters:
  • binary_map_path (str): 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).

compute_tvdi

def compute_tvdi(
    self,
    ndvi_path: str,
    lst_path: str,
    output_path: str
):
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).
  • output_path (str): Relative path to save the computed TVDI raster (e.g., “question17/tvdi_2022-01-16.tif”).
Returns: str: Path to the saved TVDI GeoTIFF file.

band_ratio

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
):
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. 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”.
Returns: str: Full path to the saved PWV GeoTIFF.

lst_single_channel

def lst_single_channel(
    self,
    bt_path: str,
    red_path: str,
    nir_path: str,
    output_path: 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:
  • 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, e.g. “question17/lst_2022-01-16.tif”.
Returns: str: Full path to the saved LST GeoTIFF.

lst_multi_channel

def lst_multi_channel(
    self,
    band31_path: str,
    band32_path: str,
    output_path: 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) 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).
  • output_path (str): Relative path for the output LST GeoTIFF, e.g. “question17/lst_2022-01-16.tif”.
Returns: str: Full path to the saved LST GeoTIFF.

split_window

def split_window(
    self,
    band31_path: str,
    band32_path: str,
    emissivity31_path: str,
    emissivity32_path: str,
    parameter: str,
    output_path: 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 Args. Only one parameter is computed based on the user-selected parameter. Parameters:
  • 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.
  • output_path (str): Relative path for the output raster file, e.g. "question17/lst_2022-01-16.tif".
Returns: str: Full path to the saved GeoTIFF containing the selected parameter.

temperature_emissivity_separation

def temperature_emissivity_separation(
    self,
    tir_band_paths: list[str],
    representative_band_index: int,
    output_path: 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, 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”).
Returns: str: Path to the saved GeoTIFF file containing:
  • Band 1: LST (K)
  • Band 2: Emissivity (ε)
  • Band 3: Emissivity variation (Δε)

modis_day_night_lst

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
):
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”).
Returns: str: Path to the exported GeoTIFF with six bands:
  • Band 1: LST (Day)
  • Band 2: LST (Night)
  • Band 3: BT (Day)
  • Band 4: BT (Night)
  • Band 5: Emissivity (Day)
  • Band 6: Emissivity (Night)

ttm_lst

def ttm_lst(
    self,
    tir_band_paths: list[str],
    output_path: str,
    wavelengths: list[float] | None = None
):
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. Parameters:
  • 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].
Returns: str: Path to exported GeoTIFF with LST (K) and emissivity bands.

calculate_mean_lst_by_ndvi

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'
):
Calculate the average Land Surface Temperature (LST) across multiple images where NDVI is either above or below a given threshold. Parameters:
  • 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).
  • ndvi_threshold (float): Threshold value for NDVI.
  • 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.

calculate_max_lst_by_ndvi

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. Parameters:
  • 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’.
Returns: float: Maximum LST value over the selected NDVI region. Returns np. nan if no valid data.

calculate_ATI

def calculate_ATI(
    self,
    day_temp_path: str,
    night_temp_path: str,
    albedo_path: str,
    output_path: 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.
  • 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”.
Returns: str: Path to the saved Apparent Thermal Inertia GeoTIFF file.

dual_polarization_differential

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'
):
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. 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”.
Returns: str: Path to the exported parameter GeoTIFF.

dual_frequency_diff

def dual_frequency_diff(
    self,
    band1_path: str,
    band2_path: str,
    parameter: str,
    alpha: float,
    beta: float,
    output_path: str
):
Dual-frequency Differential Method (DDM) for parameter inversion. 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’.
  • 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”
Returns: str: Path to the saved combined output GeoTIFF (difference and parameter).

multi_freq_bt

def multi_freq_bt(
    self,
    bt_paths: list[str],
    diff_pairs: list[list[int]],
    parameter: str,
    output_path: str
):
Multi-frequency Brightness Temperature Method for inversion. Uses local raster data for parameter inversion. 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]]).
  • 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”
Returns: str: Path to the saved inverted parameter GeoTIFF.

chang_single_param_inversion

def chang_single_param_inversion(
    self,
    bt_paths: list[str],
    diff_pairs: list[list[int]],
    parameter: str,
    output_path: str
):
Chang algorithm for single parameter inversion. Uses 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.
  • 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”
Returns: str: File path to saved GeoTIFF with inverted parameter band.

nasa_team_sea_ice_concentration

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
):
Estimate Sea Ice Concentration using NASA Team Algorithm. Uses 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”
Returns: str: Path to saved GeoTIFF with sea ice concentration band.

dual_polarization_ratio

def dual_polarization_ratio(
    self,
    bt_paths: dict,
    parameter: str,
    output_path: str,
    coeffs: dict | None = None
):
Estimate VWC or SM using Dual-Polarization Ratio Method (PRM). 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": {...}}.
Returns: str: File path of the saved GeoTIFF containing the inverted parameter and PR band.

calculate_water_turbidity_ntu

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
):
Calculate water turbidity in NTU from red band raster file. NTU = Nephelometric Turbidity Units. Saves result to output path. Parameters:
  • 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” (aRed+b), “power” (aRed^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.
Returns: str: Path to the output NTU raster file.

threshold_segmentation

def threshold_segmentation(
    self,
    input_image_path,
    threshold,
    output_path
):
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). 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”.
Returns: str: Message indicating the file path where the result is saved.

bbox_expansion

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].
  • radius (float): Expansion radius in the same unit as the GSD.
  • 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].

count_above_threshold

def count_above_threshold(self, file_path: str, threshold: float):
Count pixels in an image whose values exceed the threshold. Parameters:
  • file_path (str): Path to the input image (GeoTIFF or raster format).
  • threshold (float): Threshold value for hotspot detection.
Returns: count (int): Number of pixels with values greater than the threshold.

count_skeleton_contours

def count_skeleton_contours(self, image_path):
Count external contours in a skeletonized binary image. Reads a binary image, applies erosion and skeletonization, then counts the number of external contours. Parameters:
  • image_path (str): Path to the input binary (black and white) image.
Returns: count (int): Number of external contours detected after skeletonization.

bboxes2centroids

def bboxes2centroids(self, bboxes):
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].
Returns: centroids (list[tuple[float, float]]): A list of centroid coordinates, each in (x, y) format.

centroid_distance_extremes

def centroid_distance_extremes(self, centroids):
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:
  • centroids (list[tuple[float, float]] or np.ndarray): A list or NumPy array of centroid coordinates in (x, y) format.
Returns: result (dict): A dictionary containing:
  • ‘min’: (index1, index2, distance) Indices of the closest centroid pair and their distance.
  • ‘max’: (index1, index2, distance) Indices of the farthest centroid pair and their distance.

calculate_bbox_area

def calculate_bbox_area(self, bboxes, gsd = None):
Calculate the total area of bounding boxes in [x, y, w, h] format. Parameters:
  • 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².

compute_linear_trend

def compute_linear_trend(self, y: list, x: list | None = None):
Compute linear trend (slope and intercept) of a time series. Fits a line of the form y = a * x + b using least squares method. Parameters:
  • 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.
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.

mann_kendall_test

def mann_kendall_test(self, x: list):
Description: Conduct the Mann-Kendall trend test on a time series to assess whether a statistically significant monotonic trend exists. The test is non-parametric and does not assume normality. Handles tied ranks with variance correction. Parameters:
  • x (list[float]): The input time series data as a list of floats or ints. Any missing values (NaN) should be removed beforehand.
Returns: trend (str): Type of detected trend:
  • “increasing” if a significant upward trend is found
  • “decreasing” if a significant downward trend is found
  • “no trend” if no significant trend is detected p_value (float): Two-tailed p-value of the test. z (float): Standard normal test statistic. tau (float): Kendall’s Tau statistic (measure of rank correlation, range -1 to 1).

sens_slope

def sens_slope(self, x: list):
Description: 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:
  • 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). slopes (list[float]): List of all pairwise slopes, which can be used for further distributional or variability analysis.

stl_decompose

def stl_decompose(
    self,
    x: list,
    period: int,
    robust: bool = True
):
Apply STL decomposition to a univariate time series. Decomposes input data into three additive components: trend, seasonal, and residual using LOESS. Parameters:
  • x (list[float]): Input time series values.
  • period (int): Number of observations in one seasonal cycle.
Returns: dict: Dictionary with keys “trend”, “seasonal”, “resid”, each containing list[float] of component values.

detect_change_points

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 where the statistical structure of the signal changes. Parameters:
  • signal (list[float]): Input time series data.
  • model (str, default="l2"): Segmentation cost model to use. - “l1”: robust to outliers (absolute loss) - “l2”: mean shift model (squared loss, default) - “rbf”: kernel-based model for nonlinear changes - others supported by ruptures
  • penalty (float, default=10): Penalty value controlling sensitivity. Higher values detect fewer change points (more conservative).
Returns: change_points (list[int]): List of indices marking change points in the series. The final index of the signal is always included.

autocorrelation_function

def autocorrelation_function(self, x: list, nlags: int = 20):
Compute the Autocorrelation Function (ACF) of a time series. The ACF describes correlation between the series and its lagged values, commonly used to detect seasonality or serial dependence. Parameters:
  • x (list[float]): Input time series data.
  • nlags (int, default=20): Number of lags to compute.
Returns: acf (list[float]): Autocorrelation values for lags 0 to nlags. acf[0] = 1.0 (self-correlation), acf[k] = correlation at lag k.

detect_seasonality_acf

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.
  • min_acf (float, default=0.3): ACF threshold to consider significant.
Returns: result (int | str): Dominant period (lag) if detected, or “Data is not cyclical” if no significant seasonality found.

getis_ord_gi_star

def getis_ord_gi_star(
    self,
    image_path: str,
    weight_matrix: list,
    output_path: str
):
Compute Getis-Ord Gi* statistic for local spatial autocorrelation. Positive Gi* values indicate hot spots (clusters of high values), negative values indicate cold spots (clusters of low values). Parameters:
  • 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 saved GeoTIFF with Gi* statistics (float32 raster). Preserves georeference and projection from input if available.

analyze_hotspot_direction

def analyze_hotspot_direction(self, hotspot_map_path: 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 binary hotspot map GeoTIFF. Hotspot pixels should be value=1; others are ignored.
Returns: str: “north”, “south”, “east”, “west” for dominant direction, or “no hotspots found” if no hotspot pixels exist.

count_spikes_from_values

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:
  • 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, logger.infos details for each detected spike.
Returns: int: Number of detected upward spikes.

coefficient_of_variation

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:
  • x (list[float]): Input dataset values (numeric).
  • ddof (int, default=1): Delta Degrees of Freedom for standard deviation calculation: - ddof=0 → population standard deviation - ddof=1 → sample standard deviation (default)
Returns: cv (float): The computed Coefficient of Variation. Returns NaN if mean(x) == 0 to avoid division by zero.

skewness

def skewness(self, x: list, bias: bool = True):
Compute skewness of a dataset (distribution asymmetry). 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) for unbiased estimator.
Returns: skew (float): Skewness value. Returns 0.0 if no variation.

kurtosis

def kurtosis(
    self,
    x: list,
    bias: bool = True,
    fisher: bool = True
):
Compute kurtosis of a dataset (tailedness measure). 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.
  • fisher (bool, default=True): If True, returns “excess kurtosis” (normal=0). If False, returns regular kurtosis (normal=3).
Returns: kurt (float): Kurtosis value. Returns 0.0 if no variation.

calc_single_image_mean

def calc_single_image_mean(self, file_path: str, uint8: bool = False):
Compute mean value of an image. Parameters:
  • file_path (str): Path to input image.
Returns: mean (float): Mean pixel value

calc_batch_image_mean

def calc_batch_image_mean(self, file_list: list[str], uint8: bool = False):
Compute mean value of an batch of images. Returns: mean (list(float)): Mean pixel value

calc_single_image_std

def calc_single_image_std(self, file_path: str, uint8: bool = False):
Compute standard deviation value of an image. Parameters:
  • file_path (str): Path to input image.
Returns: std (float): Standard deviation

calc_batch_image_std

def calc_batch_image_std(self, file_list: list[str], uint8: bool = False):
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 to uint8 first. Default = False.
Returns: list[float]: Standard deviation values, one per input image.

calc_single_image_median

def calc_single_image_median(self, file_path: str, uint8: bool = False):
Compute median value of an image. Parameters:
  • file_path (str): Path to input image.
Returns: median (float): Median pixel value

calc_batch_image_median

def calc_batch_image_median(self, file_list: list[str], uint8: bool = False):
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 to uint8 first. Default = False.
Returns: list[float]: Median pixel values, one per input image.

calc_single_image_min

def calc_single_image_min(self, file_path: str, uint8: bool = False):
Compute min value of an image. Parameters:
  • file_path (str): Path to input image.
Returns: min (float): Minimum pixel value

calc_batch_image_min

def calc_batch_image_min(self, file_list: list[str], uint8: bool = False):
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 to uint8 first. Default = False.
Returns: list[float]: Minimum pixel values, one per input image.

calc_single_image_max

def calc_single_image_max(self, file_path: str, uint8: bool = False):
Compute max value of an image. Parameters:
  • file_path (str): Path to input image.
Returns: max (float): Maximum pixel value

calc_batch_image_max

def calc_batch_image_max(self, file_list: list[str], uint8: bool = False):
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 to uint8 first. Default = False.
Returns: list[float]: Maximum pixel values, one per input image.

calc_single_image_skewness

def calc_single_image_skewness(self, file_path: str, uint8: bool = False):
Compute skewness value of an image. Parameters:
  • file_path (str): Path to input image.
Returns: skewness: Skewness of pixel value distribution

calc_batch_image_skewness

def calc_batch_image_skewness(self, file_list: list[str], uint8: bool = False):
Compute skewness of pixel distributions for a batch of images. Positive skew = longer right tail, negative = longer left tail, zero = symmetric distribution. Parameters:
  • file_list (list[str]): List of input image file paths.
  • uint8 (bool, optional): Whether to convert to uint8 first. Default = False.
Returns: list[float]: Skewness values, one per input image.

calc_single_image_kurtosis

def calc_single_image_kurtosis(self, file_path: str, uint8: bool = False):
Compute kurtosis value of an image. Parameters:
  • file_path (str): Path to input image.
Returns: kurtosis: Kurtosis of pixel value distribution (excess kurtosis)

calc_batch_image_kurtosis

def calc_batch_image_kurtosis(self, file_list: list[str], uint8: bool = False):
Compute kurtosis of pixel distributions for a batch of images. Kurtosis measures “tailedness” relative to normal distribution. Normal = 3, higher = heavier tails, lower = lighter tails. Parameters:
  • file_list (list[str]): List of input image file paths.
  • uint8 (bool, optional): Whether to convert to uint8 first. Default = False.
Returns: list[float]: Kurtosis values, one per input image.

calc_single_image_sum

def calc_single_image_sum(self, file_path: str, uint8: bool = False):
Compute sum value of an image. Parameters:
  • file_path (str): Path to input image.
  • uint8 (bool): Whether to use uint8 format.
Returns: sum (float): Sum pixel value

calc_batch_image_sum

def calc_batch_image_sum(self, file_list: list[str], uint8: bool = False):
Description: Compute the sum of pixel values for a batch of images. Returns:
  • sum (list[float]): List of pixel sum values, one for each image.

calc_single_image_hotspot_percentage

def calc_single_image_hotspot_percentage(
    self,
    file_path: str,
    threshold: float,
    uint8: bool = False
):
Compute hotspot percentage of an image. Parameters:
  • file_path (str): Path to input image.
  • threshold (float): Threshold value for hotspot detection.
  • uint8 (bool): Whether to use uint8 format.
Returns: percentage (float): Hotspot area percentage (0.0 to 1.0).

calc_batch_image_hotspot_percentage

def calc_batch_image_hotspot_percentage(
    self,
    file_list: list[str],
    threshold: float,
    uint8: bool = False
):
Description: Compute the hotspot percentage (fraction of pixels above a threshold) for a batch of images. Returns:
  • percentage (list[float]): List of hotspot area percentages (0.0-1.0), one for each input image.

calc_single_image_hotspot_tif

def calc_single_image_hotspot_tif(
    self,
    file_path: str,
    threshold: float,
    output_path: str,
    uint8: bool = False
):
Create a binary map highlighting areas below the threshold and save as GeoTIFF. Parameters:
  • 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”
Returns: str: Path to the saved GeoTIFF image containing the binary map.

calc_batch_image_hotspot_tif

def calc_batch_image_hotspot_tif(
    self,
    file_list: list[str],
    threshold: float,
    output_path_list: list[str],
    uint8: bool = False
):
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. Returns:
  • list[str]: Paths to the saved GeoTIFF images containing the binary hotspot maps.

difference

def difference(self, a: float, b: float):
Description: Compute the absolute difference between two numbers. Returns:
  • diff (float): The absolute difference |a - b|.

division

def division(self, a: float, b: float):
Description: Perform division between two numbers. Returns:
  • result (float): The result of b ÷ a. Returns +inf if a = 0.

percentage_change

def percentage_change(self, a: float, b: float):
Description: Calculate the percentage change between two numbers, useful for comparing relative growth or decline. Returns:
  • percent (float): The percentage change, computed as ((b - a) / a) * 100. Positive values indicate increase, negative values indicate decrease.

kelvin_to_celsius

def kelvin_to_celsius(self, kelvin: float):
Description: Convert temperature from Kelvin to Celsius. Returns:
  • celsius (float): Temperature in Celsius, computed as (Kelvin - 273.15).

celsius_to_kelvin

def celsius_to_kelvin(self, celsius: float):
Description: Convert temperature from Celsius to Kelvin. Parameters:
  • celsius (float): Temperature in Celsius.
Returns: kelvin (float): Temperature in Kelvin, computed as: Kelvin = Celsius + 273.15

max_value_and_index

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. Returns:
  • result (tuple[float, int]): A tuple containing:
  • max_value (float): The maximum value in the list.
  • max_index (int): The index of the maximum value.

min_value_and_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. Returns:
  • result (tuple[float, int]): A tuple containing:
  • min_value (float): The minimum value in the list.
  • min_index (int): The index of the minimum value.

multiply

def multiply(self, a, b):
Description: Multiply two numbers and return their product. Parameters:
  • a (float or int): First number.
  • b (float or int): Second number.
Returns: result (float or int): The product of a and b.

ceil_number

def ceil_number(self, n: float):
Description: Return the ceiling (rounded up integer) of a given number. Parameters:
  • n (float): A numeric value.
Returns: result (int): The smallest integer greater than or equal to n.

get_list_object_via_indexes

def get_list_object_via_indexes(self, input_list, indexes):
Description: Retrieve elements from a list using a list or tuple of indices. Parameters:
  • 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.
Returns: result (list): A list of elements corresponding to the provided indices.

mean

def mean(self, x: list):
Description: Compute the arithmetic mean (average) of a dataset. Parameters:
  • x (list[float]): Input data array.
Returns: mean_value (float): The arithmetic mean of the input values.

calculate_threshold_ratio

def calculate_threshold_ratio(
    self,
    image_paths: str | list[str],
    threshold: float = 0.75,
    band_index: int = 0
):
Description: Calculate the average percentage of pixels above a given threshold for one or more images and a specified band. Parameters:
  • image_paths (str or list[str]): Path or list of image file paths.
  • threshold (float, optional): Threshold value. Default = 0.75.
  • band_index (int, optional): Band index to use (0-based). Default = 0 (first band).
Returns: percentage (float): Average percentage of pixels above the threshold across all images.

calc_single_image_fire_pixels

def calc_single_image_fire_pixels(self, file_path: str, fire_threshold: float = 0):
Compute the number of fire pixels (MaxFRP > threshold) in an image. Parameters:
  • file_path (str): Path to input image.
  • fire_threshold (float): Minimum FRP value to be considered as fire (default: 0).
Returns: fire_pixels (int): Number of fire pixels

calc_batch_fire_pixels

def calc_batch_fire_pixels(self, file_list: list[str], fire_threshold: float = 0):
Description: Compute the number of fire pixels (FRP > threshold) for a batch of images. Parameters:
  • file_list (list[str]): Paths to input images.
  • fire_threshold (float, optional): Minimum FRP value to be considered as fire. Default = 0.
Returns: fire_pixels (list[int]): A list of fire pixel counts, one per input image.

create_fire_increase_map

def create_fire_increase_map(
    self,
    change_image_path: str,
    output_path: str,
    threshold: float = 20.0
):
Description: Create a binary map highlighting areas where fire increase exceeds a specified threshold. Parameters:
  • change_image_path (str): Path to the fire change image.
  • output_path (str): 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.
Returns: result (str): Path to the saved GeoTIFF fire increase map.

identify_fire_prone_areas

def identify_fire_prone_areas(
    self,
    file_path: str,
    output_path: str,
    threshold_percentile: float = 75,
    uint8: bool = False
):
Description: Identify fire-prone areas from a hotspot map based on a given percentile threshold. Parameters:
  • file_path (str): Path to the input hotspot map file.
  • output_path (str): 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.
  • uint8 (bool, optional): Whether to use uint8 format when reading the input. Default = False.
Returns: result (tuple[str, float]): A tuple containing:
  • Path to the saved GeoTIFF file with fire-prone areas.
  • Threshold value used for classification.

get_percentile_value_from_image

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. Parameters:
  • image_path (str): Path to the input raster (.tif) file.
  • percentile (int or float): 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).

image_division_mean

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 or between two bands of the same image. Parameters:
  • image_path1 (str): 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.
  • band1 (int, optional): 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.
Returns: result (float): The mean of the valid pixel-wise division results.

calculate_intersection_percentage

def calculate_intersection_percentage(
    self,
    path1,
    threshold1,
    path2,
    threshold2
):
Description: Calculate the percentage of pixels that simultaneously satisfy threshold conditions in two raster images. Parameters:
  • path1 (str): Path to the first raster image (e.g., NDVI).
  • threshold1 (float): Threshold value for the first image (e.g., NDVI > 0.3).
  • path2 (str): Path to the second raster image (e.g., TVDI).
  • threshold2 (float): Threshold value for the second image (e.g., TVDI > 0.7).
Returns: percentage (float): Percentage of pixels that satisfy both conditions over the total valid pixels.

calc_batch_image_mean_mean

def calc_batch_image_mean_mean(self, file_list: list[str], uint8: bool = False):
Description: Compute the average of mean pixel values across a batch of images. Parameters:
  • file_list (list[str]): List of image file paths.
  • uint8 (bool, optional): Whether to convert images to uint8 format (0-255). Default = False.
Returns: mean_of_means (float): The average of the mean pixel values across all images.

calc_batch_image_mean_max

def calc_batch_image_mean_max(self, file_list: list[str], uint8: bool = False):
Description: Compute the mean pixel values of a batch of images and return the maximum mean. Parameters:
  • file_list (list[str]): Paths to input images.
  • uint8 (bool, optional): Whether to treat image as uint8 (0-255 normalization). Default = False.
Returns: max_mean (float): The maximum mean pixel value among all images.

calc_batch_image_mean_max_min

def calc_batch_image_mean_max_min(self, file_list: list[str], uint8: bool = False):
Description: Compute the batch-wise statistics across multiple images, including:
  • Mean of mean values
  • Maximum of maximum values
  • Minimum of minimum values
Parameters:
  • file_list (list[str]): List of image file paths.
  • uint8 (bool, optional): Whether to convert the data to uint8 range (0-255). Default = False.
Returns: result (tuple[float, float, float]): A tuple containing: (mean of means, max of maxs, min of mins)

calc_batch_image_mean_threshold

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'
):
Description: Calculate the percentage or count of images whose mean pixel values (in a specified band) are above or below a given threshold. Parameters:
  • 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.
  • uint8 (bool, optional): 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). Default = “ratio”.
Returns: float | int: Percentage (0-100) or count of images satisfying the condition.

calculate_multi_band_threshold_ratio

def calculate_multi_band_threshold_ratio(self, image_path: str, band_conditions: list):
Description: Calculate the percentage of pixels that simultaneously satisfy multiple band threshold conditions. Parameters:
  • 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): - band_index (int): Zero-based band index. - threshold_value (float): Threshold to apply. - compare_type (str): “above” or “below”.
Returns: float: Percentage of pixels satisfying all conditions (intersection).

count_pixels_satisfying_conditions

def count_pixels_satisfying_conditions(self, image_path: str, band_conditions: list):
Description: Count the number of pixels that simultaneously satisfy multiple band threshold conditions. Parameters:
  • 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): - 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).

count_images_exceeding_threshold_ratio

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
):
Count how many images have a percentage of pixels above or below a threshold that exceeds a specified ratio. Parameters:
  • 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): Percentage threshold for comparison (e.g., 20.0 means 20%).
  • mode (str): - ‘above’: pixels > value_threshold - ‘below’: pixels < value_threshold Default is ‘above’.
  • verbose (bool): If True, logger.infos detailed ratio results per image.
Returns: int: Number of images whose pixel ratio exceeds the ratio_threshold.

average_ratio_exceeding_threshold

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
):
Calculate the average percentage of pixels exceeding a value threshold, considering only images where the ratio is greater than a specified ratio threshold. Parameters:
  • 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%).
  • mode (str): - ‘above’: pixels > value_threshold - ‘below’: pixels < value_threshold Default is ‘above’.
  • verbose (bool): If True, logger.infos detailed ratio results per image.
Returns: float: Average percentage of qualifying images. Returns 0.0 if no image meets the criteria.

count_images_exceeding_mean_multiplier

def count_images_exceeding_mean_multiplier(
    self,
    image_paths: str | list[str],
    mean_multiplier: float = 1.1,
    mode: str = 'above',
    verbose: bool = True
):
Count how many images have a mean pixel value above or below a multiple of the overall mean pixel value across all images. Parameters:
  • 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 Default is ‘above’.
  • verbose (bool): If True, logger.infos detailed mean and threshold comparisons per image.
Returns: int: Number of images satisfying the condition.

calculate_band_mean_by_condition

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
):
Calculate the mean value of a target band over pixels where a condition band satisfies a threshold. Parameters:
  • image_path (str): Path to the multi-band raster image.
  • condition_band_index (int): Zero-based index of the band used for thresholding.
  • condition_threshold (float): Threshold value to apply on the condition band.
  • condition_mode (str, default='above'): - ‘above’: select pixels where condition_band >= threshold - ‘below’: select pixels where condition_band < threshold
  • target_band_index (int, default=0): Zero-based index of the band for which the mean is calculated.
Returns: float: Mean value of the target band over selected pixels.

calc_threshold_value_mean

def calc_threshold_value_mean(
    self,
    path1: str | list[str],
    path2: str | list[str],
    threshold: float = 300.0
):
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).
Returns: float: Mean value of path2 pixels that meet the threshold condition in path1. Returns np.nan if no valid data is found.

calculate_tif_average

def calculate_tif_average(
    self,
    file_list: list[str],
    output_path: str,
    uint8: bool = False
):
Calculate average of multiple tif files and save result to same directory. Parameters:
  • 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”
  • uint8 (bool): Convert to uint8 format, default False.
Returns: output_path (str): Full path of output file.

calculate_tif_difference

def calculate_tif_difference(
    self,
    image_a_path: str,
    image_b_path: str,
    output_path: str,
    uint8: bool = False
):
Calculate difference between two tif files (image_b - image_a) and save result. Parameters:
  • 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”
  • uint8 (bool): Convert to uint8 format, default False.
Returns: output_path (str): Full path of output file.

subtract

def subtract(
    self,
    img1_path: str,
    img2_path: str,
    output_path: str
):
Subtract two images and save result. Parameters:
  • 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”
Returns: str: Path to output file.

calculate_area

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.
Returns: area (int): The area of non-zero pixels in the input image.

grayscale_to_colormap

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:
  • 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.
  • preserve_geo (bool): If True, preserves georeferencing.

get_filelist

def get_filelist(self, dir_path: str):
Returns a list of files in the specified directory. Parameters:
  • dir_path (str): Path to the directory.
Returns: list: List of file names in the directory.

radiometric_correction_sr

def radiometric_correction_sr(self, input_band_path, output_path):
Apply Landsat 8 surface reflectance (SR_B*) radiometric correction. Parameters:
  • 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”
Returns: str: Path to the saved corrected reflectance file.

apply_cloud_mask

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. Parameters:
  • 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”
Returns: str: Path to the saved masked raster file.

read_image

def read_image(self, file_path: str):

read_image_uint8

def read_image_uint8(self, file_path: str):

get_geotransform

def get_geotransform(self, file_path):

get_tools

def get_tools(self):
Returns: List[FunctionTool]: A list of FunctionTool objects representing the functions in the toolkit.