Strabon

changeset 411:6c25dbff525d

Fix v2.1
author Kostis Kyzirakos <kkyzir@di.uoa.gr>
date Mon Jul 09 20:49:14 2012 +0300 (2012-07-09)
parents 854d64bc2b60
children 0b9312eb8bba
files scripts/v2.1/DeleteInSea.sparql scripts/v2.1/Refine.sparql scripts/v2.1/TimePersistence.sparql scripts/v2.1/count.sparql scripts/v2.1/discover.sparql scripts/v2.1/endpoint scripts/v2.1/runNoaRefinementChain.sh scripts/v2.1/runNoaRefinementChain.sh-bakcup
line diff
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/scripts/v2.1/DeleteInSea.sparql	Mon Jul 09 20:49:14 2012 +0300
     1.3 @@ -0,0 +1,18 @@
     1.4 +PREFIX noa: <http://teleios.di.uoa.gr/ontologies/noaOntology.owl#> 
     1.5 +PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> 
     1.6 +PREFIX strdf: <http://strdf.di.uoa.gr/ontology#> 
     1.7 +PREFIX xsd: <http://www.w3.org/2001/XMLSchema#> 
     1.8 +
     1.9 +INSERT {?h noa:isDiscarded "1"^^xsd:int} 
    1.10 +WHERE {
    1.11 +?h   noa:hasAcquisitionTime "TIMESTAMP"^^xsd:dateTime; 
    1.12 +     noa:producedFromProcessingChain "PROCESSING_CHAIN"^^xsd:string; 
    1.13 +     noa:isDerivedFromSensor "SENSOR"^^xsd:string;
    1.14 +     noa:hasGeometry ?hGeo.
    1.15 +  OPTIONAL {
    1.16 +    ?c rdf:type noa:Coastline;
    1.17 +       noa:hasGeometry ?cGeo . 
    1.18 +    FILTER(strdf:anyInteract(?hGeo, ?cGeo)) .
    1.19 +  } 
    1.20 +  FILTER(!bound(?c)) . 
    1.21 +}
     2.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     2.2 +++ b/scripts/v2.1/Refine.sparql	Mon Jul 09 20:49:14 2012 +0300
     2.3 @@ -0,0 +1,32 @@
     2.4 +PREFIX noa: <http://teleios.di.uoa.gr/ontologies/noaOntology.owl#> 
     2.5 +PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> 
     2.6 +PREFIX strdf: <http://strdf.di.uoa.gr/ontology#> 
     2.7 +PREFIX xsd: <http://www.w3.org/2001/XMLSchema#> 
     2.8 +
     2.9 +
    2.10 +INSERT { ?h noa:isDiscarded "1"^^xsd:int . 
    2.11 +	 ?valid rdf:type noa:Hotspot ;
    2.12 +		noa:hasConfidence ?conf ;
    2.13 +	        noa:hasGeometry ?dif ;
    2.14 +		noa:hasAcquisitionTime "TIMESTAMP"^^xsd:dateTime ; 
    2.15 +	        noa:isDerivedFromSensor "SENSOR"^^xsd:string ;
    2.16 +		noa:hasConfirmation noa:unknown ;
    2.17 +	        noa:producedFromProcessingChain "PROCESSING_CHAIN"^^xsd:string ; 
    2.18 +		noa:isProducedBy noa:noa ;
    2.19 +		noa:isDerivedFromSatellite "SAT"^^xsd:string .
    2.20 +}
    2.21 +WHERE { 
    2.22 +  SELECT ?h  (strdf:intersection(?hGeo, strdf:union(?cGeo)) AS ?dif) (BNODE() AS ?valid) ?conf 
    2.23 +  WHERE { 
    2.24 +?h     noa:hasAcquisitionTime "TIMESTAMP"^^xsd:dateTime; 
    2.25 +       noa:producedFromProcessingChain "PROCESSING_CHAIN"^^xsd:string ; 
    2.26 +       noa:isDerivedFromSensor "SENSOR"^^xsd:string ;
    2.27 +       noa:hasGeometry ?hGeo ;
    2.28 +       noa:hasConfidence ?conf .
    2.29 +?c     rdf:type noa:Coastline ;
    2.30 +       noa:hasGeometry ?cGeo .
    2.31 +    FILTER(strdf:anyInteract(?hGeo, ?cGeo)) . 
    2.32 +  }
    2.33 +  GROUP BY ?h ?hGeo ?conf 
    2.34 +  HAVING strdf:overlap(?hGeo, strdf:union(?cGeo))
    2.35 +}
     3.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     3.2 +++ b/scripts/v2.1/TimePersistence.sparql	Mon Jul 09 20:49:14 2012 +0300
     3.3 @@ -0,0 +1,43 @@
     3.4 +PREFIX noa: <http://teleios.di.uoa.gr/ontologies/noaOntology.owl#> 
     3.5 +PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> 
     3.6 +PREFIX strdf: <http://strdf.di.uoa.gr/ontology#> 
     3.7 +PREFIX xsd: <http://www.w3.org/2001/XMLSchema#> 
     3.8 +
     3.9 +INSERT {
    3.10 + ?newHotspot rdf:type noa:Hotspot ;
    3.11 +		noa:hasConfidence ?hConfidence ;
    3.12 +	        noa:hasGeometry ?hGeometry1 ;
    3.13 +		noa:hasAcquisitionTime "TIMESTAMP"^^xsd:dateTime ; 
    3.14 +	        noa:isDerivedFromSensor "SENSOR"^^xsd:string ;
    3.15 +		noa:hasConfirmation noa:unknown ;
    3.16 +	        noa:producedFromProcessingChain "PROCESSING_CHAIN"^^xsd:string ; 
    3.17 +		noa:isProducedBy noa:noa ;
    3.18 +		noa:isDerivedFromSatellite "SAT"^^xsd:string .
    3.19 +
    3.20 +}
    3.21 +WHERE {
    3.22 +  SELECT (BNODE() AS ?newHotspot)
    3.23 +  (SUM(?hConfidence1)/ACQUISITIONS_IN_HALF_AN_HOUR AS ?hConfidence)
    3.24 +  ?hGeometry1
    3.25 +  WHERE {
    3.26 +    ?H1 noa:hasConfidence ?hConfidence1 .
    3.27 +    ?H1 noa:hasGeometry ?hGeometry1 .
    3.28 +    ?H1 noa:hasAcquisitionTime ?hAcquisitionTime1 .
    3.29 +    ?H1 noa:isDerivedFromSensor "SENSOR"^^xsd:string .
    3.30 +    ?H1 noa:producedFromProcessingChain "PROCESSING_CHAIN"^^xsd:string .
    3.31 +    OPTIONAL { ?H1 noa:isDiscarded ?z } .
    3.32 +    FILTER (!BOUND(?z)) .
    3.33 +    FILTER( "MIN_ACQUISITION_TIME"^^xsd:dateTime <= ?hAcquisitionTime1 && ?hAcquisitionTime1 < "TIMESTAMP"^^xsd:dateTime ) .
    3.34 +    OPTIONAL {
    3.35 +      ?H2 noa:hasGeometry ?HGEO2 .
    3.36 +      ?H2 noa:hasAcquisitionTime "TIMESTAMP"^^xsd:dateTime .
    3.37 +      ?H2 noa:isDerivedFromSensor "SENSOR"^^xsd:string .
    3.38 +      ?H2 noa:producedFromProcessingChain "PROCESSING_CHAIN"^^xsd:string .
    3.39 +      FILTER(("PROCESSING_CHAIN"^^xsd:string = ?hProcessingChain2)||("PROCESSING_CHAIN-TimePersistence"^^xsd:string = ?hProcessingChain2)).
    3.40 +      FILTER( strdf:equals(?hGeometry1, ?HGEO2) ) .
    3.41 +    }
    3.42 +    FILTER( !BOUND(?H2) ) .
    3.43 +  }
    3.44 +  GROUP BY ?hGeometry1
    3.45 +  HAVING(SUM(?hConfidence1)>0.0)
    3.46 +}
     4.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     4.2 +++ b/scripts/v2.1/count.sparql	Mon Jul 09 20:49:14 2012 +0300
     4.3 @@ -0,0 +1,2 @@
     4.4 +SELECT (count(*) AS ?count)
     4.5 +WHERE {?s ?p ?o}
     5.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     5.2 +++ b/scripts/v2.1/discover.sparql	Mon Jul 09 20:49:14 2012 +0300
     5.3 @@ -0,0 +1,24 @@
     5.4 +#Discover hotspots depending on their acquisition time, processing chain and sensor
     5.5 +#Return the hotspot's uri, its geometry and the affected municipalities
     5.6 +#reference dataset: http://dev.strabon.di.uoa.gr/rdf/Kallikratis-Coastline.ntriples
     5.7 +
     5.8 +PREFIX noa: <http://teleios.di.uoa.gr/ontologies/noaOntology.owl#> 
     5.9 +PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> 
    5.10 +PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#> 
    5.11 +PREFIX strdf: <http://strdf.di.uoa.gr/ontology#> 
    5.12 +PREFIX xsd: <http://www.w3.org/2001/XMLSchema#> 
    5.13 +PREFIX gag: <http://teleios.di.uoa.gr/ontologies/gagKallikratis.rdf#>
    5.14 +
    5.15 +SELECT ?h ?geo ?conf (GROUP_CONCAT(?dLabel ; SEPARATOR=', ') AS ?dimoi )
    5.16 +WHERE { 
    5.17 +?h   noa:hasGeometry ?hGeo ;
    5.18 +     noa:hasAcquisitionTime "TIMESTAMP"^^xsd:dateTime ; 
    5.19 +     noa:producedFromProcessingChain "PROCESSING_CHAIN"^^xsd:string ; 
    5.20 +     noa:isDerivedFromSensor "SENSOR"^^xsd:string ;
    5.21 +     noa:hasConfidence ?conf .
    5.22 +?d   rdf:type gag:Dhmos;
    5.23 +     strdf:hasGeometry ?dGeo;
    5.24 +     rdfs:label ?dLabel.
    5.25 +  FILTER(strdf:anyInteract(?dGeo, ?hGeo)).
    5.26 +}
    5.27 +GROUP BY ?h (strdf:transform(?hGeo, <http://www.opengis.net/def/crs/EPSG/0/4326>) AS ?geo) ?conf 
     6.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     6.2 +++ b/scripts/v2.1/endpoint	Mon Jul 09 20:49:14 2012 +0300
     6.3 @@ -0,0 +1,234 @@
     6.4 +#!/bin/bash
     6.5 +#
     6.6 +# Script for executing SPARQL queries and SPARQL Update queries 
     6.7 +# as well as storing RDF triples on a Strabon Endpoint.
     6.8 +#
     6.9 +# Author: Charalampos (Babis) Nikolaou <charnik@di.uoa.gr>
    6.10 +#
    6.11 +
    6.12 +# this command
    6.13 +CMD="$(basename ${0})"
    6.14 +
    6.15 +function help() {
    6.16 +	echo "Usage: ${CMD} [OPTIONS] COMMAND ENDPOINT ARGS"
    6.17 +	echo
    6.18 +	echo "Execute SPARQL and SPARQL Update queries as well as store RDF triples on a Strabon endpoint."
    6.19 +	echo
    6.20 +	echo "	COMMAND	 : one of query, queryfile, update, store, or help"
    6.21 +	echo "	ENDPOINT : the URL of the Strabon Endpoint (e.g., http://localhost:8080/StrabonEndpoint)"
    6.22 +	echo "	ARGS	 : arguments according to selected command"
    6.23 +	echo 
    6.24 +	echo "OPTIONS can be any of the following"
    6.25 +	echo "	-d	 : don't run, just print what shall be executed"
    6.26 +}
    6.27 +
    6.28 +function help_query() {
    6.29 +	echo "Usage: ${CMD} query ENDPOINT SPARQL_QUERY [RESULT_FORMAT]"
    6.30 +	echo
    6.31 +	echo "	ENDPOINT	: the URL of Strabon Endpoint (e.g., http://localhost:8080/StrabonEndpoint/)"
    6.32 +	echo "	SPARQL_QUERY	: the SPARQL query to execute or the alias name corresponding to a"
    6.33 +	echo "			  predefined query such as:"
    6.34 +	echo "				\`size': SELECT (count(*) as ?c) WHERE {?s ?p ?o}"
    6.35 +	echo "	RESULT_FORMAT	: the format of the result. Possible values are \`KMLMAP\, \`GEOJSON', "
    6.36 +	echo "			  \`HTML', \`KMZMAP', \`XML' (default), or \`KML'."
    6.37 +}
    6.38 +
    6.39 +function help_queryfile() {
    6.40 +        echo "Usage: ${CMD} queryfile ENDPOINT SPARQL_QUERY_FILE [RESULT_FORMAT]"
    6.41 +        echo
    6.42 +        echo "  ENDPOINT          : the URL of Strabon Endpoint (e.g., http://localhost:8080/StrabonEndpoint/)"
    6.43 +        echo "  SPARQL_QUERY_FILE : the file that contain the SPARQL query to execute"
    6.44 +        echo "  RESULT_FORMAT     : the format of the result. Possible values are \`KMLMAP\, \`GEOJSON', "
    6.45 +        echo "                      \`HTML', \`KMZMAP', \`XML' (default), or \`KML'."
    6.46 +}
    6.47 +
    6.48 +function help_update() {
    6.49 +	echo "Usage: ${CMD} update ENDPOINT SPARQL_QUERY"
    6.50 +	echo
    6.51 +	echo "	ENDPOINT     : the URL of Strabon Endpoint (e.g., http://localhost:8080/StrabonEndpoint/)"
    6.52 +	echo "	SPARQL_QUERY : the SPARQL update query to execute or the alias name corresponding to a"
    6.53 +	echo "		       predefined query such as:"
    6.54 +	echo "				\`clear': DELETE {?s ?p ?o} WHERE {?s ?p ?o}"
    6.55 +}
    6.56 +
    6.57 +function help_store() {
    6.58 +	echo "Usage: ${CMD} store ENDPOINT FORMAT -t TRIPLES|-u TRIPLES_URL"
    6.59 +	echo
    6.60 +	echo "	ENDPOINT    : the URL of Strabon Endpoint (e.g., http://localhost:8080/StrabonEndpoint/)"
    6.61 +	echo "	FORMAT	    : the RDF format of the input (one of RDF/XML, N-Triples, Turtle, N3, TriX, TriG, or BinaryRDF)"
    6.62 +	echo "	TRIPLES	    : the RDF triples to store"
    6.63 +	echo "	TRIPLES_URL : the URL containing the RDF triples to store"
    6.64 +}
    6.65 +
    6.66 +CURL_OPTS="-w HTTP_CODE='%{http_code}\n' -H \"Content-Type:application/x-www-form-urlencoded\" -H \"Accept:text/xml\""
    6.67 +
    6.68 +# if set to 1, then only the command to be executed is printed
    6.69 +DEBUG=0
    6.70 +
    6.71 +case "${1}" in
    6.72 +	-d)
    6.73 +		shift
    6.74 +		DEBUG=1
    6.75 +		;;
    6.76 +esac
    6.77 +
    6.78 +case "${1}" in
    6.79 +	help)
    6.80 +		shift
    6.81 +		if test $# -eq 1; then
    6.82 +			case "${1}" in
    6.83 +				query)
    6.84 +					help_query
    6.85 +					;;
    6.86 +				queryfile)
    6.87 +					help_queryfile
    6.88 +					;;
    6.89 +				update)
    6.90 +					help_update
    6.91 +					;;
    6.92 +				store)
    6.93 +					help_store
    6.94 +					;;
    6.95 +				*)
    6.96 +					help
    6.97 +					;;
    6.98 +			esac
    6.99 +			exit 1
   6.100 +		fi
   6.101 +		help
   6.102 +		exit 0
   6.103 +		;;
   6.104 +	query)
   6.105 +		shift
   6.106 +		if ! test $# -ge 2; then
   6.107 +			help_query
   6.108 +			exit 1
   6.109 +		fi
   6.110 +		URL="${1}/Query"
   6.111 +		QUERY="${2}"
   6.112 +
   6.113 +		shift
   6.114 +		shift
   6.115 +		# predefined queries
   6.116 +		case "${QUERY}" in
   6.117 +			size)
   6.118 +				QUERY="SELECT (count(*) as ?c) WHERE {?s ?p ?o}"
   6.119 +				;;
   6.120 +		esac
   6.121 +
   6.122 +		# set default format
   6.123 +		FORMAT="XML"
   6.124 +		if test $# -eq 1; then
   6.125 +			FORMAT="${1}"
   6.126 +		fi
   6.127 +
   6.128 +		case "${FORMAT}" in
   6.129 +			[Kk][Mm][Ll][Mm][Aa][Pp]|[Gg][Ee][Oo][Jj][Ss][Oo][Nn]|[Hh][Tt][Mm][Ll]|[Kk][mM][Zz][Mm][Aa][Pp]|[Xx][Mm][Ll]|[Kk][Mm][Ll])
   6.130 +				shift
   6.131 +				;;
   6.132 +			*)
   6.133 +				echo "${CMD}: unknown format \"${FORMAT}\"."
   6.134 +				echo "${CMD}: possible values are \`KMLMAP\, \`GEOJSON' \`HTML', \`KMZMAP', \`XML' (default), or \`KML'"
   6.135 +				exit 2
   6.136 +				;;
   6.137 +		esac
   6.138 +
   6.139 +		EXEC="curl ${CURL_OPTS} -d format='${FORMAT}' --data-urlencode SPARQLQuery='${QUERY}' ${URL}"
   6.140 +		;;
   6.141 +	queryfile)
   6.142 +		shift
   6.143 +		if ! test $# -ge 2; then
   6.144 +			help_queryfile
   6.145 +			exit 1
   6.146 +		fi
   6.147 +
   6.148 +		if [ ! -f ${2} ];
   6.149 +		then
   6.150 +			echo "${CMD}: File not found."
   6.151 +			exit 2
   6.152 +		fi
   6.153 +
   6.154 +		URL="${1}/Query"
   6.155 +		QUERY=`cat ${2} | sed 's/\"/\\\"/g'`
   6.156 +
   6.157 +		shift
   6.158 +		shift
   6.159 +		
   6.160 +		# set default format
   6.161 +		FORMAT="XML"
   6.162 +		if test $# -eq 1; then
   6.163 +			FORMAT="${1}"
   6.164 +		fi
   6.165 +
   6.166 +		case "${FORMAT}" in
   6.167 +			[Kk][Mm][Ll][Mm][Aa][Pp]|[Gg][Ee][Oo][Jj][Ss][Oo][Nn]|[Hh][Tt][Mm][Ll]|[Kk][mM][Zz][Mm][Aa][Pp]|[Xx][Mm][Ll]|[Kk][Mm][Ll])
   6.168 +				shift
   6.169 +				;;
   6.170 +			*)
   6.171 +				echo "${CMD}: unknown format \"${FORMAT}\"."
   6.172 +				echo "${CMD}: possible values are \`KMLMAP\, \`GEOJSON' \`HTML', \`KMZMAP', \`XML' (default), or \`KML'"
   6.173 +				exit 2
   6.174 +				;;
   6.175 +		esac
   6.176 +
   6.177 +		EXEC="curl ${CURL_OPTS} -d format='${FORMAT}' --data-urlencode SPARQLQuery='${QUERY}' ${URL}"
   6.178 +		;;
   6.179 +
   6.180 +	update)
   6.181 +		shift
   6.182 +		if ! test $# -eq 2; then
   6.183 +			help_update
   6.184 +			exit 1
   6.185 +		fi
   6.186 +		URL="${1}/Update"
   6.187 +		QUERY="${2}"
   6.188 +		
   6.189 +		# predefined queries
   6.190 +		case "${QUERY}" in
   6.191 +			clear)
   6.192 +				QUERY="DELETE {?s ?p ?o} WHERE {?s ?p ?o}"
   6.193 +				;;
   6.194 +		esac
   6.195 +
   6.196 +		EXEC="curl ${CURL_OPTS} --data-urlencode SPARQLQuery='${QUERY}' ${URL}"
   6.197 +		;;
   6.198 +	store)
   6.199 +		shift
   6.200 +		if ! test $# -eq 4; then
   6.201 +			help_store
   6.202 +			exit 1
   6.203 +		fi
   6.204 +		URL="${1}/Store"
   6.205 +		FORMAT="${2}"
   6.206 +		case "${3}" in
   6.207 +			-t)
   6.208 +				TRIPLES="${4}"
   6.209 +				EXEC="curl ${CURL_OPTS} -d format='${FORMAT}' --data-urlencode data='${TRIPLES}' ${URL}"
   6.210 +				;;
   6.211 +			-u)
   6.212 +				URL_TRIPLES="${4}"
   6.213 +				EXEC="curl ${CURL_OPTS} -d format='${FORMAT}' --data-urlencode url='${URL_TRIPLES}' -d fromurl='' ${URL}"
   6.214 +				;;
   6.215 +			 *)
   6.216 +				help_store
   6.217 +				exit 1
   6.218 +				;;
   6.219 +		esac
   6.220 +		;;
   6.221 +	*) 
   6.222 +		help
   6.223 +		echo
   6.224 +		echo "${CMD}: unknown command \"${1}\"."
   6.225 +		exit 1
   6.226 +		;;
   6.227 +esac
   6.228 +
   6.229 +# execute or debug
   6.230 +if test $DEBUG -eq 1; then
   6.231 +	echo "${CMD}: Debug is ON"
   6.232 +	echo "${CMD}: Printing command for execution"	
   6.233 +	echo "	$EXEC"
   6.234 +else
   6.235 +	eval ${EXEC}
   6.236 +fi
   6.237 +
     7.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     7.2 +++ b/scripts/v2.1/runNoaRefinementChain.sh	Mon Jul 09 20:49:14 2012 +0300
     7.3 @@ -0,0 +1,184 @@
     7.4 +#!/bin/bash
     7.5 +LOC="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
     7.6 +
     7.7 +ENDPOINT="http://localhost:8080/endpoint"
     7.8 +DB="endpoint"
     7.9 +GRIDURL="http://kk.di.uoa.gr/grid_4.nt"
    7.10 +
    7.11 +CHECKDIR="/home/konstantina/allhot/"
    7.12 +#CHECKDIR="${HOME}/teleios/nkua/Hotspots/"
    7.13 +
    7.14 +POSTGISTEMPLATE="postgistemplate"
    7.15 +#POSTGISTEMPLATE="template_postgis"
    7.16 +
    7.17 +#dataDir="http://localhost/noa-teleios/out_triples/"
    7.18 +#dataDir="http://kk.di.uoa.gr/out_triples/"
    7.19 +dataDir="http://godel.di.uoa.gr/allhot/"
    7.20 +name="HMSG2_IR_039_s7_07"
    7.21 +suffix=".hotspots.nt"
    7.22 +
    7.23 +logFile="chain.log"
    7.24 +#countWTime="/usr/bin/time -p   %e"
    7.25 +#echo > ${logFile}
    7.26 +
    7.27 +function timer()
    7.28 +{
    7.29 +    if [[ $# -eq 0 ]]; then
    7.30 +        echo $(date '+%s')
    7.31 +    else
    7.32 +        local  stime=$1
    7.33 +        etime=$(date '+%s')
    7.34 +
    7.35 +        if [[ -z "$stime" ]]; then stime=$etime; fi
    7.36 +
    7.37 +        dt=$((etime - stime))
    7.38 +        ds=$((dt % 60))
    7.39 +        dm=$(((dt / 60) % 60))
    7.40 +        dh=$((dt / 3600))
    7.41 +        printf '%d:%02d:%02d' $dh $dm $ds
    7.42 +    fi
    7.43 +}
    7.44 +
    7.45 +#prin
    7.46 +#tmr1=$(timer)
    7.47 +#meta
    7.48 +#tmr2=$(timer)
    7.49 +#ektypwsi
    7.50 +#printf 'LALA %s %s\n' $((tmr2-tmr1)) $(timer $tmr1)
    7.51 +
    7.52 +
    7.53 +deleteSeaHotspots=`cat ${LOC}/DeleteInSea.sparql` # | sed 's/\"/\\\"/g'`
    7.54 +refinePartialSeaHotspots=`cat ${LOC}/Refine.sparql` # | sed 's/\"/\\\"/g'`
    7.55 +refineTimePersistence=`cat ${LOC}/TimePersistence.sparql` # | sed 's/\"/\\\"/g'`
    7.56 +
    7.57 +# Initialize
    7.58 +sudo service postgresql restart
    7.59 +echo "Dropping endpoint database";
    7.60 +sudo -u postgres dropdb ${DB}
    7.61 +echo "Creating endpoint database"
    7.62 +sudo -u postgres createdb ${DB} -T ${POSTGISTEMPLATE}
    7.63 +echo "restarting tomcat"
    7.64 +sudo service tomcat restart
    7.65 +
    7.66 +echo "initializing database"
    7.67 +echo "S D R TP" >>stderr.txt
    7.68 +
    7.69 +# ../endpoint store ${ENDPOINT} N-Triples -u ${GRIDURL}
    7.70 +
    7.71 +sudo -u postgres sh -c "curl -s  http://dev.strabon.di.uoa.gr/rdf/Kallikratis-Coastline-dump.tgz|tar xz -O|psql -d ${DB}"
    7.72 +#./scripts/endpoint query ${ENDPOINT} "SELECT (COUNT(*) AS ?C) WHERE {?s ?p ?o}"
    7.73 +#sudo -u postgres psql -d endpoint -c 'CREATE INDEX datetime_values_idx_value ON datetime_values USING btree(value)';
    7.74 +#sudo -u postgres psql -d endpoint -c 'VACUUM ANALYZE;';
    7.75 +
    7.76 +#echo "Continue?"
    7.77 +#read a
    7.78 +
    7.79 +
    7.80 +for mon in `seq 7 10`; do
    7.81 +for d in `seq 1 30`; do
    7.82 +for h in `seq 0 23 `; do
    7.83 +    for m in `seq 0 15 45`; do
    7.84 +            time=`printf "%02d%02d\n" $h $m`
    7.85 +            time2=`printf "%02d:%02d\n" $h $m`
    7.86 +	    day=`printf "%02d" $d`
    7.87 +            month=`printf "%02d" $mon`
    7.88 +            file=${dataDir}${name}${month}${day}_${time}$suffix
    7.89 +#            file=${dataUrl}${name}_${time}$suffix
    7.90 +
    7.91 +    check=${CHECKDIR}${name}${month}${day}_${time}$suffix
    7.92 +
    7.93 +	      if [[ !  -e $check ]];
    7.94 +              then echo "FILE" $check "NOT EXISTS" ; continue
    7.95 +	      fi
    7.96 +
    7.97 +            # store file
    7.98 +            echo -n "storing " $file; echo; echo; 
    7.99 +	  # echo "Hotspot : " $h:$m >> stderr.txt
   7.100 +#            ${countTime} ./strabon -db endpoint store $file
   7.101 +
   7.102 + tmr1=$(timer)
   7.103 +            ../endpoint store ${ENDPOINT} N-Triples -u ${file}
   7.104 + tmr2=$(timer)
   7.105 +printf '%s ' $((tmr2-tmr1)) >>stderr.txt
   7.106 +
   7.107 +	   # sudo -u postgres psql -d endpoint -c 'VACUUM ANALYZE;';
   7.108 +
   7.109 +            echo;echo;echo;echo "File ${file} stored!" >> ${logFile}
   7.110 +#            echo "Continue?"
   7.111 +#            read a
   7.112 +
   7.113 +            # deleteSeaHotspots
   7.114 +            echo -n "Going to deleteSeaHotspots 2007-${month}-${day}T${time2}:00 " ;echo; echo; echo;
   7.115 +            query=`echo "${deleteSeaHotspots}" | sed "s/TIMESTAMP/2007-${month}-${day}T${time2}:00/g" | \
   7.116 +                sed "s/PROCESSING_CHAIN/DynamicThresholds/g" | \
   7.117 +                sed "s/SENSOR/MSG2/g"`
   7.118 +#            ${countTime} ./strabon -db endpoint update "${query}"
   7.119 +
   7.120 +tmr1=$(timer)
   7.121 +  ../endpoint update ${ENDPOINT} "${query}"
   7.122 +
   7.123 +tmr2=$(timer)
   7.124 +printf '%s ' $((tmr2-tmr1)) >>stderr.txt
   7.125 +
   7.126 +            echo;echo;echo;echo "File ${file} deleteSeaHotspots done!"
   7.127 +#            echo "Continue?"
   7.128 +#            read a
   7.129 +
   7.130 +            # refinePartialSeaHotspots
   7.131 +            echo -n "refinePartialSeaHotspots 2007-${month}-${day}T${time2}:00 "  ; echo; echo ; echo;
   7.132 +            query=`echo "${refinePartialSeaHotspots}" | sed "s/TIMESTAMP/2007-${month}-${day}T${time2}:00/g" | \
   7.133 +                sed "s/PROCESSING_CHAIN/DynamicThresholds/g" | \
   7.134 +                sed "s/SENSOR/MSG2/g" |\
   7.135 +		sed "s/SAT/METEOSAT9/g"`
   7.136 +#            ${countTime} ./strabon -db endpoint update "${query}"
   7.137 +tmr1=$(timer)
   7.138 +              ../endpoint update ${ENDPOINT} "${query}"
   7.139 +tmr2=$(timer)
   7.140 +printf '%s ' $((tmr2-tmr1)) >>stderr.txt
   7.141 +
   7.142 +            echo "File ${file} refinePartialSeaHotspots done!"
   7.143 +#            echo "Continue?"
   7.144 +#            read a
   7.145 +
   7.146 +            # refineTimePersistence
   7.147 +            echo -n "Going to refineTimePersistence 2007-${month}-${day}T${time2}:00 ";echo;echo;echo; 
   7.148 +            min_acquisition_time=`date --date="2007-${month}-${day} ${time2}:00 EEST -30 minutes" +%Y-%m-%dT%H:%m:00`
   7.149 +            query=`echo "${refineTimePersistence}" | sed "s/TIMESTAMP/2007-${month}-${day}T${time2}:00/g" | \
   7.150 +                sed "s/PROCESSING_CHAIN/DynamicThresholds/g" | \
   7.151 +                sed "s/SENSOR/MSG2/g" | \
   7.152 +                sed "s/ACQUISITIONS_IN_HALF_AN_HOUR/3.0/g" | \
   7.153 +                sed "s/MIN_ACQUISITION_TIME/${min_acquisition_time}/g" |\
   7.154 +		sed "s/SAT/METEOSAT9/g"`
   7.155 +
   7.156 +#            echo "Query:"
   7.157 +#            echo "${query}"
   7.158 +#            echo "Continue?"
   7.159 +#            read a
   7.160 +#            ${countTime} ./strabon -db endpoint update "${query}"
   7.161 +#            ${countTime} ../endpoint update ${ENDPOINT} "${query}"
   7.162 +
   7.163 + sudo -u postgres psql -d ${DB} -c 'VACUUM ANALYZE;';
   7.164 +
   7.165 +
   7.166 +tmr1=$(timer)
   7.167 +              ../endpoint update ${ENDPOINT} "${query}"
   7.168 + tmr2=$(timer)
   7.169 +printf '%s \n' $((tmr2-tmr1)) >>stderr.txt
   7.170 +            echo;echo;echo;echo "File ${file} timePersistence done!"
   7.171 +#            echo "Continue?"
   7.172 +#            read a
   7.173 +    done
   7.174 +done
   7.175 +done
   7.176 +done
   7.177 +
   7.178 +
   7.179 +#for f in `ls /home/konstantina/noa-teleios/out_triples/HMSG2_IR_039_s7_070825_*.hotspots.n3`
   7.180 +#do
   7.181 +
   7.182 +#    echo "Store $f"
   7.183 +#	${countTime} ./scripts/strabon -db endpoint store $f
   7.184 +#
   7.185 +#
   7.186 +#done
   7.187 +
     8.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     8.2 +++ b/scripts/v2.1/runNoaRefinementChain.sh-bakcup	Mon Jul 09 20:49:14 2012 +0300
     8.3 @@ -0,0 +1,167 @@
     8.4 +#!/bin/bash
     8.5 +LOC="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
     8.6 +
     8.7 +ENDPOINT="http://localhost:8080/endpoint"
     8.8 +DB="endpoint"
     8.9 +GRIDURL="http://kk.di.uoa.gr/grid_4.nt"
    8.10 +
    8.11 +#dataDir="http://localhost/noa-teleios/out_triples/"
    8.12 +dataDir="http://godel.di.uoa.gr/hotspots/"
    8.13 +name="HMSG2_IR_039_s7_070825"
    8.14 +suffix=".hotspots.n3"
    8.15 +
    8.16 +logFile="chain.log"
    8.17 +#countWTime="/usr/bin/time -p   %e"
    8.18 +#echo > ${logFile}
    8.19 +
    8.20 +function timer()
    8.21 +{
    8.22 +    if [[ $# -eq 0 ]]; then
    8.23 +        echo $(date '+%s')
    8.24 +    else
    8.25 +        local  stime=$1
    8.26 +        etime=$(date '+%s')
    8.27 +
    8.28 +        if [[ -z "$stime" ]]; then stime=$etime; fi
    8.29 +
    8.30 +        dt=$((etime - stime))
    8.31 +        ds=$((dt % 60))
    8.32 +        dm=$(((dt / 60) % 60))
    8.33 +        dh=$((dt / 3600))
    8.34 +        printf '%d:%02d:%02d' $dh $dm $ds
    8.35 +    fi
    8.36 +}
    8.37 +
    8.38 +#prin
    8.39 +#tmr1=$(timer)
    8.40 +#meta
    8.41 +#tmr2=$(timer)
    8.42 +#ektypwsi
    8.43 +#printf 'LALA %s %s\n' $((tmr2-tmr1)) $(timer $tmr1)
    8.44 +
    8.45 +
    8.46 +deleteSeaHotspots=`cat ${LOC}/DeleteInSea.sparql` # | sed 's/\"/\\\"/g'`
    8.47 +refinePartialSeaHotspots=`cat ${LOC}/Refine.sparql` # | sed 's/\"/\\\"/g'`
    8.48 +refineTimePersistence=`cat ${LOC}/TimePersistence.sparql` # | sed 's/\"/\\\"/g'`
    8.49 +
    8.50 +# Initialize
    8.51 +sudo service postgresql restart
    8.52 +echo "Dropping endpoint database";
    8.53 +sudo -u postgres dropdb ${DB}
    8.54 +echo "Creating endpoint database"
    8.55 +sudo -u postgres createdb ${DB} -T template_postgis
    8.56 +echo "restarting tomcat"
    8.57 +sudo service tomcat7 restart
    8.58 +
    8.59 +echo "initializing database"
    8.60 +echo "S D R TP" >>stderr.txt
    8.61 +
    8.62 + ../endpoint store ${ENDPOINT} N-Triples -u ${GRIDURL}
    8.63 +
    8.64 +#./scripts/endpoint query ${ENDPOINT} "SELECT (COUNT(*) AS ?C) WHERE {?s ?p ?o}" 
    8.65 +#sudo -u postgres psql -d endpoint -c 'CREATE INDEX datetime_values_idx_value ON datetime_values USING btree(value)';
    8.66 +#sudo -u postgres psql -d endpoint -c 'VACUUM ANALYZE;';
    8.67 +
    8.68 +
    8.69 +#echo "Continue?"
    8.70 +#read a
    8.71 +
    8.72 +
    8.73 +
    8.74 +
    8.75 +for h in `seq 0 23 `; do
    8.76 +    for m in `seq 0 15 45`; do
    8.77 +            time=`printf "%02d%02d\n" $h $m`
    8.78 +            time2=`printf "%02d:%02d\n" $h $m`
    8.79 +            file=${dataDir}${name}_${time}$suffix
    8.80 +#            file=${dataUrl}${name}_${time}$suffix
    8.81 +    
    8.82 +            # store file
    8.83 +            echo -n "storing " $file; echo; echo; 
    8.84 +	  # echo "Hotspot : " $h:$m >> stderr.txt
    8.85 +#            ${countTime} ./strabon -db endpoint store $file      
    8.86 +
    8.87 + tmr1=$(timer)
    8.88 +            ../endpoint store ${ENDPOINT} N-Triples -u ${file} 
    8.89 + tmr2=$(timer)
    8.90 +printf '%s ' $((tmr2-tmr1)) >>stderr.txt
    8.91 +           
    8.92 +	   # sudo -u postgres psql -d endpoint -c 'VACUUM ANALYZE;';
    8.93 +
    8.94 +            echo;echo;echo;echo "File ${file} stored!" >> ${logFile}
    8.95 +#            echo "Continue?"
    8.96 +#            read a
    8.97 +         
    8.98 +            # deleteSeaHotspots
    8.99 +            echo -n "Going to deleteSeaHotspots 2007-08-25T${time2}:00 " ;echo; echo; echo;
   8.100 +            query=`echo "${deleteSeaHotspots}" | sed "s/TIMESTAMP/2007-08-25T${time2}:00/g" | \
   8.101 +                sed "s/PROCESSING_CHAIN/DynamicThresholds/g" | \
   8.102 +                sed "s/SENSOR/MSG2/g"`
   8.103 +#            ${countTime} ./strabon -db endpoint update "${query}"
   8.104 +
   8.105 +tmr1=$(timer)           
   8.106 +  ../endpoint update ${ENDPOINT} "${query}"  
   8.107 +            
   8.108 +tmr2=$(timer)
   8.109 +printf '%s ' $((tmr2-tmr1)) >>stderr.txt
   8.110 +
   8.111 +            echo;echo;echo;echo "File ${file} deleteSeaHotspots done!"
   8.112 +#            echo "Continue?"
   8.113 +#            read a
   8.114 +            
   8.115 +            # refinePartialSeaHotspots
   8.116 +            echo -n "refinePartialSeaHotspots 2007-08-25T${time2}:00 "  ; echo; echo ; echo;
   8.117 +            query=`echo "${refinePartialSeaHotspots}" | sed "s/TIMESTAMP/2007-08-25T${time2}:00/g" | \
   8.118 +                sed "s/PROCESSING_CHAIN/DynamicThresholds/g" | \
   8.119 +                sed "s/SENSOR/MSG2/g"`
   8.120 +#            ${countTime} ./strabon -db endpoint update "${query}"
   8.121 +tmr1=$(timer)
   8.122 +              ../endpoint update ${ENDPOINT} "${query}"
   8.123 +            
   8.124 +tmr2=$(timer)
   8.125 +printf '%s ' $((tmr2-tmr1)) >>stderr.txt
   8.126 +
   8.127 +            echo "File ${file} refinePartialSeaHotspots done!"
   8.128 +#            echo "Continue?"
   8.129 +#            read a
   8.130 +
   8.131 +            # refineTimePersistence
   8.132 +            echo -n "Going to refineTimePersistence 2007-08-25T${time2}:00 ";echo;echo;echo; 
   8.133 +            min_acquisition_time=`date --date="2007-08-25 ${time2}:00 EEST -30 minutes" +%Y-%m-%dT%H:%m:00`
   8.134 +            query=`echo "${refineTimePersistence}" | sed "s/TIMESTAMP/2007-08-25T${time2}:00/g" | \
   8.135 +                sed "s/PROCESSING_CHAIN/DynamicThresholds/g" | \
   8.136 +                sed "s/SENSOR/MSG2/g" | \
   8.137 +                sed "s/ACQUISITIONS_IN_HALF_AN_HOUR/3.0/g" | \
   8.138 +                sed "s/MIN_ACQUISITION_TIME/${min_acquisition_time}/g"`
   8.139 +
   8.140 +#            echo "Query:"
   8.141 +#            echo "${query}"
   8.142 +#            echo "Continue?"
   8.143 +#            read a
   8.144 +#            ${countTime} ./strabon -db endpoint update "${query}"
   8.145 +#            ${countTime} ../endpoint update ${ENDPOINT} "${query}"
   8.146 +
   8.147 + sudo -u postgres psql -d ${DB} -c 'VACUUM ANALYZE;';
   8.148 +
   8.149 +
   8.150 +tmr1=$(timer)
   8.151 +              ../endpoint update ${ENDPOINT} "${query}"
   8.152 + tmr2=$(timer)
   8.153 +printf '%s \n' $((tmr2-tmr1)) >>stderr.txt
   8.154 +           
   8.155 +            echo;echo;echo;echo "File ${file} timePersistence done!"
   8.156 +#            echo "Continue?"
   8.157 +#            read a
   8.158 +    done
   8.159 +done
   8.160 +
   8.161 +
   8.162 +#for f in `ls /home/konstantina/noa-teleios/out_triples/HMSG2_IR_039_s7_070825_*.hotspots.n3`
   8.163 +#do
   8.164 +
   8.165 +#    echo "Store $f"
   8.166 +#	${countTime} ./scripts/strabon -db endpoint store $f
   8.167 +#	
   8.168 +#	
   8.169 +#done
   8.170 +