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

### $Id$
### Author: GRHamell 
### NAME: 22ne20ne.pl 
### Copyright (c) 2003, California Institute of Technology. All rights
### reserved. Unauthorized reproduction prohibited.
###
###
### CALLING SEQUENCE:  perl 22ne20ne.pl  
###
### PURPOSE:
###	This script contains a contribution from Dr.R.Leske.
###	It generates a web page containing the 22Ne/20Ne ratio in 
###	32 large SEP events from launch through the end of 2001. 
###	A link to this web page is made from 
###	http://www.srl.caltech.edu/ACE/ASC/DATA/level3/index.html
###
### INPUT:
###	
###
### OUTPUT:
###	
###
### RETURN:
###	
###
### MODIFICATION HISTORY: 
### ===================== 
### 2003 Apr 25 - GRHamell, Created. 
###
###################################################


$date = `date`;

# FILENAMES 

 $tbl_out  = "sep_ne_ratios.html";	# Output HTML file
#$tbl_out  = "gh_tbl_out.html";
$filein    = "22ne20ne.dat" ;   # input filename 

open(HTML_PG, ">$tbl_out") or die "can't open file $tbl_out";
open(FH,      "<$filein" ) or die "can't open file $filein";

	# get records: yr doy doy ratio +/-
@yddr = <FH>;
$i_last = $#yddr ;		# & index of last element of list
@yddr   = reverse @yddr ;	# put most current first
#print "@yddr\n";

print HTML_PG "<HTML>
<!-- **********************************************************************
This HTML file created with the script: /home/mussel5/ftp/pub/ace/level3/SEP/22ne20ne.pl
************************************************************************-->
<HEAD>
   <TITLE>ACE/SIS Neon isotope ratios in Large SEP Events</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/\" TARGET=\"_top\"><IMG SRC=\"/ACE/ASC/images/asc100x79.gif\" align=right BORDER=0></A>
<BR><BR>
<CENTER>
<H1>Solar Energetic Particle <SUP>22</SUP>Ne/<SUP>20</SUP>Ne Ratios from ACE/SIS</H1>
<H2>~15-72 MeV/nucleon</H2>
</CENTER>
<BR>";


print HTML_PG "<P>\n";


$yr_frst = 0;
$yr_last = 0;

# Find the First & last YEAR values
$yddr[ 0 ]       =~ /(\d\d\d\d).*/ ;
$yr_frst = $1;
$yddr[ $i_last ] =~ /(\d\d\d\d).*/ ;
$yr_last = $1;
#print "yr_last='$yr_last'\n";


# Make Links (jump tbl) to each year
$yr = $yr_frst;
print HTML_PG "<HR><UL>\n";

while( $yr >= $yr_last ) {
  print HTML_PG "<LI><A HREF=\"#$yr\">$yr</A>\n";
  $yr--;
}
print HTML_PG "<LI><A HREF=\"#References\">References</A>\n";
print HTML_PG "</UL>\n";


# Get separate list for each year 

#print HTML_PG "<table>\n";
$yr = $yr_frst;

while( $yr >= $yr_last ) {
  $ftnoteflg = "off";		# used to control printing of foot note
  print HTML_PG "</table>\n";
  print HTML_PG "<A HREF=\"$tbl_out\"><IMG SRC=\"http://www.srl.caltech.edu/ACE/ASC/images/top.gif\" ALT=\"top\" BORDER=0 HEIGHT=22 WIDTH=36 ALIGN=RIGHT></A>";
  print HTML_PG "<HR  WIDTH=\"100%\"><BR>\n" ;
  print HTML_PG "\n<A name=$yr><BR>";
  print HTML_PG "Large SEPs &nbsp;  for year <B>$yr</B>";
  print HTML_PG "\n";
  print HTML_PG "<BR><table border=0 cellpadding=3 cellspacing=0>\n";
  print HTML_PG "<tr>";

  print HTML_PG "<td ALIGN=CENTER>Year</td>";
  print HTML_PG "<td> &nbsp;</td>";

  print HTML_PG "<td ALIGN=CENTER>start/<BR>DOY</td>";
  print HTML_PG "<td> &nbsp;</td>";

  print HTML_PG "<td ALIGN=CENTER>end/<BR>DOY</td>";
  print HTML_PG "<td> &nbsp;</td>";

  print HTML_PG "<td ALIGN=CENTER>Ratio<BR><SUP>22</SUP>Ne\/<SUP>20</SUP>Ne</td>";
  print HTML_PG "<td> &nbsp;</td>";

  print HTML_PG "<td ALIGN=CENTER>+\/-</td>";
  print HTML_PG "<td> &nbsp;</td>";

  print HTML_PG "</tr><BR><tr>\n";
  
  @lines = ();
  @lines = grep( /^$yr/ , @yddr );
  
  foreach $ln ( @lines ) {
    @fields = split( " ", $ln );

#print "\nln='$ln' \n";

    foreach $f ( @fields ) {

#print "f='$f' \n";

      print HTML_PG "<td ALIGN=CENTER>$f</td>";
      print HTML_PG "<td> &nbsp;</td>";
    }
    print HTML_PG "</tr>\n<tr>";
    #is field flagged?
    $ch = substr( $fields[ 2 ], -1, 1 );
    if( $ch eq "*" ) { 
      $ftnoteflg = "on" ;
    }
  }
  print HTML_PG "</tr></table>\n";
  if( $ftnoteflg eq "on" ) {
    print HTML_PG "\* indicates period near peak of event";
    print HTML_PG " (when isotopic resolution degrades) was omitted";
  }
  $yr--;
}
print HTML_PG "<HR>
<a name=\"References\">
<H3>References</H3>\n
<P>
R.A. Leske, R.A. Mewaldt, C.M.S. Cohen, A.C. Cummings, E.C. Stone, M.E. Wiedenbeck, E.R. Christian, and T.T. von Rosenvinge, ``Event-to-event variations in the isotopic composition of neon in solar energetic particle events'', GRL 26, 2693-2696, 1999.
\n<P>
R.A. Leske, R.A. Mewaldt, C.M.S. Cohen, E.R. Christian, A.C. Cummings, P.L. Slocum, E.C. Stone, T.T. von Rosenvinge, and M.E. Wiedenbeck, ``Isotopic Abundances in the Solar Corona as Inferred from ACE Measurements of Solar Energetic Particles'',in Solar and Galactic Composition, edited by R.F. Wimmer-Schweingruber, AIP Conf. Proc. 598, 127-132, 2001.
\n<P>
R.A. Leske, R.A. Mewaldt, C.M.S. Cohen, E.R. Christian, A.C. Cummings, P.L. Slocum, E.C. Stone, T.T. von Rosenvinge, and M.E. Wiedenbeck, ``Mass fractionation in solar energetic particles and the isotopic composition of the corona'', Proc. 27th ICRC (Hamburg), 8, 3124-3127, 2001.
\n<P>
R.A. Leske, R.A. Mewaldt, C.M.S. Cohen, E.R. Christian, A.C. Cummings, P.L. Slocum, E.C. Stone, T.T. von Rosenvinge, and M.E. Wiedenbeck, ``The Coronal Isotopic Composition as Determined Using Solar Energetic Particles'', in Solar Wind 10, edited by M. Velli, AIP Conf. Proc. 679, 616-619, 2003.
\n<P>
R.A. Leske, R.A. Mewaldt, C.M.S. Cohen, A.C. Cummings, E.C. Stone, M.E. Wiedenbeck, and T.T. von Rosenvinge, ``Solar Isotopic Composition as Determined Using Solar Energetic Particles'', Sp. Sci. Rev. 130, 195-205, 2007.
\n<P>";

print HTML_PG "
<A HREF=\"/ACE/ASC/level2/sis_l2desc.html\">SIS Data Description Page</A>
<P>
<A HREF=\"/ACE/ASC/DATA/ftp/pub/ace/level3/index.html\">Level 3 (Contributed) Data Page</A>
<P>
<A HREF=\"/ACE/ASC/\" TARGET=\"_top\">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);

#------------------------------
