-
Notifications
You must be signed in to change notification settings - Fork 0
/
combine_3d_rinex.sh
107 lines (102 loc) · 3.19 KB
/
combine_3d_rinex.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
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
#!/bin/bash
# append rinex file with 12 hours of data from days before and after
# to eliminate edge effects during processing
# outputs a file of the same name in a new directory
gps_yr=24
# first and last day of year to loop through
sta_doy=182
end_doy=200
# station name
stn=hel2
# path to dir with rinex data and new directory to write files
path_1drnx=rinex
path_3drnx=rinex3d
for i in `seq ${sta_doy} ${end_doy}`
do
if [ $i -lt 100 ]
then
gdoy=0${i}
if [ $i -lt 10 ]
then
gdoy=0${gdoy}
fi
else
gdoy=${i}
fi
#Check if there is data the day before
doy1=$((i-1))
if [ $doy1 -lt 100 ]
then
gdoy1=0${doy1}
if [ $doy1 -lt 10 ]
then
gdoy1=0${gdoy1}
fi
else
gdoy1=${doy1}
fi
#Check if there is data the day after
doy2=$((i+1))
if [ $doy2 -lt 100 ]
then
gdoy2=0${doy2}
if [ $doy2 -lt 10 ]
then
gdoy2=0${gdoy2}
fi
else
gdoy2=${doy2}
fi
#Combine file
stni=$(echo ${stn} | tr ";" "\n")
for stnki in ${stni}
do
f_stn=${stnki}${gdoy}0.${gps_yr}o
f_stn1=${stnki}${gdoy1}0.${gps_yr}o
f_stn2=${stnki}${gdoy2}0.${gps_yr}o
echo "Form observation file ${f_stn}"
if [ ! -f "${path_1drnx}/${f_stn}" ]
then
echo "No data for ${stnki} on ${gdoy}"
else
fstn_3i=`ls ${path_1drnx}/${f_stn1} ${path_1drnx}/${f_stn} ${path_1drnx}/${f_stn2}`
teqc ${fstn_3i} >${path_3drnx}/tmp
sed -e "1,/END OF HEADER/w ${path_3drnx}/header
/END OF HEADER/,\$w ${path_3drnx}/tmpn" ${path_3drnx}/tmp >${path_3drnx}/tmp3d
rm ${path_3drnx}/tmp3d
rm -irf ${path_3drnx}/tmp
tail -n +2 ${path_3drnx}/tmpn >${path_3drnx}/tmpn1
rm -irf ${path_3drnx}/tmpn
grep -n "RINEX FILE SPLICE" ${path_3drnx}/tmpn1| grep -Eo '^[^:]+'>ln1
awk '{print($1-1)}' ln1 >ln0
rm -irf ln1
sed -i'.bak' 's/$/d;/' ln0
rm *.bak
dl0=`echo $(cat ln0)`
rm -irf ln0
sed -i'.bak' -e "${dl0}" ${path_3drnx}/tmpn1
sed -i'.bak' '/COMMENT/d' ${path_3drnx}/tmpn1
sed -i'.bak' '/XYZ/d' ${path_3drnx}/tmpn1
sed -i'.bak' '/Time/d' ${path_3drnx}/tmpn1
sed -i'.bak' '/HEADER/d' ${path_3drnx}/tmpn1
sed -i'.bak' '/SECOND/d' ${path_3drnx}/tmpn1
sed -i'.bak' '/INTERVAL/d' ${path_3drnx}/tmpn1
sed -i'.bak' '/TYPE/d' ${path_3drnx}/tmpn1
sed -i'.bak' '/WAVE/d' ${path_3drnx}/tmpn1
sed -i'.bak' '/ANT/d' ${path_3drnx}/tmpn1
sed -i'.bak' '/OBS/d' ${path_3drnx}/tmpn1
sed -i'.bak' '/MARK/d' ${path_3drnx}/tmpn1
sed -i'.bak' '/DATE/d' ${path_3drnx}/tmpn1
cat ${path_3drnx}/header ${path_3drnx}/tmpn1 > ${path_3drnx}/tmpn2
rm -irf ${path_3drnx}/header
rm -irf ${path_3drnx}/*.bak
rm -irf ${path_3drnx}/tmpn1
gps_mt=`doy ${gps_yr} ${doy1}| (sed -n "1,1p"| awk '{print(substr($2,6,2))}')`
gps_dy=`doy ${gps_yr} ${doy1}| (sed -n "1,1p"| awk '{print(substr($2,9,2))}')`
teqc -st ${gps_yr}:${gps_mt}:${gps_dy}:12:00:00 +dh 48 ${path_3drnx}/tmpn2 >${path_3drnx}/tmpn3
teqc -O.obs C1C2L1L2P2 ${path_3drnx}/tmpn3 > ${path_3drnx}/${f_stn}
rm -irf ${path_3drnx}/tmpn2
rm -irf ${path_3drnx}/tmpn3
fi
done
done