<?php
require_once "../../config/settings.inc.php";
require_once "../../include/myview.php";
require_once "../../include/generators.php";
$t = new MyView();
$t->title = "NWS COOP Data";
$t->headextra = <<<EOM
<link rel="stylesheet" type="text/css" href="index.css">
EOM;

$yr = date("Y");

$dict = array(
    array(
        "img" => "chart_line_f_t.png",
        "url" => "/plotting/coop/threshold_histogram_fe.phtml",
        "title" => "Winter Min Low Temp Frequencies",
        "desc" => "Histogram showing the number of years that a certain low temperature threshold is exceeded."
    ),

    array(
        "img" => "chart_line_h_t.png",
        "url" => "/plotting/coop/spread_fe.phtml",
        "title" => "Daily Temperature Spread",
        "desc" => "Histogram showing daily high/low temperatures."
    ),

    array(
        "img" => "data_table.png",
        "url" => "/sites/hist.phtml?station=AMSI4&network=IA_COOP",
        "title" => "Observations by Month",
        "desc" => "View observations per station and per month basis."
    ),

    array(
        "img" => "data_table.png",
        "url" => "/COOP/freezing.php",
        "title" => "Fall Freezing Dates",
        "desc" => "Statistics of dates for significant first fall freezes."
    ),

    array(
        "img" => "data_table.png",
        "url" => "/COOP/snowd_duration.phtml",
        "title" => "Snow Depth Duration",
        "desc" => "For a given date, how long will the snow stick around?"
    ),

    array(
        "img" => "data_table.png",
        "url" => "/COOP/extremes.php",
        "title" => "Daily Climate in Tables",
        "desc" => "Tables of daily temperature and precipitation climatology."
    ),

    array(
        "img" => "thumb_map.png",
        "url" => "/GIS/apps/coop/index.php",
        "title" => "Daily Climate in Maps",
        "desc" => "Plots of daily extremes and averages with a GIS Ready! download of the data presented."
    ),

    array(
        "img" => "chart_line_t_d.png",
        "url" => "/plotting/coop/climate_fe.php",
        "title" => "Daily Average Temperatures",
        "desc" => "Dynamically produced chart of average daily temperatures."
    ),

    array(
        "img" => "chart_line_t_y.png",
        "url" => "/plotting/auto/?q=100",
        "title" => "Yearly Average Temperatures",
        "desc" => "Plot average daily temperatures for a year of your choice."
    ),

    array(
        "img" => "chart_line_d_a.png",
        "url" => "/plotting/auto/?q=107",
        "title" => "Accumulated Precipitation Probabilities",
        "desc" => "Chart of precip probabilities for a time period of your choice."
    ),

    array(
        "img" => "chart_line_t_d.png",
        "url" => "/plotting/auto/?q=99",
        "title" => "Yearly Departures from Average",
        "desc" => "Plot average temperatures versus what actually occured during one year."
    ),

    array(
        "img" => "chart_line_ac_d.png",
        "url" => "/plotting/auto/?q=108",
        "title" => "Accumulated Departures from Average",
        "desc" => "Plot an accumulated departure from average for rainfall and growing degree days for a time period of your choice!"
    ),

    array(
        "img" => "thumb_map.png",
        "url" => "/COOP/map/",
        "title" => "Map Daily Observations",
        "desc" => "Interactive map of daily observations."
    ),

);
$content = "";
foreach ($dict as $k => $v) {
        // Card-like teaser; image is decorative (title + text already conveys info)
        $content .= <<<EOM
<div class="col" role="listitem">
    <article class="card h-100 shadow-sm">
        <div class="card-body p-3">
            <div class="d-flex align-items-start">
                <div class="flex-shrink-0 me-2">
                    <a href="{$v["url"]}" class="stretched-link" aria-label="Open: {$v["title"]}">
                        <img src="/images/{$v["img"]}" alt="" class="img-fluid" loading="lazy" decoding="async" width="48" height="48" />
                    </a>
                </div>
                <div class="flex-grow-1">
                    <h4 class="h6 mb-1">{$v["title"]}</h4>
                    <p class="card-text small mb-0">{$v["desc"]}</p>
                </div>
            </div>
        </div>
    </article>
</div>
EOM;
}

$t->content = <<<EOM

<section aria-labelledby="coop-intro" class="mb-4">
    <h2 id="coop-intro" class="h3">National Weather Service Cooperative Observer Program (COOP)</h2>
    <p>The COOP network is comprised of volunteer observers reporting once-daily high and low air temperature, liquid precipitation, snowfall and snow depth. Explore popular applications below.</p>
    <nav aria-label="COOP quick actions" class="mb-3">
        <div class="d-flex flex-wrap gap-2">
            <a class="btn btn-outline-secondary" href="current.phtml"><i class="bi bi-arrow-repeat" aria-hidden="true"></i><span class="visually-hidden">Refresh</span> <span>Sortable Currents</span></a>
            <a class="btn btn-primary" href="/request/coop/obs-fe.phtml"><i class="bi bi-cloud-download" aria-hidden="true"></i><span class="visually-hidden">Download</span> <span>Download Observations</span></a>
            <a class="btn btn-outline-secondary" href="/sites/locate.php?network=IA_COOP"><i class="bi bi-search" aria-hidden="true"></i><span class="visually-hidden">Search</span> <span>Locate Sites</span></a>
            <a class="btn btn-outline-secondary" href="cat.phtml"><i class="bi bi-eye" aria-hidden="true"></i><span class="visually-hidden">View</span> <span>View Obs by Day/Year</span></a>
        </div>
    </nav>
</section>

<section aria-labelledby="climodat" class="mb-4">
    <h2 id="climodat" class="h3">IEM Value-Added Climodat Dataset</h2>
    <p>The IEM processes preliminary COOP reports, applies limited quality control, and estimates some missing data to produce the coherent <strong>Climodat</strong> dataset. Popular Climodat applications:</p>
    <nav aria-label="Climodat quick actions" class="mb-3">
        <div class="d-flex flex-wrap gap-2">
            <a class="btn btn-outline-secondary" href="/climodat/"><i class="bi bi-file-earmark-text" aria-hidden="true"></i><span class="visually-hidden">Report</span> <span>Climodat Reports</span></a>
            <a class="btn btn-primary" href="/request/coop/fe.phtml"><i class="bi bi-cloud-download" aria-hidden="true"></i><span class="visually-hidden">Download</span> <span>Download Quality Controlled</span></a>
            <a class="btn btn-outline-secondary" href="/sites/locate.php?network=IACLIMATE"><i class="bi bi-search" aria-hidden="true"></i><span class="visually-hidden">Search</span> <span>Locate Sites</span></a>
            <a class="btn btn-outline-secondary" href="/GIS/apps/coop/gsplot.phtml"><i class="bi bi-image" aria-hidden="true"></i><span class="visually-hidden">Image</span> <span>Growing Season Plotter</span></a>
        </div>
    </nav>
</section>


<div class="row g-4">
<aside class="col-md-5" aria-labelledby="data-plots-heading">

<h2 id="data-plots-heading" class="h4">Data Plots</h2>
<ul>
    <li><a href="/timemachine/?product=37">Iowa Precipitation Contour</a></li>
    <li><a href="/timemachine/?product=38">Midwest Precipitation Contour</a></li>
    <li><a href="/data/coopMonthPlot.gif">Rainfall totals for this month</a></li>
    <li><a href="/data/coopSnowPlot.gif">Snowfall totals this morning</a></li>
    <li><a href="/data/coopMonthSPlot.gif">Snowfall totals this month</a></li>
    <li><a href="/data/coopSnowDepth.gif">Snow depth this morning</a></li>
    <li><a href="/data/coopHighLow.gif">High + Low Temperatures this morning</a></li>
</ul>

<h2 class="h4">Data + Summaries</h2>

<ul>
 <li>A <a href="/data/gis/shape/4326/iem/coopobs.zip">GIS shapefile</a> is
 generated daily with the most recent set of COOP observation in it.</li>
 <li>A <a href="/data/csv/coop.csv">Comma Delimited File</a> of today's
 COOP observations.</li>
 <li><a href="/data/text/IEMNWSDPR.txt">Today's Rainfall Reports</a>
    <br />Rainfall reports valid for today along with today's climatology.</li>
 <li><a href="/data/text/IEMNWSMPR.txt">This Month's Totals</a>
    <br />Rainfall totals for this month along with climatology.</li>
 <li><a href="/data/text/IEMNWSYPR.txt">This Year's Totals</a>
    <br />Rainfall totals this year along with climatology.</li>

</ul>

<h2 class="h4">Download Data</h2>
<ul>
  <li><a href="/request/coop/fe.phtml">Download Daily Oberservations</a>
    <br>Pick your site, pick a time period, and download the data.</li>
  <li><a href="/COOP/cat.phtml">2004-<?php echo date("Y"); ?> Observations</a>
    <br />View all obs from 2004 to <?php echo date("Y"); ?> for one site or pick a date and view all sites!</li>
  <li><a href="/climodat">ClimoDat Interface</a>
    <br>Handy application to access summary COOP data.</li>
  <li><a href="/COOP/hpd.php">Fisher Porter Rain Gauge Download</a>
    <br />IEM processed data made available by NCEI for Iowa stations only.</li>
  <li><a href="/GIS/apps/coop/gsplot.phtml">Growing Season Plotter</a>
    <br>Plot growing season totals since 1893 for a date span of your choice.
    <br>The resulting data is also available in a GIS Ready! format.</li>
  <li><a href="dl/normals.phtml">Daily Climate Normals</a>
    <br>Download daily normal high and low temperatures and average rainfall.</li>
</ul>

</aside>
<div class="col-md-7" aria-labelledby="data-apps-heading">
    <h2 id="data-apps-heading" class="h4 mb-3">Data Applications</h2>
    <div class="row row-cols-1 row-cols-sm-2 g-3" role="list">
        {$content}
    </div>
</div>
</div><!-- /.row -->
EOM;
$t->render('full.phtml');
