#!/bin/csh -bf # # gp.addstasvec # # Script to add station site vectors to sta_info/sta_svec. # N.E. King # October 1993 # December 1993: Modified to look for names in GIPSY format. # # Still to do: Get 4-character code from RINEX file name # and campaign index, instead of from RINEX file header. # Account for possible year and month changes # in calculation of time duration. # Modifications: # 1995/10/13 whp Convert to gp.addstavec. Added ability to # look at the duration of SVEC entries. # 1997/01/15 whp Now uses four character code from file name # instead of information from MARKER NAME in rinex file. # 2000/01/04 jls Added test for IGS code in rinex header. Find the antenna code # in the rinex header and convert it to a character string # that can be found in the pcenter file. # 2000/11/17 ml One digit endtime year (e.g., 0 instead of 00) is now handled # correctly. # Define station info directory # ----------------------------- set Prefix = "/goa/sta_info" # SEARCH FOR RINEX FILES IN JPL FORMAT # ----------------------------------- set numfiles = `ls *.rnx | wc -l ` if ($numfiles == 0) then echo " " echo "gp.addstasvec:" echo "No RINEX observation files found in this directory." echo "Check file names for proper format" echo " " exit 1 else set filesearch="" set filesearch=($filesearch *.rnx) shift filesearch endif # FOR EACH RINEX OBS FILE, CONSTRUCT LINE FOR STA_SVEC # ---------------------------------------------------- foreach file ($filesearch) set base=`basename $file` set sta1 = `echo $base | awk '{print substr($1,8,4) }'` set sta2 = `echo $sta1 | gp.NameTransLookup` set sta = `echo $sta2 | tr '[a-z]' '[A-Z]'` set rindate = `grep 'TIME OF FIRST OBS' $file | awk '{ print $1,$2,$3,$4,$5,$6}'` set yyyy = `echo $rindate | awk '{print $1}'` set yrtest = `echo $yyyy | awk '{print substr($1,1,2) }'` if ($yrtest != 19 && $yrtest != 20) then set yyyy = 19${yyyy} endif @ yy = $yyyy - 1900 set mm = `echo $rindate | awk '{print $2}'` while (`echo $mm | awk '{print length($1)}'` < 2) set mm = 0${mm} end set dd = `echo $rindate | awk '{print $3}'` while (`echo $dd | awk '{print length($1)}'` < 2) set dd = 0${dd} end set HH = `echo $rindate | awk '{print $4}'` while (`echo $HH | awk '{print length($1)}'` < 2) set HH = 0${HH} end set MM = `echo $rindate | awk '{print $5}'` while (`echo $MM | awk '{print length($1)}'` < 2) set MM = 0${MM} end set SEC = `echo $rindate | awk '{print $6}'` set IntSec = `echo $SEC | awk -F. '{print $1}'` while (`echo $IntSec | awk '{print length($1)}'` < 2) set SEC = 0${SEC} set IntSec = `echo $SEC | awk -F. '{print $1}'` end # Save start time in output format # -------------------------------- set sttime = `echo $yyyy $mm $dd ${HH}:${MM}:00.00` # Calculate J2000 seconds for start time # -------------------------------------- set J2000stDecimal = `cal2sec $yyyy $mm $dd $HH $MM $SEC` @ J2000st = `echo $J2000stDecimal | awk -F. '{print $1}'` set NumLines = `grep "^ $sta" $Prefix/sta_svec | wc -l | awk '{print $1}'` set FoundAGoodOne = "false" if ($NumLines > 0) then @ i = 0 while ($i < $NumLines) @ i++ set yyyy = `grep "^ $sta" $Prefix/sta_svec | sed -n ${i}p | awk '{print substr($0,12,4)}'` set mm = `grep "^ $sta" $Prefix/sta_svec | sed -n ${i}p | awk '{print substr($0,17,2)}'` set dd = `grep "^ $sta" $Prefix/sta_svec | sed -n ${i}p | awk '{print substr($0,20,2)}'` set HH = `grep "^ $sta" $Prefix/sta_svec | sed -n ${i}p | awk '{print substr($0,23,2)}'` set MM = `grep "^ $sta" $Prefix/sta_svec | sed -n ${i}p | awk '{print substr($0,26,2)}'` set SEC = `grep "^ $sta" $Prefix/sta_svec | sed -n ${i}p | awk '{print substr($0,29,5)}'` set LDurationDecimal = `grep "^ $sta" $Prefix/sta_svec | sed -n ${i}p | awk '{print substr($0,35,12)}'` # CARR CARR 1995 07 21 00:00:00.00 ___86400.00 # 12345678901234567890123456789012345678901234567890 # 1 2 3 4 5 @ LDuration = `echo $LDurationDecimal | awk -F. '{print $1}'` set LStartDecimal = \ `cal2sec $yyyy $mm $dd $HH $MM $SEC` @ LStart = `echo $LStartDecimal | awk -F. '{print $1}'` @ LStop = $LStart + $LDuration if ($LStart <= $J2000st && $J2000st <= $LStop) then set FoundAGoodOne = "true" endif end endif # Examine results of test. # If svec contains an entry for this station # and start time, we're done. # If not, add one. # --------------- if ($FoundAGoodOne != "true") then # Time duration for which setup is valid # ------------------------------------ set StopTime = `tail -25 $file | sed -n '/^ [ 089][0-9] [ 01][0-9] [ 0123][0-9]/p' | tail -1` # Calculate J2000 seconds for end time # Year is treated with a kluge # Depends on what Rinex does in year 2000 # This might work until 2070 # Then compute time of validity for this entry # -------------------------------------------- echo $StopTime set yearend = `echo $StopTime | awk '{ print $1 }'` set len = `expr "$yearend" : '[0-9]*'` # ml mod if ($yearend < 70 ) then if ($len == 1) then set yyyyend = 200$yearend else set yyyyend = 20$yearend endif endif # old code # if ($yearend < 70 ) then # set yyyyend = 20$yearend if ($yearend >= 70) then set yyyyend = 19$yearend endif set mm = `echo $StopTime | awk '{print $2}'` set dd = `echo $StopTime | awk '{print $3}'` set HH = `echo $StopTime | awk '{print $4}'` set MM = `echo $StopTime | awk '{print $5}'` set SEC = `echo $StopTime | awk '{print $6}'` set J2000endDecimal = `cal2sec $yyyyend $mm $dd $HH $MM $SEC` @ J2000end = `echo $J2000endDecimal | awk -F. '{print $1}'` @ temp = $J2000end - $J2000st set valtime = ${temp}.00 while (`echo $valtime | awk '{print length($1)}'` < 11) set valtime = _${valtime} end # Set various values for new record in svec file # ---------------------------------------------- set rnxrcvr = `grep "ANT #" $file | head -1 | awk '{print $2}'` set rcvr = `grep $rnxrcvr /goa/sta_info/AntennaTrans | awk '{print $2}'` # if ($rcvr == "UNKNOWN" || $rcvr == "") then if ($rcvr == "UNKNOWN" || $rcvr == "") then echo " " echo "gp.addstasvec: PROBLEM PROBLEM PROBLEM PROBLEM PROBLEM PROBLEM PROBLEM PROBLEM PROBLEM" echo "gp.addstasvec: UNKNOWN ANTENNA TYPE, CHECK RINEX HEADER AND /goa/sta_info/AntennaTrans" echo " " exit 1 endif while (`echo $rcvr | awk '{print length($1)}'` < 13) set rcvr = ${rcvr}_ end set ecc = "0.0000" set hi = `grep 'ANTENNA: DELTA H/E/N' $file | head -1 | awk '{ print $1 }'` while (`echo $hi | awk '{print length($1)}'` < 6) set hi = ${hi}0 end set flag = "l" set datedone = `date '+%Y %m %d'` set creator = "gp.addstasvec" # Write new record to a temporary file. # ------------------------------------- echo " $sta $sta $sttime $valtime $rcvr $ecc $ecc $ecc $hi $flag $datedone[1] $datedone[2] $datedone[3] $creator" >> addstasvec.$$ echo "---------------YOU ARE HERE------------------------" echo " $sta $sta $sttime $valtime $rcvr $ecc $ecc $ecc $hi $flag $datedone[1] $datedone[2] $datedone[3] $creator" echo gp.addstasvec: echo " "{$sta} $sta $sttime " "{$valtime} $rcvr " " {$ecc}" " {$ecc}" " {$ecc}" " $hi $flag $datedone $creator endif # End of clause to entry notfound end # End foreach rinex file if (-e addstasvec.$$) then # SAVE OLD STA_SVEC FILE # ---------------------- cp $Prefix/sta_svec $Prefix/sta_svec_old/sta_svec.old.$$ # CHANGE LEADING AND TRAILING _ TO BLANKS # ----------------------------------------- set counter = `ls addstasvec.$$ | wc -l` if ($counter > 0) then mv addstasvec.$$ addstasvectemp2.$$ sed 's/_/ /g' addstasvectemp2.$$ > addstasvec.$$ cat addstasvec.$$ $Prefix/sta_svec > sta_svec.$$ if (-e sta_svec.$$ ) then rm $Prefix/sta_svec mv sta_svec.$$ $Prefix/sta_svec chmod 775 $Prefix/sta_svec endif # CLEAN UP # -------- rm addstasvectemp2.$$ rm addstasvec.$$ endif endif