Commit 421baee8 authored by Germain Salgues's avatar Germain Salgues

ENH: Add tests for snow annual map, requires Data-LIS-1.5

parent 6e19a738
......@@ -453,7 +453,6 @@ def main():
"date_margin":15,
"mode":"DEBUG",
"input_products_list":[],
"snow_products_dir":"/work/OT/siaa/Theia/Neige/PRODUITS_NEIGE_LIS_develop_1.5",
"path_tmp":os.environ.get('TMPDIR'),
"path_out":"/home/qt/salguesg/scratch/workdir",
"ram":4096,
......
......@@ -111,12 +111,25 @@ add_test(NAME s2-small_zip_test_json_builder_test
"${OUTPUT_TEST_S2_SMALL_ZIP}"
)
set(CURRENT_TEST_BASELINE ${BASELINE}/${test_name}_test)
set(CURRENT_TEST_OUTPUT ${OUTPUT_TEST}/${test_name})
add_test(NAME s2-small_zip_test
COMMAND ${PYTHON_EXECUTABLE}
${CMAKE_BINARY_DIR}/app/run_snow_detector.py ${OUTPUT_TEST_S2_SMALL_ZIP}/param_test.json
)
set_tests_properties(s2-small_zip_test PROPERTIES DEPENDS s2-small_zip_test_json_builder_test)
add_test(NAME snow_annual_map_test
COMMAND ${CMAKE_CURRENT_SOURCE_DIR}/snow_annual_map_test.py
"${DATA_TEST}/SNOW_PRODUCTS"
"${OUTPUT_TEST}/snow_annual_map_test"
"${OUTPUT_TEST}/snow_annual_map_test/tmp"
)
add_test(NAME snow_annual_map_compare_test
COMMAND gdalcompare.py
"${BASELINE}/snow_annual_map_test/SNOW_OCCURENCE_T31TCH_20180101_20180131.tif"
"${OUTPUT_TEST}/snow_annual_map_test/T31TCH_20180101_20180131/SNOW_OCCURENCE_T31TCH_20180101_20180131.tif"
)
set_tests_properties(snow_annual_map_compare_test PROPERTIES DEPENDS snow_annual_map_test)
# add_test(NAME compare_preprocessing_output_test
# COMMAND ${CMAKE_COMMAND} -E compare_files
......
#!/usr/bin/env python
# -*- coding: utf-8 -*-
import os
import sys
import os.path as op
import logging
from s2snow import snow_annual_map_evaluation
def main(argv):
logging.info("Start snow_annual_map_test")
data_path = str(argv[1])
out_path = str(argv[2])
if not op.exists(out_path):
os.mkdir(out_path)
tmp_path = str(argv[3])
if not op.exists(tmp_path):
os.mkdir(tmp_path)
# Remove the target file, because the success of the test depends on this file creation
target_file = op.join(out_path, "T31TCH_20180101_20180131", "SNOW_OCCURENCE_T31TCH_20180101_20180131.tif")
if op.exists(target_file):
os.remove(target_file)
params = {
"densification_products_list": [
op.join(data_path,"LANDSAT8-OLITIRS-XS_20180115-103629-617_L2A_T31TCH_D_V1-9"),
op.join(data_path,"LANDSAT8-OLITIRS-XS_20180131-103619-890_L2A_T31TCH_D_V1-9")
],
"date_margin": 10,
"path_out": out_path,
"mode": "DEBUG",
"input_products_list": [
op.join(data_path,"SENTINEL2A_20180101-105435-457_L2A_T31TCH_D_V1-4"),
op.join(data_path,"SENTINEL2A_20180131-105416-437_L2A_T31TCH_D_V1-4")
],
"log": True,
"log_stdout": op.join(data_path,"stdout.log"),
"date_start": "01/01/2018",
"log_stderr": op.join(data_path,"stderr.log"),
"path_tmp": tmp_path,
"ram": 1024,
"use_densification": True,
"data_availability_check": True,
"tile_id": "T31TCH",
"date_stop": "31/01/2018",
"nbThreads": 1}
# Run the snow detector
snow_annual_map_evaluation_app = snow_annual_map_evaluation.snow_annual_map_evaluation(params)
snow_annual_map_evaluation_app.run()
if params.get("run_comparison_evaluation", False):
snow_annual_map_evaluation_app.run_evaluation()
if params.get("run_modis_comparison", False):
snow_annual_map_evaluation_app.compare_modis()
if not op.exists(op.join(out_path, "T31TCH_20180101_20180131", "SNOW_OCCURENCE_T31TCH_20180101_20180131.tif")):
logging.error("The target does not exists, the test has failed")
sys.exit(1)
logging.info("End snow_annual_map_test")
if __name__== "__main__":
# Set logging level and format.
logging.basicConfig(stream=sys.stdout, level=logging.INFO, format=\
'%(asctime)s - %(filename)s:%(lineno)s - %(levelname)s - %(message)s')
main(sys.argv)
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment