[cig-commits] commit: fix option message, change map.sh to grdmap.sh, start extra script w/ e (ex: erpatch.sh), add stress output in grd format in the first step.

Mercurial hg at geodynamics.org
Sat Nov 26 15:00:15 PST 2011


changeset:   48:bf1575daaa90
user:        Sylvain Barbot <sbarbot at caltech.edu>
date:        Sat Nov 26 13:32:16 2011 -0800
files:       input.f90 latex/documentation.tex relax.f90 util/erpatch.sh util/erpatch_slip.sh util/grdmap.sh util/map.sh util/readme.txt util/rpatch.sh util/rpatch_slip.sh util/test.sh
description:
fix option message, change map.sh to grdmap.sh, start extra script w/ e (ex: erpatch.sh), add stress output in grd format in the first step.


diff -r 1fb527946306 -r bf1575daaa90 input.f90
--- a/input.f90	Fri Nov 11 16:39:55 2011 -0800
+++ b/input.f90	Sat Nov 26 13:32:16 2011 -0800
@@ -171,28 +171,28 @@ CONTAINS
     IF (in%isoutputgrd) THEN
        PRINT '("     * export to GRD format")'
     ELSE
-       PRINT '("     * export to GRD format cancelled                     (--",a,")")', trim(opts(4)%name)
+       PRINT '("     * export to GRD format cancelled                     (--",a,")")', trim(opts(5)%name)
     END IF
 #endif
 #ifdef XYZ
     IF (in%isoutputxyz) THEN
        PRINT '("     * export to XYZ format")'
     ELSE
-       PRINT '("     * export to XYZ format cancelled                     (--",a,")")', trim(opts(5)%name)
+       PRINT '("     * export to XYZ format cancelled                     (--",a,")")', trim(opts(6)%name)
     END IF
 #endif
 #ifdef TXT
     IF (in%isoutputtxt) THEN
        PRINT '("     * export to TXT format")'
     ELSE
-       PRINT '("     * export to TXT format cancelled                     (--",a,")")', trim(opts(2)%name)
+       PRINT '("     * export to TXT format cancelled                     (--",a,")")', trim(opts(3)%name)
     END IF
 #endif
 #ifdef VTK
     IF (in%isoutputvtk) THEN
        PRINT '("     * export to VTK format")'
     ELSE
-       PRINT '("     * export to VTK format cancelled                     (--",a,")")', trim(opts(3)%name)
+       PRINT '("     * export to VTK format cancelled                     (--",a,")")', trim(opts(4)%name)
     END IF
 #endif
 #ifdef PROJ
diff -r 1fb527946306 -r bf1575daaa90 latex/documentation.tex
--- a/latex/documentation.tex	Fri Nov 11 16:39:55 2011 -0800
+++ b/latex/documentation.tex	Sat Nov 26 13:32:16 2011 -0800
@@ -514,18 +514,18 @@ coseismic event 001
 \label{input:out_coseismic}
 \end{figure}
 
-To visualize the coseismic displacement at the surface, it is convenient to use the script \verb'map.sh'. The plotting routine \verb'map.sh' provided with the code and numerous other post-processing scripts can be used to analyze the modeled scenario. The unix script \verb'map.sh', a wrapper around GMT programs, produces map views of any grid but is optimized to work with the three-dimensional output of RELAX.
+To visualize the coseismic displacement at the surface, it is convenient to use the script \verb'grdmap.sh'. The plotting routine \verb'grdmap.sh' provided with the code and numerous other post-processing scripts can be used to analyze the modeled scenario. The unix script \verb'grdmap.sh', a wrapper around GMT programs, produces map views of any grid but is optimized to work with the three-dimensional output of RELAX.
 \begin{alltt}
-{\color{NavyBlue}map.sh -b -30/30/-30/30 -p -0.05/0.05/0.001 -v 0.5 \textbackslash
-       -u "m" -e rpatch.sh output_directory/000}
+{\color{NavyBlue}grdmap.sh -b -30/30/-30/30 -p -0.05/0.05/0.001 -v 0.5 \textbackslash
+       -u "m" -e erpatch.sh output_directory/000}
 \end{alltt}
-where the \verb'-b' option defines the boundary of the map in the GMT format W/E/S/N, the \verb'-p' option defines the range of the color scale for the vertical displacements, the \verb'-v' option defines the length of the vectors for the horizontal displacement, the "-u" option defines the unit of the color scale, and the "-e" option call the additional script \verb'rpatch.sh' to plot the spatial extent of the fault on the map. The last argument \verb'output_directory/000' refers to the prefix of all GMT binary files associated with the index \verb'000'. Any file prefix followed by \verb'-north.grd', \verb'-east.grd' and \verb'-up.grd' can be used in this manner. To look at an individual file, for example the stress component $\sigma_{12}$ at 5\,km depth, simply use
+where the \verb'-b' option defines the boundary of the map in the GMT format W/E/S/N, the \verb'-p' option defines the range of the color scale for the vertical displacements, the \verb'-v' option defines the length of the vectors for the horizontal displacement, the "-u" option defines the unit of the color scale, and the "-e" option call the additional script \verb'erpatch.sh' to plot the spatial extent of the fault on the map. The last argument \verb'output_directory/000' refers to the prefix of all GMT binary files associated with the index \verb'000'. Any file prefix followed by \verb'-north.grd', \verb'-east.grd' and \verb'-up.grd' can be used in this manner. To look at an individual file, for example the stress component $\sigma_{12}$ at 5\,km depth, simply use
 \begin{alltt}
 
-{\color{NavyBlue}map.sh -b -30/30/-30/30 -p -500/500/1 \textbackslash
-       -u "kPa" -e rpatch.sh output_directory/000-s12.grd}
+{\color{NavyBlue}grdmap.sh -b -30/30/-30/30 -p -500/500/1 \textbackslash
+       -u "kPa" -e erpatch.sh output_directory/000-s12.grd}
 \end{alltt}
-For this command to work, it is assumed that \verb'map.sh' and \verb'rpatch.sh' are both located in a directory listed in the \verb'$PATH' environment variable, such as \verb'/usr/local/bin'.
+For this command to work, it is assumed that \verb'grdmap.sh' and \verb'erpatch.sh' are both located in a directory listed in the \verb'$PATH' environment variable, such as \verb'/usr/local/bin'.
 
 The coseismic slip distribution of a real earthquake can be a long and detailed description of the source coming from an inversion of geophysical data. To include these models and conform them to the format required by the RELAX program, it is convenient to use other unix tricks, such as \verb'awk', \verb'wc' and the use of variables, for instance, if the source is described in the file \verb'src.dat', but the file missing a line counter and the units in meters, one can alter it as follows
 \begin{alltt}
diff -r 1fb527946306 -r bf1575daaa90 relax.f90
--- a/relax.f90	Fri Nov 11 16:39:55 2011 -0800
+++ b/relax.f90	Sat Nov 26 13:32:16 2011 -0800
@@ -180,6 +180,7 @@
   !! \todo 
   !!   - homogenize VTK output so that geometry of events match event index
   !!   - evaluate Green function, stress and body forces in GPU
+  !!   - write the code for MPI multi-thread
   !!   - fix the vtk export to grid for anisotropic sampling
   !!   - export position of observation points to long/lat in opts-geo.dat
   !------------------------------------------------------------------------
@@ -389,8 +390,20 @@ PROGRAM relax
   END IF
 
   ! export initial stress
+#ifdef GRD
+  IF (in%isoutputgrd .AND. in%isoutputstress) THEN
+     CALL exportstressgrd(sig,in%sx1,in%sx2,in%sx3/2,in%dx1,in%dx2,in%dx3, &
+                          in%ozs,in%x0,in%y0,in%wdir,0)
+  END IF
+#endif
+#ifdef PROJ
+  IF (in%isoutputproj .AND. in%isoutputstress) THEN
+      CALL exportstressproj(sig,in%sx1,in%sx2,in%sx3/2,in%dx1,in%dx2,in%dx3,in%ozs, &
+                            in%x0,in%y0,in%lon0,in%lat0,in%zone,in%umult,in%wdir,0)
+  END IF
+#endif
 #ifdef VTK
-  WRITE (digit4,'(I4.4)') oi-1
+  WRITE (digit4,'(I4.4)') 0
   IF (in%isoutputvtk .AND. in%isoutputstress) THEN
      filename=trim(in%wdir)//"/sigma-"//digit4//".vtk"//char(0)
      title="stress tensor field"//char(0)
diff -r 1fb527946306 -r bf1575daaa90 util/erpatch.sh
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/util/erpatch.sh	Sat Nov 26 13:32:16 2011 -0800
@@ -0,0 +1,33 @@
+#!/bin/sh
+
+# extra script for mapping tool map.sh plotting the contours
+# of fault patches projected in map view
+#
+#   map.sh -e rpatch.sh WDIR/file.grd
+#
+# assumes files WDIR/rfaults-???.dat contain slip model, as
+# created by program relax and alike.
+
+set -e
+self=$(basename $0)
+trap 'echo $self: Some errors occurred. Exiting.; exit' ERR
+
+if [ "$#" -lt "2" ]; then
+	echo $self": extra script for map.sh."
+	echo $self": expected $self file.ps xmin/xmax/ymin/ymax. exiting."
+	exit 1
+fi
+
+echo $self: $*
+PSFILE=$1
+bds=$2
+
+WDIR=$(dirname $PSFILE)
+
+# plot a coseismic model
+psxy -O -K -JX -R$bds -L -M \
+         -W1.0p/20/20/20 \
+        <<EOF >> $PSFILE
+`awk '{if (">"==$1){print $1}else{print $2,$1}}' $WDIR/rfaults-???.xy`
+EOF
+
diff -r 1fb527946306 -r bf1575daaa90 util/erpatch_slip.sh
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/util/erpatch_slip.sh	Sat Nov 26 13:32:16 2011 -0800
@@ -0,0 +1,31 @@
+#!/bin/sh
+
+# extra script for mapping tool map.sh plotting the slip model
+# projected in map view
+#
+#   map.sh -e rpatch_slip.sh WDIR/file.grd
+#
+# assumes files WDIR/rfaults-???.dat contain slip model, as
+# created by program relax and alike.
+
+set -e
+self=$(basename $0)
+trap 'echo $self: Some errors occurred. Exiting.; exit' ERR
+
+if [ "$#" -lt "2" ]; then
+	echo $self": expected $self file.ps xmin/xmax/ymin/ymax. exiting."
+	exit 1
+fi
+
+echo $self: $*
+PSFILE=$1
+bds=$2
+
+WDIR=$(dirname $PSFILE)
+
+psxy -O -K -JX -R$bds -C$WDIR/palette.cpt -W1p0/0/0 -L -M \
+         -W0.5p/20/20/20 \
+        <<EOF >> $PSFILE
+`awk '{if (">"==$1){print $0}else{print $2,$1}}' $WDIR/rfaults-???.xy`
+EOF
+
diff -r 1fb527946306 -r bf1575daaa90 util/grdmap.sh
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/util/grdmap.sh	Sat Nov 26 13:32:16 2011 -0800
@@ -0,0 +1,260 @@
+#!/bin/sh
+
+set -e
+self=$(basename $0)
+selfdir=$(dirname $0)
+cmdline=$*
+trap 'echo $self: Some errors occurred. Exiting.; exit' ERR
+
+my_gmt(){
+
+grdimage $U3 -R$bds -J${PROJ} \
+    $AXIS \
+    -K -C$colors -P -X1.2i -Y${YSHIFT}i $illumination \
+    > $PSFILE
+
+# running all required subprograms
+for subprog in $EXTRA;do
+if [ -e "$selfdir/$subprog" ]; then
+	#echo $self: running $subprog $PSFILE $bds $VECTOR $U3 $HEIGHT
+	eval "$subprog $PSFILE $bds $VECTOR $U3 $HEIGHT"
+else
+	if [ -e "$subprog" ]; then
+		#echo $self: running $subprog $PSFILE $bds $VECTOR $U3 $HEIGHT
+		eval "$subprog $PSFILE $bds $VECTOR $U3 $HEIGHT"
+	fi
+fi
+done
+
+# plotting vectors
+if [ -e $U1 ]; then
+
+#echo $self": found "$U1": plotting vectors"
+echo $self": Using VECTOR="$VECTOR", STEP="$ADX
+
+# arrowwidth/headlength/headwidth
+# grdvector crashes with wrong sampling
+#	-Q0.51c/0.8c/0.7cn1.0c \
+grdvector $U1 $U2 -K -J${PROJ} -O -R$bds -I$ADX/$ADX \
+	-Q0.3c/0.5c/0.4cn1.0c \
+	-S$VECTOR -W0.1p/0/0/0 \
+	-G255/255/255 \
+	 >> $PSFILE
+fi
+
+# plot the vector legend if $VECTOR is set
+if [ "$VECTOR" != "-" ]; then
+UL=`echo $bds | awk -F "/" '{print $1,$4}' `
+pstext -O -K -J${PROJ} -N -R$bds \
+	-G0/0/0 -Ya0.3i \
+	<<EOF >> $PSFILE
+$UL 14 0 4 LM $SIZE $unit
+EOF
+psxy -O -K -J${PROJ} -R$bds -N \
+	-W0.5p/0/0/0 -Xa0.9i \
+	-Sv0.2c/1.0c/0.4cn1.0c \
+	<<EOF >> $PSFILE
+$UL 0 1
+EOF
+REVERT="-Xa-0.9i -Ya-0.3i"
+fi
+
+	#-Q0.20c/1.0c/0.4cn1.0c \
+psscale -O -Ba$PSSCALE/:$unit: -D2.0i/-0.8i/3.1i/0.2ih \
+	-C$colors $REVERT \
+	>> $PSFILE 
+
+rm -f $colors
+
+}
+
+if (test $# -lt "1"); then
+        echo "usage: grdmap.sh [-b -5/5/-5/5] [-p -1.5/1.5/0.1] [...] file1.grd ... fileN.grd"
+	echo "or"
+        echo "       grdmap.sh [-b -5/5/-5/5] [-p -1.5/1.5/0.1] [...] dir1/index1 ... dirN/indexN"
+	echo ""
+        echo "options:"
+        echo "         -b bds sets the map bound to bds"
+	echo "         -c palette_name [default my_jet]"
+        echo "         -e file.sh runs file.sh to add content to map"
+        echo "         -g switch to geographic projection (longitude/latitude)"
+	echo "         -i file.grd illuminates the grd image with file.grd"
+        echo "         -o output directory"
+        echo "         -p palette sets the color scale bounds to palette"
+        echo "         -r reverse the y-axis"
+        echo "         -s step sets the distance between vectors"
+        echo "         -u defines the color scale unit"
+        echo "         -v vector sets the vector scale to vector"
+	echo "         -t tick interval"
+	echo "         -x do not display map (only create .ps file)"
+        echo "         -Y shift the plot vertically on the page"
+	echo ""
+	echo "Creates N maps based on grd files file1.grd ... fileN.grd, or based"
+	echo "on files dir1/index1-{up,north.east}.grd ... dirN/indexN-{up,north,east}.grd"
+	echo ""
+        
+        exit
+fi
+
+gmtset LABEL_FONT_SIZE 12p
+gmtset HEADER_FONT_SIZE 12p
+gmtset ANOT_FONT_SIZE 12p 
+gmtset COLOR_BACKGROUND 0/0/255
+gmtset COLOR_FOREGROUND 255/0/0
+gmtset COLOR_NAN 255/255/255
+gmtset PAPER_MEDIA a5
+
+libdir=$(dirname $0)
+EXTRA=""
+
+while getopts "b:c:e:gi:o:p:v:s:t:u:xrY:" flag
+do
+  case "$flag" in
+    b) bset=1;bds=$OPTARG;;
+    c) cset=1;carg=$OPTARG;;
+    e) eset=1;EXTRA="$EXTRA $OPTARG";;
+    g) gset=1;;
+    i) iset=1;illumination="-I$OPTARG";;
+    o) oset=1;ODIR=$OPTARG;;
+    p) pset=1;P=$OPTARG;PSSCALE=`echo $OPTARG | awk -F"/" 'function abs(x){return x<0?-x:x}{print abs($2)}'`;;
+    v) vset=1;SIZE=$OPTARG;VECTOR=$OPTARG"c";;
+    r) rset=1;;
+    s) sset=1;ADX=$OPTARG;;
+    t) tset=1;tick=$OPTARG;;
+    u) uset=1;unit=$OPTARG;;
+    x) xset=1;;
+    Y) Yset=1;Yshift=$OPTARG;;
+  esac
+done
+for item in $bset $cset $iset $oset $pset $vset $sset $tset $uset $Yset $EXTRA;do
+	shift;shift
+done
+for item in $gset $xset $rset;do
+	shift;
+done
+
+while [ "$#" != "0" ];do
+
+WDIR=`dirname $1`
+INDEX=`basename $1`
+
+# default names
+U1=$WDIR/$INDEX-east.grd
+U2=$WDIR/$INDEX-north.grd
+U3=$WDIR/$INDEX-up.grd
+
+if [ -e $U3 ]; then
+	U3=$U3;
+else
+	U3=$WDIR/$INDEX
+fi
+
+echo $self": Using directory "$WDIR", plotting index "$INDEX
+
+# defaults
+if [ "$bset" != "1" ]; then
+	bds=`grdinfo -C $U3 | awk '{s=1;print $2/s"/"$3/s"/"$4/s"/"$5/s}'`
+fi
+if [ "$tset" != "1" ]; then
+	tick=`echo $bds | awk -F "/" '{s=1;print ($2-$1)/s/4}'`
+fi
+HEIGHT=`echo $bds | awk -F "/" '{printf("%fi\n",($4-$3)/($2-$1)*4)}'`
+if [ "$gset" != "1" ]; then
+	if [ "$rset" != "1" ]; then
+		PROJ="X4i/"$HEIGHT
+	else
+		PROJ="X4i/"-$HEIGHT
+	fi
+        AXIS=-Ba${tick}:"":/a${tick}:""::."$U3":WSne
+else
+	PROJ="M0/0/4i"
+        AXIS=-B${tick}:"":/${tick}:""::."$U3":WSne
+fi
+
+if [ "$uset" != "1" ]; then
+	# retrieve the "Remarks"
+	# use grdedit -D:=:=:=:=:=:=:cm: file.grd to update the value
+	unit=`grdinfo $U3 | grep "Remark" | awk -F ": " '{print $3}'`
+fi
+
+if [ "$Yset" != "1" ]; then
+	YSHIFT=2.0
+else
+	YSHIFT=`echo $Yshift | awk '{print $1+2}'`
+fi
+
+if [ "$cset" != "1" ]; then
+	#cptfile=hot
+	cptfile=$libdir/my_jet
+	#cptfile=$libdir/my_hot_inv
+else
+	if [ -e $libdir/$carg ]; then 
+		cptfile=$libdir/$carg
+	else 
+		cptfile=$carg;
+	fi
+fi
+
+colors=$WDIR/palette.cpt
+echo $self: using colorfile $cptfile
+if [ "$pset" != "1" ]; then
+	# cool, copper, gebco, globe, gray, haxby, hot, jet, no_green, ocean
+	# polar, rainbow, red2green, relief, topo, sealand, seis, split, wysiwyg  
+	PSSCALE=`grdinfo $U3 -C | awk 'function abs(x){return x<0?-x:x}{if (abs($6) >= abs($7)) print abs($6); else print abs($7)}'`
+	if [ "0" == $PSSCALE ]; then
+		grd2cpt $U3 -C$cptfile -Z -T= -L-1/1 > $colors
+		PSSCALE=0.5
+	else
+		grd2cpt $U3 -C$cptfile -Z -T= > $colors
+	fi
+else
+	makecpt -C$cptfile -T$P -Z -D > $colors;
+fi
+if [ "$oset" != "1" ]; then
+	ODIR=$WDIR
+fi
+if [ -e $U1 ]; then
+	if [ "$vset" != "1" ]; then
+                MAX1=`grdinfo $U1 -C | awk '{if (sqrt($7^2)>sqrt($6^2)){print sqrt($7^2)}else{print sqrt($6^2)}}'`
+                MAX2=`grdinfo $U2 -C | awk '{if (sqrt($7^2)>sqrt($6^2)){print sqrt($7^2)}else{print sqrt($6^2)}}'`
+		SIZE=`echo "$MAX1 $MAX2"| awk '{print ($1+$2)*0.95}'`
+		VECTOR=$SIZE"c"
+	fi
+	if [ "$sset" != "1" ]; then
+		ADX=`grdinfo $U2 -C | awk '{printf "5*%11.9f\n", $8}' | bc`
+	fi
+else
+	# unused value but preserve the number of elements in call to subroutine
+	if [ "$vset" != "1" ]; then
+		VECTOR="-"
+	fi
+fi
+
+echo $self": z-min/z-max for "$U3": "`grdinfo -C $U3 | awk '{print $6,$7}'`
+
+PSFILE=$ODIR/$INDEX-plot.ps
+PDFFILE=$ODIR/$INDEX-plot.pdf
+
+my_gmt $INDEX
+
+# add trailer information
+echo %% Postscript created with >> $PSFILE
+echo %% $(basename $0) $cmdline >> $PSFILE
+
+# open file for display
+echo $self": Created map "$PSFILE
+
+if [ "$xset" != "1" ]; then
+	#display -trim $PSFILE &
+	#gv -spartan $PSFILE &
+	ps2pdf -sPAPERSIZE="a4" $PSFILE $PDFFILE
+	echo $self": Converted to pdf file "$PDFFILE
+	xpdf -paper "A5" $PDFFILE -z 100 -g 565x655 >& /dev/null &
+fi
+
+shift
+if [ "$#" != "0" ];then
+	echo ""
+fi
+done
+
diff -r 1fb527946306 -r bf1575daaa90 util/map.sh
--- a/util/map.sh	Fri Nov 11 16:39:55 2011 -0800
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,260 +0,0 @@
-#!/bin/sh
-
-set -e
-self=$(basename $0)
-selfdir=$(dirname $0)
-cmdline=$*
-trap 'echo $self: Some errors occurred. Exiting.; exit' ERR
-
-my_gmt(){
-
-grdimage $U3 -R$bds -J${PROJ} \
-    $AXIS \
-    -K -C$colors -P -X1.2i -Y${YSHIFT}i $illumination \
-    > $PSFILE
-
-# running all required subprograms
-for subprog in $EXTRA;do
-if [ -e "$selfdir/$subprog" ]; then
-	#echo $self: running $subprog $PSFILE $bds $VECTOR $U3 $HEIGHT
-	eval "$subprog $PSFILE $bds $VECTOR $U3 $HEIGHT"
-else
-	if [ -e "$subprog" ]; then
-		#echo $self: running $subprog $PSFILE $bds $VECTOR $U3 $HEIGHT
-		eval "$subprog $PSFILE $bds $VECTOR $U3 $HEIGHT"
-	fi
-fi
-done
-
-# plotting vectors
-if [ -e $U1 ]; then
-
-#echo $self": found "$U1": plotting vectors"
-echo $self": Using VECTOR="$VECTOR", STEP="$ADX
-
-# arrowwidth/headlength/headwidth
-# grdvector crashes with wrong sampling
-#	-Q0.51c/0.8c/0.7cn1.0c \
-grdvector $U1 $U2 -K -J${PROJ} -O -R$bds -I$ADX/$ADX \
-	-Q0.3c/0.5c/0.4cn1.0c \
-	-S$VECTOR -W0.1p/0/0/0 \
-	-G255/255/255 \
-	 >> $PSFILE
-fi
-
-# plot the vector legend if $VECTOR is set
-if [ "$VECTOR" != "-" ]; then
-UL=`echo $bds | awk -F "/" '{print $1,$4}' `
-pstext -O -K -J${PROJ} -N -R$bds \
-	-G0/0/0 -Ya0.3i \
-	<<EOF >> $PSFILE
-$UL 14 0 4 LM $SIZE $unit
-EOF
-psxy -O -K -J${PROJ} -R$bds -N \
-	-W0.5p/0/0/0 -Xa0.9i \
-	-Sv0.2c/1.0c/0.4cn1.0c \
-	<<EOF >> $PSFILE
-$UL 0 1
-EOF
-REVERT="-Xa-0.9i -Ya-0.3i"
-fi
-
-	#-Q0.20c/1.0c/0.4cn1.0c \
-psscale -O -Ba$PSSCALE/:$unit: -D2.0i/-0.8i/3.1i/0.2ih \
-	-C$colors $REVERT \
-	>> $PSFILE 
-
-rm -f $colors
-
-}
-
-if (test $# -lt "1"); then
-        echo "usage: map.sh [-b -5/5/-5/5] [-p -1.5/1.5/0.1] [...] file1.grd ... fileN.grd"
-	echo "or"
-        echo "       map.sh [-b -5/5/-5/5] [-p -1.5/1.5/0.1] [...] dir1/index1 ... dirN/indexN"
-	echo ""
-        echo "options:"
-        echo "         -b bds sets the map bound to bds"
-	echo "         -c palette_name [default my_jet]"
-        echo "         -e file.sh runs file.sh to add content to map"
-        echo "         -g switch to geographic projection (longitude/latitude)"
-	echo "         -i file.grd illuminates the grd image with file.grd"
-        echo "         -o output directory"
-        echo "         -p palette sets the color scale bounds to palette"
-        echo "         -r reverse the y-axis"
-        echo "         -s step sets the distance between vectors"
-        echo "         -u defines the color scale unit"
-        echo "         -v vector sets the vector scale to vector"
-	echo "         -t tick interval"
-	echo "         -x do not display map (only create .ps file)"
-        echo "         -Y shift the plot vertically on the page"
-	echo ""
-	echo "Creates N maps based on grd files file1.grd ... fileN.grd, or based"
-	echo "on files dir1/index1-{up,north.east}.grd ... dirN/indexN-{up,north,east}.grd"
-	echo ""
-        
-        exit
-fi
-
-gmtset LABEL_FONT_SIZE 12p
-gmtset HEADER_FONT_SIZE 12p
-gmtset ANOT_FONT_SIZE 12p 
-gmtset COLOR_BACKGROUND 0/0/255
-gmtset COLOR_FOREGROUND 255/0/0
-gmtset COLOR_NAN 255/255/255
-gmtset PAPER_MEDIA a5
-
-libdir=$(dirname $0)
-EXTRA=""
-
-while getopts "b:c:e:gi:o:p:v:s:t:u:xrY:" flag
-do
-  case "$flag" in
-    b) bset=1;bds=$OPTARG;;
-    c) cset=1;carg=$OPTARG;;
-    e) eset=1;EXTRA="$EXTRA $OPTARG";;
-    g) gset=1;;
-    i) iset=1;illumination="-I$OPTARG";;
-    o) oset=1;ODIR=$OPTARG;;
-    p) pset=1;P=$OPTARG;PSSCALE=`echo $OPTARG | awk -F"/" 'function abs(x){return x<0?-x:x}{print abs($2)}'`;;
-    v) vset=1;SIZE=$OPTARG;VECTOR=$OPTARG"c";;
-    r) rset=1;;
-    s) sset=1;ADX=$OPTARG;;
-    t) tset=1;tick=$OPTARG;;
-    u) uset=1;unit=$OPTARG;;
-    x) xset=1;;
-    Y) Yset=1;Yshift=$OPTARG;;
-  esac
-done
-for item in $bset $cset $iset $oset $pset $vset $sset $tset $uset $Yset $EXTRA;do
-	shift;shift
-done
-for item in $gset $xset $rset;do
-	shift;
-done
-
-while [ "$#" != "0" ];do
-
-WDIR=`dirname $1`
-INDEX=`basename $1`
-
-# default names
-U1=$WDIR/$INDEX-east.grd
-U2=$WDIR/$INDEX-north.grd
-U3=$WDIR/$INDEX-up.grd
-
-if [ -e $U3 ]; then
-	U3=$U3;
-else
-	U3=$WDIR/$INDEX
-fi
-
-echo $self": Using directory "$WDIR", plotting index "$INDEX
-
-# defaults
-if [ "$bset" != "1" ]; then
-	bds=`grdinfo -C $U3 | awk '{s=1;print $2/s"/"$3/s"/"$4/s"/"$5/s}'`
-fi
-if [ "$tset" != "1" ]; then
-	tick=`echo $bds | awk -F "/" '{s=1;print ($2-$1)/s/4}'`
-fi
-HEIGHT=`echo $bds | awk -F "/" '{printf("%fi\n",($4-$3)/($2-$1)*4)}'`
-if [ "$gset" != "1" ]; then
-	if [ "$rset" != "1" ]; then
-		PROJ="X4i/"$HEIGHT
-	else
-		PROJ="X4i/"-$HEIGHT
-	fi
-        AXIS=-Ba${tick}:"":/a${tick}:""::."$U3":WSne
-else
-	PROJ="M0/0/4i"
-        AXIS=-B${tick}:"":/${tick}:""::."$U3":WSne
-fi
-
-if [ "$uset" != "1" ]; then
-	# retrieve the "Remarks"
-	# use grdedit -D:=:=:=:=:=:=:cm: file.grd to update the value
-	unit=`grdinfo $U3 | grep "Remark" | awk -F ": " '{print $3}'`
-fi
-
-if [ "$Yset" != "1" ]; then
-	YSHIFT=2.0
-else
-	YSHIFT=`echo $Yshift | awk '{print $1+2}'`
-fi
-
-if [ "$cset" != "1" ]; then
-	#cptfile=hot
-	cptfile=$libdir/my_jet
-	#cptfile=$libdir/my_hot_inv
-else
-	if [ -e $libdir/$carg ]; then 
-		cptfile=$libdir/$carg
-	else 
-		cptfile=$carg;
-	fi
-fi
-
-colors=$WDIR/palette.cpt
-echo $self: using colorfile $cptfile
-if [ "$pset" != "1" ]; then
-	# cool, copper, gebco, globe, gray, haxby, hot, jet, no_green, ocean
-	# polar, rainbow, red2green, relief, topo, sealand, seis, split, wysiwyg  
-	PSSCALE=`grdinfo $U3 -C | awk 'function abs(x){return x<0?-x:x}{if (abs($6) >= abs($7)) print abs($6); else print abs($7)}'`
-	if [ "0" == $PSSCALE ]; then
-		grd2cpt $U3 -C$cptfile -Z -T= -L-1/1 > $colors
-		PSSCALE=0.5
-	else
-		grd2cpt $U3 -C$cptfile -Z -T= > $colors
-	fi
-else
-	makecpt -C$cptfile -T$P -Z -D > $colors;
-fi
-if [ "$oset" != "1" ]; then
-	ODIR=$WDIR
-fi
-if [ -e $U1 ]; then
-	if [ "$vset" != "1" ]; then
-                MAX1=`grdinfo $U1 -C | awk '{if (sqrt($7^2)>sqrt($6^2)){print sqrt($7^2)}else{print sqrt($6^2)}}'`
-                MAX2=`grdinfo $U2 -C | awk '{if (sqrt($7^2)>sqrt($6^2)){print sqrt($7^2)}else{print sqrt($6^2)}}'`
-		SIZE=`echo "$MAX1 $MAX2"| awk '{print ($1+$2)*0.95}'`
-		VECTOR=$SIZE"c"
-	fi
-	if [ "$sset" != "1" ]; then
-		ADX=`grdinfo $U2 -C | awk '{printf "5*%11.9f\n", $8}' | bc`
-	fi
-else
-	# unused value but preserve the number of elements in call to subroutine
-	if [ "$vset" != "1" ]; then
-		VECTOR="-"
-	fi
-fi
-
-echo $self": z-min/z-max for "$U3": "`grdinfo -C $U3 | awk '{print $6,$7}'`
-
-PSFILE=$ODIR/$INDEX-plot.ps
-PDFFILE=$ODIR/$INDEX-plot.pdf
-
-my_gmt $INDEX
-
-# add trailer information
-echo %% Postscript created with >> $PSFILE
-echo %% $(basename $0) $cmdline >> $PSFILE
-
-# open file for display
-echo $self": Created map "$PSFILE
-
-if [ "$xset" != "1" ]; then
-	#display -trim $PSFILE &
-	#gv -spartan $PSFILE &
-	ps2pdf -sPAPERSIZE="a4" $PSFILE $PDFFILE
-	echo $self": Converted to pdf file "$PDFFILE
-	xpdf -paper "A5" $PDFFILE -z 100 -g 565x655 >& /dev/null &
-fi
-
-shift
-if [ "$#" != "0" ];then
-	echo ""
-fi
-done
-
diff -r 1fb527946306 -r bf1575daaa90 util/readme.txt
--- a/util/readme.txt	Fri Nov 11 16:39:55 2011 -0800
+++ b/util/readme.txt	Sat Nov 26 13:32:16 2011 -0800
@@ -1,17 +1,20 @@ list of post-processing scripts:
 list of post-processing scripts: 
-- coulomb.sh       coulomb.sh projects a stress tensor along a hypothetic fault defined by strike and dip orientation
-- extrude.sh       computes the coordinates y1,y2 and y3 of end points of a fault or volume located at x1,x2 and x3.
-- grdadd.sh        adds two sets of files index-{north,east,up}.grd 
-- grddetrend.sh    removes a plane from a grd file
+- coulomb.sh       project a stress tensor along a hypothetic fault defined by strike and dip orientation
+- extrude.sh       compute the coordinates y1,y2 and y3 of end points of a fault or volume located at x1,x2 and x3.
+- grdadd.sh        add two sets of files index-{north,east,up}.grd 
+- grddetrend.sh    remove a plane from a grd file
 - grdinsar.sh      convert sets of files index-{north,east,up}.grd into a los-of-sight projection index-los.grd
-- grdrotate.sh     converts the content of sets of files index-{north,east,up}.grd by an angle
-- grdsub.sh        subtracts sets of files index-{north,east,up}.grd
-- grdtrack.sh      exports a 1-D profile from a set index-{north,east,up}.grd
-- map.sh           displays files index.grd or sets of files index-{north,east,up}.grd
-- obsrelax.sh      removes the coseismic component from the time series gps1.txt ... gpsN.txt
-- plot.sh          plots time series or profiles
-- slip2source.sh   Creates source input files from slip distributions files exported in txt format from an observation plane.
-- wang2xyz.sh      converts results from Wang's program edcmp to index-{north,east,up}.xyz format
-- xyz2grd.sh       converts index-{north,east,up}.xyz into index-{north,east,up}.grd
-- xyz2vtk.sh       converts foo.xy or foo.xyz into vtp format foo.vtp for visualization in Paraview
+- grdrotate.sh     convert the content of sets of files index-{north,east,up}.grd by an angle
+- grdsub.sh        subtract sets of files index-{north,east,up}.grd
+- grdtrack.sh      export a 1-D profile from a set index-{north,east,up}.grd
+- grdmap.sh        display files index.grd or sets of files index-{north,east,up}.grd
+- obsrelax.sh      remove the coseismic component from the time series gps1.txt ... gpsN.txt
+- plot.sh          plot time series or profiles
+- slip2source.sh   create source input files from slip distributions files exported in txt format from an observation plane.
+- wang2xyz.sh      convert results from Wang's program edcmp to index-{north,east,up}.xyz format
+- xyz2grd.sh       convert index-{north,east,up}.xyz into index-{north,east,up}.grd
+- xyz2vtk.sh       convert foo.xy or foo.xyz into vtp format foo.vtp for visualization in Paraview
  
+extra scripts for grdmap.sh (for example: grdmap.sh -e script.sh wdir/file.grd)
+- erpatch.sh       add the contour of the slip patches to the current map
+- erpatch_slip.sh  add the contour and the slip amplitude of the slip patches to the current map
diff -r 1fb527946306 -r bf1575daaa90 util/rpatch.sh
--- a/util/rpatch.sh	Fri Nov 11 16:39:55 2011 -0800
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,33 +0,0 @@
-#!/bin/sh
-
-# extra script for mapping tool map.sh plotting the contours
-# of fault patches projected in map view
-#
-#   map.sh -e rpatch.sh WDIR/file.grd
-#
-# assumes files WDIR/rfaults-???.dat contain slip model, as
-# created by program relax and alike.
-
-set -e
-self=$(basename $0)
-trap 'echo $self: Some errors occurred. Exiting.; exit' ERR
-
-if [ "$#" -lt "2" ]; then
-	echo $self": extra script for map.sh."
-	echo $self": expected $self file.ps xmin/xmax/ymin/ymax. exiting."
-	exit 1
-fi
-
-echo $self: $*
-PSFILE=$1
-bds=$2
-
-WDIR=$(dirname $PSFILE)
-
-# plot a coseismic model
-psxy -O -K -JX -R$bds -L -M \
-         -W1.0p/20/20/20 \
-        <<EOF >> $PSFILE
-`awk '{if (">"==$1){print $1}else{print $2,$1}}' $WDIR/rfaults-???.xy`
-EOF
-
diff -r 1fb527946306 -r bf1575daaa90 util/rpatch_slip.sh
--- a/util/rpatch_slip.sh	Fri Nov 11 16:39:55 2011 -0800
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,31 +0,0 @@
-#!/bin/sh
-
-# extra script for mapping tool map.sh plotting the slip model
-# projected in map view
-#
-#   map.sh -e rpatch_slip.sh WDIR/file.grd
-#
-# assumes files WDIR/rfaults-???.dat contain slip model, as
-# created by program relax and alike.
-
-set -e
-self=$(basename $0)
-trap 'echo $self: Some errors occurred. Exiting.; exit' ERR
-
-if [ "$#" -lt "2" ]; then
-	echo $self": expected $self file.ps xmin/xmax/ymin/ymax. exiting."
-	exit 1
-fi
-
-echo $self: $*
-PSFILE=$1
-bds=$2
-
-WDIR=$(dirname $PSFILE)
-
-psxy -O -K -JX -R$bds -C$WDIR/palette.cpt -W1p0/0/0 -L -M \
-         -W0.5p/20/20/20 \
-        <<EOF >> $PSFILE
-`awk '{if (">"==$1){print $0}else{print $2,$1}}' $WDIR/rfaults-???.xy`
-EOF
-
diff -r 1fb527946306 -r bf1575daaa90 util/test.sh
--- a/util/test.sh	Fri Nov 11 16:39:55 2011 -0800
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,9 +0,0 @@
-#!/bin/sh
-
-echo $*
-for i in $* ; do
-
-	echo $1, $i
-	shift
-done
-



More information about the CIG-COMMITS mailing list