-
Notifications
You must be signed in to change notification settings - Fork 0
/
Intarsis_05_unwrap
executable file
·127 lines (112 loc) · 3.74 KB
/
Intarsis_05_unwrap
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
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
#!/bin/bash
# This program unwrap the phase using snaphu.csh or snaphu_interp.csh
# It uses parallel to spawn the unwrapping across several threads.
# A script called unwrap_intf.csh is needed in order to run this program.
# TODO: include generation of unwrap_intf.csh, allow enable or disable interpolation
# Intarsis root folder check
if [ ! -f ".intarsis_folder" ]; then
echo "You must run Intarsis_05_unwrap inside a Intarsis root folder"
echo "Run Intarsis_01_file_preparation and other routines first"
exit
fi
# Getting parameters from intarsis.config
if [ -f "intarsis.config" ]; then
MERGE=$(grep merge_swaths intarsis.config | awk '{print $2}')
if $MERGE; then IW=merged; else IW=$(grep swath_number intarsis.config | awk '{print $2}' | tr '[:lower:]' '[:upper:]'); fi
COHERENCE=$(grep unwrap_coherence intarsis.config | awk '{print $2}')
INTERPOLATION=$(grep unwrap_interpolation intarsis.config | awk '{print $2}')
PARALLEL=$(grep use_parallel intarsis.config | awk '{print $2}')
NUM_THREADS=$(grep num_cores intarsis.config | awk '{print $2}')
fi
if [[ "$1" == "F1" ]] || [[ "$1" == "F2" ]] || [[ "$1" == "F3" ]]; then
IW=$1
IWN=$(echo $IW | cut -c 2)
IW_config=false
elif [[ "$IW" == "F1" ]] || [[ "$IW" == "F2" ]] || [[ "$IW" == "F3" ]]; then
IWN=$(echo $IW | cut -c 2)
IW_config=true
elif [[ $1 == "merged" ]] || [[ $1 == "MERGED" ]]; then
IW=merged
IW_config=false
elif [[ $IW == "merged" ]]; then
IW=merged
IW_config=true
elif [ -z $1 ]; then
echo "Must specify IW as parameters or configure it in intarsis.config"
echo "Example: Intarsis_05_unwrap F1"
exit
else
echo "You must specify the IW as F1,F2 or F3"
exit
fi
# Intarsis previous step check
if [ $IW == "merged" ]; then
if [ ! -f ".intarsis_step04a" ]; then
echo "You must run Intarsis_04a_merge first"
exit
fi
else
if [ ! -f ".intarsis_step03_$IW" ]; then
echo "You must run Intarsis_03_interferograms first"
exit
fi
fi
# Report of the selected parameters
echo "###################################################################"
echo "Intarsis Unwrap parameters:"
if $IW_config; then
echo "Swath to process: $IW (imported from intarsis.config)"
else
echo "Swath to process: $IW (command line)"
fi
# Check if B_P and B_T are configured as valid numbers
if [ $(echo "$COHERENCE > 0" | bc -l) ] && [ $(echo "$COHERENCE < 1" | bc -l) ] 2>/dev/null; then
echo "Coherence threshold for unwrap: $COHERENCE (imported from intarsis.config)"
else
COHERENCE=0.15
echo "Coherence threshold for unwrap: $COHERENCE (default value)"
fi
if $INTERPOLATION; then
echo "Selected interpolation for low coherence pixels"
else
echo "No interpolation in unwrapping"
fi
if $PARALLEL; then
echo "Paralellization is on"
if [ -n "$NUM_THREADS" ] && [ "$NUM_THREADS" -eq "$NUM_THREADS" ] 2>/dev/null; then
echo "Number of CPU threads: $NUM_THREADS (imported from intarsis.config)"
else
NUM_THREADS=6
echo "Number of CPU threads: $NUM_THREADS (default value)"
fi
else
echo "Paralelization is off"
fi
# Test for unwrap_intf.csh for parallelization
which unwrap_intf.csh &> /dev/null
if [ "$?" -eq 0 ]; then
echo "unwrap_intf.csh is found"
else
echo "unwrap_intf.csh not found, exiting"
exit
fi
echo "###################################################################"
echo "$(date "+%d/%m/%y %H:%M") - Starting unwrap $IW" >> intarsis.log
if [ $IW == "merged" ]; then
cd merged
else
cd $IW/intf_all
fi
rm intflist
ls -d 2*/ > intflist
sed -i 's/\///g' intflist
unwrap_parallel.csh intflist $NUM_THREADS
rm log_*.txt # clean log files
if [ $IW == "merged" ]; then
cd ..
else
cd ../..
fi
# Update log & create control files
touch .intarsis_step05_$IW &> /dev/null # Intarsis step control file
echo "$(date "+%d/%m/%y %H:%M") - Finished unwrap $IW" >> intarsis.log