#!/bin/sh
# $Id: shaded_globe,v 1.3 2002-08-01 13:00:32-06 braup Exp braup $
# Makes a shaded globe

originlon="140"     # Tokyo
originlat="35"      # Tokyo

sunposition="170 45"

origin="$originlon $originlat"

proj=G$originlon/$originlat/15c
region=-180/180/-90/90
inc=1
grdfile=shade.grd
out=location_map.ps
pngout=location_map.png

echo "Origin = $origin" >&2
bndpen=0.5p/0/0/0
gmtset PAPER_MEDIA letter BASEMAP_TYPE plain FRAME_PEN 1p HEADER_FONT_SIZE 20p
gmtset D_FORMAT %lg DEGREE_FORMAT 1
grdmath -R$region -I$inc -F $sunposition GDIST COSD = $grdfile
grdmath $grdfile 0.2 ADD = land.grd
grd2cpt $grdfile -S-0.2/1.2/0.05 -Cgray -Z > shade.cpt
grdimage $grdfile -R$region -J$proj -Cshade.cpt -K -V > $out
pscoast -R$region -J$proj -A3000 -Dc -Gc -O -K -V >> $out
grdimage land.grd -R$region -J$proj -Cshade.cpt -O -K -V >> $out
pscoast -R$region -J$proj -Q -O -K -V >> $out
gzip -dc /home/braup/lib/GMT/State_Country_Boundaries/Asia/japan.dat.gz |
  psxy -R$region -J$proj -G0 -W0.9p/0 -L -M -O -V >> $out
#pscoast -R$region -J$proj -A3000 -Dc -N1/$bndpen -W$bndpen -O -K -V >> $out
#echo "$origin" | psxy -J$proj -R$region -Sc0.2c -G0/0/255 -O -V >> $out

convert -density 80 -rotate 90 -trim $out $pngout
