forked from GEUS-SICE/SICE
-
Notifications
You must be signed in to change notification settings - Fork 0
/
S3_wrapper.sh
executable file
·84 lines (64 loc) · 2.3 KB
/
S3_wrapper.sh
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
#!/usr/bin/env bash
# Wrapper for running SICE pipeline
set -o errexit
set -o nounset
set -o pipefail
set -x
red='\033[0;31m'; orange='\033[0;33m'; green='\033[0;32m'; nc='\033[0m' # No Color
log_info() { echo -e "${green}[$(date --iso-8601=seconds)] [INFO] ${@}${nc}"; }
log_warn() { echo -e "${orange}[$(date --iso-8601=seconds)] [WARN] ${@}${nc}"; }
log_err() { echo -e "${red}[$(date --iso-8601=seconds)] [ERR] ${@}${nc}" 1>&2; }
# CREODIAS
SEN3_local=/eodata/Sentinel-3
SEN3_source=~/sice-data/SICE/S3
proc_root=~/sice-data/SICE/proc
mosaic_root=~/sice-data/SICE/mosaic
### dev
# SEN3_source=./SEN3
# proc_root=./out
# mosaic_root=./mosaic
# Geographic area
area=Greenland
# Svalbard...
# Slope correction
slopey=false
# Fast processing:
fast=true
if [ "$fast" = true ] ; then
# so far the only speed up done is to not extract all bands
xml_file=S3_fast.xml
else
xml_file=S3.xml
fi
LD_LIBRARY_PATH=. # SNAP requirement
for year in 2020 ; do
for doy in $(seq -w 91 276); do
### DEBUG
# for year in 2018; do
# for doy in 227; do # 2017-08-15=227
date=$(date -d "${year}-01-01 +$(( 10#${doy}-1 )) days" "+%Y-%m-%d")
if [[ -d "${mosaic_root}/${date}" ]] && [[ -e "${mosaic_root}/${date}/conc.tif" ]]; then
log_warn "${mosaic_root}/${date} already exists, date skipped"
continue
fi
### Fetch one day of OLCI & SLSTR scenes over Greenland
## Use local files (PTEP, DIAS, etc.)
./dhusget_wrapper.sh -d ${date} -l ${SEN3_local} -o ${SEN3_source}/${year}/${date} \
-f ${area} -u usr -p psswd || error=true
## Download files
# ./dhusget_wrapper.sh -d ${date} -o ${SEN3_source}/${year}/${date} \
# -f Svalbard -u <user> -p <password>
# SNAP: Reproject, calculate reflectance, extract bands, etc.
./S3_proc.sh -i ${SEN3_source}/${year}/${date} -o ${proc_root}/${date} -X ${xml_file} -t || error=true
# Run the Simple Cloud Detection Algorithm (SCDA)
python ./SCDA.py ${proc_root}/${date} || error=true
# Mosaic
./dm.sh ${date} ${proc_root}/${date} ${mosaic_root} || error=true
if [ "$slopey" = true ] ; then
# Run the slopey correction
python ./get_ITOAR.py ${mosaic_root}/${date}/ $(pwd)/ArcticDEM/ || error=true
fi
# SICE
python ./sice.py ${mosaic_root}/${date} || error=true
done
done