LWplot_w
author A.M. Thurnherr <athurnherr@yahoo.com>
Sun, 26 Jul 2015 20:04:48 +0000
changeset 29 c1ff35103176
parent 27 2053d8de8d6b
permissions -rwxr-xr-x
a few days pre WHOI
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
27
2053d8de8d6b updated plots & seabed code; GoM data process correctly
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 26
diff changeset
     1
#!/bin/sh
4
e681262d0fd7 yay! first version I am really happy with. With plots 'n all.
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff changeset
     2
#======================================================================
e681262d0fd7 yay! first version I am really happy with. With plots 'n all.
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff changeset
     3
#					 L W P L O T _ W 
e681262d0fd7 yay! first version I am really happy with. With plots 'n all.
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff changeset
     4
#                    doc: Sat Oct 15 13:42:50 2011
29
c1ff35103176 a few days pre WHOI
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 27
diff changeset
     5
#                    dlm: Wed May 20 20:47:23 2015
4
e681262d0fd7 yay! first version I am really happy with. With plots 'n all.
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff changeset
     6
#                    (c) 2011 A.M. Thurnherr
29
c1ff35103176 a few days pre WHOI
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 27
diff changeset
     7
#                    uE-Info: 52 0 NIL 0 0 72 2 2 4 NIL ofnI
4
e681262d0fd7 yay! first version I am really happy with. With plots 'n all.
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff changeset
     8
#======================================================================
e681262d0fd7 yay! first version I am really happy with. With plots 'n all.
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff changeset
     9
e681262d0fd7 yay! first version I am really happy with. With plots 'n all.
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff changeset
    10
# HISTORY:
e681262d0fd7 yay! first version I am really happy with. With plots 'n all.
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff changeset
    11
#	Oct 15, 2011: - created
5
509cc9966b68 ======================================================================
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 4
diff changeset
    12
#	Oct 17, 2011: - turned into filter
509cc9966b68 ======================================================================
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 4
diff changeset
    13
#				  - added %run_label
509cc9966b68 ======================================================================
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 4
diff changeset
    14
#	Oct 19, 2011: - fiddled
509cc9966b68 ======================================================================
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 4
diff changeset
    15
#   Oct 24, 2011: - LADCP_bin_length => ADCP_bin_length
6
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 5
diff changeset
    16
#	Nov 14, 2011: - added file layout check
7
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 6
diff changeset
    17
#	Mar 12, 2012: - sh -> ksh as this does not work with /bin/sh on MacOSX 10.6.4
8
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 6
diff changeset
    18
#   Apr 12, 2012: - made re-entrant
20
d6dc9c9da138 updated LWplot to make fixbb optional
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 9
diff changeset
    19
#	Apr  5, 2015: - made fixbb optional
26
b89d4b01fcc5 after implementing new schemes for plotting and active files
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 20
diff changeset
    20
#   Apr 16, 2015: - removed copy of input on stdout
27
2053d8de8d6b updated plots & seabed code; GoM data process correctly
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 26
diff changeset
    21
#				  - changed shell from /bin/ksh to /bin/sh
2053d8de8d6b updated plots & seabed code; GoM data process correctly
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 26
diff changeset
    22
#				  - added seabed if available
29
c1ff35103176 a few days pre WHOI
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 27
diff changeset
    23
#   Apr 20, 2015: - removed _skel dependence
c1ff35103176 a few days pre WHOI
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 27
diff changeset
    24
#   May 20, 2015: - made it quit on EOF
4
e681262d0fd7 yay! first version I am really happy with. With plots 'n all.
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff changeset
    25
e681262d0fd7 yay! first version I am really happy with. With plots 'n all.
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff changeset
    26
#--------------------------------------------------
e681262d0fd7 yay! first version I am really happy with. With plots 'n all.
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff changeset
    27
# Usage
e681262d0fd7 yay! first version I am really happy with. With plots 'n all.
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff changeset
    28
#--------------------------------------------------
e681262d0fd7 yay! first version I am really happy with. With plots 'n all.
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff changeset
    29
5
509cc9966b68 ======================================================================
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 4
diff changeset
    30
USAGE="Usage: $0 <eps-file> [in-file]"
509cc9966b68 ======================================================================
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 4
diff changeset
    31
	[ $# -eq 2 ] && exec <"$2" "$0" "$1"
509cc9966b68 ======================================================================
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 4
diff changeset
    32
	[ $# -ne 1 ] && { echo $USAGE >&2; exit 1; }
6
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 5
diff changeset
    33
eps_file="$1"
4
e681262d0fd7 yay! first version I am really happy with. With plots 'n all.
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff changeset
    34
e681262d0fd7 yay! first version I am really happy with. With plots 'n all.
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff changeset
    35
#--------------------------------------------------
e681262d0fd7 yay! first version I am really happy with. With plots 'n all.
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff changeset
    36
# Read Header Data
e681262d0fd7 yay! first version I am really happy with. With plots 'n all.
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff changeset
    37
#--------------------------------------------------
e681262d0fd7 yay! first version I am really happy with. With plots 'n all.
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff changeset
    38
29
c1ff35103176 a few days pre WHOI
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 27
diff changeset
    39
read line
c1ff35103176 a few days pre WHOI
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 27
diff changeset
    40
while [ -z "$fields" -a -n "$line" ]
5
509cc9966b68 ======================================================================
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 4
diff changeset
    41
do
509cc9966b68 ======================================================================
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 4
diff changeset
    42
	[ -z "$out_basename" ] && out_basename=`expr -- "$line" : '#ANTS#PARAMS#.*out_basename{\([^}]*\)}`
509cc9966b68 ======================================================================
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 4
diff changeset
    43
	[ -z "$run_label" ] && run_label=`expr -- "$line" : '#ANTS#PARAMS#.*run_label{\([^}]*\)}`
509cc9966b68 ======================================================================
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 4
diff changeset
    44
	[ -z "$min_depth" ] && min_depth=`expr -- "$line" : '#ANTS#PARAMS#.*min_depth{\([^}]*\)}`
509cc9966b68 ======================================================================
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 4
diff changeset
    45
	[ -z "$max_depth" ] && max_depth=`expr -- "$line" : '#ANTS#PARAMS#.*max_depth{\([^}]*\)}`
27
2053d8de8d6b updated plots & seabed code; GoM data process correctly
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 26
diff changeset
    46
	[ -z "$water_depth" ] && water_depth=`expr -- "$line" : '#ANTS#PARAMS#.*water_depth{\([^}]*\)}`
5
509cc9966b68 ======================================================================
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 4
diff changeset
    47
	[ -z "$min_ens" ] && min_ens=`expr -- "$line" : '#ANTS#PARAMS#.*min_ens{\([^}]*\)}`
509cc9966b68 ======================================================================
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 4
diff changeset
    48
	[ -z "$max_ens" ] && max_ens=`expr -- "$line" : '#ANTS#PARAMS#.*max_ens{\([^}]*\)}`
509cc9966b68 ======================================================================
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 4
diff changeset
    49
	[ -z "$ADCP_bin_length" ] && ADCP_bin_length=`expr -- "$line" : '#ANTS#PARAMS#.*ADCP_bin_length{\([^}]*\)}`
509cc9966b68 ======================================================================
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 4
diff changeset
    50
	[ -z "$fields" ] && fields=`expr -- "$line" : '#ANTS#FIELDS# \(.*\)' | sed -e s/{//g -e s/}//g`
29
c1ff35103176 a few days pre WHOI
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 27
diff changeset
    51
	read line
5
509cc9966b68 ======================================================================
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 4
diff changeset
    52
done
509cc9966b68 ======================================================================
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 4
diff changeset
    53
6
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 5
diff changeset
    54
set -- $fields
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 5
diff changeset
    55
[ "$1" = ensemble -a "$4" = depth -a "$7" = w ] || {
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 5
diff changeset
    56
	echo "$0: file layout error" >&2
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 5
diff changeset
    57
	exit 1
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 5
diff changeset
    58
}
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 5
diff changeset
    59
5
509cc9966b68 ======================================================================
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 4
diff changeset
    60
#--------------------------------------------------
509cc9966b68 ======================================================================
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 4
diff changeset
    61
# Plot Data
509cc9966b68 ======================================================================
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 4
diff changeset
    62
#--------------------------------------------------
509cc9966b68 ======================================================================
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 4
diff changeset
    63
8
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 6
diff changeset
    64
eps_file="$PWD/$eps_file"	# make outfile name absolute (hopefully, it is not already...)
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 6
diff changeset
    65
mkdir /tmp/$$				# GMT makes tmpfiles and is not reentrant
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 6
diff changeset
    66
cd /tmp/$$
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 6
diff changeset
    67
5
509cc9966b68 ======================================================================
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 4
diff changeset
    68
TMPFILE=/tmp/$$.LWplot_w
26
b89d4b01fcc5 after implementing new schemes for plotting and active files
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 20
diff changeset
    69
cat > $TMPFILE
5
509cc9966b68 ======================================================================
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 4
diff changeset
    70
4
e681262d0fd7 yay! first version I am really happy with. With plots 'n all.
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff changeset
    71
[ -f .gmtdefaults4 ] ||
e681262d0fd7 yay! first version I am really happy with. With plots 'n all.
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff changeset
    72
	gmtset	PAPER_MEDIA letter+ \
e681262d0fd7 yay! first version I am really happy with. With plots 'n all.
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff changeset
    73
			LABEL_FONT_SIZE 14 ANNOT_FONT_SIZE_PRIMARY 14 \
e681262d0fd7 yay! first version I am really happy with. With plots 'n all.
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff changeset
    74
			WANT_EURO_FONT true \
e681262d0fd7 yay! first version I am really happy with. With plots 'n all.
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff changeset
    75
	        PLOT_DEGREE_FORMAT ddd:mm:ssF
e681262d0fd7 yay! first version I am really happy with. With plots 'n all.
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff changeset
    76
27
2053d8de8d6b updated plots & seabed code; GoM data process correctly
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 26
diff changeset
    77
[ -n "$water_depth" ] && blim=`echo "scale=1;$water_depth+25"|bc` \
2053d8de8d6b updated plots & seabed code; GoM data process correctly
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 26
diff changeset
    78
				      || blim=`echo "scale=1;$max_depth+$ADCP_bin_length"|bc`
2053d8de8d6b updated plots & seabed code; GoM data process correctly
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 26
diff changeset
    79
R=-R`echo "scale=1;$min_ens-0.5"|bc`/`echo "scale=1;$max_ens+0.5"|bc`/0/$blim
2053d8de8d6b updated plots & seabed code; GoM data process correctly
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 26
diff changeset
    80
	 
4
e681262d0fd7 yay! first version I am really happy with. With plots 'n all.
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff changeset
    81
U=-R0/1/0/1
e681262d0fd7 yay! first version I am really happy with. With plots 'n all.
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff changeset
    82
X=-JX10/-10
29
c1ff35103176 a few days pre WHOI
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 27
diff changeset
    83
C=-C`which LWplot_w | sed 's@LWplot_w$@w.cpt@'`
4
e681262d0fd7 yay! first version I am really happy with. With plots 'n all.
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff changeset
    84
e681262d0fd7 yay! first version I am really happy with. With plots 'n all.
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff changeset
    85
ens_width=`echo "scale=5;10/($max_ens-$min_ens+1)"|bc`
5
509cc9966b68 ======================================================================
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 4
diff changeset
    86
bin_length=`echo "scale=5;10*$ADCP_bin_length/($max_depth-$min_depth+$ADCP_bin_length)"|bc`
509cc9966b68 ======================================================================
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 4
diff changeset
    87
509cc9966b68 ======================================================================
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 4
diff changeset
    88
awk "{print \$1, \$4, \$7, $ens_width, $bin_length}" $TMPFILE \
29
c1ff35103176 a few days pre WHOI
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 27
diff changeset
    89
	| psxy -P -K $R $X $C -Sr > "$eps_file"
27
2053d8de8d6b updated plots & seabed code; GoM data process correctly
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 26
diff changeset
    90
[ -n "$water_depth" ] && {
2053d8de8d6b updated plots & seabed code; GoM data process correctly
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 26
diff changeset
    91
	echo $min_ens $blim;
2053d8de8d6b updated plots & seabed code; GoM data process correctly
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 26
diff changeset
    92
	echo $max_ens $blim;
2053d8de8d6b updated plots & seabed code; GoM data process correctly
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 26
diff changeset
    93
	echo $max_ens $water_depth;
2053d8de8d6b updated plots & seabed code; GoM data process correctly
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 26
diff changeset
    94
	echo $min_ens $water_depth;
2053d8de8d6b updated plots & seabed code; GoM data process correctly
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 26
diff changeset
    95
} | psxy -O -K $R $X -G204/153/102 >> "$eps_file"
5
509cc9966b68 ======================================================================
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 4
diff changeset
    96
	
6
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 5
diff changeset
    97
echo 0.02 0.02 12 0 0 TL $out_basename $run_label | pstext -O -K $U $X >> "$eps_file"
4
e681262d0fd7 yay! first version I am really happy with. With plots 'n all.
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff changeset
    98
5
509cc9966b68 ======================================================================
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 4
diff changeset
    99
if [ 0 -eq `echo "($max_depth-$min_depth)>1000"|bc` ]
509cc9966b68 ======================================================================
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 4
diff changeset
   100
then
509cc9966b68 ======================================================================
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 4
diff changeset
   101
	depth_tics=f10a100
509cc9966b68 ======================================================================
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 4
diff changeset
   102
	ens_tics=f50a500
509cc9966b68 ======================================================================
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 4
diff changeset
   103
else
509cc9966b68 ======================================================================
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 4
diff changeset
   104
	depth_tics=f100a500
509cc9966b68 ======================================================================
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 4
diff changeset
   105
	ens_tics=f500a1000
509cc9966b68 ======================================================================
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 4
diff changeset
   106
fi
4
e681262d0fd7 yay! first version I am really happy with. With plots 'n all.
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff changeset
   107
29
c1ff35103176 a few days pre WHOI
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 27
diff changeset
   108
psbasemap -O -K $R $X -B$ens_tics:"Ensemble":/$depth_tics:"Depth [m]":WeSn >> "$eps_file"
4
e681262d0fd7 yay! first version I am really happy with. With plots 'n all.
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff changeset
   109
29
c1ff35103176 a few days pre WHOI
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 27
diff changeset
   110
gmtset ANNOT_FONT_SIZE_PRIMARY 7
c1ff35103176 a few days pre WHOI
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 27
diff changeset
   111
psscale -O -E -D8/2/3/0.4 $C -B/:w: >> "$eps_file"
5
509cc9966b68 ======================================================================
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 4
diff changeset
   112
509cc9966b68 ======================================================================
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 4
diff changeset
   113
rm $TMPFILE
20
d6dc9c9da138 updated LWplot to make fixbb optional
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 9
diff changeset
   114
[ -n "`which fixbb`" ] && fixbb "$eps_file"
8
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 6
diff changeset
   115
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 6
diff changeset
   116
cd "$PWD"
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 6
diff changeset
   117
rm -rf /tmp/$$
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 6
diff changeset
   118