| 1 |
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" |
| 2 |
"http://www.w3.org/TR/html4/loose.dtd"> |
| 3 |
<html xmlns="http://www.w3.org/1999/xhtml" |
| 4 |
xmlns:n="http://nevow.com/ns/nevow/0.1"> |
| 5 |
<head n:render="commonhead"> |
| 6 |
<link rel="author" href="http://www.g-vo.org"/> |
| 7 |
<link rel="license" href="http://creativecommons.org/publicdomain/zero/1.0/"/> |
| 8 |
<title>Help: Vizier-like expressions</title> |
| 9 |
</head> |
| 10 |
<body n:render="withsidebar"> |
| 11 |
<h1>Help on Vizier-like expressions</h1> |
| 12 |
<p>The <span n:render="prependsite"/> |
| 13 |
supports search expressions modelled after <a href="http://vizier.u-strasbg.fr/cgi-bin/Help?VizieR/syntax">what |
| 14 |
CDS' Vizier service provides</a>. Our implementation is not yet complete. |
| 15 |
If you need a given feature, please let us know.</p> |
| 16 |
|
| 17 |
<p>The rough idea is that you can specify |
| 18 |
the values you search for with certain operators, depending on the type |
| 19 |
of the field you are matching against.</p> |
| 20 |
|
| 21 |
<h2><a name="floats">Vizier-like expressions for numeric values</a></h2> |
| 22 |
<h3>Overview</h3> |
| 23 |
<p>For numeric expressions, you can use the following operators:</p> |
| 24 |
<ul> |
| 25 |
<li>No operator: this is equivalent to =.</li> |
| 26 |
<li>Comparisons: The operators <, <=, >, >=, =, != are prefixed |
| 27 |
and behave like their mathematical counterparts.</li> |
| 28 |
<li>Enumeration: You can enumerate values you are interested in using |
| 29 |
the comma (",") operator.</li> |
| 30 |
<li>Range: To specify a range of acceptable values, use the ".." operator. |
| 31 |
Note that you must surround this operator with whitespace; alternatively, |
| 32 |
you can give "value and error" with the "+/-" operator.</li> |
| 33 |
<li>Logical operators: The operators ! (not), & (and), and | (or) provide |
| 34 |
simple logic. The precedence is in the given sequence. If you need to do |
| 35 |
fancy things here, contact us and we will add support for grouping (parentheses) |
| 36 |
</li> |
| 37 |
</ul> |
| 38 |
|
| 39 |
<h3>Examples</h3> |
| 40 |
<ul> |
| 41 |
<li><code>50</code> or <code>=50</code> – select only values exactly 50</li> |
| 42 |
<li><code>!=50</code> – select only values different from 50</li> |
| 43 |
<li><code>< 60.0</code>; <code>> 4e-8</code>; <code>>= -.5</code>; |
| 44 |
<code><= -5.e13</code> – selects values smaller, greater, greater or |
| 45 |
equal to their operands.</li> |
| 46 |
<li><code>50. .. 80.5</code> – selects values between 50 and 80.5 inclusive.</li> |
| 47 |
<li><code>50 +/- 10</code> – selects values between 40 and 60 inclusive.</li> |
| 48 |
<li><code>40, 50, 50.5, 60</code> – select any of the enumerated values.</li> |
| 49 |
<li><code>!40, 50, 50.5, 60</code> – select anything other than the enumerated values.</li> |
| 50 |
<li><code>40 | 100 +/- 5</code> – select values equal to 40 or between 95 and 105.</li> |
| 51 |
</ul> |
| 52 |
|
| 53 |
<h3>Usage on min/max pairs</h3> |
| 54 |
|
| 55 |
When used on min/max columns representing an interval (e.g., |
| 56 |
em_min/em_max on Obscore), these operators have a slightly different |
| 57 |
meaning: |
| 58 |
|
| 59 |
<ul> |
| 60 |
<li>Equality is translated to between min and max</li> |
| 61 |
<li>Input intervals, whether given as ranges or using +/-, are compared |
| 62 |
for overlap with the interval given by min/max.</li> |
| 63 |
<li>Comparisons are a bit funky: < is translated to “smaller than the |
| 64 |
lower bound”, <= to “smaller than the <em>upper</em> bound”. |
| 65 |
Similarly, > is “larger than the upper bound” and >= “larger than |
| 66 |
the lower bound”. This particular behaviour we might reconsider in the |
| 67 |
future.</li> |
| 68 |
</ul> |
| 69 |
|
| 70 |
<h3>Grammar</h3> |
| 71 |
<p>For those into such things, here is the grammar we currently use to parse |
| 72 |
numeric expressions (the base nonterminal is expr).</p> |
| 73 |
|
| 74 |
<pre> |
| 75 |
preOp ::= "=" | ">=" | ">" | "<=" | "<" |
| 76 |
rangeOp ::= ".." |
| 77 |
pmOp ::= "+/-" | "\xb1" (this is the ± character) |
| 78 |
orOp ::= "|" |
| 79 |
andOp ::= "&" |
| 80 |
notOp ::= "!" |
| 81 |
commaOp ::= "," |
| 82 |
|
| 83 |
preopExpr ::= [preOp] floatLiteral |
| 84 |
rangeExpr ::= floatLiteral rangeOp floatLiteral |
| 85 |
valList ::= floatLiteral { commaOp floatLiteral } |
| 86 |
pmExpr ::= floatLiteral pmOp floatLiteral |
| 87 |
simpleExpr ::= rangeExpr | pmExpr | valList | preopExpr |
| 88 |
|
| 89 |
notExpr ::= [notOp] simpleExpr |
| 90 |
andExpr ::= notExpr {andOp + notExpr} |
| 91 |
expr ::= andExpr {orOp + expr} |
| 92 |
</pre> |
| 93 |
|
| 94 |
<p>floatLiteral is a usual C decimal integer or float literal.</p> |
| 95 |
|
| 96 |
|
| 97 |
<h2 id="dates"><a name="dates">Vizier-like expressions for dates</a></h2> |
| 98 |
|
| 99 |
<h3>Overview</h3> |
| 100 |
|
| 101 |
<p>Dates support the same operators as <a href="#floats">numeric operands</a>, |
| 102 |
except that the "error" in expressions with +/- is a simple float (in days). |
| 103 |
Dates |
| 104 |
are given in one the the VO's preferred ISO formats, |
| 105 |
i.e., YYYY-MM-DD or YYYY-MM-DDTHH-MM-SS. You can also give simple floating |
| 106 |
point numbers as dates, which will be interpreted as Julian years if |
| 107 |
between 1000 and 3000, as MJD if between 1e4 and 1e5, and JD if between |
| 108 |
2e6 and 4e6. If you hit midnight when giving JD (i.e., number.5) or MJD |
| 109 |
(number.0), DaCHS will interpret the specification as “whole day” and |
| 110 |
expand the range accordingly.</p> |
| 111 |
|
| 112 |
<p>In the VO, timezones are frowned upon. Hence, you will usually deal |
| 113 |
with UTC or a related time scale (like TT). For the reference |
| 114 |
positions, you will have to inspect the metadata.</p> |
| 115 |
|
| 116 |
<p>Times |
| 117 |
without dates are not yet supported. In general, we try to interpret |
| 118 |
dates without times in a sensible way; for instance, if you just |
| 119 |
give a date, all records with a timestamp on that date will match.</p> |
| 120 |
|
| 121 |
<h3>Examples</h3> |
| 122 |
|
| 123 |
<p>See also the examples for <a href="#float">numeric expressions</a>.</p> |
| 124 |
|
| 125 |
<ul> |
| 126 |
<li><code><2003-04-06</code> – select values earlier than |
| 127 |
April 6th, 2003.</li> |
| 128 |
<li><code>2003-04-06 +/- 4</code> – select values four days around |
| 129 |
April 6th, 2003.</li> |
| 130 |
<li><code>1980.233</code> – select values for the exact time |
| 131 |
1980-03-23T14:28:40 (this will rarely be a good idea)</li> |
| 132 |
<li><code>1980.233 +/- 1</code> – interpreted as a Julian year: select |
| 133 |
values between 1980-03-22T14:28:40 and 1980-03-24T14:28:40 (i.e., a |
| 134 |
tolerance remains in days even for julian years)</li> |
| 135 |
<li><code>54221</code> – interpreted as MJD: select values at any time |
| 136 |
on 2007-05-01 (this is because it hits midnight; 54221.5 would match the |
| 137 |
exact moment 2007-05-01T12:00:00 instead)</li> |
| 138 |
<li><code>2454222.0 .. 2454225.0</code> – interpreted as JD: match values |
| 139 |
between 2007-05-01-12-00-00 and 2007-05-05-12-00-00</li> |
| 140 |
</ul> |
| 141 |
|
| 142 |
<h3>Usage on min/max pairs</h3> |
| 143 |
|
| 144 |
When used on min/max columns representing an interval (e.g., |
| 145 |
t_min/t_max on Obscore), these operators have a slightly different |
| 146 |
meaning: |
| 147 |
|
| 148 |
<ul> |
| 149 |
<li>Equality is translated to between min and max; this, for now, does |
| 150 |
<em>not</em> expand days, i.e., for interval comparisons, 1855-01-01 is exactly |
| 151 |
midnight on January 1st, 1855 (in the scale and for whatever position the data |
| 152 |
happens to adopt).</li> |
| 153 |
<li>Input intervals, whether given as ranges or using +/-, are compared |
| 154 |
for overlap with the interval given by min/max.</li> |
| 155 |
<li>Comparisons are a bit funky: < is translated to “smaller than the |
| 156 |
lower bound”, <= to “smaller than the <em>upper</em> bound”. |
| 157 |
Similarly, > is “larger than the upper bound” and >= “larger than |
| 158 |
the lower bound”. This particular behaviour we might reconsider in the |
| 159 |
future.</li> |
| 160 |
</ul> |
| 161 |
|
| 162 |
|
| 163 |
<h3>Grammar</h3> |
| 164 |
|
| 165 |
<p>The grammar is identical to the one of <a href="#float">numeric |
| 166 |
expressions</a>, except that floatLiteral is dateLiteral with the exception |
| 167 |
of pmExpr that is</p> |
| 168 |
<pre> |
| 169 |
pmExpr := dateLiteral pmOp floatLiteral</pre> |
| 170 |
<p>here. The dates themselves currently follow the regular expression |
| 171 |
<code>[0-9][0-9][0-9][0-9]-[0-9][0-9]-[0-9][0-9]</code>. This will |
| 172 |
be relaxed in the future.</p> |
| 173 |
|
| 174 |
<h2><a name="string">Vizier-like expression for strings</a></h2> |
| 175 |
|
| 176 |
<h3>Overview</h3> |
| 177 |
|
| 178 |
<p><strong>Note:</strong> Contrary to what Vizier does, the default on string |
| 179 |
expressions on this site is to match expressions literally (i.e., the default |
| 180 |
operator is == rather than ~).</p> |
| 181 |
|
| 182 |
<p>Some of the operators below work on <em>patterns</em>. A pattern |
| 183 |
contains the meta characters [, ], *, and ?; all others are "normal" |
| 184 |
characters matched literally. The * matches zero or more characters, the |
| 185 |
? exactly one; characters in square brackets match any character enumerated |
| 186 |
within them. You can use ranges like "A-Z" within square brackets. If the |
| 187 |
first character in the square brackets is a caret (<code>^</code>), all |
| 188 |
characters except the ones listed are matched.</p> |
| 189 |
|
| 190 |
<p>The following operators can be used when matching strings – when we talk |
| 191 |
about literals as operands, metacharacter interpretation is suppressed (i.e., |
| 192 |
the strings are matched literally), otherwise we talk about patterns.</p> |
| 193 |
|
| 194 |
<p>Note that both patterns and literally interpreted strings must match |
| 195 |
the <em>whole</em> data field. This is substantially different from the |
| 196 |
usual regular expression engines (but corresponds to what you may know |
| 197 |
from filename patterns).</p> |
| 198 |
|
| 199 |
<ul> |
| 200 |
<li><code>==</code> – matches if your input matches the entire input |
| 201 |
field literally, |
| 202 |
i.e., preserving case. This is the default when no operator is given, but it |
| 203 |
may be necessary to use the operator if, e.g., your pattern would be interpreted |
| 204 |
as an expression.</li> |
| 205 |
<li><code>=~</code> – Like ==, but ignoring case.</li> |
| 206 |
<li><code>~</code> – selects pattern matches of operand ignoring case.</li> |
| 207 |
<li><code>=</code> – case-sensitive version of <code>~</code>.</li> |
| 208 |
<li><code>!~</code> – reversal of <code>~</code> (i.e., matches when |
| 209 |
<code>~</code> doesn't).</li> |
| 210 |
<li><code>!</code> – reversal of <code>=</code>.</li> |
| 211 |
<li><code>!=</code> – selects all but literal matches of the operand.</li> |
| 212 |
<li><code>>=</code>, <code>></code>, <code><=</code>, <code><</code> |
| 213 |
– selects strings larger or equal, larger, etc., than the operand. |
| 214 |
Comparisons happen according to ASCII value (i.e., in the C locale).</li> |
| 215 |
<li><code>=,</code> and <code>=|</code> – these start enumerations, i.e., |
| 216 |
they match when a literal in the following list is matched. |
| 217 |
There are two versions of these so you can include either the comma or the |
| 218 |
vertical bar in your literals. If you need both, you are out of luck.</li> |
| 219 |
</ul> |
| 220 |
|
| 221 |
<h3>Examples</h3> |
| 222 |
|
| 223 |
<p>Here is a table of expressions and their matches:</p> |
| 224 |
|
| 225 |
<style type="text/css"> |
| 226 |
<!-- |
| 227 |
table#vizstringtable { |
| 228 |
border:2px solid gray; |
| 229 |
border-collapse: collapse; |
| 230 |
width: 100%; |
| 231 |
} |
| 232 |
|
| 233 |
#vizstringtable * td { |
| 234 |
border: 1px solid gray; |
| 235 |
padding: 2pt; |
| 236 |
text-align: center; |
| 237 |
} |
| 238 |
|
| 239 |
#vizstringtable * th { |
| 240 |
padding: 4pt; |
| 241 |
text-align: center; |
| 242 |
--> |
| 243 |
</style> |
| 244 |
|
| 245 |
<table id="vizstringtable"> |
| 246 |
<tr><th>Expression</th><th colspan="9">Data</th></tr> |
| 247 |
<tr><td></td><td>M4e</td><td>M4ep</td><td>m4e</td><td>A4p</td><td>O4p</td><td>M*</td><td>m|a</td><td>x,a</td><td>=x</td></tr> |
| 248 |
<tr><td>M4e</td><td>X</td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td></tr> |
| 249 |
<tr><td>=x</td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td></tr> |
| 250 |
<tr><td>== =x</td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td>X</td></tr> |
| 251 |
<tr><td>!= =x</td><td>X</td><td>X</td><td>X</td><td>X</td><td>X</td><td>X</td><td>X</td><td>X</td><td> </td></tr> |
| 252 |
<tr><td>==M4e</td><td>X</td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td></tr> |
| 253 |
<tr><td>=~m4e</td><td>X</td><td> </td><td>X</td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td></tr> |
| 254 |
<tr><td>=~m4</td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td></tr> |
| 255 |
<tr><td>~*</td><td>X</td><td>X</td><td>X</td><td>X</td><td>X</td><td>X</td><td>X</td><td>X</td><td>X</td></tr> |
| 256 |
<tr><td>~m*</td><td>X</td><td>X</td><td>X</td><td> </td><td> </td><td>X</td><td>X</td><td> </td><td> </td></tr> |
| 257 |
<tr><td>M*</td><td> </td><td> </td><td> </td><td> </td><td> </td><td>X</td><td> </td><td> </td><td> </td></tr> |
| 258 |
<tr><td>!~m*</td><td> </td><td> </td><td> </td><td>X</td><td>X</td><td> </td><td> </td><td>X</td><td>X</td></tr> |
| 259 |
<tr><td>~*p</td><td> </td><td>X</td><td> </td><td>X</td><td>X</td><td> </td><td> </td><td> </td><td> </td></tr> |
| 260 |
<tr><td>!~*p</td><td>X</td><td> </td><td>X</td><td> </td><td> </td><td>X</td><td>X</td><td>X</td><td>X</td></tr> |
| 261 |
<tr><td>~?4p</td><td> </td><td> </td><td> </td><td>X</td><td>X</td><td> </td><td> </td><td> </td><td> </td></tr> |
| 262 |
<tr><td>~[MO]4[pe]</td><td>X</td><td> </td><td>X</td><td> </td><td>X</td><td> </td><td> </td><td> </td><td> </td></tr> |
| 263 |
<tr><td>=[MO]4[pe]</td><td>X</td><td> </td><td> </td><td> </td><td>X</td><td> </td><td> </td><td> </td><td> </td></tr> |
| 264 |
<tr><td>>O</td><td> </td><td> </td><td>X</td><td> </td><td>X</td><td> </td><td>X</td><td>X</td><td> </td></tr> |
| 265 |
<tr><td>>O5</td><td> </td><td> </td><td>X</td><td> </td><td> </td><td> </td><td>X</td><td>X</td><td> </td></tr> |
| 266 |
<tr><td>>=m</td><td> </td><td> </td><td>X</td><td> </td><td> </td><td> </td><td>X</td><td>X</td><td> </td></tr> |
| 267 |
<tr><td><M</td><td> </td><td> </td><td> </td><td>X</td><td> </td><td> </td><td> </td><td> </td><td>X</td></tr> |
| 268 |
<tr><td>=|M4e| O4p| x,a</td><td>X</td><td> </td><td> </td><td> </td><td>X</td><td> </td><td> </td><td>X</td><td> </td></tr> |
| 269 |
<tr><td>=,x,a,=x,m|a</td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td>X</td><td> </td><td>X</td></tr> |
| 270 |
</table> |
| 271 |
|
| 272 |
<p>Maybe some comments are in order:</p> |
| 273 |
<ol> |
| 274 |
<li><code>=x</code> matches nothing since the leading = is interpreted as an |
| 275 |
operator ("match as pattern case-insensitively"), and there is nothing |
| 276 |
matching the pattern x in the sample (in this case , only x and X would match).</li> |
| 277 |
<li><code>== =x</code> is the simplest way to search for "=x" – its analogues |
| 278 |
work for all other metacharacters as well.</li> |
| 279 |
<li><code>=~m4</code> matches nothing, because the pattern has to match the |
| 280 |
<em>entire</em> string, and all strings in the sample have some annexes to |
| 281 |
their variations of m4.</li> |
| 282 |
<li><code>M*</code> only matches "M*" since the default on our system is |
| 283 |
literal matching. This expression would have behaved completely differently on |
| 284 |
Vizier.</li> |
| 285 |
</ol> |
| 286 |
|
| 287 |
<h3>Grammar</h3> |
| 288 |
|
| 289 |
<p>The following grammar describes the parsing of string expressions:</p> |
| 290 |
<pre> |
| 291 |
simpleOperator ::= "==" | "!=" | ">=" | ">" | "<=" | "<" |
| 292 |
simpleOperand ::= Regex(".*") |
| 293 |
simpleExpr ::= simpleOperator + simpleOperand |
| 294 |
|
| 295 |
commaOperand ::= Regex("[^,]+") |
| 296 |
barOperand ::= Regex("[^|]+") |
| 297 |
commaEnum ::= "=," commaOperand { "," commaOperand } |
| 298 |
exclusionEnum ::= "!=," commaOperand { "," + commaOperand } |
| 299 |
barEnum ::= "=|" barOperand { "|" + barOperand } |
| 300 |
enumExpr ::= exclusionEnum | commaEnum | barEnum |
| 301 |
|
| 302 |
patLiterals ::= CharsNotIn("[*?") |
| 303 |
wildStar ::= "*" |
| 304 |
wildQmark ::= "?" |
| 305 |
setElems ::= CharsNotIn("]") |
| 306 |
setSpec ::= "[" + setElems + "]" |
| 307 |
patElem ::= setSpec | wildStar | wildQmark | patLiterals |
| 308 |
pattern ::= patElem { patElem } |
| 309 |
|
| 310 |
patternOperator ::= "~" | "=" | "!~" | "!" |
| 311 |
patternExpr ::= patternOperator pattern |
| 312 |
|
| 313 |
stringExpr ::= enumExpr | simpleExpr | patternExpr | nakedExpr |
| 314 |
</pre> |
| 315 |
</body> |
| 316 |
</html> |