#!/usr/bin/csh # # gp.RunQOCA # W. Prescott 1999/06/15 # # This script will run qoca for an arbitrary collection of stacov files. # It also includes a few commands for looking at the input/output. # First step must be completed manually, before running script # # Some lines are intended to be run interactively. # These are protected. The script can be run, without executing them. # But they can be copied directly to an interactive window # for manual execution. # echo " gp.RunQOCA is obsolete" echo " " echo " Instead use:" echo " gp.RunQOCA.pl NetName" echo " ^^^" exit # ----------------------------------------------------------------------- # Check number of arguments if ($#argv == 0) then # Print instructions and stop # --------------------------- echo "Usage: 1) gp.RunQOCA CampaignName" echo " or: 2) gp.RunQOCA -r CampaignName" echo "1) Creates a Campaign directory" echo " cd's to that directory" echo " and runs qoca for all files found in SolutionList" echo " " echo "2) Reruns just the qoca separate and global solutions" echo " and puts results on web" exit else if ($#argv == 1) then # Full solution from scratch # -------------------------- set Campaign = $argv[1] mkdir $Campaign cd $Campaign else # Just rerun two qoca solutions and web # ------------------------------------- set Campaign = $argv[2] echo "Running qoca (1)" qoca qoca.sep.drv > qoca.sep.log echo "Running qoca (2)" qoca qoca.glo.drv > qoca.glo.log gp.www.qoca $Campaign exit endif # ----------------------------------------------------------------------- # Get point stacov files echo "Retrieving stacov files" mkdir gpsFiles rm -f $$.StaList # Get list of stations # -------------------- set StaList = `grep ^$Campaign\[^A-Za-z0-9\#_\] /attic/CampaignList | \\ awk '{print $2}'` echo "$#StaList stations requested" # Get list of solutions # --------------------- touch $$.StaList1 foreach sta ($StaList) grep ^$sta /attic/StaSolutionList | awk '{print $2}' >> $$.StaList1 end grep point $$.StaList1 | sort -u > $$.StaList2 # Get stacov files # ---------------- set Number = `wc -l $$.StaList2 | awk '{print $1}'` echo "$Number stacov files requested" cat $$.StaList2 | gp.RunQOCA.GetStacovs.pl rm -f $$.StaList? # ----------------------------------------------------------------------- # Define reference frame file set RefFrame = "/GPSdata/postprocess/itrf/itrf96/gp.stacov" set TemplatesDir = "/goa/local/templates/qoca" # ----------------------------------------------------------------------- # Copy template driver files to local directory echo "Copying Driver Files" cp $TemplatesDir/qoca.sep.drv . cp $TemplatesDir/qoca.glo.drv . cp $TemplatesDir/mk_qob.drv . cp $TemplatesDir/inter_cons.list . if (! -e unuse.list) then cp $TemplatesDir/unuse.list . endif # ----------------------------------------------------------------------- # Run transform to put stacovs into a reference frame echo "Putting stacovs into reference frame (if necessary)" cd gpsFiles set NumStacovs = `ls * | wc -l | awk '{print $1}'` set NumTransforms = `ls *.point | wc -l | awk '{print $1}'` echo $NumStacovs stacov files found echo $NumTransforms need to be transformed foreach file (`ls *.point`) # Transform file # -------------- set jpldate = `head -1 $file | awk '{print $4}' | awk -F. '{print $1}'` stamrg -i $RefFrame -o RefFrame.mapped -v $jpldate >> transform.log transform -f RefFrame.mapped -i $file -o $file.ref -r -s -t \ >> ../transform.log # Save transformed file # --------------------- set yyyymmdd = `echo $file | awk -F. '{print $2}'` cp $file.ref `ap tr $yyyymmdd`/$file compress -f `ap tr $yyyymmdd`/$file end echo "Done with reference frame transformation" rm -f RefFrame.mapped cd .. # ----------------------------------------------------------------------- # Run stamrg to get a complete single stacov file to use for apriori echo "Construct apriori file" # Strategy: # 1) Pull all the station names from all stacov.ref files # Sort -u to get a unique list # Initialize apriori stacov to the first stacov.ref file # Go through the list of stations one-by-one # If the station is not in the current apriori file # stamrg the current apriori file with # the first stacov.ref file containing the current station # 2) Then remove all the observed positions of the ref stations # 3) Finally merge with the itrf reference stacov file. # Get list of stations # -------------------- echo "Getting list of stations" echo "" > $$.stalist foreach file (`ls gpsFiles/*.ref`) stacov_sta $file >> $$.stalist end set StaList = `cat $$.stalist | sort -u` echo $#StaList stations needed for apriori file rm $$.stalist # Build apriori gd file # ------------------------- echo "Building apriori file" set file = `ls gpsFiles/*.ref | head -1` cp $file $$.1.stacov statistics -r $$.1.stacov -gd foreach Sta ($StaList) echo -n "$Sta " set Test = `grep $Sta $$.1.gd | awk '{print substr($1,1,4)}' | sort -u` if ($Test != $Sta) then set file = `grep $Sta gpsFiles/*.ref | head -1 | awk -F: '{print $1}'` cp $file $$.2.stacov statistics -r $$.2.stacov -gd cat $$.1.gd $$.2.gd > $$.3.gd mv $$.3.gd $$.1.gd endif end echo "" sort -k 1,3 $$.1.gd > $$.2.gd sort -k 2.1,2.0 -um $$.2.gd > $$.1.gd rm $$.?.stacov # Remove random values of reference stations # ------------------------------------------ echo "Removing observed positions of ref stas from apriori" set RefStas = `stacov_sta $RefFrame` foreach Sta ($RefStas) echo -n "$Sta " sed /$Sta/d $$.1.gd > $$.2.gd mv $$.2.gd $$.1.gd end echo "" # Add in reference station positions from itrf # -------------------------------------------- # echo "Inserting reference positions for ref stas" cp $RefFrame . statistics -r gp.stacov -gd cat $$.1.gd gp.gd > gpsFiles/apriori.gd rm $$.?.gd gp.gd gp.stacov # ----------------------------------------------------------------------- # Run mk_net to convert to qoca apriori format mk_net gpsFiles/apriori.gd mk_net.out gipsy # ----------------------------------------------------------------------- # Create a list for mk_qob set StacovList = `ls gpsFiles/*.ref` echo " $#StacovList" > mk_qob.list foreach file ($StacovList) echo $file $file.qob >> mk_qob.list end # ----------------------------------------------------------------------- # Run mk_qob to convert stacov files to qob files mk_qob mk_qob.drv # ----------------------------------------------------------------------- # Create a list for mrg_dat set qobList = `ls gpsFiles/*.qob` echo " $#qobList" > mrg_dat.in foreach file ($qobList) echo $file >> mrg_dat.in end # ----------------------------------------------------------------------- # Merge qob files (scaling by factor of 2) mrg_dat mrg_dat.in $$.mrg_dat.out sed '/qob$/s/$/ 2.0/' $$.mrg_dat.out > mrg_dat.out rm $$.mrg_dat.out # ----------------------------------------------------------------------- # Check variance-covariance matrix (run manually) if (0 == 1) then cov_eigen mrg_dat.out cov_eigen.out endif # ----------------------------------------------------------------------- # Create table of observed station-dates and look at it get_obs_tbl mrg_dat.out get_obs_tbl.out if (0 == 1) then more get_obs_tbl.out endif # ----------------------------------------------------------------------- # Run QOCA for individual observation files (separately) echo "Running qoca (1)" qoca qoca.sep.drv > qoca.sep.log # ----------------------------------------------------------------------- # Create postscript plots (uses a mapping file created by qoca) # (NOT USED currently) # stacov_sta gpsFiles/combined.stacov > mk_pos_ps.in # mkdir psFiles # mk_pos_ps qoca.sep.map mk_pos_ps.in psFiles # ----------------------------------------------------------------------- # Look at plots (run manually) if (0 == 1) then gs psFiles/* endif # ----------------------------------------------------------------------- # Create list of stations for strain calculation if (! -e strain.list) then echo " 2" > strain.list set StrainList = \ `grep ^$Campaign\[^A-Za-z0-9\#_\] \\ /attic/CampaignList | awk '{ print $2}'` echo " $#StrainList" >> strain.list foreach sta ($StrainList) echo $sta | sed \ '/.*/y/abcdefghijklmnopqrstuvwxyz/ABCDEFGHIJKLMNOPQRSTUVWXYZ/' \ >> strain.list end endif # ----------------------------------------------------------------------- # Run QOCA globally echo "Running qoca (2)" qoca qoca.glo.drv > qoca.glo.log # ----------------------------------------------------------------------- # Post results to web gp.www.qoca $Campaign # ----------------------------------------------------------------------- # Look at results (run manually) if (0 == 1) then grep subf *.out | more more strain.out more qoca.glo.map more get_obs_tbl.out endif # ----------------------------------------------------------------------- exit