#!/usr/local/bin/perl # # CheckSvec # # Read SVEC File and write a list of all overlapping entries. # # 1996/12/12 W. Prescott # # # Mods: # Check number of arguments. # ------------------------- if ($#ARGV >= 0) { $StaSvec = $ARGV[0]; } else { $StaSvec = "/goa/sta_info/sta_svec"; } print("CheckSvec: Checking $StaSvec\n"); # Define paths # ------------ $Pcenter = "/goa/sta_info/pcenter"; # Read svec file # -------------- open (StaSvecHdl, $StaSvec); undef @SvecLinesTemp; while () { push (@SvecLinesTemp,$_); } close (StaSvecHdl); @SvecLines = sort (@SvecLinesTemp); # Read phase-center file # ---------------------- open (PcenterHdl, $Pcenter); undef @PcenterLine; while () { $frequency = substr($_,10,2); if ($frequency eq "LC") { $anttype = substr($_,0,9); $PCenterOffset{$anttype} = substr($_,32,7); } } close (PcenterHdl); $staname1 = ""; $year1 = 0; $month1 = 0; $day1 = 0; $hour1 = 0; $minutes1 = 0; $secs1 = 0; $duration1 = 0; $stasvecstart1 = -1000000000; $stasvecendtime1 = -1000000000; $hi1 = 0; $antenna1 = ""; # Read sta_svec file # ------------------ foreach (@SvecLines) { $staname2 = substr($_,1,4); $year2 = substr($_,11,4); $month2 = substr($_,16,2); $day2 = substr($_,19,2); $hour2 = substr($_,22,2); $minutes2 = substr($_,25,2); $secs2 = substr($_,28,5); $duration2 = substr($_,34,12); $antenna2 = substr($_,47,9); $hi2 = substr($_,94,7); $stasvecstart2 = &CallCal2Sec($year2,$month2,$day2, $hour2,$minutes2,$secs2); $stasvecendtime2 = $stasvecstart2 + $duration2; # Check for overlapping intervals # ------------------------------- if ($staname2 eq $staname1 && $stasvecstart2 <= $stasvecendtime1) { $ShouldBe = $stasvecstart2 - $stasvecstart1 - 1.0; $HIdelta = $hi2 - $hi1; printf ("%s %s %s %s %s %s %s %12.2f %s %12.2f %s %7.4f\n", $staname1,$year1,$month1,$day1, $hour1,$minutes1,$secs1,$duration1, "ShouldBe=",$ShouldBe, "HI-diff=",$HIdelta); } $staname1 = $staname2; $year1 = $year2; $month1 = $month2; $day1 = $day2; $hour1 = $hour2; $minutes1 = $minutes2; $secs1 = $secs2; $duration1 = $duration2; $stasvecstart1 = $stasvecstart2; $stasvecendtime1 = $stasvecendtime2; $antenna1 = $antenna2; $hi1 = $hi2; } print("CheckSvec: Done\n"); exit; # Procedure CallCal2Sec # --------------------- # Convert yyyy mm dd to seconds sub CallCal2Sec { local($year,$month,$day,$hour,$minutes,$secs) = @_; system ("cal2sec $year $month $day $hour $minutes $secs > Date.$$"); open (DateHdl, "Date.$$"); read (DateHdl, $Seconds, 16384); close (DateHdl); system ("rm Date.$$"); $Seconds = int($Seconds); } # Procedure CallSec2Cal # --------------------- # Convert yyyy mm dd to seconds sub CallSec2Cal { local($Seconds) = @_; local ($yyyy,$mm,$dd); system ("sec2cal $Seconds > Date.$$"); open (DateHdl, "Date.$$"); read (DateHdl, $Date, 16384); close (DateHdl); system ("rm Date.$$"); ($yyyy,$mm,$dd) = split(' ',$Date); while (length ($mm) < 2) {$mm = "0$mm";} while (length ($dd) < 2) {$dd = "0$dd";} @Return = ($yyyy,$mm,$dd); }