Introduction

Discussion of script

The script is given below. It is will commented. The only difference between this version and that for GMT Versions 5 and up is that DOSOLUTION is replaced by DOSOLUTION5.

#!/bin/bash
#####
#	set up directory structure for an event that we get from the IRIS
#####

export MYPWD=`pwd`

#####
#	test usage
#####

if [ $# -ne 15 ]
then
echo DOGEOFON YEAR MO DY HR MN SC MSC  LAT    LON    DEP  MAG REG NEIC FELTID STATE
echo DOGEOFON 2006 02 05 08 17 04 000 66.25 -143.02 18.60 5.1 CUS iuae Xiuae_06 Alaska
	echo $*
	exit 0
fi


#####
#	define internal variables: the quotes are required since some fields can have 
#       blank spacing within"
#####
YEAR="${1}"
MO="${2}"
DY="${3}"
HR="${4}"
MN="${5}"
SEC="${6}"
MSEC="${7}"
LAT="${8}"
LON="${9}"
DEP="${10}"
MAG="${11}"
REG="${12}"
NEIC="${13}"
FELTID="${14}"
STATE="${15}"

#####
#    
#    now run three scripts that set up everything
#    DOSETUP - sets up the directory structure for the inversion
#    DOGEOFONSETUP 
#    DOSOLUTION - runs the moment tensor solution through the grid search
#####

cd ${MYPWD}
./DOSETUP "${YEAR}" "${MO}" "${DY}" "${HR}" "${MN}" "${SEC}" "${MSEC}" "${LAT}" "${LON}" "${DEP}" "${MAG}" "${REG}" "${NEIC}" "${FELTID}" "${STATE}" "${MYPWD}"  > out 2>&1

cd ${MYPWD}
./DOGEOFONSETUP "${YEAR}" "${MO}" "${DY}" "${HR}" "${MN}" "${SEC}" "${MSEC}" "${LAT}" "${LON}" "${DEP}" "${MAG}" "${REG}" "${NEIC}" "${FELTID}" "${STATE}" "${MYPWD}"   > out 2>&1



#####
#	create the processing file that
#	does the deconvolution and solves for the solution
#	after the binary data is installed
#####

DIR=${YEAR}${MO}${DY}${HR}${MN}${SEC}
echo "1. Enter the command:"
echo "   DOFINISH"
echo "   This will create file doit in ${DIR}/${DIR}/Orig."
echo "   Edit this file to select the desired networks. "
echo "   Rdit the file ${DIR}/${DIR}/DOCLEAN to change the MAXDIST, which is"
echo "   uses to reject data at very large distances. This is required because"
echo "   the fdsnws_fetch cannot select data by distance."
echo "2. cd ${DIR}/${DIR}/Orig"
echo "   sh ./doit > doit.out 2>&1"
echo "3. When this is completed, "
echo "   cd ${DIR}/${DIR}"
echo "   IDOEVT;IDOROT;IDODIST;IDOQC"
echo "   cd .."
echo "   cd ML.REG;DOMLG;cd .."
echo "   cd GRD.REG"
echo "       edit the DOSTA for frequency band and time window"
echo "   DOGRD;DODELAY;DOPLTSAC;cd ../HTML.REG;DOHTML"
echo "   ---------------------------------------------------------------------"

#####
#	create the command DOFINISH and make the script executable
#####

cat > DOFINISH << EOF
#!/bin/sh
export PATH=${MYPWD}/bin:$PATH

#####
#	set up the event variables
#####
YEAR="${1}"
MO="${2}"
DY="${3}"
HR="${4}"
MN="${5}"
SEC="${6}"
MSEC="${7}"
LAT="${8}"
LON="${9}"
DEP="${10}"
MAG="${11}"
REG="${12}"
NEIC="${13}"
FELTID="${14}"
STATE="${15}"

if [ "${REG}" = "EU" ]
then
DEG=20
DURATION=600
else
DEG=6.0
DURATION=300
fi


export MYPWD="${MYPWD}"

#####
#	deconvolve the instrument response, rotate, decimate, do qc
#####
cd ${MYPWD}/${DIR}/${DIR}
#####
#     get the data
#####
mkdir Orig
cd Orig
START=\`redodate \$YEAR \$MO \$DY \$HR \$MN \$SEC \$MSEC -60 | \
        awk '{printf "%4.4d-%2.2d-%2.2dT%2.2d:%2.2d:%2.2d",\$1,\$2,\$3,\$4,\$5,\$6}' \`
END=\`redodate \$YEAR \$MO \$DY \$HR \$MN \$SEC \$MSEC \${DURATION} | \
        awk '{printf "%4.4d-%2.2d-%2.2dT%2.2d:%2.2d:%2.2d",\$1,\$2,\$3,\$4,\$5,\$6}' \`
CCORD=\`echo \${LAT} \${LON} \${DEG} | awk '{printf "%f:%f:%f",\$1,\$2,\$3}' \`
cat > doit << EOG
#!/bin/sh
set -x
for NET in AC BS BW CH CR FR GE GR HL HT HU II IU MN OE OX PL RO SJ SX TH SL SK CZ
do
fdsnws_fetch -N \\\${NET} -S '*' -L '*' -C 'BH*,HH*' -s \${START}  -e \${END}    -v -o \\\${NET}.data.mseed
fdsnws_fetch -N \\\${NET} -S '*' -L '*' -C 'BH*,HH*' -s \${START}  -e \${END} -y station -q level=response    -v -o \\\${NET}.station.xml
#####
#    convert station xml to dataless
#####

java -jar ~/bin/stationxml-seed-converter-2.1.0.jar --input \\\${NET}.station.xml --output \\\${NET}.dataless
(cd ../Sac
rdseed -f ../Orig/\\\${NET}.data.mseed -g ../Orig/\\\${NET}.dataless -p -o -d 1
)

done
EOG
EOF
echo $DIR
chmod +x DOFINISH



Last changed May 21, 2022