-
Notifications
You must be signed in to change notification settings - Fork 0
/
Intarsis_02_allign
executable file
·154 lines (132 loc) · 4.41 KB
/
Intarsis_02_allign
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
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
#!/bin/bash
# Start the IW allignement
# You must input as arguments the IW as F1, F2 or F3 and the master date as YYYYMMDD
# Also, a master_image file containing the date of MM is possible to use.
# TODO: check if MM is present in the SLC.
# Intarsis root folder check
if [ ! -f ".intarsis_folder" ]; then
echo "You must run Intarsis_02a_allign inside a Intarsis root folder"
echo "Run Intarsis_01_file_preparation and other routines first"
exit
fi
INTARSIS_FOLDER=$(pwd)
# Intarsis previous step check
if [ ! -f ".intarsis_step01" ]; then
echo "You must run Intarsis_02_allign first"
exit
fi
if [ -f "intarsis.config" ]; then
echo "intarsis.config found, importing variables"
IW=$(grep swath_number intarsis.config | awk '{print $2}'| tr '[:lower:]' '[:upper:]')
MM=$(grep master_slc intarsis.config | awk '{print $2}')
ESD=$(grep use_esd intarsis.config | awk '{print $2}')
ESD_MODE=$(grep esd_mode 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 [ -z $1 ]; then
echo "Must specify IW and MM date as parameters or configure it in intarsis.config"
echo "Example: Intarsis_02_allign F[1,2,3] YYYYMMDD"
exit
else
echo "You must specify the IW as F1,F2 or F3"
exit
fi
if [[ ! -z $MM ]] && [[ $(echo "$MM > 20140000" | bc -l) == 1 ]] && [[ $(echo "$MM < 20250000" | bc -l) == 1 ]]; then
#echo "master SLC selected via intarsis.config: $MM"
MM_config=true
elif [ -z $2 ]; then
echo "Must specify IW and MM date as parameters or configure it in intarsis.config"
echo "Example: Intarsis_02_allign F[1,2,3] YYYYMMDD"
exit
elif [[ $(echo "$2 > 20140000" | bc -l) == 1 ]] && [[ $(echo "$2 < 20250000" | bc -l) == 1 ]]; then
#echo "Master Master set to $2"
MM=$2
MM_config=false
else
echo "Error in Master Master date"
exit
fi
if [ -z $ESD ]; then
echo "Disabling ESD mode (default)"
ESD=false
fi
echo "###################################################################"
echo "Intarsis corregistration settings:"
if $MM_config; then
echo "Master master date: $MM (imported from intarsis.config)"
else
echo "Master master date: $MM (command line)"
fi
if $IW_config; then
echo "Swath to process: $IW (imported from intarsis.config)"
else
echo "Swath to process: $IW (command line)"
fi
if $ESD; then
echo "ESD for fine corregistration is enabled"
if [ -z $ESD_MODE ]; then
echo "ESD mode is not defined. Configure it in intarsis.config or disable ESD"
exit
else
if [ $ESD_MODE == "0" ]; then
echo "ESD mode is set to: 0 (average)"
elif [ $ESD_MODE == "1" ]; then
echo "ESD mode is set to: 1 (median)"
elif [ $ESD_MODE == "2" ]; then
echo "ESD mode is set to: 2 (interpolation)"
else
echo "Invalid ESD mode, please use 0, 1 or 2"
exit
fi
fi
else
echo "ESD is disabled"
fi
echo "###################################################################"
echo "$(date "+%d/%m/%y %H:%M") - Run Allign $IW" >> intarsis.log
# Creating Directories
# TODO: ask before remove existing IW folder
rm -r $IW &> /dev/null # Cleaning from previous processings
mkdir $IW $IW/raw $IW/topo
ln -s $(pwd)/topo/dem.grd $IW/topo/
cd $IW/raw
ln -s ../../data/F*/*.SAFE/*/*iw$IWN*vv*xml .
ln -s ../../data/F*/*.SAFE/*/*iw$IWN*vv*tiff .
ln -s ../../data/*EOF .
ln -s ../topo/dem.grd .
ln -s ../../data/orbits.list .
prep_data_linux.csh
# RUN FIRST STEP OF PREPROC_BATCH (generates baseline_table.dat)
if $ESD; then
preproc_batch_tops_esd.csh data.in dem.grd 1 $ESD_MODE
else
preproc_batch_tops.csh data.in dem.grd 1
fi
# Modify data.in to put the MM on the top
grep '\-vv\-'$MM'' data.in > data.in_temp
grep -v '\-vv\-'$MM'' data.in >> data.in_temp
mv data.in data.in.old
mv data.in_temp data.in
# RUN SECOND STEP OF PREPROC_BATCH
if $ESD; then
preproc_batch_tops_esd.csh data.in dem.grd 2 $ESD_MODE
else
preproc_batch_tops.csh data.in dem.grd 2
fi
# Generation of baseline_table.dat (due to bug present in trunk)
rm baseline_table.dat &> /dev/null
MM_PRM='S1_'$MM'_ALL_'$IW'.PRM'
for i in $(ls *ALL*PRM); do
baseline_table.csh $MM_PRM $i >> baseline_table.dat
done
cp baseline_table.dat ..
# Update log & create control files
cd $INTARSIS_FOLDER
touch .intarsis_step02_$IW &> /dev/null # Creates a file to identify step02 done
echo "$(date "+%d/%m/%y %H:%M") - Finished Allign $IW" >> intarsis.log