Strabon

changeset 265:05b7ddbd273e

A script for running noa refinement
author George Garbis <ggarbis@di.uoa.gr>
date Fri Jun 08 15:49:34 2012 +0300 (2012-06-08)
parents b46fde34ad71
children 8d6b0628e37a
files scripts/runNoaRefinement.sh
line diff
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/scripts/runNoaRefinement.sh	Fri Jun 08 15:49:34 2012 +0300
     1.3 @@ -0,0 +1,189 @@
     1.4 +#! /bin/bash
     1.5 +
     1.6 +dataDir="/home/ggarbis/TELEIOS/NOA_Processing_Chain/chain_msg2/data/out_triples/"
     1.7 +dataUrl="http://pathway.di.uoa.gr/hotspots/out_triples/"
     1.8 +name="HMSG2_IR_039_s7_070825"
     1.9 +suffix=".hotspots.n3"
    1.10 +
    1.11 +logFile="chain.log"
    1.12 +countTime="/usr/bin/time -ao ${logFile} -f %e"
    1.13 +echo > ${logFile}
    1.14 +
    1.15 +deleteSeaHotspots="PREFIX noa: <http://teleios.di.uoa.gr/ontologies/noaOntology.owl#> 
    1.16 +PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> 
    1.17 +PREFIX strdf: <http://strdf.di.uoa.gr/ontology#> 
    1.18 +PREFIX xsd: <http://www.w3.org/2001/XMLSchema#> 
    1.19 +
    1.20 +DELETE {?h ?property ?object} 
    1.21 +WHERE {
    1.22 +  ?h rdf:type noa:Hotspot; 
    1.23 +     noa:hasAcquisitionTime \"TIMESTAMP\"^^xsd:dateTime; 
    1.24 +     noa:producedFromProcessingChain \"PROCESSING_CHAIN\"^^xsd:string; 
    1.25 +     noa:isDerivedFromSensor \"SENSOR\"^^xsd:string;
    1.26 +     noa:hasGeometry ?hGeo;
    1.27 +     ?property ?object . 
    1.28 +  OPTIONAL {
    1.29 +    ?c rdf:type noa:Coastline;
    1.30 +       noa:hasGeometry ?cGeo . 
    1.31 +    FILTER(strdf:anyInteract(?hGeo, ?cGeo)) .
    1.32 +  } 
    1.33 +  FILTER(!bound(?c)) . 
    1.34 +}"
    1.35 +
    1.36 +refinePartialSeaHotspots="PREFIX noa: <http://teleios.di.uoa.gr/ontologies/noaOntology.owl#> 
    1.37 +PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> 
    1.38 +PREFIX strdf: <http://strdf.di.uoa.gr/ontology#> 
    1.39 +PREFIX xsd: <http://www.w3.org/2001/XMLSchema#> 
    1.40 +
    1.41 +DELETE { ?h noa:hasGeometry ?hGeo} 
    1.42 +INSERT { ?h noa:hasGeometry ?dif} 
    1.43 +WHERE { 
    1.44 +  SELECT DISTINCT ?h ?hGeo (strdf:intersection(?hGeo, strdf:union(?cGeo)) AS ?dif) 
    1.45 +  WHERE { 
    1.46 +    ?h rdf:type noa:Hotspot; 
    1.47 +       noa:hasAcquisitionTime ?hAcqTime; 
    1.48 +       noa:producedFromProcessingChain \"PROCESSING_CHAIN\"^^xsd:string; 
    1.49 +       noa:isDerivedFromSensor \"SENSOR\"^^xsd:string;
    1.50 +       noa:hasGeometry ?hGeo .
    1.51 +    FILTER(\"TIMESTAMP\"^^xsd:dateTime = ?hAcqTime) .
    1.52 +    ?c rdf:type noa:Coastline;
    1.53 +       noa:hasGeometry ?cGeo .
    1.54 +    FILTER(strdf:anyInteract(?hGeo, ?cGeo)) . 
    1.55 +  }
    1.56 +  GROUP BY ?h ?hGeo 
    1.57 +  HAVING strdf:overlap(?hGeo, strdf:union(?cGeo))
    1.58 +}"
    1.59 +
    1.60 +refineTimePersistence="PREFIX noa: <http://teleios.di.uoa.gr/ontologies/noaOntology.owl#> 
    1.61 +PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> 
    1.62 +PREFIX strdf: <http://strdf.di.uoa.gr/ontology#> 
    1.63 +PREFIX xsd: <http://www.w3.org/2001/XMLSchema#> 
    1.64 +
    1.65 +INSERT {
    1.66 +  ?newHotspot rdf:type noa:Hotspot .
    1.67 +  ?newHotspot noa:hasConfidence ?hConfidence .
    1.68 +  ?newHotspot noa:hasGeometry ?hGeometry1 .
    1.69 +  ?newHotspot noa:hasAcquisitionTime \"TIMESTAMP\"^^xsd:dateTime .
    1.70 +  ?newHotspot noa:isDerivedFromSensor \"SENSOR\"^^xsd:string .
    1.71 +  ?newHotspot noa:hasConfirmation noa:unknown .
    1.72 +  ?newHotspot noa:producedFromProcessingChain ?hProcessingChain .
    1.73 +  ?newHotspot noa:isProducedBy noa:noa .
    1.74 +}
    1.75 +WHERE {
    1.76 +  SELECT (BNODE() AS ?newHotspot)
    1.77 +  (SUM(?hConfidence1)/ACQUISITIONS_IN_HALF_AN_HOUR AS ?hConfidence)
    1.78 +  ?hGeometry1
    1.79 +  (CONCAT(\"PROCESSING_CHAIN\"^^xsd:string,\"-TimePersistence\") AS ?hProcessingChain)
    1.80 +  WHERE {
    1.81 +    ?H1 rdf:type noa:Hotspot .
    1.82 +    ?H1 noa:hasConfidence ?hConfidence1 .
    1.83 +    ?H1 noa:hasGeometry ?hGeometry1 .
    1.84 +    ?H1 noa:hasAcquisitionTime ?hAcquisitionTime1 .
    1.85 +    ?H1 noa:isDerivedFromSensor \"SENSOR\"^^xsd:string .
    1.86 +    ?H1 noa:hasConfirmation noa:unknown .
    1.87 +    ?H1 noa:producedFromProcessingChain \"PROCESSING_CHAIN\"^^xsd:string .
    1.88 +    ?H1 noa:isProducedBy noa:noa .
    1.89 +    FILTER( \"MIN_ACQUISITION_TIME\"^^xsd:dateTime <= ?hAcquisitionTime1 && ?hAcquisitionTime1 < \"TIMESTAMP\"^^xsd:dateTime ) .
    1.90 +    OPTIONAL {
    1.91 +      ?H2 rdf:type noa:Hotspot .
    1.92 +      ?H2 noa:hasGeometry ?HGEO2 .
    1.93 +      ?H2 noa:hasAcquisitionTime ?hAcquisitionTime2 .
    1.94 +      ?H2 noa:isDerivedFromSensor \"SENSOR\"^^xsd:string .
    1.95 +      ?H2 noa:producedFromProcessingChain ?hProcessingChain2 .
    1.96 +      FILTER(regex(\"PROCESSING_CHAIN\"^^xsd:string, ?hProcessingChain2)).
    1.97 +      FILTER( strdf:equals(?hGeometry1, ?HGEO2) ) .
    1.98 +      FILTER(?hAcquisitionTime2 = \"TIMESTAMP\"^^xsd:dateTime) .
    1.99 +    }
   1.100 +    FILTER( !BOUND(?H2) ) .
   1.101 +  }
   1.102 +  GROUP BY ?hGeometry1
   1.103 +  HAVING(SUM(?hConfidence1)>0.0)
   1.104 +}
   1.105 +"
   1.106 +
   1.107 +# Initialize
   1.108 +sudo service postgresql restart
   1.109 +dropdb endpoint
   1.110 +createdb endpoint -T template_postgis
   1.111 +sudo service tomcat6 restart
   1.112 +./endpoint store http://localhost:8080/endpoint N-Triples -u http://pathway.di.uoa.gr/hotspots/grid_4.nt
   1.113 +
   1.114 +#./scripts/endpoint query http://localhost:8080/endpoint "SELECT (COUNT(*) AS ?C) WHERE {?s ?p ?o}"
   1.115 +#echo "Continue?"
   1.116 +#read a
   1.117 +
   1.118 +
   1.119 +
   1.120 +for h in `seq 0 12`; do
   1.121 +    for m in `seq 0 15 45`; do
   1.122 +            time=`printf "%02d%02d\n" $h $m`
   1.123 +            time2=`printf "%02d:%02d\n" $h $m`
   1.124 +#            file=${dataDir}${name}_${time}$suffix
   1.125 +            file=${dataUrl}${name}_${time}$suffix
   1.126 +    
   1.127 +            # store file
   1.128 +            echo -n "storing 2007-08-25T${time2}:00 " >> ${logFile}
   1.129 +#            ${countTime} ./strabon -db endpoint store $file      
   1.130 +            ${countTime} ./endpoint store http://localhost:8080/endpoint N-Triples -u ${file}
   1.131 +            
   1.132 +#            echo "File ${file} stored!" >> ${logFile}
   1.133 +#            echo "Continue?"
   1.134 +#            read a
   1.135 +         
   1.136 +            # deleteSeaHotspots
   1.137 +            echo -n "deleteSeaHotspots 2007-08-25T${time2}:00 " >> ${logFile}
   1.138 +            query=`echo "${deleteSeaHotspots}" | sed "s/TIMESTAMP/2007-08-25T${time2}:00/g" | \
   1.139 +                sed "s/PROCESSING_CHAIN/DynamicThresholds/g" | \
   1.140 +                sed "s/SENSOR/MSG2/g"`
   1.141 +#            ${countTime} ./strabon -db endpoint update "${query}"
   1.142 +            ${countTime} ./endpoint update http://localhost:8080/endpoint "${query}"
   1.143 +            
   1.144 +#            echo "File ${file} deleteSeaHotspots done!"
   1.145 +#            echo "Continue?"
   1.146 +#            read a
   1.147 +            
   1.148 +            # refinePartialSeaHotspots
   1.149 +            echo -n "refinePartialSeaHotspots 2007-08-25T${time2}:00 " >> ${logFile}
   1.150 +            query=`echo "${refinePartialSeaHotspots}" | sed "s/TIMESTAMP/2007-08-25T${time2}:00/g" | \
   1.151 +                sed "s/PROCESSING_CHAIN/DynamicThresholds/g" | \
   1.152 +                sed "s/SENSOR/MSG2/g"`
   1.153 +#            ${countTime} ./strabon -db endpoint update "${query}"
   1.154 +            ${countTime} ./endpoint update http://localhost:8080/endpoint "${query}"
   1.155 +            
   1.156 +#            echo "File ${file} refinePartialSeaHotspots done!"
   1.157 +#            echo "Continue?"
   1.158 +#            read a
   1.159 +
   1.160 +            # refineTimePersistence
   1.161 +            echo -n "refineTimePersistence 2007-08-25T${time2}:00 " >> ${logFile}
   1.162 +            min_acquisition_time=`date --date="2007-08-25 ${time2}:00 EEST -30 minutes" +%Y-%m-%dT%H:%m:00`
   1.163 +            query=`echo "${refineTimePersistence}" | sed "s/TIMESTAMP/2007-08-25T${time2}:00/g" | \
   1.164 +                sed "s/PROCESSING_CHAIN/DynamicThresholds/g" | \
   1.165 +                sed "s/SENSOR/MSG2/g" | \
   1.166 +                sed "s/ACQUISITIONS_IN_HALF_AN_HOUR/3.0/g" | \
   1.167 +                sed "s/MIN_ACQUISITION_TIME/${min_acquisition_time}/g"`
   1.168 +
   1.169 +#            echo "Query:"
   1.170 +#            echo "${query}"
   1.171 +#            echo "Continue?"
   1.172 +#            read a
   1.173 +#            ${countTime} ./strabon -db endpoint update "${query}"
   1.174 +#            ${countTime} ./endpoint update http://localhost:8080/endpoint "${query}"
   1.175 +            ${countTime} ./endpoint update http://localhost:8080/endpoint "${query}"
   1.176 +            
   1.177 +#            echo "File ${file} refinePartialSeaHotspots done!"
   1.178 +#            echo "Continue?"
   1.179 +#            read a
   1.180 +    done
   1.181 +done
   1.182 +
   1.183 +
   1.184 +#for f in `ls /home/ggarbis/TELEIOS/NOA_Processing_Chain/chain_msg2/data/out_triples/HMSG2_IR_039_s7_070825_*.hotspots.n3`
   1.185 +#do
   1.186 +
   1.187 +#    echo "Store $f"
   1.188 +#	${countTime} ./scripts/strabon -db endpoint store $f
   1.189 +#	
   1.190 +#	
   1.191 +#done
   1.192 +