diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index f76b34d..5b01bf4 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -9,13 +9,13 @@ ci: repos: - repo: https://github.com/adamchainz/blacken-docs - rev: "1.18.0" + rev: "1.20.0" hooks: - id: blacken-docs additional_dependencies: [black==24.*] - repo: https://github.com/pre-commit/pre-commit-hooks - rev: "v4.6.0" + rev: "v6.0.0" hooks: - id: check-added-large-files - id: check-case-conflict @@ -45,14 +45,14 @@ repos: args: [--prose-wrap=always] - repo: https://github.com/astral-sh/ruff-pre-commit - rev: "v0.6.3" + rev: "v0.15.21" hooks: - id: ruff args: ["--fix", "--show-fixes"] - id: ruff-format - repo: https://github.com/codespell-project/codespell - rev: v2.3.0 + rev: v2.4.2 hooks: - id: codespell # Checks spelling in `docs/source` dirs ONLY @@ -60,18 +60,18 @@ repos: args: ["--skip=*.ipynb,docs/_build"] - repo: https://github.com/shellcheck-py/shellcheck-py - rev: "v0.10.0.1" + rev: "v0.11.0.1" hooks: - id: shellcheck - repo: https://github.com/abravalheri/validate-pyproject - rev: "v0.19" + rev: "v0.25" hooks: - id: validate-pyproject additional_dependencies: ["validate-pyproject-schema-store[all]"] - repo: https://github.com/python-jsonschema/check-jsonschema - rev: "0.29.2" + rev: "0.37.4" hooks: - id: check-dependabot - id: check-github-workflows diff --git a/docs/paper.md b/docs/paper.md index 4b0b9d1..9261d20 100644 --- a/docs/paper.md +++ b/docs/paper.md @@ -91,9 +91,9 @@ training, snow-covered area map generation, AOI simplification, canopy-aware post-processing of snow-covered area (SCA) time series, and validation against airborne reference snow surveys. Sample data and a pre-trained model are provided to demonstrate the library's functions. PlanetSCA requires users to -have an account with Planet Data Explorer (https://www.planet.com/explorer/) -and an API key to utilize its search and download capabilities. Limited access -to free PlanetScope images is available at +have an account with Planet Data Explorer (https://www.planet.com/explorer/) and +an API key to utilize its search and download capabilities. Limited access to +free PlanetScope images is available at https://www.planet.com/industries/education-and-research/. # Statement of Need @@ -135,8 +135,8 @@ A persistent challenge in satellite-based snow detection is the obstruction of the sensor's view by forest canopy, which can cause snow-covered pixels beneath dense tree cover to be systematically misclassified as snow-free. PlanetSCA addresses this through a `post_process` module that provides canopy-aware -spatial infilling of SCA predictions using a canopy height model (CHM). -Forested pixels classified as snow-free are reclassified as snow-covered when a +spatial infilling of SCA predictions using a canopy height model (CHM). Forested +pixels classified as snow-free are reclassified as snow-covered when a sufficient fraction of their open-area neighbors are snow-covered, with configurable kernel radius and threshold. The module further provides temporal median filtering applied independently to forested and open pixels, nodata @@ -145,9 +145,9 @@ day-since-disappearance (DSD) dates for characterizing snowmelt timing. A complementary `validate` module supports quantitative evaluation of PlanetSCA predictions against Airborne Snow Observatory (ASO) lidar-derived reference data, computing standard binary classification metrics (precision, recall, -F1-score, accuracy, and Cohen's kappa) and producing a four-class -snow-by-canopy validation raster for stratified assessment of model performance -in forested versus open terrain. +F1-score, accuracy, and Cohen's kappa) and producing a four-class snow-by-canopy +validation raster for stratified assessment of model performance in forested +versus open terrain. # Acknowledgements diff --git a/src/planetsca/validate.py b/src/planetsca/validate.py index a1ce27b..14b2084 100644 --- a/src/planetsca/validate.py +++ b/src/planetsca/validate.py @@ -508,15 +508,15 @@ def validation_tif_4class( ) chm_binary = chm_tif.squeeze() - assert ( - aso_binary.shape == chm_binary.shape - ), "ASO and CHM rasters must have the same shape" - assert ( - aso_binary.rio.crs == chm_binary.rio.crs - ), "ASO and CHM rasters must have the same CRS" - assert ( - aso_binary.rio.transform() == chm_binary.rio.transform() - ), "ASO and CHM rasters must have the same transform" + assert aso_binary.shape == chm_binary.shape, ( + "ASO and CHM rasters must have the same shape" + ) + assert aso_binary.rio.crs == chm_binary.rio.crs, ( + "ASO and CHM rasters must have the same CRS" + ) + assert aso_binary.rio.transform() == chm_binary.rio.transform(), ( + "ASO and CHM rasters must have the same transform" + ) combined = np.full(aso_binary.shape, np.nan, dtype=np.float32) combined[(aso_binary == 0) & (chm_binary == 1)] = 0