Strabon

view scripts/archive/v2.1/runNoaRefinementChain.sh @ 1277:92b90ac06d39

[maven-release-plugin] prepare release v3.2.9
author Babis Nikolaou <charnik@di.uoa.gr>
date Sat Oct 19 23:37:23 2013 +0300 (2013-10-19)
parents 28ce0ecfb65b
children
line source
1 #!/bin/bash
2 LOC="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
4 ENDPOINT="http://localhost:8080/endpoint"
5 DB="endpoint"
6 GRIDURL="http://kk.di.uoa.gr/grid_4.nt"
8 CHECKDIR="/home/konstantina/allhot/"
9 #CHECKDIR="${HOME}/teleios/nkua/Hotspots/"
11 #POSTGISTEMPLATE="postgistemplate"
12 POSTGISTEMPLATE="template_postgis"
14 #dataDir="http://localhost/noa-teleios/out_triples/"
15 #dataDir="http://kk.di.uoa.gr/out_triples/"
16 dataDir="http://godel.di.uoa.gr/allhot/"
17 name="HMSG2_IR_039_s7_07"
18 suffix=".hotspots.nt"
20 logFile="chain.log"
21 #countWTime="/usr/bin/time -p %e"
22 #echo > ${logFile}
24 function timer()
25 {
26 if [[ $# -eq 0 ]]; then
27 echo $(date '+%s')
28 else
29 local stime=$1
30 etime=$(date '+%s')
32 if [[ -z "$stime" ]]; then stime=$etime; fi
34 dt=$((etime - stime))
35 ds=$((dt % 60))
36 dm=$(((dt / 60) % 60))
37 dh=$((dt / 3600))
38 printf '%d:%02d:%02d' $dh $dm $ds
39 fi
40 }
42 function chooseTomcat()
43 {
44 if test -s /etc/fedora-release ; then
45 tomcat="tomcat"
46 #elif test -s /etc/centos-release ; then
47 #elif test -s /etc/yellowdog-release ; then
48 #elif test -s /etc/redhat-release ; then
49 #elif test -s /etc/SuSE-release ; then
50 #elif test -s /etc/gentoo-release ; then
51 elif test -s /etc/lsb-release ; then # Ubuntu
52 tomcat="tomcat7"
53 elif test -s /etc/debian_version ; then
54 tomcat="tomcat"
55 fi
56 }
58 #prin
59 #tmr1=$(timer)
60 #meta
61 #tmr2=$(timer)
62 #ektypwsi
63 #printf 'LALA %s %s\n' $((tmr2-tmr1)) $(timer $tmr1)
66 deleteSeaHotspots=`cat ${LOC}/DeleteInSea.sparql` # | sed 's/\"/\\\"/g'`
67 refinePartialSeaHotspots=`cat ${LOC}/Refine.sparql` # | sed 's/\"/\\\"/g'`
68 refineTimePersistence=`cat ${LOC}/TimePersistence.sparql` # | sed 's/\"/\\\"/g'`
70 # Initialize
71 chooseTomcat
72 sudo service postgresql restart
73 echo "Dropping endpoint database";
74 sudo -u postgres dropdb ${DB}
75 echo "Creating endpoint database"
76 sudo -u postgres createdb ${DB} #-T ${POSTGISTEMPLATE}
77 echo "restarting tomcat"
78 sudo service ${tomcat} restart
80 echo "initializing database"
81 echo "S D R TP" >>stderr.txt
83 # ../endpoint store ${ENDPOINT} N-Triples -u ${GRIDURL}
85 sudo -u postgres sh -c "curl -s http://dev.strabon.di.uoa.gr/rdf/Kallikratis-Coastline-dump.tgz|tar xz -O|psql -d ${DB}"
86 #./scripts/endpoint query ${ENDPOINT} "SELECT (COUNT(*) AS ?C) WHERE {?s ?p ?o}"
87 #sudo -u postgres psql -d endpoint -c 'CREATE INDEX datetime_values_idx_value ON datetime_values USING btree(value)';
88 #sudo -u postgres psql -d endpoint -c 'VACUUM ANALYZE;';
90 #echo "Continue?"
91 #read a
94 for mon in `seq 7 10`; do
95 for d in `seq 1 30`; do
96 for h in `seq 0 23 `; do
97 for m in `seq 0 15 45`; do
98 time=`printf "%02d%02d\n" $h $m`
99 time2=`printf "%02d:%02d\n" $h $m`
100 day=`printf "%02d" $d`
101 month=`printf "%02d" $mon`
102 file=${dataDir}${name}${month}${day}_${time}$suffix
103 # file=${dataUrl}${name}_${time}$suffix
105 check=${CHECKDIR}${name}${month}${day}_${time}$suffix
106 wget -q --spider $check
108 if [[ ! $? -ne 0 ]];
109 then echo "FILE" $check "NOT EXISTS" ; continue
110 fi
112 # store file
113 echo -n "storing " $file; echo; echo;
114 # echo "Hotspot : " $h:$m >> stderr.txt
115 # ${countTime} ./strabon -db endpoint store $file
117 tmr1=$(timer)
118 ../endpoint store ${ENDPOINT} N-Triples -u ${file}
119 tmr2=$(timer)
120 printf '%s ' $((tmr2-tmr1)) >>stderr.txt
122 # sudo -u postgres psql -d endpoint -c 'VACUUM ANALYZE;';
124 echo;echo;echo;echo "File ${file} stored!" >> ${logFile}
125 # echo "Continue?"
126 # read a
128 # deleteSeaHotspots
129 echo -n "Going to deleteSeaHotspots 2007-${month}-${day}T${time2}:00 " ;echo; echo; echo;
130 query=`echo "${deleteSeaHotspots}" | sed "s/TIMESTAMP/2007-${month}-${day}T${time2}:00/g" | \
131 sed "s/PROCESSING_CHAIN/DynamicThresholds/g" | \
132 sed "s/SENSOR/MSG2/g"`
133 # ${countTime} ./strabon -db endpoint update "${query}"
135 tmr1=$(timer)
136 ../endpoint update ${ENDPOINT} "${query}"
138 tmr2=$(timer)
139 printf '%s ' $((tmr2-tmr1)) >>stderr.txt
141 echo;echo;echo;echo "File ${file} deleteSeaHotspots done!"
142 # echo "Continue?"
143 # read a
145 # refinePartialSeaHotspots
146 echo -n "refinePartialSeaHotspots 2007-${month}-${day}T${time2}:00 " ; echo; echo ; echo;
147 query=`echo "${refinePartialSeaHotspots}" | sed "s/TIMESTAMP/2007-${month}-${day}T${time2}:00/g" | \
148 sed "s/PROCESSING_CHAIN/DynamicThresholds/g" | \
149 sed "s/SENSOR/MSG2/g" |\
150 sed "s/SAT/METEOSAT9/g"`
151 # ${countTime} ./strabon -db endpoint update "${query}"
152 tmr1=$(timer)
153 ../endpoint update ${ENDPOINT} "${query}"
154 tmr2=$(timer)
155 printf '%s ' $((tmr2-tmr1)) >>stderr.txt
157 echo "File ${file} refinePartialSeaHotspots done!"
158 # echo "Continue?"
159 # read a
161 # refineTimePersistence
162 echo -n "Going to refineTimePersistence 2007-${month}-${day}T${time2}:00 ";echo;echo;echo;
163 min_acquisition_time=`date --date="2007-${month}-${day} ${time2}:00 EEST -30 minutes" +%Y-%m-%dT%H:%m:00`
164 query=`echo "${refineTimePersistence}" | sed "s/TIMESTAMP/2007-${month}-${day}T${time2}:00/g" | \
165 sed "s/PROCESSING_CHAIN/DynamicThresholds/g" | \
166 sed "s/SENSOR/MSG2/g" | \
167 sed "s/ACQUISITIONS_IN_HALF_AN_HOUR/3.0/g" | \
168 sed "s/MIN_ACQUISITION_TIME/${min_acquisition_time}/g" |\
169 sed "s/SAT/METEOSAT9/g"`
171 # echo "Query:"
172 # echo "${query}"
173 # echo "Continue?"
174 # read a
175 # ${countTime} ./strabon -db endpoint update "${query}"
176 # ${countTime} ../endpoint update ${ENDPOINT} "${query}"
178 sudo -u postgres psql -d ${DB} -c 'VACUUM ANALYZE;';
181 tmr1=$(timer)
182 ../endpoint update ${ENDPOINT} "${query}"
183 tmr2=$(timer)
184 printf '%s \n' $((tmr2-tmr1)) >>stderr.txt
185 echo;echo;echo;echo "File ${file} timePersistence done!"
186 # echo "Continue?"
187 # read a
188 done
189 done
190 done
191 done
194 #for f in `ls /home/konstantina/noa-teleios/out_triples/HMSG2_IR_039_s7_070825_*.hotspots.n3`
195 #do
197 # echo "Store $f"
198 # ${countTime} ./scripts/strabon -db endpoint store $f
199 #
200 #
201 #done