Strabon

view examples/teleios/instantiate.sh @ 711:9111700fb49f

minor addition in ValueJoinOptimizer
author Konstantina
date Fri Nov 16 18:36:40 2012 +0200 (2012-11-16)
parents 81ac0fc6733e
children c7afd12bf80f
line source
1 #!/bin/bash
3 #
4 # This Source Code Form is subject to the terms of the Mozilla Public
5 # License, v. 2.0. If a copy of the MPL was not distributed with this
6 # file, You can obtain one at http://mozilla.org/MPL/2.0/.
7 #
8 # Copyright (C) 2010, 2011, 2012, Pyravlos Team
9 #
10 # http://www.strabon.di.uoa.gr/
11 #
13 #
14 # Script for instantiating NOA refinement queries.
15 #
16 # Author: Charalampos (Babis) Nikolaou <charnik@di.uoa.gr>
17 #
19 # command name
20 CMD="$(basename ${0})"
22 # absolute directory name of this command
23 LOC="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
25 function help() {
26 echo "Usage: ${CMD} [OPTIONS] QUERY_FILE..."
27 echo
28 echo "Script for instantiating NOA refinement queries."
29 echo
30 echo "OPTIONS can be any of the following (variable names and values are case sensitive)"
31 echo " -s, --sensor : the sensor to use, e.g., \`MSG1' or \`MSG2'"
32 echo " (determines the value for satellite, template variable \`SAT'"
33 echo " and number of acquisitions in an hour, template variable"
34 echo " \`ACQUISITIONS_IN_HALF_AN_HOUR')"
35 echo " -c, --chain : the processing chain to use, e.g., \`DynamicThresholds'"
36 echo " -t, --timestamp : the timestamp to use, e.g., \`2010-08-21T19:50:00'"
37 echo " -m, --min_acq_time : the minimum acquisition time (used in a persistence query only)"
38 echo " -M, --max_acq_time : the maximum acquisition time (used in a discovery query only)"
39 echo
40 echo "Example run:"
41 echo " ./instantiate.sh -s MSG1 -t '2010-08-21T19:50:00' -c "DynamicThresholds" -m '2010-08-21T19:50:00' -M '2010-08-21T19:50:00' *.rq"
42 }
44 SENSOR=
45 CHAIN=
46 SAT=
47 N_ACQUISITIONS=
48 TIMESTAMP=
49 MIN_ACQ_TIME=
50 MAX_ACQ_TIME=
52 if test $# -eq 0; then
53 help
54 exit 1
55 fi
57 # read script options
58 while test $# -gt 0 -a "X${1:0:1}" == "X-"; do
59 case "${1}" in
60 -h|--help)
61 help
62 exit 0
63 ;;
64 -s|--sensor)
65 shift
66 SENSOR="${1}"
68 # determine satellite and number of acquisitions per hour
69 if test "${SENSOR}" = "MSG2"; then
70 SAT="METEOSAT9"
71 N_ACQUISITIONS=3.0
72 else
73 SAT="METEOSAT8"
74 N_ACQUISITIONS=7.0
76 # change MSG1 to MSG1_RSS (for whatever reason NOA uses it :-))
77 SENSOR="MSG1_RSS"
78 fi
79 shift
80 ;;
81 -c|--chain)
82 shift
83 CHAIN="${1}"
84 shift
85 ;;
86 -t|--timestamp)
87 shift
88 TIMESTAMP="${1}"
89 shift
90 ;;
91 -m|--min_acq_time)
92 shift
93 MIN_ACQ_TIME="${1}"
94 shift
95 ;;
96 -M|--max_acq_time)
97 shift
98 MAX_ACQ_TIME="${1}"
99 shift
100 ;;
101 -*)
102 echo "${CMD}: unknown option \"${1}\""
103 help
104 exit 1
105 ;;
106 esac
107 done
109 # build sed expression
110 ARGS=
112 if test ! -z "${CHAIN}"; then
113 ARGS="${ARGS} -e 's/PROCESSING_CHAIN/${CHAIN}/g'"
114 fi
116 if test ! -z "${SENSOR}"; then
117 ARGS="${ARGS} -e 's/SENSOR/${SENSOR}/g'"
118 fi
120 if test ! -z "${SAT}"; then
121 ARGS="${ARGS} -e 's/SAT/${SAT}/g'"
122 fi
124 if test ! -z "${N_ACQUISITIONS}"; then
125 ARGS="${ARGS} -e 's/ACQUISITIONS_IN_HALF_AN_HOUR/${N_ACQUISITIONS}/g'"
126 fi
128 if test ! -z "${TIMESTAMP}"; then
129 ARGS="${ARGS} -e 's/TIMESTAMP/${TIMESTAMP}/g'"
130 fi
132 if test ! -z "${MIN_ACQ_TIME}"; then
133 ARGS="${ARGS} -e 's/MIN_ACQUISITION_TIME/${MIN_ACQ_TIME}/g'"
134 fi
136 if test ! -z "${MAX_ACQ_TIME}"; then
137 ARGS="${ARGS} -e 's/MAX_ACQUISITION_TIME/${MAX_ACQ_TIME}/g'"
138 fi
140 if test -z "${ARGS}"; then
141 echo "${CMD}: You would be so kind to provide at least one OPTION."
142 help
143 exit 2
144 fi
146 QUERY="`eval sed ${ARGS} ${@}`"
147 #echo "$QUERY"
148 #echo eval sed ${ARGS} ${@}
150 # check for unbounded variables
151 GREP_RESULT=`echo "${QUERY}" | egrep -o 'PROCESSING_CHAIN|SENSOR|"SAT"|ACQUISITIONS_IN_HALF_AN_HOUR|TIMESTAMP|MIN_ACQUISITION_TIME|MAX_ACQUISITION_TIME'`
152 if ! test $? -eq 0; then
153 echo "${QUERY}"
155 else
156 echo -e "${CMD}: WARNING: found unbounded variables "$(echo "${GREP_RESULT}"|sort -u)""
157 echo
158 help
159 fi