#!/bin/bash
#
#	$Id: spotter.sh 12464 2013-11-06 15:58:22Z fwobbe $
#
#	Examples of how to use the SPOTTER package
#
#	Paul Wessel
#	29-DEC-1999
#

POLES=WK97.d	# Rotation poles to use
#POLES=DC85.d	# Rotation poles to use

# Example 1 - Using gmt backtracker
#
# We will use gmt backtracker to test all four functions.  We will
# 1. Plot hotspot track from Loihi forwards for 80 m.y.
# 2. forthtrack where Loihi will be in 80 m.y
# 3. Plot flowline from Suiko back until paleoridge (100 Ma)
# 4. Backtrack the location of Suiko using an age of 64.7 Ma

echo -n "Running example 1..."

echo "205 20 80.0" > loihi.d
echo "170 44 100" > suiko.d
gmt pscoast -R150/220/00/65 -JM6i -P -K -G30/120/30 -A500 -Dl -W0.25p -B20WSne > example_1.ps
gmt psxy -R -JM -O -K -SC0.1 -G255/0/0 -W0.5p loihi.d >> example_1.ps
# Task 1.1:
gmt backtracker loihi.d -Df -Lb25 -E${POLES} | gmt psxy -R -JM -O -K -M -W1p >> example_1.ps
# Task 1.2:
gmt backtracker loihi.d -Df -E${POLES} | gmt psxy -R -JM -O -K -SC0.1 -G0/255/0 -W0.5p >> example_1.ps
# Task 1.3:
gmt backtracker suiko.d -Db -Lf25 -E${POLES} | gmt psxy -R -JM -O -K -M -W1top >> example_1.ps
echo "170 44 64.7" > suiko.d
# Task 1.4:
gmt backtracker suiko.d -Db -E${POLES} | gmt psxy -R -JM -O -K -ST0.1 -G255/255/0 -W0.5p >> example_1.ps
gmt psxy -R -JM -O -ST0.1 -G0/255/255 -W0.5p suiko.d >> example_1.ps
echo "Done.  View example_1.ps"
#ghostview example_1.ps

# Example 2 - Using gmt hotspotter
#
# We will use gmt hotspotter to create a CVA image for the Pacific.
# It will look similar to the ones we have published but we will
# here use only seamounts with a VGG amplitude of at least 100 Eotvos.

echo "Running example 2..."

DATA=seamounts.d		# The data to use
tmax=145			# Upper age limit
dx=10m				# The grid spacing to use
region=130/260/-66/60		# Our Pacific region

gmt hotspotter $DATA -h -I$dx -R$region -E${POLES} -Gexample_1.nc -V -T -N$tmax

# Make a suitable color table

gmt makecpt -Chot -T0/3000/300 -Z > t.cpt

gmt grdimage example_1.nc -JM6i -P -K -Ct.cpt -V > example_2.ps
gmt pscoast -R -JM -O -G30/120/30 -A500 -Dl -W0.25p -B20WSne >> example_2.ps
\rm -f t.cpt loihi.d suiko.d
echo "Done.  View example_2.ps"
#ghostview example_2.ps

# Example 3 - Using gmt originator
#
# We will use gmt originator to determine the most likely hotspot origins
# for the seamounts in the seamounts.d file, given a plate motion model
# and a list of possible hotspots.

echo "Running example 3..."

DATA=seamounts.d		# The data to use
HS=pac_hs.d			# The allowable hotspots to compare to
dx=10m				# The flowline sampling interval to use
region=130/260/-66/60		# Our Pacific region
N=2				# return the two most likely hotspots per seamount

gmt originator $DATA -S${N} -h -D$dx -E${POLES} -F${HS} -V > example_3.d

echo "Done.  Inspect example_3.d data file"
#$EDITOR example_3.d
