-
Notifications
You must be signed in to change notification settings - Fork 4
/
extract-l2.sh
executable file
·88 lines (72 loc) · 1.35 KB
/
extract-l2.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
#!/bin/bash -u
function help_string()
{
echo "$0 <source> <version> [ echo ]
Mandatory arguments:
- source : CSR, GFZ or JPL (no other options possible)
Optional arguments:
- version : as of 10/2018 (the 'RL' part is added internally):
- CSR : 05, 05_mean_field, 06
- GFZ : 05, 05_WEEKLY, 06
- JPL : 05, 05.1, 06
- echo : show what would have been done but don't actually do anything (optional)
- help : show this string (optional)
"
}
#inits
SOURCE=CSR
VERSION=06.2
ECHO=
for i in "$@"
do
case "$i" in
-x)
set -x
;;
CSR|GFZ|JPL)
SOURCE=$i
;;
0[56]*)
VERSION=$i
;;
echo)
ECHO=echo
;;
help|-help|--help|h|-h)
help_string
exit 1
;;
*)
echo "ERROR: cannot handle input argument '$i'"
exit 3
;;
esac
done
#sanity in mandatory inputs
if [ -z "$SOURCE" ]
then
echo "ERROR: need <source>"
help_string
exit 3
fi
#sanity in mandatory inputs
if [ -z "$VERSION" ]
then
echo "ERROR: need <version>"
help_string
exit 3
fi
LOCALDIR=$(cd $(dirname $BASH_SOURCE); pwd)/L2/$SOURCE/RL$VERSION/
#check if sink directory exists
if [ ! -d $LOCALDIR ]
then
echo "ERROR: cannot find directory $LOCALDIR"
exit 3
fi
for i in $(find $LOCALDIR -name \*.gz)
do
if [ ! -e ${i%.gz}.gsm ]
then
$ECHO gunzip -kfv $i && mv -v ${i%.gz} ${i%.gz}.gsm
fi
done