This repository was archived by the owner on Feb 15, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathrun_experiment.sh
More file actions
executable file
·92 lines (64 loc) · 6.55 KB
/
run_experiment.sh
File metadata and controls
executable file
·92 lines (64 loc) · 6.55 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
#!/bin/bash
# Path to base directory with scripts.
script_dir="/home/alber/Documents/ghProjects/deforestation-sentinel2"
# Path to brick files.
brick_dir="./brick_sentinel2"
# Path to Sentinel images
sentinel_L1C="./data/raster/sentinel_L1C"
sentinel_L2A="./data/raster/sentinel_L2A"
#---- Build bricks ----
# Build VRTs from the bands.
"${script_dir}"/01_build_bricks/./build_vrt_base.sh bilinear "${sentinel_L2A}"/*/GRANULE/*/IMG_DATA/*/*.jp2
# Build VRTs from the FMASKs.
"${script_dir}"/01_build_bricks/./build_vrt_base.sh nearest "${sentinel_L1C}"/S2A_MSIL1C_201*/GRANULE/*/FMASK_DATA/*.tif
# NOTE: build_index.sh already uses GNU parallel to run.
parallel -j 1 "${script_dir}"/01_build_bricks/./build_index.sh ::: evi_10m ndmi_10m ndvi_10m savi_10m
# NOTE: build_index.sh already uses GNU parallel to run.
parallel -j 1 "${script_dir}"/01_build_bricks/./mask_images.sh ::: B02_10m B03_10m B04_10m B08_10m B11_10m B12_10m B8A_10m evi_10m ndmi_10m ndvi_10m savi_10m
parallel -j 8 "${script_dir}"/01_build_bricks/./build_vrt_brick.sh ::: B02_10m B03_10m B04_10m B08_10m B11_10m B12_10m B8A_10m evi_10m ndmi_10m ndvi_10m savi_10m
# NOTE: Build VRTs for masked bands and indeces
parallel -j 8 "${script_dir}"/01_build_bricks/./build_vrt_brick.sh ::: B02_masked_10m B03_masked_10m B04_masked_10m B08_masked_10m B11_masked_10m B12_masked_10m B8A_masked_10m evi_masked_10m ndmi_masked_10m ndvi_masked_10m savi_masked_10m
parallel -j 8 "${script_dir}"/01_build_bricks/./build_tif_brick.sh ::: B02_10m B03_10m B04_10m B08_10m B11_10m B12_10m B8A_10m evi_10m ndmi_10m ndvi_10m savi_10m
# NOTE: Build TIFs for masked bands and indeces
parallel -j 8 "${script_dir}"/01_build_bricks/./build_tif_brick.sh ::: B02_masked_10m B03_masked_10m B04_masked_10m B08_masked_10m B11_masked_10m B12_masked_10m B8A_masked_10m evi_masked_10m ndmi_masked_10m ndvi_masked_10m savi_masked_10m
#---- Interpolate masked bricks ----
Rscript "${script_dir}"/01_build_bricks/interp_sentinel-2.R approx "${brick_dir}"/S2A_MSIL2A_R096_T20LKP_20180812T143751_B02_masked_10m.tif "${brick_dir}"/S2A_MSIL2A_R096_T20LKP_20180812T143751_B02_approx_10m.tif
Rscript "${script_dir}"/01_build_bricks/interp_sentinel-2.R approx "${brick_dir}"/S2A_MSIL2A_R096_T20LKP_20180812T143751_B03_masked_10m.tif "${brick_dir}"/S2A_MSIL2A_R096_T20LKP_20180812T143751_B03_approx_10m.tif
Rscript "${script_dir}"/01_build_bricks/interp_sentinel-2.R approx "${brick_dir}"/S2A_MSIL2A_R096_T20LKP_20180812T143751_B04_masked_10m.tif "${brick_dir}"/S2A_MSIL2A_R096_T20LKP_20180812T143751_B04_approx_10m.tif
Rscript "${script_dir}"/01_build_bricks/interp_sentinel-2.R approx "${brick_dir}"/S2A_MSIL2A_R096_T20LKP_20180812T143751_B08_masked_10m.tif "${brick_dir}"/S2A_MSIL2A_R096_T20LKP_20180812T143751_B08_approx_10m.tif
Rscript "${script_dir}"/01_build_bricks/interp_sentinel-2.R approx "${brick_dir}"/S2A_MSIL2A_R096_T20LKP_20180812T143751_B11_masked_10m.tif "${brick_dir}"/S2A_MSIL2A_R096_T20LKP_20180812T143751_B11_approx_10m.tif
Rscript "${script_dir}"/01_build_bricks/interp_sentinel-2.R approx "${brick_dir}"/S2A_MSIL2A_R096_T20LKP_20180812T143751_B12_masked_10m.tif "${brick_dir}"/S2A_MSIL2A_R096_T20LKP_20180812T143751_B12_approx_10m.tif
Rscript "${script_dir}"/01_build_bricks/interp_sentinel-2.R approx "${brick_dir}"/S2A_MSIL2A_R096_T20LKP_20180812T143751_B8A_masked_10m.tif "${brick_dir}"/S2A_MSIL2A_R096_T20LKP_20180812T143751_B8A_approx_10m.tif
Rscript "${script_dir}"/01_build_bricks/interp_sentinel-2.R approx "${brick_dir}"/S2A_MSIL2A_R096_T20LKP_20180812T143751_evi_masked_10m.tif "${brick_dir}"/S2A_MSIL2A_R096_T20LKP_20180812T143751_evi_approx_10m.tif
Rscript "${script_dir}"/01_build_bricks/interp_sentinel-2.R approx "${brick_dir}"/S2A_MSIL2A_R096_T20LKP_20180812T143751_ndmi_masked_10m.tif "${brick_dir}"/S2A_MSIL2A_R096_T20LKP_20180812T143751_ndmi_approx_10m.tif
Rscript "${script_dir}"/01_build_bricks/interp_sentinel-2.R approx "${brick_dir}"/S2A_MSIL2A_R096_T20LKP_20180812T143751_ndvi_masked_10m.tif "${brick_dir}"/S2A_MSIL2A_R096_T20LKP_20180812T143751_ndvi_approx_10m.tif
Rscript "${script_dir}"/01_build_bricks/interp_sentinel-2.R approx "${brick_dir}"/S2A_MSIL2A_R096_T20LKP_20180812T143751_savi_masked_10m.tif "${brick_dir}"/S2A_MSIL2A_R096_T20LKP_20180812T143751_savi_approx_10m.tif
#---- Install SITS ----
Rscript "${script_dir}"/other/install_sits.R
#---- Get time series ----
# NOTE: approx refers to bricks on which the clouds have been replace by interpolation (R's approx function).
# NOTE: raw refers to bricks made of images as they are.
"${script_dir}"/02_get_time_series/get_time_series.R "${script_dir}"/data/validation/samples_all_bands.csv "${brick_dir}" approx "${script_dir}"/data/validation/samples_A_approx.rds
"${script_dir}"/02_get_time_series/get_time_series.R "${script_dir}"/data/validation/samples_indices.csv "${brick_dir}" approx "${script_dir}"/data/validation/samples_B_approx.rds
"${script_dir}"/02_get_time_series/get_time_series.R "${script_dir}"/data/validation/samples_all_bands.csv "${brick_dir}" raw "${script_dir}"/data/validation/samples_A_raw.rds
"${script_dir}"/02_get_time_series/get_time_series.R "${script_dir}"/data/validation/samples_indices.csv "${brick_dir}" raw "${script_dir}"/data/validation/samples_B_raw.rds
"${script_dir}"/02_get_time_series/create_samples_3_labels.R "${script_dir}"/data/validation/samples_A_approx.rds
"${script_dir}"/02_get_time_series/create_samples_3_labels.R "${script_dir}"/data/validation/samples_B_approx.rds
"${script_dir}"/02_get_time_series/create_samples_3_labels.R "${script_dir}"/data/validation/samples_A_raw.rds
"${script_dir}"/02_get_time_series/create_samples_3_labels.R "${script_dir}"/data/validation/samples_B_raw.rds
#---- Compute K-Folds ----
"${script_dir}"/03_kfolds/k-folds_analysis.R "${script_dir}"/data/validation/samples_B_approx_3l.rds "${script_dir}"/plot/kfold_approx
"${script_dir}"/03_kfolds/k-folds_analysis.R "${script_dir}"/data/validation/samples_B_raw_3l.rds "${script_dir}"/plot/kfold_raw
#---- Classify bricks ----
samples_B_approx_3l="${script_dir}"/data/validation/samples_B_approx_3l.rds
three_labels="Deforestatio,Forest,NonForest"
bands="blue,bnir,green,nnir,red,swir1,swir2"
indices="evi,ndmi,ndvi"
version="009"
out_base_dir="${script_dir}"/results9
"${script_dir}"/04_classify/classify_bricks.R approx "${brick_dir}" "${samples_B_approx_3l}" "${three_labels}" "${bands}" "${version}" "${out_base_dir}"
"${script_dir}"/04_classify/classify_bricks.R approx "${brick_dir}" "${samples_B_approx_3l}" "${three_labels}" "${indices}" "${version}" "${out_base_dir}"
#---- Post-processing ----
#---- Validation ----
"${script_dir}"/06_validation/validate_results.R
exit 0