#!/iag/bin/perl #-------------------------------------------------------------------------- # Program: mkcable47.pl # # Description: Create the cable47.dat file # # Usage: mkcable47.pl # # Inputs: File containing the dates from the .AVG file that # we want to use and the means for each (see README) # avg-m47.AVG File containing minute averaged data # # Outputs: cable47.dat File that we will run through CALSH6 # # Dependencies: # # Comments: # #-------------------------------------------------------------------------- initialize (); #-------------------------------------------------------------------------- # Loop through the file reading lines #-------------------------------------------------------------------------- while ($_ = ) { s/^\s+//; @field = split('\s+',$_); #-------------------------------------------------------------------------- # check if this is the date we want #-------------------------------------------------------------------------- if ($field[0] =~ /$nxtdt/) { if ($field[1] =~ /FFFF/) { #-------------------------------------------------------------------- # store the values in the temperature arrays #-------------------------------------------------------------------- push @t3, $field[2]; push @t4, $field[3]; push @t5, $field[4]; push @t6, $field[5]; push @t7, $field[6]; push @t8, $field[7]; push @t9, $field[8]; push @t10, $field[9]; push @t11, $field[10]; push @t12, $field[11]; } elsif ($field[1] =~ /0000/) { #-------------------------------------------------------------------- # store the values in the calibration arrays #-------------------------------------------------------------------- push @c3, $field[2]; push @c4, $field[3]; push @c5, $field[4]; push @c6, $field[5]; push @c7, $field[6]; push @c8, $field[7]; push @c9, $field[8]; push @c10, $field[9]; push @c11, $field[10]; push @c12, $field[11]; last unless ($nxtdt = shift (@dates)); # Get the next date } else { print "ERROR in ./avg-m47.AVG field[1]=/$field[1]/\n"; exit; } } } #-------------------------------------------------------------------------- # Make sure we don't have any dates left over #-------------------------------------------------------------------------- if ($#dates ge 0) { printf "We have the following dates not found;\n%s\n", join (", ", @dates); exit; } #-------------------------------------------------------------------------- # printout what the data #-------------------------------------------------------------------------- printf OUT "10 %d 1\n", $num_dates +1; printf OUT "%s\n", join (" ", @means); printf OUT "4703 1\n%s\n%s\n", join (" ", @t3), join (" ", @c3); printf OUT "4704 1\n%s\n%s\n", join (" ", @t4), join (" ", @c4); printf OUT "4705 1\n%s\n%s\n", join (" ", @t5), join (" ", @c5); printf OUT "4706 1\n%s\n%s\n", join (" ", @t6), join (" ", @c6); printf OUT "4707 1\n%s\n%s\n", join (" ", @t7), join (" ", @c7); printf OUT "4708 1\n%s\n%s\n", join (" ", @t8), join (" ", @c8); printf OUT "4709 1\n%s\n%s\n", join (" ", @t9), join (" ", @c9); printf OUT "4710 1\n%s\n%s\n", join (" ", @t10), join (" ", @c10); printf OUT "4711 1\n%s\n%s\n", join (" ", @t11), join (" ", @c11); printf OUT "4712 1\n%s\n%s\n", join (" ", @t12), join (" ", @c12); #-------------------------------------------------------------------------- # Close the files and exit #-------------------------------------------------------------------------- close (INP); close (OUT); print "\nFinished mkcable47.pl\n"; exit; #\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\ # # initialize # #////////////////////////////////////////////////////////////////////////////// sub initialize { #--------------------------------------------------------------------------- # Verify command line #--------------------------------------------------------------------------- if ($#ARGV ne 0) { print "Usage: mkcable47.pl \n"; exit; } $usrFile = shift (@ARGV); #-------------------------------------------------------------------------- # open the user data file #-------------------------------------------------------------------------- open DTS, "./$usrFile" || die "Couldn't open ./$usrFile for input"; #-------------------------------------------------------------------------- # open input file #-------------------------------------------------------------------------- open INP, "./avg-m47.AVG" || die "Couldn't open ./avg-m47.AVG for input"; #-------------------------------------------------------------------------- # open OUTPUT file #-------------------------------------------------------------------------- open OUT, "> ./cable47.dat" || die "Couldn't open ./cable47.dat for output"; #-------------------------------------------------------------------------- # Get all the dates and mean values #-------------------------------------------------------------------------- while () { s/^\s+//; @usrdat = split('\s+',$_); push (@dates, $usrdat[0]); push (@means, $usrdat[1]); } close (DTS); if ($#dates < 0) { die "The $usrFile file is incorrect"; } #-------------------------------------------------------------------------- # initialize the variables #-------------------------------------------------------------------------- $num_dates = $#dates; $nxtdt = shift (@dates); (@t3, @t4, @t5, @t6, @t7, @t8, @t9, @t10, @t11, @t12) = (); (@c3, @c4, @c5, @c6, @c7, @c8, @c9, @c10, @c11, @c12) = (); } #---initialize---#