#!/bin/csh

set id1   = $1
set id2   = $2
set ofile = $3
set prods = `ls tplots/${id2}_${id1}*taylor* | cut -d_ -f3-5 | cut -d. -f1 | sed "s/_taylor//g" | sort | uniq`
set sens1  = "`../scripts/get_sensor.csh $id1`"
set sens2  = "`../scripts/get_sensor.csh $id2`"

echo "<html>" > ${ofile}
echo "" >> ${ofile}
echo "<head>" >> ${ofile}
echo "    <title>$sens1 and $sens2 Trend Statistics</title>" >> ${ofile}
echo "  </head>" >> ${ofile}
echo "" >> ${ofile}
echo "<CENTER>" >> ${ofile}
echo "" >> ${ofile}
echo "  <body>" >> ${ofile}
echo "    <h1>$sens1 ($id1) and $sens2 ($id2) Trend Statistics</h1>" >> ${ofile}
echo "    <h2>Global Subsets</h2>" >> ${ofile}
echo "    Derived from Binned Level-3 Mission Trends<br>" >> ${ofile}
echo "    Black=Deep-Water, Blue=Oligotrophic, Green=Mesotrophic, Red=Eutrophic<br>" >> ${ofile}
echo "<p>" >> ${ofile}
echo "<TABLE width="100%">" >> ${ofile}
echo "  <TBODY>" >> ${ofile}
    echo "<TR>" >> ${ofile}
      echo "<TD align="CENTER"><B>Product</B></TD>" >> ${ofile}
      echo "<TD align="CENTER" colspan=1><B>Taylor Diagram</B></TD>" >> ${ofile}
      echo "<TD align="CENTER" colspan=1><B>Target Diagram</B></TD>" >> ${ofile}
    echo "</TR>" >> ${ofile}

    foreach p ($prods) 
    echo "<TR>" >> ${ofile}
      echo "<TD align=Center><b>${p}</b></TD>" >> ${ofile}
      echo "<TD align=CENTER><a href=tplots/${id2}_${id1}_${p}_taylor.png><IMG src=tplots/${id2}_${id1}_${p}_taylor.small.png></TD>" >> ${ofile}
      echo "<TD align=CENTER><a href=tplots/${id2}_${id1}_${p}_target.png><IMG src=tplots/${id2}_${id1}_${p}_target.small.png></TD>" >> ${ofile}
    echo "</TR>" >> ${ofile}
end

echo "</TBODY>" >> ${ofile}
echo "</TABLE>" >> ${ofile}

echo "" >> ${ofile}
echo "<hr>" >> ${ofile}
echo "" >> ${ofile}
echo "</CENTER>" >> ${ofile}
echo "<address><a href=mailto:bryan.a.franz@nasa.gov>Bryan A. Franz</a></address>" >> ${ofile}
echo "</body>" >> ${ofile}
echo "</html>" >> ${ofile}
