Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions tests/config_test_only_water.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"main_config": "tests/main_only_water_config.json",
"features_test_img": "/work/CAMPUS/etudes/Masques_CO3D/Validation/Input-Data/SanFrancisco/xt_SanFrancisco.tif",
"ref_dir": "/work/CAMPUS/etudes/Masques_CO3D/Validation/Input-Data/SanFrancisco/ref",
"valid_stack": "/work/CAMPUS/etudes/Masques_CO3D/Validation/Input-Data/SanFrancisco/ref/valid_stack.tif"
}
137 changes: 137 additions & 0 deletions tests/main_only_water_config.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,137 @@
{
"input": {
"file_vhr": "/work/CAMPUS/etudes/Masques_CO3D/Validation/Input-Data/SanFrancisco/xt_SanFrancisco.tif",
"sensor_mode": false
},
"aux_layers": {
"valid_stack": "/work/CAMPUS/etudes/Masques_CO3D/Validation/Input-Data/SanFrancisco/ref/valid_stack.tif",
"file_ndvi": "/work/CAMPUS/etudes/Masques_CO3D/Validation/Input-Data/SanFrancisco/ref/ndvi.tif",
"file_ndwi": "/work/CAMPUS/etudes/Masques_CO3D/Validation/Input-Data/SanFrancisco/ref/ndwi.tif",
"extracted_pekel": "/work/CAMPUS/etudes/Masques_CO3D/Validation/Input-Data/SanFrancisco/ref/pekel.tif",
"extracted_hand": "/work/CAMPUS/etudes/Masques_CO3D/Validation/Input-Data/SanFrancisco/ref/hand.tif",
"extracted_wsf": "/work/CAMPUS/etudes/Masques_CO3D/Validation/Input-Data/SanFrancisco/ref/wsf.tif",
"extracted_wbm": "/work/CAMPUS/etudes/Masques_CO3D/Validation/Input-Data/SanFrancisco/ref/wbm.tif",
"file_texture": "/work/CAMPUS/etudes/Masques_CO3D/Validation/Input-Data/SanFrancisco/ref/texture.tif",
"mnh": null,
"file_cloud_gml": null
},
"masks": {
"watermask": "/work/CAMPUS/etudes/Masques_CO3D/Validation/Input-Data/SanFrancisco/test/watermask.tif",
"urbanmask": "/work/CAMPUS/etudes/Masques_CO3D/Validation/Input-Data/SanFrancisco/test/urbanmask.tif",
"vegetationmask": "/work/CAMPUS/etudes/Masques_CO3D/Validation/Input-Data/SanFrancisco/test/vegetationmask.tif",
"shadowmask": "/work/CAMPUS/etudes/Masques_CO3D/Validation/Input-Data/SanFrancisco/test/shadowmask.tif",
"stackmask": "/work/CAMPUS/etudes/Masques_CO3D/Validation/Input-Data/SanFrancisco/test/stackmask.tif"
},
"resources": {
"n_workers": 8,
"tile_max_size": 1000,
"multiproc_context": "spawn",
"n_jobs": 1,
"save_mode": "none"
},
"prepare": {
"red": 1,
"green": 2,
"nir": 4,
"cloud_mask": null,
"pekel_method": "all",
"pekel": "/work/datalake/static_aux/MASQUES/PEKEL/data2021/occurrence/occurrence.vrt",
"pekel_monthly_occurrence": "/work/datalake/static_aux/MASQUES/PEKEL/data2021/MonthlyRecurrence",
"pekel_obs": null,
"hand": "/work/datalake/static_aux/MASQUES/HAND_MERIT/hnd.vrt",
"wsf": "/work/datalake/static_aux/MASQUES/WSF/WSF2019_v1/WSF2019_v1.vrt",
"texture_rad": 5,
"dtm": null,
"geoid_file": "/softs/projets/3d/geoids/egm96.grd",
"analyse_glcm": true,
"land_cover_map": "/work/CAMPUS/DATA/ESA_WORLDCOVER/ESA_WorldCover.vrt",
"cropped_land_cover_map": false,
"effective_used_config": "out/effective_used_config.json",
"wbm": "/work/CAMPUS/etudes/Masques_CO3D/Data/WBM/wbm.vrt"
},
"post_process": {
"binary_opening": 2,
"binary_closing": 2,
"binary_dilation": 2,
"remove_small_objects": 100,
"remove_small_holes": 100,
"area_closing": null
},
"shadows": {
"th_rgb": 0.2,
"th_nir": 0.2,
"percentile": 2,
"absolute_threshold": false
},
"urban": {
"files_layers": [],
"vegmask_min_value": 21,
"veg_binary_dilation": 5,
"value_classif": 255,
"gt_binary_erosion": 5,
"nb_samples_other": 5000,
"nb_samples_urban": 1000,
"max_depth": 8,
"nb_estimators": 100
},
"vegetation": {
"texture_mode": "yes",
"filter_texture": 90,
"slic_seg_size": 100,
"slic_compactness": 0.1,
"nb_clusters_veg": 2,
"min_ndvi_veg": null,
"max_ndvi_noveg": null,
"non_veg_clusters": null,
"nb_clusters_low_veg": 2,
"max_texture_th": null,
"debug": false,
"pct_veg": 0.19173363949483352,
"pct_low_veg": 0.023727516264829697,
"pct_high_veg": 0.16800612323000383,
"pct_non_veg": 0.14772292384232683
},
"water": {
"files_layers": [],
"thresh_pekel": 50,
"thresh_hand": 25,
"hand_strict": false,
"strict_thresh": 50,
"simple_ndwi_threshold": false,
"ndwi_threshold": 0.1,
"samples_method": "grid",
"nb_samples_water": 2000,
"nb_samples_other": 10000,
"nb_samples_auto": false,
"auto_pct": 0.0002,
"smart_area_pct": 50,
"smart_minimum": 10,
"grid_spacing": 40,
"max_depth": 8,
"nb_estimators": 100,
"no_pekel_filter": false,
"hand_filter": false,
"value_classif": 1
},
"stack": {
"building_threshold": 70,
"building_erosion": 2,
"bonus_gt": 10,
"malus_shadow": 10,
"value_classif_low_veg": 1,
"value_classif_high_veg": 2,
"value_classif_water": 3,
"value_classif_buildings": 4,
"value_classif_bare_ground": 6,
"value_classif_sea": 7,
"value_classif_lake": 8,
"value_classif_river": 9,
"value_classif_false_positive_buildings": 10,
"value_classif_background": 11,
"vegmask_min_value": 21,
"minimal_size_water_area": 10000,
"binary_closing": 0,
"binary_opening": 0,
"categorized_watermask": true
}
}
30 changes: 30 additions & 0 deletions tests/test_features/test_features_watermask.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
#
"""Test water mask with differents features and different arguments values"""

import json
import sys

import pytest
Expand Down Expand Up @@ -214,3 +215,32 @@ def test_hand_filter_ci(
command = f"{cmd} -hand_filter".split()
sys.argv = command
slurp.masks.watermask.main()


@pytest.mark.features
@pytest.mark.parametrize(
"params_file",
[
"tests/config_test_only_water.json",
],
)
def test_only_water(params_file, output_dir):
"""Tests the water mask computation when recieving full water tile"""

# Charger le JSON
with open(params_file, "r") as f:
params = json.load(f)

cmd = (
write_command_compute_watermask(
1,
params["main_config"],
params["features_test_img"],
output_dir,
params["ref_dir"],
params["valid_stack"],
)
)
command = f"{cmd} -nb_samples_auto".split()
sys.argv = command
slurp.masks.watermask.main()
Loading