[cig-commits] r13106 - in seismo/3D/ADJOINT_TOMO/measure_adj: . PLOTS scripts_tomo

carltape at geodynamics.org carltape at geodynamics.org
Mon Oct 20 18:21:15 PDT 2008


Author: carltape
Date: 2008-10-20 18:21:15 -0700 (Mon, 20 Oct 2008)
New Revision: 13106

Added:
   seismo/3D/ADJOINT_TOMO/measure_adj/scripts_tomo/combine_2_adj_src.pl
   seismo/3D/ADJOINT_TOMO/measure_adj/scripts_tomo/combine_2_adj_src_all.pl
   seismo/3D/ADJOINT_TOMO/measure_adj/scripts_tomo/combine_3_adj_src.pl
   seismo/3D/ADJOINT_TOMO/measure_adj/scripts_tomo/combine_3_adj_src_all.pl
Removed:
   seismo/3D/ADJOINT_TOMO/measure_adj/scripts_tomo/combine_adj_src_all.pl
Modified:
   seismo/3D/ADJOINT_TOMO/measure_adj/PLOTS/make_pdf_all.pl
   seismo/3D/ADJOINT_TOMO/measure_adj/PLOTS/plot_win_adj.pl
   seismo/3D/ADJOINT_TOMO/measure_adj/PLOTS/plot_win_adj_all.pl
   seismo/3D/ADJOINT_TOMO/measure_adj/PLOTS/plot_win_stats.pl
   seismo/3D/ADJOINT_TOMO/measure_adj/PLOTS/plot_win_stats_all.pl
   seismo/3D/ADJOINT_TOMO/measure_adj/README
   seismo/3D/ADJOINT_TOMO/measure_adj/mt_measure_adj.f90
   seismo/3D/ADJOINT_TOMO/measure_adj/mt_sub.f90
   seismo/3D/ADJOINT_TOMO/measure_adj/scripts_tomo/README
   seismo/3D/ADJOINT_TOMO/measure_adj/scripts_tomo/prepare_mt_measure_adj.pl
   seismo/3D/ADJOINT_TOMO/measure_adj/scripts_tomo/run_mt_measure_adj.pl
   seismo/3D/ADJOINT_TOMO/measure_adj/scripts_tomo/run_tomo.pl
Log:
Updated the definition of the amplitude measurement from dlnA = (Aobs-Asyn)/Aobs to ln(Aobs/Asyn), to be consistent with the FLEXWIN algorithm.  This required also updating the formula to reconstruct the synthetics, and it may also need updating for the f1f2 subroutines that are used (need to look into this).  Also updated the run scripts and modified some of the output directory naming conventions.


Modified: seismo/3D/ADJOINT_TOMO/measure_adj/PLOTS/make_pdf_all.pl
===================================================================
--- seismo/3D/ADJOINT_TOMO/measure_adj/PLOTS/make_pdf_all.pl	2008-10-21 00:45:37 UTC (rev 13105)
+++ seismo/3D/ADJOINT_TOMO/measure_adj/PLOTS/make_pdf_all.pl	2008-10-21 01:21:15 UTC (rev 13106)
@@ -4,48 +4,100 @@
 #
 #  make_pdf_all.pl
 #  Carl Tape
-#  06-May-2008
+#  01-Oct-2008
 #
 #  This sorts the output PDF files in PLOTS into order by
-#    1  station
-#    2  distance
-#    3  azimuth
+#    1  distance
+#    2  azimuth
 #
 #  EXAMPLE (from PLOTS): make_pdf_all.pl 3 mt_cc_all
 #
 #==========================================================
 
-if (@ARGV < 2) {die("Usage: make_pdf_all.pl xxx\n")}
-($isort,$otag) = @ARGV;
+#if (@ARGV < 3) {die("Usage: make_pdf_all.pl xxx\n")}
+#($isort,$otag) = @ARGV;
 
- at tags = ("sta","dist","az");
-$tag = $tags[$isort-1];
+$station_sort = "STATIONS_sort";
+if (not -f "${station_sort}") {die("check if station_sort ${station_sort} exist or not\n")}
+open(IN,"${station_sort}"); @stalines = <IN>; close(IN); $nrec = @stalines;
 
-$ofile = "${otag}_${tag}.pdf";
+print "\n $nrec \n";
 
-$station_sort = "STATIONS_${tag}";
-if (not -f "${station_sort}") {die("check if station_sort ${station_sort} exist or not\n");}
- at pdffiles = glob("*pdf");
-$npdf = @pdffiles;
+# NOTE: make sure that the executable is there
+ at pdcat = "/home/carltape/bin/pdcat -r"; $k = 1;
 
-print "\n $npdf files\n";
+# loop over all the stations in the sorted list
+for ($ik = 1; $ik <= $nrec; $ik = $ik+1) {
 
-for ($ik = 1; $ik <= $npdf; $ik = $ik+1) {
+  ($stanet,$stalon,$stlat,undef,undef,undef,undef,undef) = split(" ",$stalines[$ik-1]);
+  ($station,$network) = split("\\.",$stanet);
+  print "$ik out of $nrec : $station $network\n";
+  
+  @files = glob("*${station}_${network}*pdf");
+  $numf = @files;
+  if ($numf == 0) {
+     print "--> no pdf file exists\n";
 
-  $pdffile0 = $pdffiles[$ik-1];
-  ($pdffile) = split(" ",`basename $pdffile0`);
-  ($sta,$net,undef,undef,undef) = split("_",$pdffile);
-  $stanet = "$sta.$net";
-  $iline=`grep -n \"$stanet\" ${station_sort} | awk -F: '{print \$1}'`; chomp($iline);
-  print "$ik $stanet $iline\n";
+  } elsif ($numf == 1) {
+     print "--> one pdf file exists\n";
+     $pdffile = $files[0]; chomp($pdffile);
+     $pdcat[$k] = $pdffile; $k = $k+1;
 
-  $sti = sprintf("%3.3i",$iline);
-  $pdffile_out = "${sti}_${pdffile}";
-  `\\mv $pdffile0 ${pdffile_out}`;
-  #print "move $iline $sti $pdffile0 ${pdffile_out}\n";
+  } else {
+     die("more than one pdf file exists\n");
+  }
+
 }
 
-# concatenate into one file
-`/home/carltape/bin/pdcat -r *.pdf $ofile`;
+print "@pdcat\n";
 
+# construct the output file name from the first file in the list
+($flabel,undef) = split("\\.",$pdcat[1]);
+($eid,$sTmin,$sTmax,$sta,$net,$smodel,$tag1,$tag2,$tag3) = split("_",$flabel);
+$ofile = "${eid}_${sTmin}_${sTmax}_${smodel}_ALL.pdf";
+print "output file is $ofile\n";
+
+$pdcat[$k] = "./$ofile";
+
+# execute pdf command
+`@pdcat`;
+`sleep 2s`;
+
+#-----------------
+# OBSOLETE VERSION AS OF 02-OCT-2008
+
+#if (@ARGV < 2) {die("Usage: make_pdf_all.pl xxx\n")}
+#($isort,$otag) = @ARGV;
+
+#@tags = ("sta","dist","az");
+#$tag = $tags[$isort-1];
+
+#$ofile = "${otag}_${tag}.pdf";
+
+#$station_sort = "STATIONS_${tag}";
+#if (not -f "${station_sort}") {die("check if station_sort ${station_sort} exist or not\n");}
+#@pdffiles = glob("*pdf");
+#$npdf = @pdffiles;
+
+#print "\n $npdf files\n";
+
+## loop over all the PDF files
+#for ($ik = 1; $ik <= $npdf; $ik = $ik+1) {
+
+#  $pdffile0 = $pdffiles[$ik-1];
+#  ($pdffile) = split(" ",`basename $pdffile0`);
+#  ($sta,$net,undef,undef,undef) = split("_",$pdffile);
+#  $stanet = "$sta.$net";
+#  $iline=`grep -n \"$stanet\" ${station_sort} | awk -F: '{print \$1}'`; chomp($iline);
+#  print "$ik $stanet $iline\n";
+
+#  $sti = sprintf("%3.3i",$iline);
+#  $pdffile_out = "${sti}_${pdffile}";
+#  `\\mv $pdffile0 ${pdffile_out}`;
+#  #print "move $iline $sti $pdffile0 ${pdffile_out}\n";
+#}
+
+## concatenate into one file
+#`/home/carltape/bin/pdcat -r *.pdf $ofile`;
+
 #=================================================================

Modified: seismo/3D/ADJOINT_TOMO/measure_adj/PLOTS/plot_win_adj.pl
===================================================================
--- seismo/3D/ADJOINT_TOMO/measure_adj/PLOTS/plot_win_adj.pl	2008-10-21 00:45:37 UTC (rev 13105)
+++ seismo/3D/ADJOINT_TOMO/measure_adj/PLOTS/plot_win_adj.pl	2008-10-21 01:21:15 UTC (rev 13106)
@@ -30,27 +30,28 @@
 sub Usage{
   print STDERR <<END;
 
-  plot_win_adj.pl -m CMTFILE -n station_name/network_name -b iboth -r -a STATION_FILE -d data_dir -s syn_dir -c recon_dir -w winfile
+  plot_win_adj.pl -m CMTFILE -n station/network -b iboth -r -a STATION_FILE -d data_dir -s syn_dir -c recon_dir -w winfile
   with
 
-       -m -- use CMTSOLUTION file to plot event focal mechanism (beach ball) on the map
+       -m -- CMTSOLUTION file to plot event focal mechanism (beach ball) on the map
        -l -- Start/End of trace to be cut
        -b -- plot MT and CC adjoint sources (=1)
        -k -- type of adjoint source (0 = waveform; 1 = multi-taper; 2 = cross-correlation)
-       -n -- station_name/network_name
+       -n -- station/network
        -r -- plot 3-compoment seismograms and adjoint sources in relatively scaled amplitude
-       -a -- use the station file to plot all the stations on the map
+       -a -- station file to plot all the stations on the map
        -d -- data directory
        -s -- synthetics directory
        -c -- reconstructed directory
        -w -- the file with the windows
        -i -- label for the model iteration
+       -j -- Tmin/Tmax
 END
   exit(1);
 }
 
 if (@ARGV == 0) { Usage(); }
-if (!getopts('k:m:l:n:b:ra:d:s:c:w:i:')) {die('Check input arguments\n');}
+if (!getopts('k:m:l:n:b:ra:d:s:c:w:i:j:')) {die('Check input arguments\n');}
 print "STATIONS file is $opt_a\n";
 if ($opt_m) {@cmtvals = &get_cmt($opt_m);}
 #if ($opt_k) {$iker = $opt_k;}   # does not work for iker = 0
@@ -63,6 +64,7 @@
 if (!$opt_s) {$opt_s = "SYN"}
 if (!$opt_c) {$opt_c = "RECON"}
 if (!$opt_i) {$opt_i = "m00"}
+if ($opt_j) {($Tmin,$Tmax) = split(/\//,$opt_j);}
 $smodel = $opt_i;
 
 # suffix for adjoint sources
@@ -71,6 +73,12 @@
 elsif($iker == 2) {$klab = "cc"; $ktitle = "cross-correlation TT";}
 else {die("ERROR: iker ($iker) must be 0,1, or 2\n");}
 
+$sTmin = sprintf("T%3.3i",$Tmin);
+$sTmax = sprintf("T%3.3i",$Tmax);
+$Ttag = "${sTmin}_${sTmax}";
+$Ttag_title = sprintf("bandpass %i s to %i s",$Tmin,$Tmax);
+$Ttag_plot = sprintf("bp [%i s, %i s]",$Tmin,$Tmax);
+
 #---------------------------
 # ADDITIONAL USER INPUT
 
@@ -97,6 +105,7 @@
 
 #---------------------------
 
+# extract values from the array cmtvals
 @M[0..5] = @cmtvals[12..17];
 $year = $cmtvals[0]; $month = $cmtvals[1]; $day = $cmtvals[2];
 $elat = $cmtvals[9]; $elon = $cmtvals[10]; $edep = $cmtvals[11];
@@ -119,7 +128,8 @@
 # set GMT defaults
 `gmtset BASEMAP_TYPE plain PAPER_MEDIA letter ANNOT_FONT_SIZE = 12p LABEL_FONT_SIZE = 12p PAGE_ORIENTATION = portrait PLOT_DEGREE_FORMAT D`;
 
-$name = "${sta}_${net}_win_adj_${klab}";
+#$name = "${sta}_${net}_win_adj_${klab}";
+$name = "${eid}_${Ttag}_${sta}_${net}_${smodel}_${klab}_win_adj";
 $ps_file = "$name.ps";
 $jpg_file = "$name.jpg";
 
@@ -215,7 +225,7 @@
 if (!$opt_l) {$tmin = $tmin0; $tmax = $tmax0;}
 
 # plot labels next to the map
- at mapstrings = ($edate,$eid,$stMw,$stedep,$strec,$stdist,$staz,$stmodel);
+ at mapstrings = ($edate,$eid,$stMw,$stedep,$strec,$stdist,$staz,"--",${Ttag_plot},$stmodel);
 $nstrings = @mapstrings;
 $x1 = $xmin - 4*$xtick;
 for ($i=0; $i < $nstrings; $i++) {
@@ -534,7 +544,7 @@
 `echo \"$xtextpos1 $ytextpos1 9 0 1 CM $strZ\" | pstext $proj $bounds -N -O -K >> $ps_file`;
 
 # plot titles
-`echo \"$xtextpos3 $ytextpos5 12 0 $fontno BC Data (Black) and Synthetics (Red)\" | pstext $proj $bounds -N -K -O >> $ps_file`;
+`echo \"$xtextpos3 $ytextpos5 12 0 $fontno BC Data (Black) and Synthetics (Red) -- ${Ttag_title}\" | pstext $proj $bounds -N -K -O >> $ps_file`;
 if ($iplot_adj==1) {
    `echo \"$xtextpos3 $ytextpos5 12 0 $fontno BC Adjoint Source ($ktitle)\" | pstext $proj $bounds -N -X$dX -K -O >> $ps_file`;
 }

Modified: seismo/3D/ADJOINT_TOMO/measure_adj/PLOTS/plot_win_adj_all.pl
===================================================================
--- seismo/3D/ADJOINT_TOMO/measure_adj/PLOTS/plot_win_adj_all.pl	2008-10-21 00:45:37 UTC (rev 13105)
+++ seismo/3D/ADJOINT_TOMO/measure_adj/PLOTS/plot_win_adj_all.pl	2008-10-21 01:21:15 UTC (rev 13106)
@@ -5,7 +5,7 @@
 # plot_all_win_adj.pl
 # 
 # EXAMPLE:
-#   plot_win_adj_all.pl -l 0/200 -m CMTSOLUTION_9818433 -b 0 -k 2 -a STATIONS_ADJOINT -d DATA -s SYN -w MEASUREMENT.WINDOWS -i m00
+#   plot_win_adj_all.pl -l 0/200 -m CMTSOLUTION_9818433 -b 0 -k 2 -a STATIONS_ADJOINT -d DATA -s SYN -w MEASUREMENT.WINDOWS -i m00 -j 3/30
 #----------------------------------------------------
 
 use Getopt::Std;
@@ -14,14 +14,14 @@
 sub Usage{
   print STDERR <<END;
 
-  plot_all_win_adj.pl -m CMTFILE -a STATION_FILE -b iboth -l tmin/tmax -k iker -d data_dir -s syn_dir -c recon_dir -w winfile -i smodel
+  plot_all_win_adj.pl -m CMTFILE -a STATION_FILE -b iboth -l tmin/tmax -k iker -d data_dir -s syn_dir -c recon_dir -w winfile -i smodel -j Tmin/Tmax
 
 END
   exit(1);
 }
 
 if (@ARGV == 0) { Usage(); }
-if (!getopts('m:a:b:d:k:l:s:c:w:i:')) {die('Check input arguments\n');}
+if (!getopts('m:a:b:d:k:l:s:c:w:i:j:')) {die('Check input arguments\n');}
 if($opt_m) {$cmtfile=$opt_m;}
 if(!$opt_b) {$iboth = 0} else {$iboth = $opt_b}
 #if($opt_k) {$iker = $opt_k;}     # does not work for iker = 1
@@ -32,7 +32,9 @@
 if($opt_s) {$syn_dir=$opt_s;}
 if($opt_c) {$recon_dir=$opt_c;}
 if($opt_i) {$smodel=$opt_i;}
+if($opt_j) {$Ts=$opt_j;}
 
+# loop over STATIONS -- first line is the number of stations
 $ns = `sed -n 1p $opt_a`;
 $nline = 1;
 for($i = 0; $i < $ns; $i++){
@@ -43,7 +45,11 @@
   print "$sta $net\n";
 
   # include the -r command here if you want the traces scaled by the max Z-R-T value
-  print "\n plot_win_adj.pl -m $cmtfile -n $sta/$net -b $iboth -l $tcuts -k $opt_k -a $station_list -d $data_dir -s $syn_dir -c $recon_dir -w $winfile -i $smodel\n";
-  `plot_win_adj.pl -m $cmtfile -n $sta/$net -b $iboth -l $tcuts -k $opt_k -a $station_list -d $data_dir -s $syn_dir -c $recon_dir -w $winfile -i $smodel`;
+  print "\n plot_win_adj.pl -m $cmtfile -n $sta/$net -b $iboth -l $tcuts -k $opt_k -a $station_list -d $data_dir -s $syn_dir -c $recon_dir -w $winfile -i $smodel -j $Ts\n";
+  `plot_win_adj.pl -m $cmtfile -n $sta/$net -b $iboth -l $tcuts -k $opt_k -a $station_list -d $data_dir -s $syn_dir -c $recon_dir -w $winfile -i $smodel -j $Ts`;
 
 }
+
+# sleep command to allow the last file to convert to PDF
+`sleep 2s`;
+#----------------

Modified: seismo/3D/ADJOINT_TOMO/measure_adj/PLOTS/plot_win_stats.pl
===================================================================
--- seismo/3D/ADJOINT_TOMO/measure_adj/PLOTS/plot_win_stats.pl	2008-10-21 00:45:37 UTC (rev 13105)
+++ seismo/3D/ADJOINT_TOMO/measure_adj/PLOTS/plot_win_stats.pl	2008-10-21 01:21:15 UTC (rev 13106)
@@ -25,7 +25,7 @@
 if (not -f $cmtall_psmeca) {die("\n check if $cmtall_psmeca exists\n")}
 
 ($Tmin,$Tmax) = split("/",$Ts);
-$sTper = sprintf("T = [%i s, %i s]",$Tmin,$Tmax);
+$sTper = sprintf("T = %i - %i s",$Tmin,$Tmax);
 
 #=============================================
 

Modified: seismo/3D/ADJOINT_TOMO/measure_adj/PLOTS/plot_win_stats_all.pl
===================================================================
--- seismo/3D/ADJOINT_TOMO/measure_adj/PLOTS/plot_win_stats_all.pl	2008-10-21 00:45:37 UTC (rev 13105)
+++ seismo/3D/ADJOINT_TOMO/measure_adj/PLOTS/plot_win_stats_all.pl	2008-10-21 01:21:15 UTC (rev 13106)
@@ -25,11 +25,12 @@
 ($Tmin,$Tmax) = split("/",$Ts);
 $sTmin = sprintf("T%3.3i",$Tmin);
 $sTmax = sprintf("T%3.3i",$Tmax);
-$sTper = sprintf("T = [%i s, %i s]",$Tmin,$Tmax);
+$sTper = sprintf("T = %i - %i s",$Tmin,$Tmax);
 
-$dir_source = "/home/carltape/results/SOURCES/socal_9";
-$dir_source_text = "${dir_source}/v9_files_text";
-$file_eids = "${dir_source}/SOCAL_FINAL_CMT_v9_eid";
+$dir_source = "/home/carltape/results/SOURCES/socal_10";
+$dir_source_text = "${dir_source}/v10_files_text";
+$file_eids = "${dir_source}/SOCAL_FINAL_CMT_v10_eid";
+#$file_eids = "/net/sierra/raid1/carltape/results/EID_LISTS/syn_run_m07";
 if (not -f $file_eids) {die("\n check if $file_eids exists\n")}
 open(IN,$file_eids); @eids = <IN>; $nevent = @eids;
 
@@ -41,7 +42,7 @@
 if (not -e $dir_run) {die("check if $dir_run exist or not\n")}
 
 # name of file containing ALL source focal mechanisms in PSMECA format (see socal_tomo_sources.m)
-$cmtall_psmeca = "${dir_source}/SOCAL_FINAL_CMT_v9_psmeca_eid";
+$cmtall_psmeca = "${dir_source}/SOCAL_FINAL_CMT_v10_psmeca_eid";
 if (not -f $cmtall_psmeca) {die("\n check if $cmtall_psmeca exists\n")}
 
 #$nevent = 5;
@@ -59,7 +60,7 @@
 $k = 0;
 $imin = 1; $imax = $nevent;   # default
 #$imin = 1; $imax = 10;
-$imin = 204; $imax = $imin;
+#$imin = 204; $imax = $imin;
 
 for ($i = $imin; $i <= $imax; $i = $i+1) {
 
@@ -92,9 +93,9 @@
     # check if the figure was made 
     if (-f "${name}.pdf") {
       $k = $k+1;
-      print "\n $i, $eid, ${name}.pdf was made";
+      print "$i, $eid, ${name}.pdf was made\n";
     } else {
-      print "\n $i, $eid, ${name}.pdf was NOT made";
+      print "$i, $eid, ${name}.pdf was NOT made\n";
     }
 
   } else {

Modified: seismo/3D/ADJOINT_TOMO/measure_adj/README
===================================================================
--- seismo/3D/ADJOINT_TOMO/measure_adj/README	2008-10-21 00:45:37 UTC (rev 13105)
+++ seismo/3D/ADJOINT_TOMO/measure_adj/README	2008-10-21 01:21:15 UTC (rev 13106)
@@ -30,8 +30,12 @@
 
 write_par_file.pl  -- writes MEASUREMENT.PAR from a set of input numbers
 prepare_adj_src.pl -- creates Z-E-N adjoint sources from Z-R-T adjoint sources
-combine_adj_src.pl -- combines two sets of adjoint sources and creates a new STATIONS_ADJOINT file
 
+PLOTS/
+  plot_win_adj_all.pl
+  plot_win_adj.pl
+  make_pdf_all.pl
+
 ==============================
 Carl Tape, 2/7/08
 
@@ -43,15 +47,16 @@
 run_mt_measure_adj.pl     -- runs the code and makes output plots
 run_mt_cc_plot.pl         -- runs the code in cross-correlation mode AND multi-taper mode for plots
 run_tomo.pl               -- master script that calls prepare_mt_measure_adj.pl and run_mt_measure_adj.pl
-combine_adj_src_all.pl    -- calls combine_adj_src.pl repeatedly to make the final set of adjoint sources
+combine_2_adj_src.pl      -- combines two sets of adjoint sources and creates a new STATIONS_ADJOINT file
+combine_2_adj_src_all.pl  -- calls combine_2_adj_src.pl repeatedly to make the final set of adjoint sources
 
 These must be COPIED into the main directory to use them.
 
 Finally, to make summary histogram plots for the measurements for each event,
 as well as a single histogram for all measurements in total, see
 
-PLOTS/plot_win_adj.pl
-PLOTS/plot_win_adj_all.pl
+PLOTS/plot_win_stats_all.pl
+PLOTS/plot_win_stats.pl
 
 This generates a succinct set of measurements and uncertainty estimates that is used for plotting.
 

Modified: seismo/3D/ADJOINT_TOMO/measure_adj/mt_measure_adj.f90
===================================================================
--- seismo/3D/ADJOINT_TOMO/measure_adj/mt_measure_adj.f90	2008-10-21 00:45:37 UTC (rev 13105)
+++ seismo/3D/ADJOINT_TOMO/measure_adj/mt_measure_adj.f90	2008-10-21 01:21:15 UTC (rev 13106)
@@ -289,15 +289,15 @@
          use_trace = .true.
       endif
 
-      ! CHT: if the CC traveltime shift is greater than the specified value, then we effectively eliminate the window
-      !      In principle, the windowing code should take care of this threshold.
+      ! CHT: If the DT is for some reason larger than the max allowable, 
+      !      then effectively eliminate the window by zeroing the
+      !      cross-correlation travel-time and amplitude measurements.
+      ! See BEFORE_TSHIFT in subroutine compute_time_shift in mt_sub.f90.
       ! NOTE: BEFORE_DLNA should be included in the PARFILE
-      BEFORE_DLNA = -0.80
-      if ( abs(tshift_xc) > BEFORE_TSHIFT .or. dlnA < BEFORE_DLNA ) then
+      if ( abs(tshift_xc) > BEFORE_TSHIFT ) then
          if (DISPLAY_DETAILS) then
             print *, ' effectively eliminating this time window -->'
             print *, ' tshift_xc   : ', tshift_xc, BEFORE_TSHIFT, abs(tshift_xc) > BEFORE_TSHIFT
-            print *, ' dlnA   : ', dlnA, BEFORE_DLNA, dlnA < BEFORE_DLNA
          endif
          tshift_xc = 0.0
          dlnA = 0.0

Modified: seismo/3D/ADJOINT_TOMO/measure_adj/mt_sub.f90
===================================================================
--- seismo/3D/ADJOINT_TOMO/measure_adj/mt_sub.f90	2008-10-21 00:45:37 UTC (rev 13105)
+++ seismo/3D/ADJOINT_TOMO/measure_adj/mt_sub.f90	2008-10-21 01:21:15 UTC (rev 13106)
@@ -158,9 +158,15 @@
 
     ! amplitude MEASUREMENT (definition of Dahlen and Baig (2002), Eq. 3,17,18 : dlnA = Aobs/Asyn - 1)
     ! note that the records are UN-SHIFTED
-    dlnA = sqrt( (dt * sum( dat_displ(1:nlen) * dat_displ(1:nlen) )) &
-               / (dt * sum( syn_displ(1:nlen) * syn_displ(1:nlen) )) ) - 1. 
+    !dlnA = sqrt( (dt * sum( dat_displ(1:nlen) * dat_displ(1:nlen) )) &
+    !           / (dt * sum( syn_displ(1:nlen) * syn_displ(1:nlen) )) ) - 1. 
 
+    ! CHT revision 15-Oct-2008
+    ! The previously used expression for dlnA is a first-order perturbation of ln(A1/A2) = (A1-A2)/A2
+    ! The new expression is better suited to getting values between -1 and 1,
+    ! with dlnA = 0 indicating perfect fit, as before.
+    dlnA = 0.5 * log( sum(dat_displ(1:nlen) * dat_displ(1:nlen)) / sum(syn_displ(1:nlen) * syn_displ(1:nlen)) )
+
     ! reconstruct synthetics using cross-correlation measurments
     call reconstruct_syn_cc(datafile,filename,dzr,dzr2,tstart,dt,nlen,ishift,tshift_xc,dlnA, tseis_recon_cc, tseis_recon_cc_dt) 
 
@@ -1044,6 +1050,7 @@
     double precision cr_shift,cc,cc_max
     integer n_left, n_right, i, j
 
+    ! these choices will slide the entire windowed record past the other
     cr_shift = nlen*dt
     n_left  = ceiling( -1.0 * cr_shift / dt )
     n_right = floor( cr_shift / dt )
@@ -1051,14 +1058,19 @@
     ! cross-correlation
     ishift = 0 
     do i = n_left, n_right, 1
+
       cc = 0.
       do j = 1, nlen
         if((j+i) > 1 .and. (j+i) < nlen) cc = cc + dzr(j) * dzr2(j+i)   
       enddo
-      if(cc > cc_max) then
+
+      !if(cc > cc_max) then
+      ! CHT, 07-Sept-2008: Do not allow time shifts larger than the specified input
+      if(cc > cc_max .and. abs(i*dt) <= BEFORE_TSHIFT ) then
         cc_max = cc
         ishift = i
       endif
+
     enddo
     tshift_xc = ishift*dt 
 
@@ -1336,7 +1348,8 @@
 
     ! apply cross-correlation amplitude measurement
     tseis_recon_cc(:) = 0.
-    tseis_recon_cc(:) = tseis_recon_cc_dt * (1. + dlnA)
+    !tseis_recon_cc(:) = tseis_recon_cc_dt * (1. + dlnA)       ! based on first-order approximation of dlnA
+    tseis_recon_cc(:) = tseis_recon_cc_dt * exp( dlnA )        ! based on dlnA = ln(Aobs/Asyn)
 
     if (OUTPUT_MEASUREMENT_FILES) then
        call dwrite_sacfile_f(datafile,trim(filename)//'.recon_syn_cc.sac',tstart,nlen,tseis_recon_cc)

Modified: seismo/3D/ADJOINT_TOMO/measure_adj/scripts_tomo/README
===================================================================
--- seismo/3D/ADJOINT_TOMO/measure_adj/scripts_tomo/README	2008-10-21 00:45:37 UTC (rev 13105)
+++ seismo/3D/ADJOINT_TOMO/measure_adj/scripts_tomo/README	2008-10-21 01:21:15 UTC (rev 13106)
@@ -5,3 +5,7 @@
 For matlab scripts to summarize the misfit function values, see 
 
 /ADJOINT_TOMO/iterate_adj/matlab/compute_misfit.m
+
+See main README for details.
+
+-------------

Added: seismo/3D/ADJOINT_TOMO/measure_adj/scripts_tomo/combine_2_adj_src.pl
===================================================================
--- seismo/3D/ADJOINT_TOMO/measure_adj/scripts_tomo/combine_2_adj_src.pl	                        (rev 0)
+++ seismo/3D/ADJOINT_TOMO/measure_adj/scripts_tomo/combine_2_adj_src.pl	2008-10-21 01:21:15 UTC (rev 13106)
@@ -0,0 +1,90 @@
+#!/usr/bin/perl -w
+
+#--------------------------------------------------------------------
+# combine_2_adj_src.pl
+# Qinya Liu, 05-May-2007
+#
+# This script combines two sets of adjoint sources (for example, P wave time windows
+# and surface wave time windows), and outputs the new adjoint sources, along with
+# a new STATIONS file to be used.
+#
+# To remove the cc label on files:
+#   mv_files.pl "*.cc.adj" "*.adj"
+#
+# CALLED BY: combine_2_adj_src_all.pl
+#
+#--------------------------------------------------------------------
+
+if (@ARGV != 5) {die("Usage: combine_2_adj_src.pl DIR_1 DIR_2 DIR_NEW type1(cc,ik,mtm) type2(cc,ik,mtm)\n");}
+
+$dir1 = $ARGV[0];
+$dir2 = $ARGV[1];
+
+$dir_new = $ARGV[2];
+$type1 = $ARGV[3];
+$type2 = $ARGV[4];
+
+$sta1 = "$dir1/STATIONS_ADJOINT";
+$sta2 = "$dir2/STATIONS_ADJOINT";
+$sta_new = "$dir_new/STATIONS_ADJOINT";
+if (not -f $sta1 or not -f $sta2) {die("Check if $sta1 and $sta2 exist or not\n");}
+if (not -d $dir_new) {system("mkdir $dir_new");}
+
+# open STATIONS file 1
+open(FILE,"$sta1");
+(@sta) = <FILE>;    # first line is the number of stations
+close(FILE);
+for ($i=1; $i<@sta; $i++){
+  ($sta,$nt,$lat,$lon,$dep,$bur) = split(" ",$sta[$i]);
+  $adj{$sta}{num} = 1;
+  $adj{$sta}{net} = "$nt";
+  $adj{$sta}{info} = "$nt $lat $lon $dep $bur";
+  @files = glob("$dir1/$sta.$nt.BH?.*adj");
+  if (@files == 0) {print("Check if $dir1/$sta.$nt.BH?.*adj exist or not\n");}
+}
+
+# open STATIONS file 2
+open(FILE,"$sta2");
+(@sta) = <FILE>;    # first line is the number of stations
+close(FILE);
+for ($i=1; $i<@sta; $i++){
+  ($sta,$nt,$lat,$lon,$dep,$bur) = split(" ",$sta[$i]);
+  if (not defined $adj{$sta}{num}) {
+    $adj{$sta}{num} = 1;
+    $adj{$sta}{net} = "$nt";
+    $adj{$sta}{info} = "$nt $lat $lon $dep $bur";}
+  else {$adj{$sta}{num} ++ ; 
+        # NOTE: this crashes if HAST.TA and HAST.BK are included
+	if ($nt ne $adj{$sta}{net}) {die("Check if network name same for $sta\n");}
+  }
+  @files = glob("$dir2/$sta.$nt.BH?.*adj");
+  if (@files == 0) {print("Check if $dir2/$sta.$nt.BH?.*adj exist or not\n");}
+}
+
+
+open(FILE,">$dir_new/sta.tmp"); $nsta = 0;
+foreach $sta (keys %adj) {
+#foreach $sta ("TCF") {
+  $net = $adj{$sta}{net}; $nsta ++ ;
+  print "$nsta, $sta, $net\n";
+  print FILE "$sta $adj{$sta}{info} \n";
+  if ($adj{$sta}{num} > 1) {
+    # add up two adjoint sources
+    foreach $comp ("BHE","BHN","BHZ") {
+      system("paste $dir1/$sta.$net.$comp.$type1.adj $dir2/$sta.$net.$comp.$type2.adj | awk '{print \$1, \$2+\$4}' > $dir_new/$sta.$net.$comp.adj");
+#      print "paste $dir1/$sta.$net.$comp.$type1.adj $dir2/$sta.$net.$comp.$type2.adj | awk '{print \$1, \$2+\$4}' > $dir_new/$sta.$net.$comp.adj\n";
+    }
+  }else{
+    # copy over the adjoint source
+    foreach $comp ("BHE","BHN","BHZ") {
+       system("cp -f $dir1/$sta.$net.$comp.$type1.adj  $dir_new/$sta.$net.$comp.adj >& /dev/null");
+       system("cp -f $dir2/$sta.$net.$comp.$type2.adj  $dir_new/$sta.$net.$comp.adj >& /dev/null");
+     }
+  }
+}
+close(FILE);
+
+print "\n number of stations in new STATIONS file should be $nsta\n";
+system(" echo $nsta > $sta_new; cat $dir_new/sta.tmp >> $sta_new");
+
+#----------------------------


Property changes on: seismo/3D/ADJOINT_TOMO/measure_adj/scripts_tomo/combine_2_adj_src.pl
___________________________________________________________________
Name: svn:executable
   + *

Added: seismo/3D/ADJOINT_TOMO/measure_adj/scripts_tomo/combine_2_adj_src_all.pl
===================================================================
--- seismo/3D/ADJOINT_TOMO/measure_adj/scripts_tomo/combine_2_adj_src_all.pl	                        (rev 0)
+++ seismo/3D/ADJOINT_TOMO/measure_adj/scripts_tomo/combine_2_adj_src_all.pl	2008-10-21 01:21:15 UTC (rev 13106)
@@ -0,0 +1,133 @@
+#!/usr/bin/perl -w
+
+#-----------------------------------
+# Carl Tape, 03-Oct-2008
+# combine_2_adj_src_all.pl
+#
+# This script calls combine_adj_src.pl to plot make composite adjoint sources.
+# for a set of events.
+# 
+# EXAMPLE:
+#    combine_2_adj_src_all.pl 2/30 6/30 cc cc m07
+#
+#-----------------------------------
+
+if (@ARGV < 5) {die("Usage: combine_2_adj_src_all.pl Tmin Tmax tag1 tag2 model iplot\n")}
+($Ts1,$Ts2,$tag1,$tag2,$smodel) = @ARGV;
+
+$pwd = $ENV{PWD};
+
+($Tmin1,$Tmax1) = split("/",$Ts1);
+($Tmin2,$Tmax2) = split("/",$Ts2);
+$Ttag1 = sprintf("T%3.3i_T%3.3i",$Tmin1,$Tmax1);
+$Ttag2 = sprintf("T%3.3i_T%3.3i",$Tmin2,$Tmax2);
+
+# list of event IDs
+#$file_eids = "/net/sierra/raid1/carltape/results/SOURCES/eid_run";     # favorites
+$file_eids = "/net/sierra/raid1/carltape/results/SOURCES/socal_10/EIDs_only_eid";
+if (not -f $file_eids) {die("\n check if $file_eids exists\n")}
+open(IN,$file_eids); @eids = <IN>; $nevent = @eids;
+
+# run directory
+$dir_run = "/net/sierra/raid1/carltape/socal/socal_3D/RUNS";
+if (not -e $dir_run) {die("check if $dir_run exist or not\n")}
+
+if (0==1) {
+  for ($i = 1; $i <= $nevent; $i = $i+1) {
+    $eid = $eids[$i-1]; chomp($eid);
+    print "$i -- $eid\n";
+  }
+  die("testing");
+}
+
+#----------------------------------------------------
+
+#$nevent = 5;
+
+# write the C-shell script to file
+$cshfile = "combine_2_adj_src_all.csh";
+print "\nWriting to $cshfile ...\n";
+open(CSH,">$cshfile");
+
+# loop over all events
+$k = 0;
+$imin = 1; $imax = $nevent;   # default
+#$imin = 1; $imax = 100;
+#$imin = 177; $imax = $imin;
+
+for ($i = $imin; $i <= $imax; $i = $i+1) {
+
+  $eid = $eids[$i-1]; chomp($eid);
+  $ftag = "${eid}_${sTmin1}";
+
+  print "\n------------------------------";
+  print "\n $i, $eid";
+  print CSH "echo $i, $eid\n";
+
+  # directories
+  $dir_run_eid = "${dir_run}/${eid}/${smodel}";        # note EID
+  $dir_meas1 = "${dir_run_eid}/MEASURE_${Ttag1}";
+  $dir_meas2 = "${dir_run_eid}/MEASURE_${Ttag2}";
+  $dir_adj1 = "${dir_meas1}/ADJOINT_${Ttag1}";
+  $dir_adj2 = "${dir_meas2}/ADJOINT_${Ttag2}";
+
+  # name of stations file
+  $sta_file1 = "${dir_adj1}/STATIONS_ADJOINT";
+  $sta_file2 = "${dir_adj2}/STATIONS_ADJOINT";
+  
+  # combined output directory
+  $odir = "${dir_run_eid}/ADJOINT_all";
+
+  # check if the combined adjoint sources have already been run
+  if ( -e $odir ) {
+    print " --> $odir already exists\n";
+
+  } else {
+
+    if ( (-f $sta_file1) && (-f $sta_file2) ) {
+      print " --> both STATIONS_ADJOINT files exist\n";
+
+    #if ( -f $sta_file1 || -f $sta_file2) {
+    #  print " --> at least one STATIONS_ADJOINT file exists";
+
+      # make output directory
+      print CSH "rm -rf $odir\n mkdir $odir\n";
+
+      if ( (-f $sta_file1) && (-f $sta_file2) ) {
+	# Case 1: both STATIONS_ADJOINT files exist: execute combine_adj_src.pl
+	print CSH "echo running combine_adj_src.pl...\n";
+	print CSH "combine_adj_src.pl $dir_adj1 $dir_adj2 $odir $tag1 $tag2\n";
+
+      } else {
+
+	# Case 2: one STATIONS_ADJOINT file: move files into output directory
+
+        # NOTE: mv_files.pl DOES NOT SEEM TO WORK FOR THE LONG FILE NAMES (06-FEB-2008)
+	print CSH "echo copying adjoint sources from one directory...\n";
+	print CSH "echo CHECK THAT THE FILE NAME EXTENSIONS HAVE BEEN REMOVED...\n";
+	if ( -f $sta_file1 ) {
+	  print CSH "cp ${dir_adj1}/* $odir\n";
+	  print CSH "mv_files.pl -x \"$odir/*.cc.adj\" \"$odir/*.adj\"\n";
+
+	} elsif ( -f $sta_file2 ) {
+	  print CSH "cp ${dir_adj2}/* $odir\n";
+	  print CSH "mv_files.pl -x \"$odir/*.mtm.adj\" \"$odir/*.adj\"\n";
+	}
+      }
+
+    } else {
+      # Case 3: neither STATIONS_ADJOINT exists
+      print " --> neither STATIONS_ADJOINT file exists";
+    }
+
+  }
+
+}
+
+#-----------------------------------------
+close(CSH);
+#system("csh -f $cshfile");
+
+print "\n\n";
+
+#================================================


Property changes on: seismo/3D/ADJOINT_TOMO/measure_adj/scripts_tomo/combine_2_adj_src_all.pl
___________________________________________________________________
Name: svn:executable
   + *

Added: seismo/3D/ADJOINT_TOMO/measure_adj/scripts_tomo/combine_3_adj_src.pl
===================================================================
--- seismo/3D/ADJOINT_TOMO/measure_adj/scripts_tomo/combine_3_adj_src.pl	                        (rev 0)
+++ seismo/3D/ADJOINT_TOMO/measure_adj/scripts_tomo/combine_3_adj_src.pl	2008-10-21 01:21:15 UTC (rev 13106)
@@ -0,0 +1,134 @@
+#!/usr/bin/perl -w
+
+#--------------------------------------------------------------------
+# combine_3_adj_src.pl
+# Qinya Liu, Carl Tape, 03-Oct-2008
+#
+# This script combines three sets of adjoint sources (for example, three
+# different bandpassed ranges), and outputs the new adjoint sources,
+# along with a new STATIONS_ADJOINT file to be used.
+#
+# To remove the cc label on files:
+#   mv_files.pl "*.cc.adj" "*.adj"
+#
+# CALLED BY: combine_3_adj_src_all.pl
+#
+#--------------------------------------------------------------------
+
+if (@ARGV != 7) {die("Usage: combine_3_adj_src.pl DIR_1 DIR_2 DIR_3 DIR_NEW type1(cc,ik,mtm) type2 type3\n");}
+
+$dir1 = $ARGV[0];
+$dir2 = $ARGV[1];
+$dir3 = $ARGV[2];
+
+$dir_new = $ARGV[3];
+$type1 = $ARGV[4];
+$type2 = $ARGV[5];
+$type3 = $ARGV[6];
+
+$sta1 = "$dir1/STATIONS_ADJOINT";
+$sta2 = "$dir2/STATIONS_ADJOINT";
+$sta3 = "$dir3/STATIONS_ADJOINT";
+$sta_new = "$dir_new/STATIONS_ADJOINT";
+if (not -f $sta1) {die("Check if $sta1 exist or not\n");}
+if (not -f $sta2) {die("Check if $sta2 exist or not\n");}
+if (not -f $sta3) {die("Check if $sta3 exist or not\n");}
+if (not -d $dir_new) {system("mkdir $dir_new");}
+
+#--------------
+
+# open STATIONS file 1 -- this becomes the initial STATIONS list
+open(FILE,"$sta1");
+(@sta) = <FILE>;    # first line is the number of stations
+close(FILE);
+for ($i=1; $i<@sta; $i++){
+  ($sta,$nt,$lat,$lon,$dep,$bur) = split(" ",$sta[$i]);
+  $adj{$sta}{num} = 1;
+  $adj{$sta}{net} = "$nt";
+  $adj{$sta}{info} = "$nt $lat $lon $dep $bur";
+  @files = glob("$dir1/$sta.$nt.BH?.*adj");
+  if (@files == 0) {print("Check if $dir1/$sta.$nt.BH?.*adj exist or not\n");}
+}
+
+# open STATIONS file 2 -- update current STATIONS list with new stations
+open(FILE,"$sta2");
+(@sta) = <FILE>;    # first line is the number of stations
+close(FILE);
+for ($i=1; $i<@sta; $i++){
+  ($sta,$nt,$lat,$lon,$dep,$bur) = split(" ",$sta[$i]);
+  if (not defined $adj{$sta}{num}) {
+    $adj{$sta}{num} = 1;
+    $adj{$sta}{net} = "$nt";
+    $adj{$sta}{info} = "$nt $lat $lon $dep $bur";}
+  else {$adj{$sta}{num} ++ ; 
+        # NOTE: this crashes if HAST.TA and HAST.BK are included
+	if ($nt ne $adj{$sta}{net}) {die("Check if network name same for $sta\n");}
+  }
+  @files = glob("$dir2/$sta.$nt.BH?.*adj");
+  if (@files == 0) {print("Check if $dir2/$sta.$nt.BH?.*adj exist or not\n");}
+}
+
+# open STATIONS file 3 -- update current STATIONS list with new stations
+open(FILE,"$sta3");
+(@sta) = <FILE>;    # first line is the number of stations
+close(FILE);
+for ($i=1; $i<@sta; $i++){
+  ($sta,$nt,$lat,$lon,$dep,$bur) = split(" ",$sta[$i]);
+  if (not defined $adj{$sta}{num}) {
+    $adj{$sta}{num} = 1;
+    $adj{$sta}{net} = "$nt";
+    $adj{$sta}{info} = "$nt $lat $lon $dep $bur";}
+  else {$adj{$sta}{num} ++ ; 
+        # NOTE: this crashes if HAST.TA and HAST.BK are included
+	if ($nt ne $adj{$sta}{net}) {die("Check if network name same for $sta\n");}
+  }
+  @files = glob("$dir3/$sta.$nt.BH?.*adj");
+  if (@files == 0) {print("Check if $dir3/$sta.$nt.BH?.*adj exist or not\n");}
+}
+
+#--------------
+# make new STATIONS_ADJOINT file, and sum the adjoint sources
+
+open(FILE,">$dir_new/sta.tmp"); $nsta = 0;
+foreach $sta (keys %adj) {
+#foreach $sta ("TCF") {
+  $net = $adj{$sta}{net}; $nsta ++ ;
+  $nmatch = $adj{$sta}{num};
+  print "$nsta, $sta, $net, $nmatch\n";
+  print FILE "$sta $adj{$sta}{info} \n";
+
+  foreach $comp ("BHE","BHN","BHZ") {
+
+    $snc = "$sta.$net.$comp";
+    $afile1 = "$dir1/$snc.$type1.adj";
+    $afile2 = "$dir2/$snc.$type2.adj";
+    $afile3 = "$dir3/$snc.$type3.adj";
+
+    if ($nmatch == 3) {		# sum the three adjoint sources
+      system("paste $afile1 $afile2 $afile3 | awk '{print \$1, \$2+\$4+\$6}' > $dir_new/$snc.adj");
+    
+    } elsif ($nmatch == 2) {	# sum the two adjoint sources
+      if (-f $afile1 && -f $afile2) {
+        system("paste $afile1 $afile2 | awk '{print \$1, \$2+\$4}' > $dir_new/$snc.adj");
+      } elsif (-f $afile1 && -f $afile3) {
+	system("paste $afile1 $afile3 | awk '{print \$1, \$2+\$4}' > $dir_new/$snc.adj");
+      } elsif (-f $afile2 && -f $afile3) {
+	system("paste $afile2 $afile3 | awk '{print \$1, \$2+\$4}' > $dir_new/$snc.adj");
+      }
+    
+    } elsif ($nmatch == 1) {    # copy over the lone-station adjoint sources
+      if (-f $afile1) {system("cp -f $afile1  $dir_new/$snc.adj >& /dev/null");}
+      if (-f $afile2) {system("cp -f $afile2  $dir_new/$snc.adj >& /dev/null");}
+      if (-f $afile3) {system("cp -f $afile3  $dir_new/$snc.adj >& /dev/null");}
+
+    } else {			# error
+      die("combine_3_adj_src.pl: NO MATCHES\n");
+    }
+  }
+}
+close(FILE);
+
+print "\n number of stations in new STATIONS file should be $nsta\n";
+system(" echo $nsta > $sta_new; cat $dir_new/sta.tmp >> $sta_new");
+
+#----------------------------


Property changes on: seismo/3D/ADJOINT_TOMO/measure_adj/scripts_tomo/combine_3_adj_src.pl
___________________________________________________________________
Name: svn:executable
   + *

Added: seismo/3D/ADJOINT_TOMO/measure_adj/scripts_tomo/combine_3_adj_src_all.pl
===================================================================
--- seismo/3D/ADJOINT_TOMO/measure_adj/scripts_tomo/combine_3_adj_src_all.pl	                        (rev 0)
+++ seismo/3D/ADJOINT_TOMO/measure_adj/scripts_tomo/combine_3_adj_src_all.pl	2008-10-21 01:21:15 UTC (rev 13106)
@@ -0,0 +1,107 @@
+#!/usr/bin/perl -w
+
+#-----------------------------------
+# Carl Tape, 03-Oct-2008
+# combine_3_adj_src_all.pl
+#
+# This script calls combine_adj_src.pl to plot make composite adjoint sources.
+# for a set of events.
+# 
+# EXAMPLE:
+#    combine_3_adj_src_all.pl 2/30 3/30 6/30 cc cc cc m11
+#
+#-----------------------------------
+
+if (@ARGV < 7) {die("Usage: combine_3_adj_src_all.pl Tmin Tmax tag1 tag2 tag3 smodel\n")}
+($Ts1,$Ts2,$Ts3,$tag1,$tag2,$tag3,$smodel) = @ARGV;
+
+$pwd = $ENV{PWD};
+
+($Tmin1,$Tmax1) = split("/",$Ts1);
+($Tmin2,$Tmax2) = split("/",$Ts2);
+($Tmin3,$Tmax3) = split("/",$Ts3);
+$Ttag1 = sprintf("T%3.3i_T%3.3i",$Tmin1,$Tmax1);
+$Ttag2 = sprintf("T%3.3i_T%3.3i",$Tmin2,$Tmax2);
+$Ttag3 = sprintf("T%3.3i_T%3.3i",$Tmin3,$Tmax3);
+
+# list of event IDs
+$file_eids = "/net/sierra/raid1/carltape/results/EID_LISTS/kernels_run_${smodel}";  # favorites
+#$file_eids = "/net/sierra/raid1/carltape/results/SOURCES/socal_09/EIDs_only_eid";
+if (not -f $file_eids) {die("\n check if $file_eids exists\n")}
+open(IN,$file_eids); @eids = <IN>; $nevent = @eids;
+
+# run directory
+$dir_run = "/net/sierra/raid1/carltape/socal/socal_3D/RUNS";
+if (not -e $dir_run) {die("check if $dir_run exist or not\n")}
+
+if (0==1) {
+  for ($i = 1; $i <= $nevent; $i = $i+1) {
+    $eid = $eids[$i-1]; chomp($eid);
+    print "$i -- $eid\n";
+  }
+  die("testing");
+}
+
+#----------------------------------------------------
+
+#$nevent = 5;
+
+# write the C-shell script to file
+$cshfile = "combine_3_adj_src_all.csh";
+print "\nWriting to $cshfile ...\n";
+open(CSH,">$cshfile");
+
+# loop over all events
+$k = 0;
+$imin = 1; $imax = $nevent;   # default
+#$imin = 1; $imax = 29;
+#$imin = 22; $imax = $imin;
+
+for ($i = $imin; $i <= $imax; $i = $i+1) {
+
+  $eid = $eids[$i-1]; chomp($eid);
+  print "------------------------------\n";
+  print "$i, $eid\n";
+  print CSH "echo $i, $eid\n";
+
+  # directories
+  $dir_run_eid = "${dir_run}/${eid}/${smodel}";        # note EID
+  $dir_meas1 = "${dir_run_eid}/MEASURE_${Ttag1}";
+  $dir_meas2 = "${dir_run_eid}/MEASURE_${Ttag2}";
+  $dir_meas3 = "${dir_run_eid}/MEASURE_${Ttag3}";
+  $dir_adj1 = "${dir_meas1}/ADJOINT_${Ttag1}";
+  $dir_adj2 = "${dir_meas2}/ADJOINT_${Ttag2}";
+  $dir_adj3 = "${dir_meas3}/ADJOINT_${Ttag3}";
+
+  # name of stations file
+  $sta_file1 = "${dir_adj1}/STATIONS_ADJOINT";
+  $sta_file2 = "${dir_adj2}/STATIONS_ADJOINT";
+  $sta_file3 = "${dir_adj3}/STATIONS_ADJOINT";
+  
+  # combined output directory
+  $odir = "${dir_run_eid}/ADJOINT_all";
+
+  # check if the combined adjoint sources have already been run
+  if ( -e $odir ) {
+    print " --> $odir already exists\n";
+
+  } else {
+    if ( (-f $sta_file1 && -f $sta_file2) && (-f $sta_file3) ) {
+      print " --> all three STATIONS_ADJOINT files exist\n";
+      print CSH "echo running combine_adj_src.pl...\n";
+      print CSH "combine_3_adj_src.pl $dir_adj1 $dir_adj2 $dir_adj3 $odir $tag1 $tag2 $tag3\n";
+
+    } else {
+      print " --> all three STATIONS_ADJOINT files do NOT exist\n";
+      #die("STOPPING: all three STATIONS_ADJOINT files do NOT exist\n");
+    }
+  }
+}
+
+#-----------------------------------------
+close(CSH);
+#system("csh -f $cshfile");
+
+print "\n--> done with $cshfile\n\n";
+
+#================================================


Property changes on: seismo/3D/ADJOINT_TOMO/measure_adj/scripts_tomo/combine_3_adj_src_all.pl
___________________________________________________________________
Name: svn:executable
   + *

Deleted: seismo/3D/ADJOINT_TOMO/measure_adj/scripts_tomo/combine_adj_src_all.pl
===================================================================
--- seismo/3D/ADJOINT_TOMO/measure_adj/scripts_tomo/combine_adj_src_all.pl	2008-10-21 00:45:37 UTC (rev 13105)
+++ seismo/3D/ADJOINT_TOMO/measure_adj/scripts_tomo/combine_adj_src_all.pl	2008-10-21 01:21:15 UTC (rev 13106)
@@ -1,129 +0,0 @@
-#!/usr/bin/perl -w
-
-#-----------------------------------
-# Carl Tape, 25-July-2008
-# combine_adj_src_all.pl
-#
-# This script calls combine_adj_src.pl to plot make composite adjoint sources.
-# for a set of events.
-# 
-# EXAMPLE:
-#    combine_adj_src_all.pl 2 6 cc cc m06
-#
-#-----------------------------------
-
-if (@ARGV < 5) {die("Usage: combine_adj_src_all.pl Tmin Tmax tag1 tag2 model iplot\n")}
-($Tmin1,$Tmin2,$tag1,$tag2,$smodel) = @ARGV;
-
-$pwd = $ENV{PWD};
-
-#($Tmin1,$Tmin2) = split("/",$Ts);
-$sTmin1 = sprintf("T%3.3i",$Tmin1);
-$sTmin2 = sprintf("T%3.3i",$Tmin2);
-
-# list of event IDs
-#$file_eids = "/net/sierra/raid1/carltape/results/SOURCES/eid_run";     # favorites
-$file_eids = "/net/sierra/raid1/carltape/results/SOURCES/socal_9/EIDs_only_eid";
-if (not -f $file_eids) {die("\n check if $file_eids exists\n")}
-open(IN,$file_eids); @eids = <IN>; $nevent = @eids;
-
-# run directory
-$dir_run = "/net/sierra/raid1/carltape/socal/socal_3D/RUNS";
-if (not -e $dir_run) {die("check if $dir_run exist or not\n")}
-
-if (0==1) {
-  for ($i = 1; $i <= $nevent; $i = $i+1) {
-    $eid = $eids[$i-1]; chomp($eid);
-    print "$i -- $eid\n";
-  }
-  die("testing");
-}
-
-#----------------------------------------------------
-
-#$nevent = 5;
-
-# write the C-shell script to file
-$cshfile = "combine_adj_src_all.csh";
-print "\nWriting to $cshfile ...\n";
-open(CSH,">$cshfile");
-
-# loop over all events
-$k = 0;
-$imin = 1; $imax = $nevent;   # default
-#$imin = 1; $imax = 100;
-#$imin = 156; $imax = $imin;
-
-for ($i = $imin; $i <= $imax; $i = $i+1) {
-
-  $eid = $eids[$i-1]; chomp($eid);
-  $ftag = "${eid}_${sTmin1}";
-
-  print "\n------------------------------";
-  print "\n $i, $eid";
-  print CSH "echo $i, $eid\n";
-
-  # directories
-  $dir_run_eid = "${dir_run}/${eid}/${smodel}";        # note EID
-  $dir_meas1 = "${dir_run_eid}/MEASURE_${sTmin1}";
-  $dir_meas2 = "${dir_run_eid}/MEASURE_${sTmin2}";
-  $dir_adj1 = "${dir_meas1}/ADJOINT_${sTmin1}";
-  $dir_adj2 = "${dir_meas2}/ADJOINT_${sTmin2}";
-
-  # name of stations file
-  $sta_file1 = "${dir_adj1}/STATIONS_ADJOINT";
-  $sta_file2 = "${dir_adj2}/STATIONS_ADJOINT";
-  
-  # combined output directory
-  $odir = "${dir_run_eid}/ADJOINT_all";
-
-  # check if the combined adjoint sources have already been run
-  if ( -e $odir ) {
-    print " --> $odir already exists";
-
-  } else {
-    if ( -f $sta_file1 && -f $sta_file2) {
-    #if ( -f $sta_file1 || -f $sta_file2) {
-      print " --> at least one STATIONS_ADJOINT file exists";
-
-      # make output directory
-      print CSH "rm -rf $odir\n mkdir $odir\n";
-
-      if ( -f $sta_file1 && -f $sta_file2) {
-	# Case 1: both STATIONS_ADJOINT files exist: execute combine_adj_src.pl
-	print CSH "echo running combine_adj_src.pl...\n";
-	print CSH "combine_adj_src.pl $dir_adj1 $dir_adj2 $odir $tag1 $tag2\n";
-
-      } else {
-
-	# Case 2: one STATIONS_ADJOINT file: move files into output directory
-
-        # NOTE: mv_files.pl DOES NOT SEEM TO WORK FOR THE LONG FILE NAMES (06-FEB-2008)
-	print CSH "echo copying adjoint sources from one directory...\n";
-	print CSH "echo CHECK THAT THE FILE NAME EXTENSIONS HAVE BEEN REMOVED...\n";
-	if ( -f $sta_file1 ) {
-	  print CSH "cp ${dir_adj1}/* $odir\n";
-	  print CSH "mv_files.pl -x \"$odir/*.cc.adj\" \"$odir/*.adj\"\n";
-
-	} elsif ( -f $sta_file2 ) {
-	  print CSH "cp ${dir_adj2}/* $odir\n";
-	  print CSH "mv_files.pl -x \"$odir/*.mtm.adj\" \"$odir/*.adj\"\n";
-	}
-      }
-
-    } else {
-      # Case 3: neither STATIONS_ADJOINT exists
-      print " --> neither STATIONS_ADJOINT file exists";
-    }
-
-  }
-
-}
-
-#-----------------------------------------
-close(CSH);
-#system("csh -f $cshfile");
-
-print "\n\n";
-
-#================================================

Modified: seismo/3D/ADJOINT_TOMO/measure_adj/scripts_tomo/prepare_mt_measure_adj.pl
===================================================================
--- seismo/3D/ADJOINT_TOMO/measure_adj/scripts_tomo/prepare_mt_measure_adj.pl	2008-10-21 00:45:37 UTC (rev 13105)
+++ seismo/3D/ADJOINT_TOMO/measure_adj/scripts_tomo/prepare_mt_measure_adj.pl	2008-10-21 01:21:15 UTC (rev 13106)
@@ -4,7 +4,7 @@
 #
 #  prepare_mt_measure_adj.pl
 #  Carl Tape
-#  07-June-2008
+#  01-Oct-2008
 #
 #  This script prepares the data and synthetics for running in the measurement code.
 #  At the moment, it is somewhat tailored to the SoCal dataset.
@@ -37,11 +37,11 @@
 # 0: grab everything from a general output directory
 #$iwindow = 0;
 
-  # label for directory
-  ($Tmin,$Tmax) = split("/",$Ts);
-  $sTmin = sprintf("T%3.3i",$Tmin);
-  $sTmax = sprintf("T%3.3i",$Tmax);
-  $Ttag = "${sTmin}_${sTmax}";
+# label for directory
+($Tmin,$Tmax) = split("/",$Ts);
+$sTmin = sprintf("T%3.3i",$Tmin);
+$sTmax = sprintf("T%3.3i",$Tmax);
+$Ttag = "${sTmin}_${sTmax}";
 
 if ($itest == 0) {
   $dir_syn  = "SYN"; $dir_data = "DATA"; $dir_meas = "MEASURE";
@@ -53,7 +53,7 @@
 # directories for data, synthetics, and window files : MUST BE CHANGED FOR EACH USER
 if ($iwindow==1) {
   # windowing code run directory
-  $dir_win_run = "/net/denali/scratch1/carltape/svn/cig/seismo/3D/automeasure_data/socal_3Dsyn_dat";
+  $dir_win_run = "/net/denali/scratch1/carltape/svn/cig/seismo/3D/flexwin_run";
   $dir_win_run_syn  = "${dir_win_run}/${dir_syn}";
   $dir_win_run_data = "${dir_win_run}/${dir_data}";
   $win_in = "${dir_win_run}/${dir_meas}/MEASUREMENT_WINDOWS";
@@ -62,10 +62,10 @@
 } else {
   $dir0 = "/net/sierra/raid1/carltape/socal/socal_3D/RUNS/$eid/$smodel";
 
-  $dir1 = "$dir0/WINDOW_${sTmin}";
+  $dir1 = "$dir0/WINDOW_${Ttag}";
   $dir_win_run_syn  = "$dir1/SYN";
   $dir_win_run_data = "$dir1/DATA";
-  $win_in = "$dir1/MEASUREMENT_WINDOWS_${eid}_${sTmin}";
+  $win_in = "$dir1/MEASUREMENT_WINDOWS_${eid}_${Ttag}_${smodel}";
 
   #$dir0 = "/net/sierra/raid1/carltape/socal/socal_3D";
   #$dir_win_run_syn  = "$dir0/SYN/model_m0/${eid}/PROCESSED";
@@ -99,7 +99,7 @@
 
 # CMTSOLUTION file
 #$dir_cmt = "/net/sierra/raid1/carltape/results/SOURCES/socal_6/CMT_files_post_inverted";
-$dir_cmt = "/net/sierra/raid1/carltape/results/SOURCES/socal_9/CMT_files_pre_inverted";
+$dir_cmt = "/net/sierra/raid1/carltape/results/SOURCES/socal_10/CMT_files_pre_inverted";
 $cmtfile = "${dir_cmt}/CMTSOLUTION_${eid}";
 if (not -f $cmtfile) {die("check if cmtfile $cmtfile exist or not\n")}
 print CSH "\\rm CMTSOLUTION*\n";
@@ -134,18 +134,19 @@
   # remove any old plots in PLOTS directory
   print CSH "\\rm PLOTS/*pdf PLOTS/*jpg PLOTS/*ps\n";
 
-  # make a set of SYNTHETIC stations lists sorted by: station, distance, azimuth
-  @tags = ("sta","dist","az");
-  $fall = "${syn_dir_plot}/*";
-  for ($ij = 1; $ij <= 3; $ij = $ij+1) {
-    $tag = $tags[$ij-1];
-    $ofile = "PLOTS/STATIONS_${tag}";
-    print CSH "\\rm -rf $ofile\n";
-    print CSH "saclst kstnm knetwk dist az f $fall | awk '{print \$2\".\"\$3,\$4,\$5}' | uniq | sort -g -k $ij > $ofile\n";
-  }
+#  # make a set of SYNTHETIC stations lists sorted by: station, distance, azimuth
+#  @tags = ("sta","dist","az");
+#  $fall = "${syn_dir_plot}/*";
+#  for ($ij = 1; $ij <= 3; $ij = $ij+1) {
+#    $tag = $tags[$ij-1];
+#    $ofile = "PLOTS/STATIONS_${tag}";
+#    print CSH "\\rm -rf $ofile\n";
+#    print CSH "saclst kstnm knetwk dist az f $fall | awk '{print \$2\".\"\$3,\$4,\$5}' | uniq | sort -g -k $ij > $ofile\n";
+#  }
+
 }
 
-## this version allows for flexibility for the exact name of the window file
+## this version allows for flexibility for the name of the window file
 #if ($iwindow==1) {
 #  $win_in = "${dir_win_run_meas}/MEASUREMENT*";
 #  @files = glob("${win_in}"); $nfiles = @files;

Modified: seismo/3D/ADJOINT_TOMO/measure_adj/scripts_tomo/run_mt_measure_adj.pl
===================================================================
--- seismo/3D/ADJOINT_TOMO/measure_adj/scripts_tomo/run_mt_measure_adj.pl	2008-10-21 00:45:37 UTC (rev 13105)
+++ seismo/3D/ADJOINT_TOMO/measure_adj/scripts_tomo/run_mt_measure_adj.pl	2008-10-21 01:21:15 UTC (rev 13106)
@@ -112,19 +112,13 @@
   # remove any plot files
   #print CSH "\\rm PLOTS/*pdf PLOTS/*jpg PLOTS/*ps\n";  
 
-  #$Lstart = -10;
-  #$Lend = 180;
-  #if($Tmin==2) {$Lend = 120;}
-  #$lcut = "$Lstart/$Lend";   # time interval to cut for plotting
-
   print CSH "cd PLOTS\n";
-  print CSH "plot_win_adj_all.pl -l $lcut -m ../$cmtfile -b $iboth -k $iker -a $stafile2 -d $dir_data -s $dir_syn -c $dir_recon -w MEASUREMENT.WINDOWS -i $smodel\n";
-  #print CSH "\\rm test*.pdf\n";
+  print CSH "plot_win_adj_all.pl -l $lcut -m ../$cmtfile -b $iboth -k $iker -a $stafile2 -d $dir_data -s $dir_syn -c $dir_recon -w MEASUREMENT.WINDOWS -i $smodel -j $Ts\n";
 
-  # make a single PDF file
-  $isort = 3;
-  $otag = "mt_cc_all";
-  print CSH "make_pdf_all.pl $isort $otag\n";
+#  # make a single PDF file
+#  $isort = 3;
+#  $otag = "mt_cc_all";
+#  print CSH "make_pdf_all.pl $isort $otag\n";
 
   #print CSH "/home/carltape/bin/pdcat -r *.pdf mt_cc_all.pdf\n";    # replace with make_pdf_all.pl
   print CSH "cd -\n";

Modified: seismo/3D/ADJOINT_TOMO/measure_adj/scripts_tomo/run_tomo.pl
===================================================================
--- seismo/3D/ADJOINT_TOMO/measure_adj/scripts_tomo/run_tomo.pl	2008-10-21 00:45:37 UTC (rev 13105)
+++ seismo/3D/ADJOINT_TOMO/measure_adj/scripts_tomo/run_tomo.pl	2008-10-21 01:21:15 UTC (rev 13106)
@@ -4,20 +4,25 @@
 #
 #  run_tomo.pl
 #  Carl Tape
-#  12-June-2008
+#  19-Oct-2008
 #
 #  This is the master program for running the measurement code on all the
 #  events for which the windowing code has been run.
 #
 #  EXAMPLE (from working measure_adj directory) :
-#  socal m06 -->
-#    run_tomo.pl m07 0 6/40 0.011 1/1/1  2.0/2.5/3.5/3.0 0.7/0.7/5.0/1.0 0.4/0.4 1.0
-#    run_tomo.pl m07 0 4/40 0.011 1/1/1  2.0/2.5/3.5/3.0 0.7/0.7/5.0/1.0 0.4/0.4 1.0
-#    run_tomo.pl m07 0 2/40 0.011 1/1/1 0.25/0.5/3.5/3.0 0.7/0.7/4.0/1.0 0.4/0.4 1.0
+#    run_tomo.pl m12 0 6/30 0.011 1/1/1  2.0/2.5/3.5/3.0 0.7/0.7/5.0/1.0 1.0/1.0 1.0
+#    run_tomo.pl m12 0 3/30 0.011 1/1/1 0.25/0.5/3.5/3.0 0.7/0.7/3.0/1.0 0.8/0.8 1.0
+#    run_tomo.pl m12 0 2/30 0.011 1/1/1 0.25/0.5/3.5/3.0 0.7/0.7/2.0/1.0 0.6/0.6 1.0
 #
 #  socal m00 - m04
 #    run_tomo.pl m04 0 6/40 0.011 1/1/1  2.0/2.5/3.5/3.0 0.7/0.7/8.0/1.0 0.2/0.2 0.8
 #    run_tomo.pl m04 0 2/40 0.011 1/1/1 0.25/0.5/3.5/3.0 0.7/0.7/8.0/1.0 0.2/0.2 0.5
+#
+#  socal m00 - m04, 0.2/0.2
+#  socal m05 - m08, 0.4/0.4
+#  socal m09, MAX: 4.0 pm 0.6 (2-30s), 4.0 pm 0.8 (3-30s), 5.0 pm 0.8 (6-30s)
+#  socal m10, MAX: 2.0 pm 0.6 (2-30s), 3.0 pm 0.8 (3-30s), 5.0 pm 0.8 (6-30s)
+#  socal m12, MAX: 2.0 pm 0.6 (2-30s), 3.0 pm 0.8 (3-30s), 5.0 pm 1.0 (6-30s)
 #  
 #==========================================================
 
@@ -26,27 +31,41 @@
 
 ($Tmin,$Tmax) = split("/",$Ts);
 $sTmin = sprintf("T%3.3i",$Tmin);
+$sTmax = sprintf("T%3.3i",$Tmax);
+$Ttag = "${sTmin}_${sTmax}";
 
 # cut times for plotting purposes only
 ($lcut_min,$lcut_max) = split("/",$lcut);
 
-$dir0 = "/net/sierra/raid1/carltape/socal/socal_3D/RUNS";
-$dir_all = "/net/sierra/raid1/carltape/results/MEASUREMENTS/${smodel}/ALL_${sTmin}";
-if (not -e $dir0) {die("check if $dir0 exist or not\n")}
-if (not -e $dir_all) {die("check if $dir_all exist or not\n")}
+#================================================================
+# USER INPUT
 
+$dir0 = "/net/sierra/raid1/carltape";
+$dir_out = "$dir0/socal/socal_3D/RUNS";
+$dir_pdf_eid = "$dir0/results/MEASUREMENTS/${smodel}/PDF_EID_${Ttag}";
+$dir_pdf_all = "$dir0/results/MEASUREMENTS/${smodel}/PDF_ALL_${Ttag}";
+if (not -e $dir_out) {die("check if dir_out $dir_out exist or not\n")}
+if (not -e $dir_pdf_eid) {die("check if dir_pdf_eid $dir_pdf_eid exist or not\n")}
+if (not -e $dir_pdf_all) {die("check if dir_pdf_all $dir_pdf_all exist or not\n")}
+
 # file containing event IDs, half-durations for source, and number of time-steps for simulations
-$file_eid = "/net/sierra/raid1/carltape/results/SOURCES/socal_9/EIDs_simulation_duration";
+$file_eid = "$dir0/results/SOURCES/socal_10/EIDs_simulation_duration";
 if (not -f ${file_eid}) {die("check if ${file_eid} exist or not\n")}
 open(IN,"${file_eid}"); @elines = <IN>; close(IN);
 $nevent = @elines;
 print "\n $nevent events in the list \n";
 
 # full stations file (copy into PLOTS directory)
-$file_stations = "/net/denali/home2/carltape/gmt/stations/seismic/Matlab_output/STATIONS_CALIFORNIA_TOMO_INNER_specfem";
-if (not -f ${file_stations}) {die("check if ${file_stations} exist or not\n")}
+$file_stations = "/net/denali/home1/carltape/gmt/stations/seismic/Matlab_output/STATIONS_CALIFORNIA_TOMO_INNER_specfem";
+if (not -f ${file_stations}) {die("check if file_stations ${file_stations} exist or not\n")}
 `cp $file_stations PLOTS/STATIONS_TOMO`;
 
+# sorted stations by distance (1) or azimuth (2)
+$isort = 2;
+if($isort == 1) {$sortlab = "dist"} else {$sortlab = "az"}
+
+#================================================================
+
 for ($ievent = 1; $ievent <= $nevent; $ievent++) {
    ($eindex,$eid,$Ldur_round,$nstep,$hdur,$Ldur,$mw) = split(" ",$elines[$ievent-1]);
    print "\n $ievent : $eid";
@@ -54,8 +73,8 @@
 #die("testing");
 
 $imin = 1; $imax = $nevent;
-$imin = 1; $imax = 100;
-#$imin = 204; $imax = $imin;
+#$imin = 1; $imax = 100;
+#$imin = 133; $imax = $imin;
 
 # EXAMPLE lines from EIDs_simulation_duration
 #     5  10222753     300.0     27300   0.26     332.0     4.010
@@ -73,6 +92,13 @@
    # read in a row of numbers
    ($eindex,$eid,$Ldur_round,$nstep,$hdur,$Ldur,$mw) = split(" ",$elines[$ievent-1]);
 
+   # get sorted stations file for ordering the plots
+   $file_stations_sort = "$dir0/results/SOURCES/EID_STATION_LISTS/STATIONS_by_${sortlab}_from_${eid}";
+   if (not -f ${file_stations_sort}) {die("check if file_stations_sort ${file_stations_sort} exist or not\n")}
+   print CSH "cp ${file_stations_sort} PLOTS/STATIONS_sort\n";
+   open(IN,${file_stations_sort}); @stalines = <IN>; $nrec = @stalines;
+   print "Total number of stations sorted by $sortlab is $nrec\n";
+
    print "$ievent -- $imin to $imax : $eid\n";
    print CSH "echo $ievent -- $imin to $imax : $eid\n";
 
@@ -85,16 +111,16 @@
    $tstart = -1.5*$hdur;
    $tvec = "$tstart/$dt/$nstep";
 
-   $ftag = "${eid}_${sTmin}";
+   $ftag = "${eid}_${Ttag}";
 
    # check if window file exists
-   $dir_eid = "$dir0/$eid/$smodel";
-   $dir1 = "${dir_eid}/WINDOW_${sTmin}";
-   $dir_win = "${dir_eid}/WINDOW_${sTmin}";
-   $dir_meas = "${dir_eid}/MEASURE_${sTmin}";
-   $dir_adj  = "${dir_meas}/ADJOINT_${sTmin}";
+   $dir_eid = "${dir_out}/$eid/$smodel";
+   $dir1 = "${dir_eid}/WINDOW_${Ttag}";
+   $dir_win = "${dir_eid}/WINDOW_${Ttag}";
+   $dir_meas = "${dir_eid}/MEASURE_${Ttag}";
+   $dir_adj  = "${dir_meas}/ADJOINT_${Ttag}";
 
-   $window_file = "${dir_win}/MEASUREMENT_WINDOWS_${ftag}";
+   $window_file = "${dir_win}/MEASUREMENT_WINDOWS_${ftag}_${smodel}";
 
    #if (-e $dir_adj) {
    if (-e $dir_meas) {
@@ -121,29 +147,33 @@
        # SOCAL: as of model m04, we are no longer making MT measurements
        print CSH "run_mt_measure_adj.pl $smodel 2 3 $ibp $Ts $lcut $tvec 0 1 0 $iparbools $par1 $par2 $par3\n";
 
-       $infile1 = "window_chi";           $outfile1 = "$dir_meas/${ftag}_${infile1}";
-       $infile2 = "run_file";             $outfile2 = "$dir_meas/${ftag}_${infile2}";
-       #$tfile = `ls PLOTS/*mt_cc*`; $infile3 = `basename $tfile`;
-       $infile3 = "mt_cc_all_az.pdf";     # NEED to make this flexible (make make_pdf_all.pl)
-       $outfile3 = "$dir_meas/${ftag}_${infile3}";
-       $infile4 = "MEASUREMENT.PAR";      $outfile4 = "$dir_meas/${ftag}_${infile4}";
-       $infile5 = "MEASUREMENT.WINDOWS";  $outfile5 = "$dir_meas/${ftag}_${infile5}";
-       #$infile6 = $outfile1;              $outfile6 = "$dir_meas/${ftag}_time_shifts";
-
-       print CSH "rm -rf $dir_meas; mkdir $dir_meas\n";
+       # copy run files into RUN directory
+       $infile1 = "window_chi";           $outfile1 = "${dir_meas}/${ftag}_${infile1}";
+       $infile2 = "run_file";             $outfile2 = "${dir_meas}/${ftag}_${infile2}";
+       $infile3 = "MEASUREMENT.PAR";      $outfile3 = "${dir_meas}/${ftag}_${infile3}";
+       $infile4 = "MEASUREMENT.WINDOWS";  $outfile4 = "${dir_meas}/${ftag}_${infile4}";
+                                          $outfile5 = "${dir_meas}/${ftag}_${infile4}_orig";
+       print CSH "rm -rf ${dir_meas}; mkdir ${dir_meas}\n";
        print CSH "cp $infile1 $outfile1\n";
        print CSH "cp $infile2 $outfile2\n";
-       print CSH "cp PLOTS/$infile3 $outfile3\n";
+       print CSH "cp $infile3 $outfile3\n";
        print CSH "cp $infile4 $outfile4\n";
-       print CSH "cp $infile5 $outfile5\n";
 
+       # make a single PDF, with pages sorted by azimuth or distance
+       print CSH "cd PLOTS\n";
+       print CSH "make_pdf_all.pl\n";
+       $infile5 = "${ftag}_${smodel}_ALL.pdf";
+       $outfile5 = "${dir_meas}/${infile5}";
+       print CSH "cp $infile5 $outfile5\n";        # composite PDF into RUN
+       print CSH "mv $infile5 ${dir_pdf_eid}\n";   # composite PDF into single directory
+       print CSH "mv *.pdf ${dir_pdf_all}\n";      # individual PDFs into single directory
+       print CSH "cd -\n";
+
+       # move adjoint sources into RUN directory
        print CSH "rm -rf $dir_adj\n";
-       print CSH "cp -r ADJOINT_SOURCES $dir_adj\n";
-       #print CSH "awk '{print \$15}' $infile6 > $outfile6\n";
+       #print CSH "cp -r ADJOINT_SOURCES $dir_adj\n";
+       print CSH "mv ADJOINT_SOURCES $dir_adj\nmkdir ADJOINT_SOURCES\n";
 
-       # copy another copy to a single directory
-       print CSH "cp -r $outfile3 $dir_all\n";
-
        print CSH "echo done with Event $eid -- $ievent out of $imax/$nevent\n";
      }
    }



More information about the CIG-COMMITS mailing list