#!/bin/csh -bf # Compiles phase center mapping information into a qregres namelist # Input arguments: qregres.nml, qm file # Modifications: # 2000/08/04 whp Script now reads antenna phase center file # in its original form, without added line feeds. if ($#argv != 2) then echo "" echo "Usage: qr_pmap (qregres.nml) (qmfile)" echo "" exit endif # Set environment variables if ($?MAPFILE == 0) then # setenv MAPFILE /deform/cervelli/gipsy/igs_01.pcv.97 setenv MAPFILE /goa/sta_info/ant_info.004 setenv PCENTER /goa/sta_info/pcenter endif #Save original qregres.nml for reference cp qregres.nml qregres.nml_no_map # Parse the namelist to get a station and antenna list # End up with list of stations, list of antennas at each station, and # list of unique antenna types. set stats = `awk '/NMLname/ {print substr($0,length($0)-4,4)}' $1` set ants = `awk '/Antenna Type/ {print $5}' $1` set antlist = `printf "%s\n" $ants | sort -u` set num_unique_ants=(`echo $antlist | wc -w | awk '{print $1}'`) # Correlate each station to a particular antenna type set i = 1 foreach antenna ($ants) set linenum1=(`grep -n "NMLTROP_DRY" qregres.nml | head -$i | tail -1 | awk -F: '{print $1}'`) @ linenum1-- head -$linenum1 qregres.nml > temp set j = 1 while ($j <= $#antlist) if ($antenna == $antlist[$j]) then echo $i $j | awk '{printf " NMLGPtCen(%3.0d) = %i\n",$1,$2}' >>temp #echo "" >> temp endif @ j++ end set tot=(`wc -l qregres.nml | awk '{print $1}'`) set diff=(`echo $tot $linenum1 | awk '{printf "%i\n",$1-$2}'`) tail -$diff qregres.nml >> temp mv temp qregres.nml @ i ++ end set linenum2= ( `grep -n "NMLSite(" qregres.nml | tail -1 | awk -F: '{print $1}'` ) head -$linenum2 qregres.nml > temp2 echo "" >> temp2 echo "! IGS phase center mapping starts here:" >> temp2 echo "" >> temp2 # Dump phase maps to temp2 file set i = 1 #counter for first foreach loop foreach antenna ($antlist) #gets antenna name and number used by mapping file plus alternative names and/or description to put in comment in qregres.nml set comment = `awk '$1 == a {print substr($0,43)}' a="$antenna" $PCENTER | head -1` #makes an entry for each unique antenna type; each entry will contain comment and information needed for pcenter mapping. echo "! Antenna ${i}: $antenna, $comment" >> temp2 echo "" >> temp2 echo " NMLGSzEl($i) = 19" >> temp2 echo " NMLGSzAz($i) = 9" >> temp2 echo " NMLGIncrE($i) = 5.0 ! deg" >> temp2 echo " NMLGIncrA($i) = 45.0 ! deg" >> temp2 echo "" >> temp2 @ i ++ end #first foreach loop echo "" >> temp2 set i=1 #counter for second foreach loop foreach antenna ($antlist) #extract igs antenna number from pcenter file using the antenna type name specified earlier in sta_svec (and thus in qregres.nml) # set igsant = `awk '$1 == foo {print substr($0,43,15)}' foo=$antenna $PCENTER | head -1` set igsant = `grep $antenna /goa/sta_info/AntennaTrans | awk '{print $1}'` #extract the correct lines for L1 and L2 from the pcenter mapping file; doesn't extract nominal offsets. # set offs = `nawk 'BEGIN {FS="\n"; RS=""} substr($1,1,length(f))==f && substr($1,length(f)+1,1)==" " {print $3 $4 $6 $7}' f="$igsant" $MAPFILE` # Note: Above nawk command required adding carriage returns between antenna sets. # Sed commands below work with unmodified antenna phase file from Mader web site. # whp 2000/08/04 # Get line number for this antenna ($igsant) in file ($MAPFILE) set igsanttemp = `HandleSlash.pl $igsant` set m = `sed -n /"^$igsanttemp "/= $MAPFILE` # Get line number for this antenna @ m++; @ m++ # First line of L1 phase centers set offs = `sed -n ${m}p $MAPFILE` @ m++; # Second line of L1 phase centers set offs = ($offs `sed -n ${m}p $MAPFILE`) @ m++; @ m++ # First line of L2 phase centers set offs = ($offs `sed -n ${m}p $MAPFILE`) @ m++; # Second line of L2 phase centers set offs = ($offs `sed -n ${m}p $MAPFILE`) #i=unique antenna-type number; j=# of diff't azimuths = 9; k=# of diff't offsets (# of diff't elevations) for each azimuth = 19 # first do L1 case: echo " ! $antlist[$i], L1" >> temp2 set j = 1 #counter for while loop 1 while ($j < 10) set k = 19 #counter for elements of "offs" echo -n " NMLGCenL1(1, $j, $i) = " >> temp2 while ($k > 0) if ($k > 1) then if ($offs[$k] == "0.0") then printf "0.0, " >> temp2 else set offset=(`echo $offs[$k] | awk '{print ($1/1000000)}'`) printf "%9.7f, " $offset >> temp2 endif else #for the case of the last entry in the table (k=1) if ($offs[$k] == "0.0") then printf "0.0\n" >> temp2 else set offset=(`echo $offs[$k] | awk '{print ($1/1000000)}'`) printf "%9.7f\n" $offset >> temp2 endif endif @ k-- #works backwards from k=19 to k=0 so that values start at 0 El and go to 90 El end @ j++ end echo "" >> temp2 # then do L2 case: echo " ! $antlist[$i], L2" >> temp2 set j = 1 #counter for while loop 2 while ($j < 10) echo -n " NMLGCenL2(1, $j, $i) = " >> temp2 set k = 38 # because offs is a list of numbers 38-long while ($k > 19) if ($k > 20) then if ($offs[$k] == "0.0") then printf "0.0, " >> temp2 else set offset=(`echo $offs[$k] | awk '{print ($1/1000000)}'`) printf "%9.7f, " $offset >> temp2 endif else if ($offs[$k] == "0.0") then printf "0.0\n" >> temp2 else set offset=(`echo $offs[$k] | awk '{print ($1/1000000)}'`) printf "%9.7f\n" $offset >> temp2 endif endif @ k-- # count backwards from 38 to 19 end @ j++ end if ($i<$num_unique_ants) then echo "" >> temp2 echo "" >> temp2 endif @ i++ end #end second foreach loop set tot=(`wc -l qregres.nml | awk '{print $1}'`) set diff=(`calc $tot-$linenum2`) tail -$diff qregres.nml >> temp2 mv temp2 qregres.nml