forked from c-eis/Filter
-
Notifications
You must be signed in to change notification settings - Fork 0
/
run_filter.sh
executable file
·43 lines (39 loc) · 1.07 KB
/
run_filter.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
#!/bin/bash
##
## Time-stamp: <2016-08-05 11:11:17 (cluettig)>
##
vx=$(grep "^vx" parameter.txt |awk -F : '{print $2}')
vy=$(grep "^vy" parameter.txt |awk -F : '{print $2}')
id=$(grep "^id" parameter.txt |awk -F : '{print $2}')
#id=$(echo "$id + 1" | bc)
echo $vx
echo $vy
path=$(dirname $vx)
bx=$(basename $vx)
by=$(basename $vy)
end=${bx/*./}
fdir=$path/filter_$id
echo "All data will be saved in directory" $fdir
#sed -i 's/id.*$/id :'$id'/' parameter.txt
mkdir $fdir
newx=$fdir/vx.nc
newy=$fdir/vy.nc
cp parameter.txt $fdir/parameter.txt
if [ $end == 'tif' ]; then
gdal_translate -of NetCDF $vx $newx
gdal_translate -of NetCDF $vy $newy
elif [ $end == 'nc' ]; then
cp $vx $newx
cp $vy $newy
else
echo "Unknown file format" $end ". Try NetCDF or GeoTIFF."
fi
vx=$newx
vy=$newy
unit=$(grep "^unit" $fdir/parameter.txt |awk -F : '{print $2}')
if [ $unit == "m/d" ]; then
gmt grdmath $vx 365.25 MUL = $vx
gmt grdmath $vy 365.25 MUL = $vy
fi
sbatch filter.sh $fdir # use this for slurm job at ollie
# ./filter_without_ollie.sh # use this on other platform