[cig-commits] r12700 - in seismo/3D/ADJOINT_TOMO/flexwin/scripts/prepare_scripts: . global

alessia at geodynamics.org alessia at geodynamics.org
Fri Aug 22 08:41:07 PDT 2008


Author: alessia
Date: 2008-08-22 08:41:06 -0700 (Fri, 22 Aug 2008)
New Revision: 12700

Added:
   seismo/3D/ADJOINT_TOMO/flexwin/scripts/prepare_scripts/global/
   seismo/3D/ADJOINT_TOMO/flexwin/scripts/prepare_scripts/global/prepare_input
   seismo/3D/ADJOINT_TOMO/flexwin/scripts/prepare_scripts/global/prepare_input_test
   seismo/3D/ADJOINT_TOMO/flexwin/scripts/prepare_scripts/global/prepare_seis
Log:
added global prepare scripts

Added: seismo/3D/ADJOINT_TOMO/flexwin/scripts/prepare_scripts/global/prepare_input
===================================================================
--- seismo/3D/ADJOINT_TOMO/flexwin/scripts/prepare_scripts/global/prepare_input	                        (rev 0)
+++ seismo/3D/ADJOINT_TOMO/flexwin/scripts/prepare_scripts/global/prepare_input	2008-08-22 15:41:06 UTC (rev 12700)
@@ -0,0 +1,51 @@
+#!/bin/sh
+
+
+event_name=$1
+
+if [ ! -e PAR_FILE ] ; then 
+  echo "Need PAR_FILE present" 
+  exit 0
+fi 
+
+min_T=`grep WIN_MIN_PERIOD PAR_FILE | awk '{printf "%03d", $NF}'`
+max_T=`grep WIN_MAX_PERIOD PAR_FILE | awk '{printf "%03d",$NF}'`
+ident=${min_T}-${max_T}
+
+period_range=10-250
+
+
+DATA=/data/alessia/events_lh/${event_name}/${event_name}.${period_range}
+SYN=/data/alessia/specfem/${event_name}/${event_name}.${period_range}
+MEASURE=/data/alessia/flexwin/MEASURE/${event_name}/${event_name}.${ident}
+input=/data/alessia/flexwin/input.${event_name}.${ident}
+
+if [ ! -d $MEASURE ] ; then ( mkdir -p $MEASURE ) ; fi
+
+echo $DATA
+echo $SYN
+
+if [ -e t1 ] ; then ( rm t1 ) ; fi
+
+n=0
+for file in ${DATA}/*[ZRT].?.SAC ; do
+
+  net=`echo $file | awk -F"/" '{print $NF}' | awk -F"." '{print $7}'`
+  sta=`echo $file | awk -F"/" '{print $NF}' | awk -F"." '{print $8}'`
+  comp=`echo $file | awk -F"/" '{print $NF}' | awk -F"." '{print $10}'`
+
+  synt=${SYN}/${sta}.${net}.${comp}.semd.sac
+  out=${MEASURE}/${sta}.${net}.${comp}
+  if [ -e $synt ] ; then
+    n=`echo $n | awk '{print $n+1}'`
+    echo $file >> t1
+    echo $synt >> t1
+    echo $out >> t1
+  fi
+done
+echo $n > $input
+cat t1 >> $input
+rm t1
+
+echo "Input file for $n traces is : $input"
+


Property changes on: seismo/3D/ADJOINT_TOMO/flexwin/scripts/prepare_scripts/global/prepare_input
___________________________________________________________________
Name: svn:executable
   + *

Added: seismo/3D/ADJOINT_TOMO/flexwin/scripts/prepare_scripts/global/prepare_input_test
===================================================================
--- seismo/3D/ADJOINT_TOMO/flexwin/scripts/prepare_scripts/global/prepare_input_test	                        (rev 0)
+++ seismo/3D/ADJOINT_TOMO/flexwin/scripts/prepare_scripts/global/prepare_input_test	2008-08-22 15:41:06 UTC (rev 12700)
@@ -0,0 +1,26 @@
+#!/bin/sh
+
+if [ -e t1 ] ; then ( rm t1 ) ; fi
+
+n=0
+for file in DATA_TEST/* ; do
+
+  net=`echo $file | awk -F"." '{print $2}'`
+  sta=`echo $file | awk -F"." '{print $3}'`
+  comp=`echo $file | awk -F"." '{print $4}'`
+  #echo $net $sta $comp
+
+  synt=SYN_TEST/${sta}.${net}.${comp}.semd.sac.d
+  out=MEASURE_TEST/${sta}.${net}.${comp}
+  if [ -e $synt ] ; then
+    n=`echo $n | awk '{print $n+1}'`
+    echo $file >> t1
+    echo $synt >> t1
+    echo $out >> t1
+  fi
+done
+echo $n > input_test
+cat t1 >> input_test
+rm t1
+
+


Property changes on: seismo/3D/ADJOINT_TOMO/flexwin/scripts/prepare_scripts/global/prepare_input_test
___________________________________________________________________
Name: svn:executable
   + *

Added: seismo/3D/ADJOINT_TOMO/flexwin/scripts/prepare_scripts/global/prepare_seis
===================================================================
--- seismo/3D/ADJOINT_TOMO/flexwin/scripts/prepare_scripts/global/prepare_seis	                        (rev 0)
+++ seismo/3D/ADJOINT_TOMO/flexwin/scripts/prepare_scripts/global/prepare_seis	2008-08-22 15:41:06 UTC (rev 12700)
@@ -0,0 +1,138 @@
+#!/bin/sh
+
+event_name=$1
+period_range=10-250
+
+#########################################################################
+#
+# Notes: 
+#
+# Files must be synchronized before this step, preferably using
+# the CMTSOLUTION file for the event and the process_data.pl and
+# process_syn.pl scripts (synthetics may need to be offset if made with 
+# specfem).
+#
+# There must be only one timeseries per net/sta/comp combination.
+# Ensure a single location id, and a single fragment of record per
+# combination before running this script.
+#
+# Ensure presence of three components (ENZ) for each net/sta combination.
+#
+#########################################################################
+
+DATA=/data/alessia/events_lh/${event_name}/${event_name}.${period_range}
+SYN=/data/alessia/specfem/${event_name}/${event_name}.${period_range}
+
+echo $DATA
+echo $SYN
+
+sac=sac.mac.$$
+
+echo echo on > $sac
+echo readerr badfile fatal >> $sac
+
+# rotate horizontal components
+
+tmp_file=/tmp/tmp.$$
+ls ${DATA}/*N.?.SAC > $tmp_file 
+
+for e_file in ${DATA}/*E.?.SAC ; do
+
+  net=`echo $e_file | awk -F"/" '{print $NF}' | awk -F"." '{print $7}'`
+  sta=`echo $e_file | awk -F"/" '{print $NF}' | awk -F"." '{print $8}'`
+  e_comp=`echo $e_file | awk -F"/" '{print $NF}' | awk -F"." '{print $10}'`
+  
+  n_comp=`echo $e_comp | sed s/E/N/`
+  r_comp=`echo $e_comp | sed s/E/R/`
+  t_comp=`echo $e_comp | sed s/E/T/`
+
+  r_file=`echo $e_file | sed s/$e_comp/$r_comp/`
+  t_file=`echo $e_file | sed s/$e_comp/$t_comp/`
+
+  synt_e=${SYN}/${sta}.${net}.${e_comp}.semd.sac
+  synt_n=${SYN}/${sta}.${net}.${n_comp}.semd.sac
+  synt_r=${SYN}/${sta}.${net}.${r_comp}.semd.sac
+  synt_t=${SYN}/${sta}.${net}.${t_comp}.semd.sac
+
+  # check corresponding N file exists
+  n_file=`grep "\.$sta\." $tmp_file | grep "\.$n_comp\." | grep "\.$net\."`
+  nchar=`echo $n_file | wc -c`
+  if [ $nchar -eq 1 ] ; then 
+    echo "No N component corresponding to $e_file.  Exiting" 
+    exit 
+  fi
+
+  # adapt the N component to the length of the E component (data)
+  echo "r $n_file" >> $sac
+  echo rtrend >> $sac
+  echo taper >> $sac
+  echo w over >> $sac
+  echo "r $e_file" >> $sac
+  echo "setbb btime &1,b" >> $sac
+  echo "setbb npoints &1,npts" >> $sac
+  echo cuterr fillz >> $sac
+  echo "cut %btime n %npoints" >> $sac
+  echo r $n_file >> $sac
+  echo cut off >> $sac
+  echo w over >> $sac
+
+  # adapt the N component to the length of the E component (synth)
+  echo "r $synt_n" >> $sac
+  echo rtrend >> $sac
+  echo taper >> $sac
+  echo w over >> $sac
+  echo "r $synt_e" >> $sac
+  echo "setbb btime &1,b" >> $sac
+  echo "setbb npoints &1,npts" >> $sac
+  echo cuterr fillz >> $sac
+  echo "cut %btime n %npoints" >> $sac
+  echo r $synt_n >> $sac
+  echo cut off >> $sac
+  echo w over >> $sac
+
+
+  # rotate both components of data
+  echo "r $n_file $e_file" >> $sac
+  echo "rot to gcp"        >> $sac
+  echo "w $r_file $t_file" >> $sac
+
+  # rotate both components of synthetic
+  echo "r $synt_n $synt_e" >> $sac
+  echo "rot to gcp"        >> $sac
+  echo "w $synt_r $synt_t" >> $sac
+  
+done
+rm $tmp_file
+
+
+# cut and fill the synthetic to match the start and end time of the data
+for file in ${DATA}/*[ZRT].?.SAC ; do
+
+  net=`echo $file | awk -F"/" '{print $NF}' | awk -F"." '{print $7}'`
+  sta=`echo $file | awk -F"/" '{print $NF}' | awk -F"." '{print $8}'`
+  comp=`echo $file | awk -F"/" '{print $NF}' | awk -F"." '{print $10}'`
+
+  synt=${SYN}/${sta}.${net}.${comp}.semd.sac
+  #echo $synt
+
+  if [ -e $synt ] ; then
+    echo r $file >> $sac
+    echo rtrend >> $sac
+    echo taper >> $sac
+    echo w over >> $sac
+    echo r $file $synt >> $sac
+    echo "setbb btime &1,b" >> $sac
+    echo "setbb npoints &1,npts" >> $sac
+    echo cuterr fillz >> $sac
+    echo "cut %btime n %npoints" >> $sac
+    echo r $synt >> $sac
+    echo cut off >> $sac
+    echo w over >> $sac
+  fi
+
+done
+echo quit >> $sac
+
+sac2000 $sac
+
+rm $sac


Property changes on: seismo/3D/ADJOINT_TOMO/flexwin/scripts/prepare_scripts/global/prepare_seis
___________________________________________________________________
Name: svn:executable
   + *



More information about the cig-commits mailing list