#! /bin/tcsh -f

set idir  = "plots"

set file  = residual_rvs.html
set title = "MODIS/Aqua Residual Scan Dependence"
set prods = "nLw_412 nLw_443 nLw_488 nLw_531 nLw_551 nLw_667 nLw_678 taua eps"

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}/*nLw_412_scan.gif) 

    set x = `basename $f | cut -d_ -f1`
    set y = `basename $x | cut -c2-5`
    set d = `basename $x | cut -c6-8`

    echo $y $d

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

    foreach p ($prods)    
        set pf   = `ls -1 ${idir}/?${y}${d}_*_${p}_scan.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

set file  = residual_det.html
set title = "MODIS/Aqua Residual Detector Dependence"
set prods = "nLw_412 nLw_443 nLw_488 nLw_531 nLw_551 nLw_667 nLw_678"

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}/*nLw_412_det.gif) 

    set x = `basename $f | cut -d_ -f1`
    set y = `basename $x | cut -c2-5`
    set d = `basename $x | cut -c6-8`

    echo $y $d

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

    foreach p ($prods)    
        set pf   = `ls -1 ${idir}/?${y}${d}_*_${p}_det.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

exit 0



