<p>
A Ground Motion database (gmdb) is a set of seismic records stored in a tabular model
as horizontal rows, where the model vertical columns represent each record field.
</p>
<p>
A selection expression on a gmdb is just a string containing a
Python expression that will be evaluated for each record, returning matching rows only 
(i.e., rows for which the expression is true). The expression involves at least one column, a
comparison operator (<code>==</code>, <code>!=</code>, <code>&lt;</code>,
<code>&lt;</code>=, <code>&gt;</code>, <code>&gt;</code>=) and any value (or algebraic expression)
consistent with the column type. E.g.:
<pre><code class="language-python">pga <= 0.01
pga != nan             # select records where PGA is not missing
station_name == "ASD"  # note quotes around string-column values
</code></pre>
</p>

<p>
Several simple expressions
can be wrapped in parenthesis and combined with logical operators (<code>&</code>
for logical and, <code>|</code> for logical or, and <code>~</code> for negation), e.g.:
<pre><code class="language-python">(pga != nan) & ((magnitude > 5) | ~(event_time <= "2016-08-30"))
</code></pre>
</p>

<p>The gmdb columns which can be used in a selection expression are listed below</p>

<table class='selexpr_table'>
	<thead>
		<tr>
			<th>Column name:</th>
			<th>Column type:</th>
			<th>Missing values are stored as (empty cell: no missing value available):</th>
		</tr>
	</thead>
	<tbody>
	{% for key, values in gmt.items %}
    <tr>
        <td>{{ key }}</td>
        {% for value in values %}
        <td>{{ value | safe }}</td>
        {% endfor %}
    </tr>
    {% endfor %}
    </tbody>
</table>

<p class='footnote'>
Note: all GSIMs are implemented in OpenQuake with set of required columns.
In all computations involving a gmdb, for any given GSIM the gmdb is first filtered by
selecting only valid records, i.e. records with non missing values in all GSIM's required columns.
Any selection expression, if provided, is then applied on valid records only.
</p>