-------------------------------------------
var,funct (left-click): write col LUT
  set val2rgblut <infile>
  write_val2rgblut
-------------------------------------------

The "W" button on the "lut:" entry line writes a
color lookup table (LUT) for current colscale
containing $val2rgblutout (default=15) entries.

Write LUT for real-valued data

If $complexvalflag unset ("cpx" unticked), a
real-valued LUT will be written for the current
colscale settings including:

  $fthresh, $sfthresh
  $fmid, $sfmid
  $fslope, $sfslope
  $interpolatelutflag
  $botedgelutflag
  $zerosymmfadeflag

Amplitude limits will be taken from the current
values of the color bar limits (entries on either
side of "bar" ($minstatcolscale, and
$minstatcolscale).  An input stat of 25.0 will be
assumed while writing the file, so set $sfthresh
to 0.0 to avoid desaturating the color LUT.

Immediately re-reading the just-written-out color
scale will recursively apply some of these
parameters. To avoid this:

  set fthresh <below-any-data-value>
  set fmid <below-any-data-value>
  set sfmid <below-any-stat-value>
  set fslope <large>
  set sfslope <large>
  set interpolatelutflag 1
  set botedgelutflag 0
  set zerosymmfadeflag 0

Write LUT for complex-valued data

If $complexvalflag is set ("cpx" clicked), a
smoothly-wrapped complex *phase* LUT will be
written (color for 0.0 will equal color for 1.0).

Here, phase controls hue, while complex amplitude
controls color saturation.  To be sure you
generate a fully saturated LUT, set set $fthresh
and $sfthresh to 0.0 just before writing the file
(an input amplitude of 5.0 and an input stat of
25.0 is assumed when writing the file).

When *displaying* data with this LUT file, the
*amplitude* will be taken from the complex
amplitude of the data that is currently read in
(incl. statistical mask, if present).

This parallels the behavior of colscale=1 ("w1")
or colscale=8 ("w2") and controlled by $fthresh,
$fmid, and $fslope.

Note that the write-time values of $revphaseflag,
$angle_offset, and $angle_cycles are incorporated
into the phase LUT file when it is created.  The
LUT file maps the unmodified 0-1 phase angle
(calcuated by atan2() from real and imaginary
data at each vertex) to the *currently displayed*
vertex color (which is affected by the current
settings of $revphaseflag, $angle_offset, and
$angle_cycles, and also $fthresh, $fmid, and
$fslope).

The raw phase angle at a vertex can be listed by
clicking a vertex and looking in the log for
something like:

  tksurfer: val/val2:(-12.905,1.963)=>(13.054,171deg),...

Note that when *displaying* a read-in color LUT,
$revphaseflag and $angle_offset will still affect
the colors the same way they affect the built-in
phase colscale=1 ("w1").

Because of this, to *display* the same colors
visible at the time the phase LUT file was
written, unset $revphaseflag (unclick "rev") and
set $angle_offset to 0.0.

At display time, the $angle_cycles field is
ignored (except to decide whether to show an
"eccentricity" or "polar angle" inset).
