[cig-commits] [commit] master: add a color scale, update xyz2vtp.sh, rename grd2vtk.sh (133df13)
cig_noreply at geodynamics.org
cig_noreply at geodynamics.org
Thu Apr 10 03:02:48 PDT 2014
Repository : ssh://geoshell/relax
On branch : master
Link : https://github.com/geodynamics/relax/compare/f58c3e4a3b537ce548f0dc9b6301d68585ba7587...64bc932cf611ccf4683972590830ed18b974c6e9
>---------------------------------------------------------------
commit 133df1372f1e0f1323deaa1ed0b3d56ddadf29d2
Author: Sylvain Barbot <sbarbot at ntu.edu.sg>
Date: Sun Mar 30 01:21:13 2014 +0800
add a color scale, update xyz2vtp.sh, rename grd2vtk.sh
>---------------------------------------------------------------
133df1372f1e0f1323deaa1ed0b3d56ddadf29d2
share/seis_inv.cpt | 14 +++++++
util/grd2vtp.sh | 109 -----------------------------------------------------
util/xyz2vtp.sh | 6 ++-
3 files changed, 19 insertions(+), 110 deletions(-)
diff --git a/share/seis_inv.cpt b/share/seis_inv.cpt
new file mode 100644
index 0000000..34222c2
--- /dev/null
+++ b/share/seis_inv.cpt
@@ -0,0 +1,14 @@
+# $Id: GMT_seis.cpt 9545 2011-07-27 19:31:54Z pwessel $
+#
+# Colormap using in seismic tomographic images
+# Designed by Suzan van der Lee
+# COLOR_MODEL = RGB
+-1.00 0 0 205 -.777 0 80 255
+-.777 0 80 255 -.555 0 240 110
+-.555 0 240 110 -.333 90 255 30
+-.333 90 255 30 -.111 255 255 0
+-.111 255 255 0 .111 255 255 0
+.111 255 255 0 .333 255 170 0
+.333 255 170 0 .555 255 85 0
+.555 255 85 0 .777 255 0 0
+.777 255 0 0 1.00 170 0 0
diff --git a/util/grd2vtp.sh b/util/grd2vtp.sh
deleted file mode 100755
index 53a34f9..0000000
--- a/util/grd2vtp.sh
+++ /dev/null
@@ -1,109 +0,0 @@
-#!/bin/bash
-
-set -e
-self=$(basename $0)
-trap 'echo $self: Some errors occurred. Exiting.; exit' ERR
-
-grd2vtp_header(){
- SX1=`grdinfo -C $GRDFILE | awk '{print $10}'`
- SX2=`grdinfo -C $GRDFILE | awk '{print $11}'`
- N=`echo $SX1 $SX2 | awk '{print $1*$2}'`
- TITLE=`grdinfo -C $GRDFILE | awk '{print $1}'`
- NPOLY=`echo $SX1 $SX2 | awk '{print ($1-1)*($2-1)*2}'`
- NSIDE=`echo $SX1 $SX2 | awk '{print ($1-1)*($2-1)*2*4}'`
-
- echo "# vtk DataFile Version 3.0"
- echo $TITLE
- echo "ASCII"
- echo "DATASET POLYDATA"
- echo "POINTS $N float"
- if [ "$tset" != "1" ]; then
- grd2xyz $GRDFILE | awk -v d=$depth '{print $2,$1,d}'
- else
- grd2xyz $GRDFILE | awk -v d=$depth '{print $2,$1,d-$3}'
- fi
- echo ""
- echo "POLYGONS $NPOLY $NSIDE"
- echo "" | awk -v SX1=$SX1 -v SX2=$SX2 '{ \
- for (x2=1;x2<SX2;x2++){ \
- for (x1=1;x1<SX1;x1++){ \
- print 3,(x2-1)*SX1+x1-1,(x2-1)*SX1+x1,x2*SX1+x1; \
- print 3,(x2-1)*SX1+x1-1,x2*SX1+x1-1,x2*SX1+x1 \
- } \
- } \
- }'
- echo ""
- echo "POINT_DATA $N"
-}
-
-grd2vtp_footer(){
- TITLE=`grdinfo -C $GRDFILE | awk '{print $1}'`
- echo "SCALARS $(basename $TITLE .grd) float"
- echo "LOOKUP_TABLE default"
- grd2xyz $GRDFILE | awk '{print $3}'
-}
-
-
-
-usage(){
- echo "$self converts a list of grd files to a vtp polygon polydata file"
- echo "in ASCII legacy format for visualization in Paraview."
- echo ""
- echo "usage: $self file.grd > file.vtp"
- echo ""
- echo "or"
- echo ""
- echo " $self file1.grd file2.grd file3.grd > file.vtp"
- echo ""
- echo "options:"
- echo " -d depth provide the uniform depth of the VTK file (0)."
- echo " -t indicates that z-value is topography."
- echo " For multiple files, the first file contains the topography."
- echo " In combination with -d option, topography is shifted by depth."
- echo ""
- echo "note: in Paraview, the X axis is north, the Y axis is east,"
- echo " and the Z axis is depth, forming a right-handed system."
- echo ""
-}
-
-# print usage is no arguments are supplied or if redirection pipe is detected
-if [ ! -t 0 ] || [ $# -eq 0 ]; then
- usage
- exit
-fi
-
-# optional command-line parameters
-while getopts "d:t" flag
-do
- case "$flag" in
- r) dset=1;depth=$OPTARG;;
- t) tset=1;;
- esac
-done
-for item in $tset $Kset $Oset ;do
- shift
-done
-for item in $dset ;do
- shift;shift
-done
-
-if [ "$dset" != "1" ]; then
- depth=0
-fi
-
-GRDFILE=$1
-grd2vtp_header
-grd2vtp_footer
-shift
-
-# loop over list of files to convert
-while [ $# -ne 0 ];do
- GRDFILE=$1
- if [ ! -e $GRDFILE ]; then
- echo $self: could not find $GRDFILE. exiting. >&2
- exit 2
- fi
- grd2vtp_footer
- shift
-done
-
diff --git a/util/xyz2vtp.sh b/util/xyz2vtp.sh
index 786dcfe..c06ac75 100755
--- a/util/xyz2vtp.sh
+++ b/util/xyz2vtp.sh
@@ -38,7 +38,11 @@ cat $XYZFILE | awk -v c=$com '
}
}
else{
- line=line " " $2" "$1" "$3;
+ if (NF<3){
+ line=line " " $2 " " $1 " 0";
+ }else{
+ line=line " " $2 " " $1 " "$3;
+ }
n=n+1;
}
}
More information about the CIG-COMMITS
mailing list