#!/usr/bin/perl
# -----------------------------------
# Begin automatic HTML generation to
# organize data collected off the
# Darling Marine Center pier...
#
# Last Modified: June 18, 2004
#
# Brandon Sackmann
# University of Maine
# School of Marine Sciences
# Ira C. Darling Marine Center
# brandon.sackmann@maine.edu
# -----------------------------------

# -----------------------------------
# INITIAL SETUP
# -----------------------------------
$homedir = '/home/optics/website/data/dmc_realtime/';
$datadir = '/home/optics/website/data/dmc_realtime/ecobb2f_0604';
$htmldir = '/data/dmc_realtime/ecobb2f_0604';
$fname1 = "ecobb2f_0604.html";

# -----------------------------------
# CONDITIONAL VARIABLES
# -----------------------------------
$TRUE = 1;
$FALSE = 0;

# -----------------------------------
# BEGIN SCRIPT
# -----------------------------------

chdir $homedir;
open(HTML_1, ">$fname1");

print HTML_1 "<head>\n";
print HTML_1 "<title>Darling Marine Center - Realtime Data Collection</title>\n";
print HTML_1 "</head>\n";

print HTML_1 "<body bgcolor=\"#FFFFFF\" text=\"#000000\">\n";

print HTML_1 "<table width=\"80%\" align=\"center\">\n";
print HTML_1 "  <tr>\n";
print HTML_1 "    <td align=\"center\"><h4><a href=\"/course_description1.html\">Course<br> Description</a></h4></td>\n";
print HTML_1 "    <td align=\"center\"><h4><a href=\"/Schedule/calendar1.html\">Calendar</a></h4></td>\n";
print HTML_1 "    <td align=\"center\"><h4><a href=\"/data/data1.html\">Data</a></h4></td>\n";
print HTML_1 "    <td align=\"center\"><h4><a href=\"/photos/photos1.html\">Photo<br> Gallery</a></h4></td>\n";
print HTML_1 "    <td align=\"center\"><h4><a href=\"/links/links1.html\">Links</a></h4></td>\n";
print HTML_1 "    <td align=\"center\"><h4><a href=\"/index.html\">Home</a></h4></td>\n";
print HTML_1 "    <td align=\"center\"><a href=\"http://www.dmc.maine.edu\"><img src=\"./web_images/dmclogo.gif\" border=\"0\"></a></td>\n";
print HTML_1 "  </tr>\n";
print HTML_1 "</table>\n";

print HTML_1 "<hr>\n";
 
print HTML_1 "<p><center><h1>Darling Marine Center</h1>\n";
print HTML_1 "<h2>- Realtime Data Collection -</h2></center></p>\n";

print HTML_1 "<ul>\n";
print HTML_1 "  <li><h3>Location Description:</h3>\n";
print HTML_1 "    <p><img src=\"./web_images/dmcdock.jpg\" ALIGN=left ALIGN=absmiddle HSPACE=20>Located in the small town of Walpole, 60 miles northeast of Portland and 100 miles south of the University's Orono campus, the Darling Marine Center (DMC) functions year round as a research and educational facility serving the marine interests of faculty, staff, students, and visiting investigators from around the world.</p>
<p>The Damariscotta River estuary is a tide dominated embayment approximately 5 km from the open waters of the Gulf of Maine. Local marine environments include rocky shores, sandy beaches, mud flats, sea grass beds, expansive sponge communities. High organic production in the Gulf of Maine supports a diversity of benthic and pelagic species. The Damariscotta River is one of several local estuaries that provide a gradient of environments varying in fresh water input, with resultant changes in types and quantities of organic production and consequent changes in biogeographic zonation. The complexity of the Maine coastline allows for a wide range of exposure to waves and ice, further adding to the diversity of habitats. Sea temperatures range from 2 to 15 C* in the open ocean and from -2 to 20 C* in the upper reaches of the estuary. Salinity at the Center's dock ranges from 28 to 32 ppt.</p>\n";

print HTML_1 "  <li><h3>Instrument Description(s):</h3>\n";
print HTML_1 "    <h4><a href=\"http://www.wetlabs.com/Products/eco/bb2f.htm\">ECO BB2F - Combination Spectral Backscattering Meter & Chlorophyll Fluorometer (WET Labs, Inc.)</a></h4>\n";
print HTML_1 "    <p><img src=\"./web_images/cloverlit.jpg\" ALIGN=right ALIGN=absmiddle HSPACE=20>WET Labs, Inc. has developed a combination sensor for concurrent determination of chlorophyll fluorescence and optical backscatterng at two wavelengths. Developed under the aegis of the National Oceanographic Partnership Program, the BB2F addresses the need for operational biogeochemical sensors for autonomous and unattended measurement platforms. Arranged in a cloverleaf configuration, the sensor measures optical backscattering at 117 degrees at both 470 and 700 nm, and additionally, chlorophyll fluorescence within the same volume. These combined capabilities make the BB2F a powerful tool for bio-optical characterization of natural waters.</p>
<p>The BB2F offers excellent performance and powerful capabilities--combined with size and pricing that's a fraction of other sensors and systems, this sensor is the preferred choice for a wide variety of research and monitoring applications.</p>
<p><a href=\"./supp_html/bb2fn.pdf\">Product Manual</a></p>\n";

print HTML_1 "  <li><h3>Data Processing:</h3>\n";
print HTML_1 "    <p>Raw data from the ECO BB2F are stored as both ASCII (.txt) and Matlab (.mat) files and each archive contains 24 hours worth of data.  Every 30 minutes data are binned at 1-minute intervals and summary statistics are calculated (mean, std, min, max, median, 16th percentile, 84th percentile, n).  Statistics are made available as separate .mat files for data collected within the last 24 hours and the last 30 days.  In addition to these 'most recent' data, individual 'daily archives' (along with corresponding summary statistics) are also available.</p>
<p>Plots are made available for some of the summary statistics that have been calculated.  For the purpose of plotting, the factory calibration has been applied to the data <i>(NB: all other data available from this site remain as raw instrument counts and have not been calibrated.  Instructions for calibrating output from the ECO BB2F can be found in the <a href=\"./supp_html/bb2fn.pdf\">product manual</a>)</i>.</p>
<p>Some useful Matlab scripts can be found <a href=\"./scripts/\">here</a>.</p>
<p>The instrument device file can be found <a href=\"./supp_html/bb2fB-035.dev\">here</a>.</p>
<p>A log detailing instrument maintenance activities can be found <a href=\"./supp_html/ecobb2f_log.txt\">here</a>.</p>\n";

print HTML_1 "  <li><h3>Realtime Data:</h3>\n";
print HTML_1 "    <center><a href=\"$htmldir/DAILYSTATS.png\"><img src=\"$htmldir/DAILYSTATS.png\" height=50% hspace=20></a><a href=\"$htmldir/MONTHLYSTATS.png\"><img src = \"$htmldir/MONTHLYSTATS.png\" height = 50% hspace=20></a></center>\n";
print HTML_1 "    <p>Summary statistics for data collected within the last 24 hours are available <a href=\"$htmldir/DAILYSTATS.mat\"> here</a> (DAILYSTATS.mat).<br>Summary statistics for data collected within the last 30 days are available <a href=\"$htmldir/MONTHLYSTATS.mat\"> here</a> (MONTHLYSTATS.mat).</p>\n";

print HTML_1 "  <li><h3>Archived Data:</h3>\n";
print HTML_1 "    <p>A <a href=\"./supp_html/yearday_calendar.html\">'Yearday Calendar'</a> can be found here.</p>\n";
print HTML_1 "    <table width=\"80%\" align=\"center\" border=1>\n";
print HTML_1 "      <tr>\n";
print HTML_1 "        <td align=\"center\"><h4>Archive Name</h4></td>\n";
print HTML_1 "        <td align=\"center\"><h4>Download</h4></td>\n";
print HTML_1 "        <td align=\"center\"><h4>Thumbnail</h4></td>\n";
print HTML_1 "      </tr>\n";

chdir $datadir;
@datafiles = `ls *RAW.txt | grep -i RAW.txt`;
chdir $homedir;
foreach $datafile (@datafiles) {
	chop $datafile;
	$namelen = length($datafile)-21;
	$identifier = substr($datafile, 0, $namelen);
	$datafile = substr($datafile, -21, 13);
	print HTML_1 "      <tr>\n";
	print HTML_1 "        <td align=\"center\">$identifier$datafile", "_RAW.txt</td>\n";
	print HTML_1 "        <td align=\"center\"><a href=\"$htmldir/$identifier$datafile", "_RAW.txt\">RAW.txt</a><br>\n";
	print HTML_1 "          <a href=\"$htmldir/$identifier$datafile", "_RAW.mat\">RAW.mat</a><br>\n";
	print HTML_1 "          <a href=\"$htmldir/$identifier$datafile", "_STATS.mat\">STATS.mat</a></td>\n";
	print HTML_1 "        <td align=\"center\"><a href=\"$htmldir/$identifier$datafile", "_STATS.png\">STATS.png</a></td>\n";
	print HTML_1 "      </tr>\n";
	$counter++;
}

print HTML_1 "    </table><br>\n";

print HTML_1 "  <li><h3>Contact Information:</h3>\n";
print HTML_1 "    <h4>This project is supported by:</h4>\n";
print HTML_1 "    <a href=\"mailto:perrymj\@maine.edu\"><b>Dr. Mary Jane Perry</b></a><br>\n";
print HTML_1 "      <a href=\"http://optics.dmc.maine.edu\"><i>Phytoplankton and Optics Lab</i></a><br>\n";
print HTML_1 "      Darling Marine Center<br>\n";
print HTML_1 "      University of Maine<br>\n";
print HTML_1 "      193 Clark's Cove Rd.<br>\n";
print HTML_1 "      Walpole, Maine 04573, USA<br>\n";
print HTML_1 "      (207) 563-3146 x245<br>\n";
print HTML_1 "    <h4>For specific website or data access questions contact:</h4>\n";
print HTML_1 "    <a href=\"mailto:brandon.sackmann\@maine.edu\"><b>Brandon Sackmann</b></a><br>\n";
print HTML_1 "      Darling Marine Center<br>\n";
print HTML_1 "      (207) 563-3146 x343<br>\n";
print HTML_1 "</ul>\n";

print HTML_1 "<hr><br>\n";

print HTML_1 "<table width=\"90%\" align=\"center\">\n";
print HTML_1 "  <tr>\n";
print HTML_1 "    <td align=\"center\"><a href=\"http://www.umaine.edu\"><img src=\"./web_images/umainelogo.jpg\" width=\"287\" height=\"92\" border=\"0\"></a></td>\n";
print HTML_1 "    <td align=\"center\">Darling Marine Center<br>\n";
print HTML_1 "      University of Maine<br>\n";
print HTML_1 "      193 Clark's Cove Rd.<br>\n";
print HTML_1 "      Walpole, Maine 04573, USA<br>\n";
print HTML_1 "      (207) 563-3146<br>\n";
print HTML_1 "      <a href=\"http://www.dmc.maine.edu\">http://www.dmc.maine.edu</a></td>\n";
print HTML_1 "  </tr>\n";
print HTML_1 "</table>\n";

print HTML_1 "</body>\n";
print HTML_1 "</html>\n";

close(HTML_1);
