#!/apps/bin/perl -w
##############################################
#  This file converts the date-time stamps for 
#  the polarizations for Edna into a linear
#  plottable format.
#                    -Ameya Kolarkar (02/25/2007)
#############################################

 $filename = "edna_all_poldat.dat";
open (EDNADAT, $filename) or die "Couldn't open $filename: $!";
open (NEWEDNA,">edna_lin_time_pol.dat");

while ( $line = <EDNADAT>) {
chomp $line;
print $line."\n";
(  $mm,  $dd,  $yy,  $hh,  $min,  $pol,  $polerr ) =  split(/[\/:\s]/, $line);

print "$mm\t$pol\t\n";

if($mm == 03) {
 $day = 31+28+$dd;
 $ttime = $day + $hh/24 + $min/(60*24)-82.099; # set the first day to zero
}
elsif($mm == 04) {
 $day = 31+28+31+$dd;
 $ttime = $day + $hh/24 + $min/(60*24)-82.099;
}
elsif($mm == 05) {
 $day = 31+28+31+30+$dd;
 $ttime = $day + $hh/24 + $min/(60*24)-82.099;
}
else {print "Error! Please check the month of data.\n\n";}


# open (NEWEDNA,">edna_lin_time_pol.dat");
print NEWEDNA "$ttime\t$pol\t$polerr\n";
# close (NEWEDNA);


}
close (NEWEDNA);
close (EDNADAT);

