<p><b>Endpoint: <span class='url'>{{ baseurl }}/{{ data.path }}</span></b></p>
<p>
eGSIM, through the GMPE-SMTK library, offers the ability to compare observed ground motions with
the GMPE model predictions using the GMPE implementations found inside OpenQuake.
This is a particularly powerful tool as it permits a
hazard modeller to undertake the GMPE comparison using the exact same GMPE implementation
found inside the seismic hazard software. All analyses undertaken will, by default,
analyse the total residual, the inter-event residual and the intra-event residual, exposed to the
user via Residuals plots.
</p>

<h3 id="{{ data.key }}_request">Request</h3>
<p>
A request to the Residuals plot service requires a list of GMPEs and IMTs, a Ground Motion
database (GMDB) and the desired plot type
</p>

<table class='request'>
	{% include "./request_template.html" with form=data.form %}
</table>

<div class='footnote'>
Notes:
<ul>
	<li><span class='pval str'>SA</span> in <span class='pname'>{{ data.form.imt.name }}</span>
		must be provided
		with the given period in parentheses, e.g. <span class='pval str'>["SA(0.1)", "SA(0.2)"]</span>
		(from the Web GUI, select <span class='pval str'>SA</span> and provide the periods
		in the field <span class='pname'>{{ data.form.sa_period.label }}</span> separated
		by <i>spaces</i> or <i>commas</i>, e.g. <span class='pval str'>0.1 0.2</span>).
	<li><span class='pname'>{{ data.form.gsim.name }}</span> and 
		<span class='pname'>{{ data.form.imt.name }}</span>
		can be input with
		<a href="https://docs.python.org/3/library/fnmatch.html" target="_blank">wildcards</a>:
		eGSIM will then select all matching items (wildcards are not implemented in the Web GUI)
</ul>

</div>

<h4 id="selexpr">Selection expression</h4>

{% include "./selexpr_help.html" %}

<h3 id="{{ data.key }}_response">Response</h3>
<p>
The number of generated Residuals plots will be the product of the requested Intensity
measure types (<span class='pname'>{{ data.form.imt.name }}</span>), the requested GMPEs
(<span class='pname'>{{ data.form.gsim.name }}</span>). Each Residual plot is futher subdivided
into three subplots:
</p>

<table>
<thead>
<tr>
	<td>Plot type</td>
	<td>Residual plots per (GMPE, IMT) tuple</td>
	<td>Plot description</td>
	<td>Additional plot attributes</td>
</thead>
<tbody class='grid'>
<tr>
	<td>{{ data.form.plot_type.choices.0.1 }}</td>
	<td rowspan="7">Intra event<br>Inter event<br>Total</td>
	<td>Histogram of frequencies (y axis) vs residuals bins (x)</td>
	<td>Mean, standard deviation of the distribution</td>
</tr>
<tr>
	<td>{{ data.form.plot_type.choices.1.1 }}</td>
	<td>Histogram of the frequencies (y) vs residuals likelihood bins (x)</td>
	<td>Median of the distribution</td>
</tr>
<tr>
	<td>{{ data.form.plot_type.choices.2.1 }}</td>
	<td>Scatter plot of residuals (y) vs. magnitude (x)</td>
	<td rowspan="5">p-value and linear regression (slope, intercept)</td>
</tr>
<tr>
	<td>{{ data.form.plot_type.choices.3.1 }}</td>
	<td>Same as above with distance as point's x</td>
</tr>
<tr>
	<td>{{ data.form.plot_type.choices.4.1 }}</td>
	<td>Same as above with Vs<sub>30</sub> as point's x</td>
</tr>
<tr>
	<td>{{ data.form.plot_type.choices.5.1 }}</td>
	<td>Same as above with depth as point's x</td>
</tr>
<!-- <tr>
	<td>{ form.residuals.plot_type.choices.6.1 }</td>
	<td>Same as above with stations as point's x</td>
</tr>
<tr>
	<td>{ form.residuals.plot_type.choices.7.1 }</td>
	<td style='width:18em'>'Intra event' (not normalised by the intra-event standard deviation),
	'Average within-event' (Average within-event residual for each station),
	'Variabilities distribution' (the distribution residual variabilities for each station)</td>
	<td>Scatter plots of the plot residuals (y axis) vs. each station (x)</td>
	<td>mean and standard deviation</td>
</tr> -->
</tbody>
</table>


<h4>JSON</h4>
<p>
Residuals plot data returned in JSON format will have the following structure:
</p>
<pre><code class="language-python">{
    "PGA": {
        "Intra event": {
            "AkkarEtAl2013": {
                "xvalues": [4, 4, 3.9, ...],
                "xlabel": "Magnitude",
                "yvalues": [-2.11, -2.27, -2.08, ...],
                "ylabel": "Z (PGA)",
                "slope": 0.269,      # see note 1
                "intercept": -1.998, # see note 1
                "pvalue": 6.6e-8,    # see note 1
                "median": null,      # see note 1
                "mean": null,        # see note 1
                "stddev": null       # see note 1
            },
            "CauzziEtAl2014": {
                # same Object type as above,
                # computed for a different GSIM
            },
            ...
        },
        "Inter event": {
            # same Object types as above,
            # computed for a different Residuals type
        },
        ...
    },
    "PGV": {
        # same Object types as above,
        # computed for a different IMT
    },
    ...
}</code></pre>
<div class='footnote'>
Notes:
<ol>
	<li>The parameters from
		<span class='pname'>slope</span>,
		<span class='pname'>intercept</span>,
		<span class='pname'>pvalue</span>,
		<span class='pname'>median</span>,
		<span class='pname'>stddev</span> are provided (not null) depending on the value of
		<span class='pname'>{{ data.form.plot_type.name }}</span>
</ol>
</div>

<h4>CSV</h4>
<p>
Residuals plot data returned in CSV format will have the following structure (represented as
csv table).
<br>
<span class='xvalues'></span> = x values (first cell is the x label), 
<span class='yvalues'></span> = y values (first cell is the y label)
</p>

<table class='csv'>
<tr>
	<td>imt</td>
	<td>type</td>
	<td>gsim</td>
	<td>mean</td>
	<td>stddev</td>
	<td>median</td>
	<td>slope</td>
	<td>intercept</td>
	<td>pvalue</td>
	<td></td>
	<td></td>
	<td></td>
	<td></td>
	<td></td>
</tr>
<tr>
	<td>PGA</td>
	<td>Intra event</td>
	<td>AkkarEtAl2013</td>
	<td></td>
	<td></td>
	<td></td>
	<td>0.269</td>
	<td>-1.998</td>
	<td>6.6e-8</td>
	<td class='xvalues'>Magnitude</td>
	<td class='xvalues'>4</td>
	<td class='xvalues'>4</td>
	<td class='xvalues'>3.9</td>
	<td class='xvalues'>&hellip;</td>
</tr>
<tr>
	<td></td>
	<td></td>
	<td></td>
	<td></td>
	<td></td>
	<td></td>
	<td></td>
	<td></td>
	<td></td>	
	<td class='yvalues'>Z (PGA)</td>
	<td class='yvalues'>-2.11</td>
	<td class='yvalues'>-2.27</td>
	<td class='yvalues'>-2.08</td>
	<td class='yvalues'>&hellip;</td>
</tr>
<tr>
	<td>PGA</td>
	<td>Intra event</td>
	<td>CauzziEtAl2014</td>
	<td></td>
	<td></td>
	<td></td>
	<td>0.28</td>
	<td>-2.281</td>
	<td>1.21e-8</td>
	<td class='xvalues'>Magnitude</td>
	<td class='xvalues'>4</td>
	<td class='xvalues'>4</td>
	<td class='xvalues'>3.9</td>
	<td class='xvalues'>&hellip;</td>
</tr>
<tr>
	<td></td>
	<td></td>
	<td></td>
	<td></td>
	<td></td>
	<td></td>
	<td></td>
	<td></td>
	<td></td>
	<td class='yvalues'>Z (PGA)</td>
	<td class='yvalues'>-1.116</td>
	<td class='yvalues'>-2.815</td>
	<td class='yvalues'>-2.11</td>
	<td class='yvalues'>&hellip;</td>
</tr>
<tr>
	<td>PGA</td>
	<td>Inter event</td>
	<td>AkkarEtAl2013</td>
	<td></td>
	<td></td>
	<td></td>
	<td>0.103</td>
	<td>-1.281</td>
	<td>0.163</td>
	<td class='xvalues'>Magnitude</td>
	<td class='xvalues'>4</td>
	<td class='xvalues'>4</td>
	<td class='xvalues'>3.9</td>
	<td class='xvalues'>&hellip;</td>
</tr>
<tr>
	<td></td>
	<td></td>
	<td></td>
	<td></td>
	<td></td>
	<td></td>
	<td></td>
	<td></td>
	<td></td>
	<td class='yvalues'>Z (PGA)</td>
	<td class='yvalues'>-1.832</td>
	<td class='yvalues'>-1.913</td>
	<td class='yvalues'>-1.85</td>
	<td class='yvalues'>&hellip;</td>
</tr>
<tr>
	<td>&hellip;</td>
	<td>&hellip;</td>
	<td>&hellip;</td>
	<td>&hellip;</td>
	<td>&hellip;</td>
	<td>&hellip;</td>
	<td>&hellip;</td>
	<td>&hellip;</td>
	<td>&hellip;</td>
	<td>&hellip;</td>
	<td>&hellip;</td>
	<td>&hellip;</td>
	<td>&hellip;</td>
	<td>&hellip;</td>
</tr>
<tr>
	<td>PGV</td>
	<td>Intra event</td>
	<td>AkkarEtAl2013</td>
	<td></td>
	<td></td>
	<td></td>
	<td>0.171</td>
	<td>-2.12</td>
	<td>0.002</td>
	<td class='xvalues'>Magnitude</td>
	<td class='xvalues'>4</td>
	<td class='xvalues'>4</td>
	<td class='xvalues'>3.9</td>
	<td class='xvalues'>&hellip;</td>
</tr>
<tr>
	<td></td>
	<td></td>
	<td></td>
	<td></td>
	<td></td>
	<td></td>
	<td></td>
	<td></td>
	<td></td>
	<td class='yvalues'>Z (PGV)</td>
	<td class='yvalues'>-0.17</td>
	<td class='yvalues'>-1.11</td>
	<td class='yvalues'>-0.871</td>
	<td class='yvalues'>&hellip;</td>
</tr>
<tr>
	<td>&hellip;</td>
	<td>&hellip;</td>
	<td>&hellip;</td>
	<td>&hellip;</td>
	<td>&hellip;</td>
	<td>&hellip;</td>
	<td>&hellip;</td>
	<td>&hellip;</td>
	<td>&hellip;</td>
	<td>&hellip;</td>
	<td>&hellip;</td>
	<td>&hellip;</td>
	<td>&hellip;</td>
	<td>&hellip;</td>
</tr>
</table>
