#!/usr/local/bin/perl -w

# script: swims_plots.pl
# created 03/02/06

# this perl script takes all the gif files in the 
# /home/mussel5/ftp/pub/ace/level3/swims/ACE_SWIMS_MMTH/
# directory and creates web pages that links to them all

$date = `date`;

open(HTML_PG, ">summary_plots.html") or die "can't open file summary_plots.html";

@fns = <mth*>;	# get files

#print "@fns\n";

print HTML_PG "<HTML>
<!-- **********************************************************************
This HTML file created with the script: /home/mussel5/ftp/pub/ace/level3/swims/ACE_SWIMS_MMTH/swims_plots.pl
************************************************************************-->
<HEAD>
   <TITLE>ACE/SWIMS Daily Solar Wind Mass Distribution Plots</TITLE>
</HEAD>

<BODY text=\"#FFFFFF\" link=\"#00EE00\" vlink=\"#EE0000\" bgcolor=\"#000000\" background=\"/ACE/ASC/images/ace12.jpg\">

<IMG SRC=\"/ACE/ASC/images/empty.gif\" WIDTH=100 HEIGHT=79 BORDER=0 ALIGN=left>

<A HREF=/ACE/ASC/><IMG SRC=\"/ACE/ASC/images/asc100x79.gif\" align=right BORDER=0></A>
<BR><BR>
<CENTER>
<H1>ACE/SWIMS Daily Solar Wind Mass Distribution Plots</H1>
</CENTER>
<BR>
<HR>
These files can be downloaded via
<a href=\"ftp://mussel.srl.caltech.edu/pub/ace/level3/swims/ACE_SWIMS_MMTH\">
anonymous ftp</a>, from mussel.srl.caltech.edu
<BR>
in the directory: pub/ace/level3/swims/ACE_SWIMS_MMTH\n<P>\n";

print HTML_PG " (Year/DOY &nbsp; .....File Size)<BR>\n";



$lg_file_size = 0;
foreach (@fns){
	$cup = -s $_;
	$lg_file_size < $cup and $lg_file_size = $cup and $fn = $_;
}
print "largest file size  $lg_file_size  $fn\n";


$yr_check = 1998;
foreach (@fns){
	/mth(\d{4})(\d{3}).*/;
	$yr = "$1";
# print "$yr\n";
	$yr_check == $yr and print HTML_PG "<P>\n<A name=$yr>\nSWIMS &nbsp;plots for year <B>'$yr_check'</B><BR>\n" and $yr_check++ ;
	$file_size = -s $_;
	print HTML_PG "<BR><A href=\"$_\">$1/$2</A> &nbsp; .....$file_size\n";

#	for ($jj=0; $jj<=10*$file_size/$lg_file_size; $jj++){
#		print HTML_PG "* ";
#	}
}

print HTML_PG "<HR>
<!--
<A HREF=\"/ACE/ASC/level2/mag_l2desc.html\">MAG Data Description Page</A>
-->
<P>
<A HREF=\"/ACE/ASC/DATA/ftp/pub/ace/level3/index.html\">Contributed Data Page</A>
<P>
<A HREF=\"/ACE/ASC/\">Return to ASC Home Page</A>
<ADDRESS>
Our Email Address:
<A HREF=\"mailto:asc\@srl.caltech.edu\">asc\@srl.caltech.edu</A>
<BR>
Last Updated: $date
</ADDRESS>

</BODY>
</HTML>
";

close(HTML_PG);
