# Please help me to run this cod (triangulate,rotation)

**URL:** <https://forum.generic-mapping-tools.org/t/please-help-me-to-run-this-cod-triangulate-rotation/3386>\
**Category:** Q&A\
**Created:** [October 26, 2022, 5:59am UTC](https://forum.generic-mapping-tools.org/t/please-help-me-to-run-this-cod-triangulate-rotation/3386 "2022-10-26T05:59:49Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![maahnaz](https://yyz1.discourse-cdn.com/flex047/user_avatar/forum.generic-mapping-tools.org/maahnaz/32/2576_2.png) [@maahnaz](https://forum.generic-mapping-tools.org/u/maahnaz)\
**Post date:** [October 26, 2022, 5:59am UTC](https://forum.generic-mapping-tools.org/t/please-help-me-to-run-this-cod-triangulate-rotation/3386/1 "2022-10-26T05:59:50Z")

</div>

Hi,  
iam a student please help me  
**i want to run this cod**. my data ( long lat E N σE σN P EN site)

```auto
#!/bin/csh -f         
#
if ( $#argv == 0 ) then
  echo " read velocity file and triangulate it "
  echo " "
  echo " USAGE: sh_triangle -f file "
  echo " "
  echo " OPTIONS: "
  echo " -f velocity file file name [Required] " 
  echo " -ps create ps file " 
  echo " -decim minlon,minlat,maxlon,maxlat select range to use " 
  echo " for triangulation " 
  echo " -kill nam1 nam2 ... station to remove "
  echo " -tri file specific triangle file "
  echo " -gmt write GMT script "
  echo " -rm keep all temporay files"
  echo " "
  echo " ex : sh_strain2 -f iran_eura040303.vel -ps -decim 40,20,65,45 "
  echo " "
  exit
endif
#-----------------------------------------------------------------
# default
set f = ""
set ps = no
set decim = no
set dec = no
set kill = ""
set kil = no
set tri = no
set gmt = no
set rm = yes
#-----------------------------------------------------------------
while ($#argv > 0 ) 
set input = ( $argv ) 
switch($input[1])
	case -f
		    set file = $input[2]
		    breaksw
	case -ps
		    set ps = yes
		    breaksw
	case -decim
		    set decim = $input[2]
		    set dec = yes
		    breaksw
	case -kill:
		    set kill = (`echo $argv | cut -d- -f2`); shift kill
		    set kil = yes
	breaksw
	case -tri:
		    set tri = $input[2]
		    set tria = yes
	breaksw
	case -gmt:
		    set gmt = yes
	breaksw
	case -rm:
		    set rm = no
	breaksw
endsw 
shift argv 
end
#-----------------------------------------------------------------

# remove comment line 
grep -v "#" $file > tmp.vel

# remove oultiers lon and lat
if ( $dec == "yes" ) then
echo $decim > tmp.dec
echo tmp.vel >> tmp.dec
set program = decimll.exe
$program < tmp.dec
\mv decim.out tmp.vel
else
echo 0,0,360,90 > tmp.dec
echo tmp.vel >> tmp.dec
set program = decimll.exe
$program < tmp.dec
\mv decim.out tmp.vel
endif

# remove stations
if ( $kil == yes ) then 
echo "Soft kill :" $kill
foreach i ( $kill )
grep -v $i tmp.vel > tmp1.vel
\mv tmp1.vel tmp.vel
end 
endif    
\mv tmp.vel triangle.vel
grep -v "(" triangle.vel > tmp.vel

# triangulate
if ( $tri == no ) then 
triangulate tmp.vel > tmp.tri
else
\cp $tri tmp.tri
endif
 
# execution du program triangle.exe
set program = triangle.exe
$program

#-----------------------------------------------------------------
# execution de v2strain
echo triangle.vel > v2strain_sphere_ini
echo name.tri >> v2strain_sphere_ini
echo groupes_rotation >> v2strain_sphere_ini
echo ">" > groupes_rotation
echo " " >> groupes_rotation
set program = v2strain_sphere.exe
$program > /dev/null
#
echo " "
echo " "
echo " To view strain : xadeli2d "
echo " load : pfile " 
echo " "
echo " "
#-----------------------------------------------------------------
# execution de rd_pfile.exe
echo 3 > tmp
echo 0 >> tmp
set program = rd_pfile.exe
$program < tmp > /dev/null
#
# strain axes
awk '{print $2,"0",$3}' strain_axe1 > tmp1
awk '{print $2,"0",$3}' strain_axe2 > tmp2
awk '{print $1,$2}' tricentr.xyz > tmp3
paste tmp3 tmp1 tmp2 > tmp
awk '{print $1,$2,$3,$6,$5}' tmp > strain_axe.xyz
# rotation
awk '{print $2}' rota > tmp1
#awk '{print $1,$2}' tricentr.xyz > tmp3
paste tmp3 tmp1 > rotation.xyz

# GMT

if ( $ps == "yes" ) then
# set Range for graphic
set Rx = `awk '{print $1,$2}' tri.xyz | minmax -I1`
psbasemap $Rx -JM15 -B5/5WESN -P -K -X2 -Y2 > strain_axe.ps
pscoast -R -JM -P -S0/0/250 -N1/0/0/0 -Df -K -O -W >> strain_axe.ps
psxy tri.xyz $Rx -JM15 -M -L -W2/0/0/0 -K -O >> strain_axe.ps
psvelo -JM -R -O -K -Sx4.02649e+14 strain_axe.xyz >> strain_axe.ps 
#awk '{print $1,$2,"12 0 4 6",$8}' tmp.vel | pstext -N -O -JM $Rx -W -C0/0 >> strain_axe.ps
pstext tri.txt -N -O -JM $Rx -W -C0/0 >> strain_axe.ps
#
psbasemap $Rx -JM15 -B5/5WESN -P -K -X2 -Y2 > rotation.ps
pscoast -R -JM -P -S0/0/250 -N1/0/0/0 -Df -K -O -W >> rotation.ps
psxy tri.xyz $Rx -JM15 -M -L -W2/0/0/0 -K -O >> rotation.ps
#psxy tricentr.xyz $Rx -JM15 -M -L -Sc0.2 -G0/0/0 -K -O >> triangle.ps
psvelo -JM -R -O -K -Sw0.5/1 rotation.xyz >> rotation.ps 
pstext tri.txt -N -O -JM $Rx -W -C0/0 >> rotation.ps
#
echo " "
echo " "
echo " To view postript files : gs strain_axe.ps "
echo " : gs rotation.ps " 
echo " "
echo " "
endif
if ( $rm == "yes" ) then
\rm tmp
\rm tmp1
\rm tmp2
\rm tmp3
\rm tmp.dec
\rm tmp.tri
\rm tmp.vel
\rm strain_axe1
\rm strain_axe2 
\rm rota
\rm poles98_rigide
\rm groupes_rotation
\rm polemin
\rm triangle.vel
\rm tricentr.xyz 
\rm vitesses98_rigide
\rm name.tri
\rm v2strain_sphere_ini
if ( $gmt == "no" ) then
\rm tri.txt
\rm tri.xyz
endif
endif
#-----------------------------------------------------------------
if ( $gmt == "yes" ) then
# set Range for graphic
set Rx = `awk '{print $1,$2}' tri.xyz | minmax -I1`

echo "# strain axes" > GMT_strain_rota.scr
echo " " >> GMT_strain_rota.scr
echo "psbasemap $Rx -JM15 -B5/5WESN -P -K -X2 -Y2 > strain_axe.ps " >> GMT_strain_rota.scr
echo "pscoast -R -JM -P -S0/0/250 -N1/0/0/0 -Df -K -O -W >> strain_axe.ps" >> GMT_strain_rota.scr
echo "psxy tri.xyz $Rx -JM15 -M -L -W2/0/0/0 -K -O >> strain_axe.ps" >> GMT_strain_rota.scr
echo "psvelo -JM -R -O -K -Sx4.02649e+14 strain_axe.xyz >> strain_axe.ps" >> GMT_strain_rota.scr
echo "pstext tri.txt -N -O -JM $Rx -W -C0/0 >> strain_axe.ps" >> GMT_strain_rota.scr
echo " " >> GMT_strain_rota.scr
echo "# rotation " >> GMT_strain_rota.scr
echo " " >> GMT_strain_rota.scr
echo "psbasemap $Rx -JM15 -B5/5WESN -P -K -X2 -Y2 > rotation.ps" >> GMT_strain_rota.scr
echo "pscoast -R -JM -P -S0/0/250 -N1/0/0/0 -Df -K -O -W >> rotation.ps" >> GMT_strain_rota.scr
echo "psxy tri.xyz $Rx -JM15 -M -L -W2/0/0/0 -K -O >> rotation.ps" >> GMT_strain_rota.scr
echo "psvelo -JM -R -O -K -Sw0.5/1 rotation.xyz >> rotation.ps " >> GMT_strain_rota.scr
echo "pstext tri.txt -N -O -JM $Rx -W -C0/0 >> rotation.ps" >> GMT_strain_rota.scr
echo " "
echo " "
echo " GMT script : GMT_strain_rota.scr "
echo " "
echo " "
\chmod u+x GMT_strain_rota.scr
endif
end

```

---

<div class="post-metadata">

**Author:** ![PlanetGus](https://yyz1.discourse-cdn.com/flex047/user_avatar/forum.generic-mapping-tools.org/planetgus/32/303_2.png) [@PlanetGus](https://forum.generic-mapping-tools.org/u/PlanetGus)\
**Post date:** [October 26, 2022, 8:59am UTC](https://forum.generic-mapping-tools.org/t/please-help-me-to-run-this-cod-triangulate-rotation/3386/2 "2022-10-26T08:59:23Z")

</div>

Is the question about how to execute a script ?  
Or is it related to an error when you try to run it? If so, what does the prompt say?

---

<div class="post-metadata">

**Author:** ![maahnaz](https://yyz1.discourse-cdn.com/flex047/user_avatar/forum.generic-mapping-tools.org/maahnaz/32/2576_2.png) [@maahnaz](https://forum.generic-mapping-tools.org/u/maahnaz)\
**Post date:** [October 27, 2022, 3:36am UTC](https://forum.generic-mapping-tools.org/t/please-help-me-to-run-this-cod-triangulate-rotation/3386/3 "2022-10-27T03:36:05Z")

</div>

Hi  
Thanks for replying  
yes. when I run it there are some errors that I cant solve them.  
if you or anyone can help me please give me your email address or WhatsApp number.  
I appreciate for help  
Mahnaz

---

<div class="post-metadata">

**Author:** ![maahnaz](https://yyz1.discourse-cdn.com/flex047/user_avatar/forum.generic-mapping-tools.org/maahnaz/32/2576_2.png) [@maahnaz](https://forum.generic-mapping-tools.org/u/maahnaz)\
**Post date:** [October 27, 2022, 5:45am UTC](https://forum.generic-mapping-tools.org/t/please-help-me-to-run-this-cod-triangulate-rotation/3386/4 "2022-10-27T05:45:30Z")

</div>

Hi,  
Dear Joaquim  
First of all, thanks for editing my code.  
I tried, but it still does not work.  
It’s my data. I am working on this code, but unfortunately, l can’t understand the problem. Please if it’s possible, help me to run this code.  
I run this command. Is it correct?  
sh\_strain2 -f iran\_eura040303.vel -ps -decim 40,20,65,45  
Thank you in advance for your attention and I look forward to your kind response.

# Test synthetique

# 0.00 0.00 0.0 0.0 1.0 1.0 0.01 ST1A

# 2.00 0.01 0.0 0.0 1.0 1.0 0.01 ST2A

# 1.00 2.00 14.0 0.0 1.0 1.0 0.01 ST3A

# 0.00 0.00 0.0 0.0 1.0 1.0 0.01 ST1B

# 2.00 0.01 0.0 0.0 1.0 1.0 0.01 ST2B

# 1.00 2.00 0.0 20.0 1.0 1.0 0.01 ST3B

# ajout McClusky et KSHA/ARDA

41.34 41.37 -0.1 2.6 1.5 1.4 -0.01 HOPA  
41.79 38.75 -5.1 14.4 1.4 1.2 0.05 KRKT  
51.255 34.150 -0.32 14.02 1.15 1.10 0.015 KSHA  
44.53 41.83 1.1 5.8 1.2 1.2 0.01 NICH

# alborz networkiran\_eura040303.vel

51.986 35.793 0.72 7.55 1.63 1.58 0.017 ABAL  
52.586 35.701 -1.90 8.82 1.68 1.62 0.020 AMIN  
51.812 35.730 -0.39 9.93 1.04 1.00 0.012 BOOM  
50.988 35.088 0.26 9.92 1.53 1.48 0.012 CHSH  
52.059 35.701 -1.64 8.00 1.67 1.64 0.019 DAMA  
52.305 36.206 -3.21 9.15 1.77 1.63 0.02

@Joaquim

---

<div class="post-metadata">

**Author:** ![PlanetGus](https://yyz1.discourse-cdn.com/flex047/user_avatar/forum.generic-mapping-tools.org/planetgus/32/303_2.png) [@PlanetGus](https://forum.generic-mapping-tools.org/u/PlanetGus)\
**Post date:** [October 27, 2022, 9:29am UTC](https://forum.generic-mapping-tools.org/t/please-help-me-to-run-this-cod-triangulate-rotation/3386/5 "2022-10-27T09:29:35Z")

</div>

It would help to tell what kind of error you get.  
Paste them between triple back ticks
