<?php
require_once "../../../config/settings.inc.php";
define("IEM_APPID", 147);
require_once "../../../include/myview.php";
$t = new MyView();

require_once "../../../include/database.inc.php";
require_once "../../../include/forms.php";

$station = isset($_GET["station"]) ? xssafe($_GET["station"]) : "IA0200";
$network = isset($_REQUEST["network"]) ? xssafe($_REQUEST["network"]) : "IACLIMATE";
$gddbase = isset($_REQUEST["gddbase"]) ? intval($_REQUEST["gddbase"]) : 2600;

$imgurl = sprintf("/plotting/auto/plot/179/network:%s::station:%s" .
    "::gddbase:%s::dpi:100.png", $network, $station, $gddbase);

$t->title = "Growing Degree Day Scenarios / Probabilities";
$nselect = networkSelect($network, $station);
$sselect = selectNetworkType("CLIMATE", $network);
$t->content = <<<EOM
<ol class="breadcrumb">
 <li><a href="/COOP/">NWS COOP Network</a></li>
 <li class="active">Growing Degree Day Probabilities</li>
</ol>

<h3>Growing Degree Day Probabilities</h3>

<p>This application creates two 2-D histograms of GDD accumulation frequencies.
These frequencies are based on historical data for the specificed site and base
the end of each year's growing season on the first sub freezing temperature of
the fall.  The left hand plot shows the overall frequency based on each year's 
data.  The right hand plot does a scenario using the combination of year to date
data for this year and then each previous year afterwards is appended to this
year's data to provide frequencies.  The right hand plot is meant to provide 
current frequencies / probabilities of what could potentially happen this year.

<p>One interpretation of the plot is given a corn emergence date of 1 May, the
frequency that {$gddbase} GDDs units are accumulated by 1 October 
and <strong>without a freeze event</strong> are XX %.  Meaning XX % of years
on record got to {$gddbase} by 1 October prior to a freeze.

<p>Data is available from the following states:
<form method="GET" name="ssss">
{$sselect}
<input type="submit" value="Select State">
</form>

<div class="text">

<form name="olselect" action="gddprobs.phtml" method="GET">
<input type="hidden" name="network" value="{$network}" />
<table class="table table-sm">
<thead>
<tr><th>Climate Site:</th><th>GDD Accumulation</th></tr>
</thead>
<tbody>
<tr>
  <td rowspan="2">{$nselect}</td>
  <td><input type="text" size="10" name="gddbase" value="{$gddbase}" /></td>
</tr>
</tbody>
</table>
 <p><input type="submit" value="Make Plot">
</form>

<p><img src="{$imgurl}" at="GDD Probs">

<p>The image will appear above and may take a few seconds to generate.

</div>
EOM;
$t->render('single.phtml');
