-
Notifications
You must be signed in to change notification settings - Fork 5
/
prep_dir.sh
executable file
·66 lines (57 loc) · 2.27 KB
/
prep_dir.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
#!/bin/bash
######################################################################
# 01
# script to prepare the directory
# GMT5SAR processing for sentinel1A/B
# 2017.01.30 "Noorlaila Hayati"
# email: [email protected] or [email protected]
######################################################################
raw_path=$1
suffix_tiff=$2
type_data=$3
orb=$4
mkdir batch_"$orb"
cd batch_"$orb"
mkdir raw_orig
cd ..
ls "$raw_path" -1 | sed -e 's/\.zip$//' > data_orb_"$orb".txt
ls "$raw_path" | awk '{print substr($0,18,8)}' > date_"$orb".txt
paste -d\ data_orb_"$orb".txt date_"$orb".txt > data_"$orb"_grub.txt
# sorted data
sort -k 2 data_"$orb"_grub.txt > data_"$orb"_grub_tmp.txt
mv data_"$orb"_grub_tmp.txt data_"$orb"_grub.txt
sort -k 1 date_"$orb".txt > date_"$orb"_tmp.txt
mv date_"$orb"_tmp.txt date_"$orb".txt
rm -f data_orb_"$orb".txt
dir_path=$(pwd)
suffix_tmp=$suffix_tiff
shopt -s extglob
IFS=" "
while read name date
do
# identify Single or Dual Polarisation
if [ $type_data == "mix" ]; then
polar=$(echo $name | awk '{print substr ($0, 14, 3)}')
if [ $polar == "SDV" ]; then
i=$(expr $suffix_tiff + 3)
suffix_tiff=$(printf "%03d" "$i")
echo " TIFF number has changed $suffix_tiff , Dual Polarisation is identified"
elif [ $polar == "SSV" ]; then
suffix_tiff=$suffix_tmp
echo " Keep TIFF number $suffix_tiff, Single Polarisation is identified"
fi
elif [ $type_data == "single" ]; then
echo " TIFF number doesn't change, all data are Single Polarisation"
elif [ $type_data == "dual" ]; then
echo " TIFF number doesn't change, all data are Dual Polarisation"
fi
unzip "$raw_path"/"$name".zip "$name".SAFE/measurement/*"$suffix_tiff".tiff
mv "$name".SAFE/measurement/*"$suffix_tiff".tiff $dir_path/batch_"$orb"/raw_orig/.
unzip "$raw_path"/"$name".zip "$name".SAFE/manifest.safe
mv "$name".SAFE/manifest.safe $dir_path/batch_"$orb"/raw_orig/"$date"_manifest.safe
unzip "$raw_path"/"$name".zip "$name".SAFE/annotation/*"$suffix_tiff".xml
mv "$name".SAFE/annotation/*"$suffix_tiff".xml $dir_path/batch_"$orb"/raw_orig/.
rm -r -f $name.SAFE
suffix_tiff=$suffix_tmp
done < data_"$orb"_grub.txt
cd $dir_path