LWplot_w
author A.M. Thurnherr <athurnherr@yahoo.com>
Mon, 20 Apr 2015 14:04:04 +0000
changeset 28 b07b23485336
parent 27 2053d8de8d6b
child 29 c1ff35103176
permissions -rwxr-xr-x
after folding in EGU flight mods (empirical Sv correction)
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
27
2053d8de8d6b updated plots & seabed code; GoM data process correctly
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 26
diff changeset
     5
#                    dlm: Thu Apr 16 11:17: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
27
2053d8de8d6b updated plots & seabed code; GoM data process correctly
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 26
diff changeset
     7
#                    uE-Info: 76 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
4
e681262d0fd7 yay! first version I am really happy with. With plots 'n all.
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff changeset
    23
e681262d0fd7 yay! first version I am really happy with. With plots 'n all.
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff changeset
    24
#--------------------------------------------------
e681262d0fd7 yay! first version I am really happy with. With plots 'n all.
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff changeset
    25
# Usage
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
5
509cc9966b68 ======================================================================
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 4
diff changeset
    28
USAGE="Usage: $0 <eps-file> [in-file]"
509cc9966b68 ======================================================================
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 4
diff changeset
    29
	[ $# -eq 2 ] && exec <"$2" "$0" "$1"
509cc9966b68 ======================================================================
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 4
diff changeset
    30
	[ $# -ne 1 ] && { echo $USAGE >&2; exit 1; }
6
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 5
diff changeset
    31
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
    32
e681262d0fd7 yay! first version I am really happy with. With plots 'n all.
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff changeset
    33
#--------------------------------------------------
e681262d0fd7 yay! first version I am really happy with. With plots 'n all.
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff changeset
    34
# 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
    35
#--------------------------------------------------
e681262d0fd7 yay! first version I am really happy with. With plots 'n all.
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff changeset
    36
5
509cc9966b68 ======================================================================
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 4
diff changeset
    37
while [ -z "$fields" ]
509cc9966b68 ======================================================================
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 4
diff changeset
    38
do
509cc9966b68 ======================================================================
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 4
diff changeset
    39
	read line
509cc9966b68 ======================================================================
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 4
diff changeset
    40
	[ -z "$out_basename" ] && out_basename=`expr -- "$line" : '#ANTS#PARAMS#.*out_basename{\([^}]*\)}`
509cc9966b68 ======================================================================
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 4
diff changeset
    41
	[ -z "$run_label" ] && run_label=`expr -- "$line" : '#ANTS#PARAMS#.*run_label{\([^}]*\)}`
509cc9966b68 ======================================================================
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 4
diff changeset
    42
	[ -z "$min_depth" ] && min_depth=`expr -- "$line" : '#ANTS#PARAMS#.*min_depth{\([^}]*\)}`
509cc9966b68 ======================================================================
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 4
diff changeset
    43
	[ -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
    44
	[ -z "$water_depth" ] && water_depth=`expr -- "$line" : '#ANTS#PARAMS#.*water_depth{\([^}]*\)}`
5
509cc9966b68 ======================================================================
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 4
diff changeset
    45
	[ -z "$min_ens" ] && min_ens=`expr -- "$line" : '#ANTS#PARAMS#.*min_ens{\([^}]*\)}`
509cc9966b68 ======================================================================
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 4
diff changeset
    46
	[ -z "$max_ens" ] && max_ens=`expr -- "$line" : '#ANTS#PARAMS#.*max_ens{\([^}]*\)}`
509cc9966b68 ======================================================================
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 4
diff changeset
    47
	[ -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
    48
	[ -z "$fields" ] && fields=`expr -- "$line" : '#ANTS#FIELDS# \(.*\)' | sed -e s/{//g -e s/}//g`
509cc9966b68 ======================================================================
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 4
diff changeset
    49
done
509cc9966b68 ======================================================================
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 4
diff changeset
    50
6
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 5
diff changeset
    51
set -- $fields
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 5
diff changeset
    52
[ "$1" = ensemble -a "$4" = depth -a "$7" = w ] || {
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 5
diff changeset
    53
	echo "$0: file layout error" >&2
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 5
diff changeset
    54
	exit 1
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 5
diff changeset
    55
}
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 5
diff changeset
    56
5
509cc9966b68 ======================================================================
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 4
diff changeset
    57
#--------------------------------------------------
509cc9966b68 ======================================================================
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 4
diff changeset
    58
# Plot Data
509cc9966b68 ======================================================================
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 4
diff changeset
    59
#--------------------------------------------------
509cc9966b68 ======================================================================
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 4
diff changeset
    60
8
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 6
diff changeset
    61
eps_file="$PWD/$eps_file"	# make outfile name absolute (hopefully, it is not already...)
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 6
diff changeset
    62
mkdir /tmp/$$				# GMT makes tmpfiles and is not reentrant
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 6
diff changeset
    63
cd /tmp/$$
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 6
diff changeset
    64
5
509cc9966b68 ======================================================================
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 4
diff changeset
    65
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
    66
cat > $TMPFILE
5
509cc9966b68 ======================================================================
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 4
diff changeset
    67
4
e681262d0fd7 yay! first version I am really happy with. With plots 'n all.
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff changeset
    68
[ -f .gmtdefaults4 ] ||
e681262d0fd7 yay! first version I am really happy with. With plots 'n all.
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff changeset
    69
	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
    70
			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
    71
			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
    72
	        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
    73
27
2053d8de8d6b updated plots & seabed code; GoM data process correctly
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 26
diff changeset
    74
[ -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
    75
				      || 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
    76
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
    77
	 
4
e681262d0fd7 yay! first version I am really happy with. With plots 'n all.
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff changeset
    78
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
    79
X=-JX10/-10
e681262d0fd7 yay! first version I am really happy with. With plots 'n all.
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff changeset
    80
e681262d0fd7 yay! first version I am really happy with. With plots 'n all.
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff changeset
    81
ens_width=`echo "scale=5;10/($max_ens-$min_ens+1)"|bc`
5
509cc9966b68 ======================================================================
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 4
diff changeset
    82
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
    83
509cc9966b68 ======================================================================
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 4
diff changeset
    84
awk "{print \$1, \$4, \$7, $ens_width, $bin_length}" $TMPFILE \
6
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 5
diff changeset
    85
	| psxy -P -K $R $X -C`which LWplot_w | sed 's@LWplot_w$@w.cpt@'` -Sr > "$eps_file"
27
2053d8de8d6b updated plots & seabed code; GoM data process correctly
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 26
diff changeset
    86
[ -n "$water_depth" ] && {
2053d8de8d6b updated plots & seabed code; GoM data process correctly
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 26
diff changeset
    87
	echo $min_ens $blim;
2053d8de8d6b updated plots & seabed code; GoM data process correctly
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 26
diff changeset
    88
	echo $max_ens $blim;
2053d8de8d6b updated plots & seabed code; GoM data process correctly
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 26
diff changeset
    89
	echo $max_ens $water_depth;
2053d8de8d6b updated plots & seabed code; GoM data process correctly
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 26
diff changeset
    90
	echo $min_ens $water_depth;
2053d8de8d6b updated plots & seabed code; GoM data process correctly
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 26
diff changeset
    91
} | psxy -O -K $R $X -G204/153/102 >> "$eps_file"
5
509cc9966b68 ======================================================================
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 4
diff changeset
    92
	
6
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 5
diff changeset
    93
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
    94
5
509cc9966b68 ======================================================================
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 4
diff changeset
    95
if [ 0 -eq `echo "($max_depth-$min_depth)>1000"|bc` ]
509cc9966b68 ======================================================================
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 4
diff changeset
    96
then
509cc9966b68 ======================================================================
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 4
diff changeset
    97
	depth_tics=f10a100
509cc9966b68 ======================================================================
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 4
diff changeset
    98
	ens_tics=f50a500
509cc9966b68 ======================================================================
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 4
diff changeset
    99
else
509cc9966b68 ======================================================================
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 4
diff changeset
   100
	depth_tics=f100a500
509cc9966b68 ======================================================================
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 4
diff changeset
   101
	ens_tics=f500a1000
509cc9966b68 ======================================================================
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 4
diff changeset
   102
fi
4
e681262d0fd7 yay! first version I am really happy with. With plots 'n all.
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff changeset
   103
6
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 5
diff changeset
   104
cat `which LWplot_w | sed 's@LWplot_w$@w_scale.skel@'` >> "$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
   105
6
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 5
diff changeset
   106
psbasemap -O $R $X -B$ens_tics:"Ensemble":/$depth_tics:"Depth [m]":WeSn >> "$eps_file"
5
509cc9966b68 ======================================================================
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 4
diff changeset
   107
509cc9966b68 ======================================================================
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 4
diff changeset
   108
rm $TMPFILE
20
d6dc9c9da138 updated LWplot to make fixbb optional
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 9
diff changeset
   109
[ -n "`which fixbb`" ] && fixbb "$eps_file"
8
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 6
diff changeset
   110
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 6
diff changeset
   111
cd "$PWD"
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 6
diff changeset
   112
rm -rf /tmp/$$
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 6
diff changeset
   113