#! /bin/tcsh -f

set idir  = "plots"

foreach subset (deep clear)
set file  = lat_trends_${subset}.html
set title = "Latitudinal Comparison"
set prods = "nLw_ratio chl_comp nLw_412_comp nLw_443_comp nLw_490_comp nLw_510_comp nLw_555_comp nLw_670_comp"

echo "<html>" > $file
echo "<head>" >> $file
echo "<title>$title</title>" >> $file
echo "</head>" >> $file
echo "<center>" >> $file
echo "<body>" >> $file
echo "<h1>$title</h1>" >> $file

echo "<table>" >> $file

echo "<tr>" >> $file
echo "<td><b>Date</b></td>" >> $file
foreach p ($prods)    
    echo "<td align=center><b>$p</b></td>" >> $file
end
echo "</tr>" >> $file


foreach f (${idir}/*${subset}Lat_nLw_ratio.gif) 

    set x = `basename $f | cut -d_ -f3`
    set y = `basename $x | cut -c1-4`
    set d = `basename $x | cut -c5-7`

    echo $y $d

    echo "<tr>" >> $file
    echo "<td><b>$y $d</b></td>" >> $file

    foreach p ($prods)    
        set pf   = `ls -1 ${idir}/*${y}${d}_${subset}Lat_${p}.gif`
        set pftn = `echo $pf | cut -d. -f1`.small.gif
        echo "<td><a href=${pf}><img src=${pftn}></a></td>" >> $file
    end
    echo "</tr>" >> $file

end
echo "</table>" >> $file

end

exit 0



