<p><b>Endpoint: <span class='url'>{{ baseurl }}/{{ data.path }}</span></b></p>
<p>
Trellis plots provide an understanding of the manner in which each GMPE characterizes the ground
motion scaling with respect to the properties of the seismic source, and the attenuation of the
motion with respect to distance. By means of the
underlying GMPE-SMTK library, eGSIM can generate different plot types:
<ul>
<li> IMT vs Magnitude plots show how the ground motion intensity value scales with
respect to the magnitude of the rupture.
<li> IMT vs Distance plots allow to compare how the GMPEs describe the attenuation of strong
motion with distance for a given magnitude. 
<li> Magnitude-Distance spectra let the user understand how a
GMPE will scale the response spectrum with magnitude and distance.
</ul>
<p>
In addition to viewing the scaling of the expected ground motion from the GMPE,
it is also possible to view the scaling of the standard deviation, for a total of six
choosable plot types.
</p>

<h3 id="{{ data.key }}_request">Request</h3>
<p>
A request to the Trellis plot service requires a list of GMPEs and IMTs,
the desired plot type and the parameters configuring the scenario (rupture), most of which are
optional. As discussed, parameters can be given in the endpoint URL (GET method) or as
separate text data in JSON or YAML format (POST method) and are:
</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>).
		In any case, if <span class='pname'>{{ data.form.plot_type.name }}</span> is
		<span class='pval str'>{{ data.form.plot_type.choices.2.0 }}</span>
		({{ data.form.plot_type.choices.2.1 }}), then
		<span class='pname'>{{ data.form.imt.name }}</span> can be omitted and will
		default to a list of pre-defined <span class='pval str'>SA</span> periods.
		Users can always provide their own list of SA with periods, but any other IMT
		will raise an error, if provided
	<li><span class='pname'>{{ data.form.gsim.name }}</span> and 
		<span class='pname'>{{ data.form.imt.name }}</span> can also 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>


<h3 id="{{ data.key }}_response">Response</h3>
<p>
The number of generated Trellis plots depends on the requested Intensity measure types (parameter
<span class='pname'>{{ data.form.imt.name }})</span> <i>and</i> the parameters
<span class='pname'>{{ data.form.magnitude.name }}</span>,
<span class='pname'>{{ data.form.distance.name }}</span> and
<span class='pname'>{{ data.form.vs30.name }}</span> (which can be given as numeric scalr or array):
</p>

<table>
<thead>
<tr>
	<td>Plot type</td>
	<td>Parameter setting the x values (should be numeric array):</td>
	<td>The number of generated plots is the product of all supplied values of:</td></tr>
</thead>
<tbody>
<tr>
	<td>{{ data.form.plot_type.choices.0.1 }}</td>
	<td><span class='pname'>{{ data.form.distance.name }}</span></td>
	<td><span class='pname'>{{ data.form.imt.name }}</span>,
	    <span class='pname'>{{ data.form.magnitude.name }}</span>,
	    <span class='pname'>{{ data.form.vs30.name }}</span>
	</td>
</tr>
<tr>
	<td>{{ data.form.plot_type.choices.1.1 }}</td>
	<td><span class='pname'>{{ data.form.magnitude.name }}</span></td>
	<td><span class='pname'>{{ data.form.imt.name }}</span>,
	    <span class='pname'>{{ data.form.distance.name }}</span>,
	    <span class='pname'>{{ data.form.vs30.name }}</span>
	</td>
</tr>
<tr>
	<td>{{ data.form.plot_type.choices.2.1 }}</td>
	<td>None: a set of pre-defined periods will be used</td>
	<td><span class='pname'>{{ data.form.magnitude.name }}</span>,
	    <span class='pname'>{{ data.form.distance.name }}</span>,
	    <span class='pname'>{{ data.form.vs30.name }}</span>
	</td>
</tbody>
</table>


<h4>JSON</h4>
<p>
Trellis plot data returned in JSON format will have the following structure:
</p>
<pre><code class="language-python">{
    "xvalues": [2.905, 3.771, ... ],  # see note 1
    "xlabel": "Rupture Dist. (km)",
    "imts": ["PGA", "PGV"],
    "PGA": [
        {
            "yvalues": {
                "AkkarEtAl2013": [0.3811, 0.3812, ...],
                "CauzziEtAl2014": [0.283, 0.283, ...],
                ...
            },
            "ylabel": "Median PGA (g)",
            "magnitude": 5,    # see note 2
            "distance": null,  # see note 2
            "vs30": 760,
            "stdvalues": {},  # see note 3
            "stdlabel": ""    # see note 3
        },
        {
           # same Object as above, computed for
           # a different magnitude/distance/vs30
        },
        ...
    ],
    "PGV": [
        # same Array type as above,
        # computed for the PGV
    ],
    ...
}</code></pre>
<div class='footnote'>
<p>Notes:</p>
<ol>
<li>All plots share the same x axis and x values, thus for performance reasons
those variables are not repeated inside each nested object.
<li><span class='pname'>magnitude</span> and <span class='pname'>distance</span>
might be null when they represent the array of x values.
<li><span class='pname'>stdvalues</span> is an empty object if the user did not choose to compute
standard deviations: Otherwise, it is an Object equal to <span class='pname'>yvalues</span> but
mapping each GSIM to the list of standard deviations. If <span class='pname'>stdvalues</span> is empty,
then <span class='pname'>stdlabel</span> is the empty string
</ol>
</div>

<h4>CSV</h4>
<p>
Trellis plot data returned in CSV format will have the following structure.
<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>gsim</td>
	<td>magnitude</td>
	<td>distance</td>
	<td>vs30</td>
	<td></td>
	<td></td>
	<td></td>
	<td></td>
</tr>
<tr>
	<td></td>
	<td></td>
	<td></td>
	<td></td>
	<td></td>
	<td class='xvalues'>Rupture Dist. (km)</td>
	<td class='xvalues'>2.905</td>
	<td class='xvalues'>3.771</td>
	<td class='xvalues'>&hellip;</td>
</tr>
<tr>
	<td>PGA</td>
	<td>AkkarEtAl2013</td>
	<td>5</td>
	<td></td>
	<td>760</td>
	<td class='yvalues'>Median PGA (g)</td>
	<td class='yvalues'>0.3811</td>
	<td class='yvalues'>0.3812</td>
	<td class='yvalues'>&hellip;</td>
</tr>
<tr>
	<td>PGA</td>
	<td>CauzziEtAl2014</td>
	<td>5.5</td>
	<td></td>
	<td>760</td>
	<td class='yvalues'>Median PGA (g)</td>
	<td class='yvalues'>0.283</td>
	<td class='yvalues'>0.283</td>
	<td class='yvalues'>&hellip;</td>
</tr>
<tr>
	<td>&hellip;</td>
	<td>&hellip;</td>
	<td>&hellip;</td>
	<td>&hellip;</td>
	<td>&hellip;</td>
	<td class='yvalues'>&hellip;</td>
	<td class='yvalues'>&hellip;</td>
	<td class='yvalues'>&hellip;</td>
	<td class='yvalues'>&hellip;</td>
</tr>
<tr>
	<td>PGV</td>
	<td>AkkarEtAl2013</td>
	<td>5</td>
	<td></td>
	<td>760</td>
	<td class='yvalues'>Median PGV (g)</td>
	<td class='yvalues'>0.21</td>
	<td class='yvalues'>0.291</td>
	<td class='yvalues'>&hellip;</td>
</tr>
</table>
