Strabon

view scripts/runNoaRefinement.sh @ 308:7f1078abc31f

Added the Geonames parser
author Kostis Kyzirakos <kkyzir@di.uoa.gr>
date Wed Jun 20 19:03:13 2012 +0300 (2012-06-20)
parents
children b95784675cc7
line source
1 #! /bin/bash
3 dataDir="/home/ggarbis/TELEIOS/NOA_Processing_Chain/chain_msg2/data/out_triples/"
4 dataUrl="http://pathway.di.uoa.gr/hotspots/out_triples/"
5 name="HMSG2_IR_039_s7_070825"
6 suffix=".hotspots.n3"
8 logFile="chain.log"
9 countTime="/usr/bin/time -ao ${logFile} -f %e"
10 echo > ${logFile}
12 deleteSeaHotspots="PREFIX noa: <http://teleios.di.uoa.gr/ontologies/noaOntology.owl#>
13 PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>
14 PREFIX strdf: <http://strdf.di.uoa.gr/ontology#>
15 PREFIX xsd: <http://www.w3.org/2001/XMLSchema#>
17 DELETE {?h ?property ?object}
18 WHERE {
19 ?h rdf:type noa:Hotspot;
20 noa:hasAcquisitionTime \"TIMESTAMP\"^^xsd:dateTime;
21 noa:producedFromProcessingChain \"PROCESSING_CHAIN\"^^xsd:string;
22 noa:isDerivedFromSensor \"SENSOR\"^^xsd:string;
23 noa:hasGeometry ?hGeo;
24 ?property ?object .
25 OPTIONAL {
26 ?c rdf:type noa:Coastline;
27 noa:hasGeometry ?cGeo .
28 FILTER(strdf:anyInteract(?hGeo, ?cGeo)) .
29 }
30 FILTER(!bound(?c)) .
31 }"
33 refinePartialSeaHotspots="PREFIX noa: <http://teleios.di.uoa.gr/ontologies/noaOntology.owl#>
34 PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>
35 PREFIX strdf: <http://strdf.di.uoa.gr/ontology#>
36 PREFIX xsd: <http://www.w3.org/2001/XMLSchema#>
38 DELETE { ?h noa:hasGeometry ?hGeo}
39 INSERT { ?h noa:hasGeometry ?dif}
40 WHERE {
41 SELECT DISTINCT ?h ?hGeo (strdf:intersection(?hGeo, strdf:union(?cGeo)) AS ?dif)
42 WHERE {
43 ?h rdf:type noa:Hotspot;
44 noa:hasAcquisitionTime ?hAcqTime;
45 noa:producedFromProcessingChain \"PROCESSING_CHAIN\"^^xsd:string;
46 noa:isDerivedFromSensor \"SENSOR\"^^xsd:string;
47 noa:hasGeometry ?hGeo .
48 FILTER(\"TIMESTAMP\"^^xsd:dateTime = ?hAcqTime) .
49 ?c rdf:type noa:Coastline;
50 noa:hasGeometry ?cGeo .
51 FILTER(strdf:anyInteract(?hGeo, ?cGeo)) .
52 }
53 GROUP BY ?h ?hGeo
54 HAVING strdf:overlap(?hGeo, strdf:union(?cGeo))
55 }"
57 refineTimePersistence="PREFIX noa: <http://teleios.di.uoa.gr/ontologies/noaOntology.owl#>
58 PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>
59 PREFIX strdf: <http://strdf.di.uoa.gr/ontology#>
60 PREFIX xsd: <http://www.w3.org/2001/XMLSchema#>
62 INSERT {
63 ?newHotspot rdf:type noa:Hotspot .
64 ?newHotspot noa:hasConfidence ?hConfidence .
65 ?newHotspot noa:hasGeometry ?hGeometry1 .
66 ?newHotspot noa:hasAcquisitionTime \"TIMESTAMP\"^^xsd:dateTime .
67 ?newHotspot noa:isDerivedFromSensor \"SENSOR\"^^xsd:string .
68 ?newHotspot noa:hasConfirmation noa:unknown .
69 ?newHotspot noa:producedFromProcessingChain ?hProcessingChain .
70 ?newHotspot noa:isProducedBy noa:noa .
71 }
72 WHERE {
73 SELECT (BNODE() AS ?newHotspot)
74 (SUM(?hConfidence1)/ACQUISITIONS_IN_HALF_AN_HOUR AS ?hConfidence)
75 ?hGeometry1
76 (CONCAT(\"PROCESSING_CHAIN\"^^xsd:string,\"-TimePersistence\") AS ?hProcessingChain)
77 WHERE {
78 ?H1 rdf:type noa:Hotspot .
79 ?H1 noa:hasConfidence ?hConfidence1 .
80 ?H1 noa:hasGeometry ?hGeometry1 .
81 ?H1 noa:hasAcquisitionTime ?hAcquisitionTime1 .
82 ?H1 noa:isDerivedFromSensor \"SENSOR\"^^xsd:string .
83 ?H1 noa:hasConfirmation noa:unknown .
84 ?H1 noa:producedFromProcessingChain \"PROCESSING_CHAIN\"^^xsd:string .
85 ?H1 noa:isProducedBy noa:noa .
86 FILTER( \"MIN_ACQUISITION_TIME\"^^xsd:dateTime <= ?hAcquisitionTime1 && ?hAcquisitionTime1 < \"TIMESTAMP\"^^xsd:dateTime ) .
87 OPTIONAL {
88 ?H2 rdf:type noa:Hotspot .
89 ?H2 noa:hasGeometry ?HGEO2 .
90 ?H2 noa:hasAcquisitionTime ?hAcquisitionTime2 .
91 ?H2 noa:isDerivedFromSensor \"SENSOR\"^^xsd:string .
92 ?H2 noa:producedFromProcessingChain ?hProcessingChain2 .
93 FILTER(regex(\"PROCESSING_CHAIN\"^^xsd:string, ?hProcessingChain2)).
94 FILTER( strdf:equals(?hGeometry1, ?HGEO2) ) .
95 FILTER(?hAcquisitionTime2 = \"TIMESTAMP\"^^xsd:dateTime) .
96 }
97 FILTER( !BOUND(?H2) ) .
98 }
99 GROUP BY ?hGeometry1
100 HAVING(SUM(?hConfidence1)>0.0)
101 }
102 "
104 # Initialize
105 sudo service postgresql restart
106 dropdb endpoint
107 createdb endpoint -T template_postgis
108 sudo service tomcat6 restart
109 ./endpoint store http://localhost:8080/endpoint N-Triples -u http://pathway.di.uoa.gr/hotspots/grid_4.nt
111 #./scripts/endpoint query http://localhost:8080/endpoint "SELECT (COUNT(*) AS ?C) WHERE {?s ?p ?o}"
112 #echo "Continue?"
113 #read a
117 for h in `seq 0 12`; do
118 for m in `seq 0 15 45`; do
119 time=`printf "%02d%02d\n" $h $m`
120 time2=`printf "%02d:%02d\n" $h $m`
121 # file=${dataDir}${name}_${time}$suffix
122 file=${dataUrl}${name}_${time}$suffix
124 # store file
125 echo -n "storing 2007-08-25T${time2}:00 " >> ${logFile}
126 # ${countTime} ./strabon -db endpoint store $file
127 ${countTime} ./endpoint store http://localhost:8080/endpoint N-Triples -u ${file}
129 # echo "File ${file} stored!" >> ${logFile}
130 # echo "Continue?"
131 # read a
133 # deleteSeaHotspots
134 echo -n "deleteSeaHotspots 2007-08-25T${time2}:00 " >> ${logFile}
135 query=`echo "${deleteSeaHotspots}" | sed "s/TIMESTAMP/2007-08-25T${time2}:00/g" | \
136 sed "s/PROCESSING_CHAIN/DynamicThresholds/g" | \
137 sed "s/SENSOR/MSG2/g"`
138 # ${countTime} ./strabon -db endpoint update "${query}"
139 ${countTime} ./endpoint update http://localhost:8080/endpoint "${query}"
141 # echo "File ${file} deleteSeaHotspots done!"
142 # echo "Continue?"
143 # read a
145 # refinePartialSeaHotspots
146 echo -n "refinePartialSeaHotspots 2007-08-25T${time2}:00 " >> ${logFile}
147 query=`echo "${refinePartialSeaHotspots}" | sed "s/TIMESTAMP/2007-08-25T${time2}:00/g" | \
148 sed "s/PROCESSING_CHAIN/DynamicThresholds/g" | \
149 sed "s/SENSOR/MSG2/g"`
150 # ${countTime} ./strabon -db endpoint update "${query}"
151 ${countTime} ./endpoint update http://localhost:8080/endpoint "${query}"
153 # echo "File ${file} refinePartialSeaHotspots done!"
154 # echo "Continue?"
155 # read a
157 # refineTimePersistence
158 echo -n "refineTimePersistence 2007-08-25T${time2}:00 " >> ${logFile}
159 min_acquisition_time=`date --date="2007-08-25 ${time2}:00 EEST -30 minutes" +%Y-%m-%dT%H:%m:00`
160 query=`echo "${refineTimePersistence}" | sed "s/TIMESTAMP/2007-08-25T${time2}:00/g" | \
161 sed "s/PROCESSING_CHAIN/DynamicThresholds/g" | \
162 sed "s/SENSOR/MSG2/g" | \
163 sed "s/ACQUISITIONS_IN_HALF_AN_HOUR/3.0/g" | \
164 sed "s/MIN_ACQUISITION_TIME/${min_acquisition_time}/g"`
166 # echo "Query:"
167 # echo "${query}"
168 # echo "Continue?"
169 # read a
170 # ${countTime} ./strabon -db endpoint update "${query}"
171 # ${countTime} ./endpoint update http://localhost:8080/endpoint "${query}"
172 ${countTime} ./endpoint update http://localhost:8080/endpoint "${query}"
174 # echo "File ${file} refinePartialSeaHotspots done!"
175 # echo "Continue?"
176 # read a
177 done
178 done
181 #for f in `ls /home/ggarbis/TELEIOS/NOA_Processing_Chain/chain_msg2/data/out_triples/HMSG2_IR_039_s7_070825_*.hotspots.n3`
182 #do
184 # echo "Store $f"
185 # ${countTime} ./scripts/strabon -db endpoint store $f
186 #
187 #
188 #done