42 |
michaesp |
1 |
#!/bin/bash
|
|
|
2 |
|
|
|
3 |
#################################################
|
|
|
4 |
# Program used to creat LAGRANTO-file from #
|
|
|
5 |
# python output file #
|
|
|
6 |
# #
|
|
|
7 |
# by Lukas Langhamer #
|
|
|
8 |
# Innsbruck, Feb. 2017 #
|
|
|
9 |
# #
|
|
|
10 |
#################################################
|
|
|
11 |
|
|
|
12 |
|
|
|
13 |
\rm -f reformat.param
|
|
|
14 |
\rm -f trainfo.param
|
|
|
15 |
\rm -f cp*
|
|
|
16 |
|
|
|
17 |
filetype=$1 # reference file
|
|
|
18 |
|
|
|
19 |
newdata=$2 # file to convert to LAGRANTO file
|
|
|
20 |
timestep=$3 # forward or backward calculation time interval in minutes
|
|
|
21 |
|
|
|
22 |
|
|
|
23 |
outfile=${filetype}_$4
|
|
|
24 |
|
|
|
25 |
prog1=${LAGRANTO}/goodies/reformat
|
|
|
26 |
prog2=${LAGRANTO}/goodies/trainfo.sh
|
|
|
27 |
|
|
|
28 |
refdate=`${prog2} ${filetype} refdate`
|
|
|
29 |
timerange=`${prog2} ${filetype} timerange`
|
|
|
30 |
|
|
|
31 |
ntim=`${prog2} ${filetype} ntim`
|
|
|
32 |
ntra=`${prog2} ${filetype} ntra`
|
|
|
33 |
ncol=`${prog2} ${newdata} ncol`
|
|
|
34 |
|
|
|
35 |
ntim=`expr ${ntim} - 1` # new file is shorter
|
|
|
36 |
timerange=`expr ${timerange} - ${timestep}` # timerange is shorter
|
|
|
37 |
|
|
|
38 |
echo "Reference date" ${refdate}" /Time range " ${timerange} "min" > cp_file # Header
|
|
|
39 |
echo " " >> cp_file # blank
|
|
|
40 |
tail -n +1 -q $newdata >> cp_file # data
|
|
|
41 |
sed '3 a\\' cp_file >> cp_file2
|
|
|
42 |
sed '3 a\\' cp_file2 >> cp_file3 # adding 2 lines -> nessecary for <reformat>
|
|
|
43 |
|
|
|
44 |
|
|
|
45 |
|
|
|
46 |
\rm -f reformat.param
|
|
|
47 |
echo '"cp_file3"' > reformat.param
|
|
|
48 |
echo \"${outfile}\" >> reformat.param
|
|
|
49 |
echo $ntra $ntim $ncol >> reformat.param
|
|
|
50 |
|
|
|
51 |
${prog1}
|
|
|
52 |
|
|
|
53 |
\rm -f reformat.param
|
|
|
54 |
\rm -f trainfo.param
|
|
|
55 |
\rm -f cp*
|
|
|
56 |
|
|
|
57 |
exit 0
|