idlastro / Math and Statistics: PARTVELVEC

[Source code]

NAME
PARTVELVEC
PURPOSE
Plot the velocity vectors of particles at their positions
EXPLANATION
This procedure plots the velocity vectors of particles (at the
positions of the particles).
For a similar procedure look at cgDrawVectors 
 http://www.idlcoyote.com/idldoc/cg/cgdrawvectors.html
CATEGORY
Plotting, Two-dimensional.
CALLING SEQUENCE
PARTVELVEC, VELX, VELY, POSX, POSY [, X, Y]
INPUTS
VELX:  An array of any dimension, containing the x-components
       of the particle velocities.   Can include NaN values
VELY:  An array of the same dimension as velx, containing the
       y-components of the particle velocities. 
POSX:  An array of the same dimension as velx, containing the
       x-components of the particle positions.
POSY:  An array of the same dimension as velx, containing the
       y-components of the particle positions.
OPTIONAL INPUTS
X:   Optional abscissa values. X must be a vector.
Y:   Optional ordinate values. Y must be a vector. If only X
     is specified, then Y is taken equal to be equal to X.
OPTIONAL INPUT KEYWORD PARAMETERS
FRACTION:   The fraction of the vectors to plot. They are
            taken at random from the complete sample.    Default is
       FRACTION = 1.0, use all vectors
LENGTH:     The maximum vectorlength relative to the plot data
            window.   Default = 0.08
COLOR:      Color for the vectors, axes and titles by string name or
            number (see cgCOLOR).   Note that if VECCOLORS is 
            supplied, then the COLOR keyword still specifies the 
            color of the axes and title.    Default  = 'Opposite'
OVER:       Plot over the previous plot
VECCOLORS:  The vector colors. Must be either a scalar, or
            a vector (nmeric or string) the same size as VELX. 
            Set to COLOR by default.
WINDOW - Set this keyword to plot to a resizeable graphics window
Plot        All other keywords available to cgPlot (e.g. AXISCOLOR,
Keywords:   LINESTYLE, XRANGE) are available (via _EXTRA)
OUTPUTS
This procedure plots the velocity vectors (VELX,VELY) at the
positions of the particles, (POSX,POSY). If X and Y are not
specified, then the size of the plot is such that all vectors
just fit within in the plot data window.
SIDE EFFECTS
Plotting on the current device is performed.
EXAMPLE
Generate some particle positions and velocities.
  POSX=RANDOMU(seed,200)
  POSY=RANDOMU(seed,200)
  VELX=RANDOMU(seed,200)-0.5
  VELY=RANDOMU(seed,200)-0.5
Plot the particle velocities.
  PARTVELVEC, VELX, VELY, POSX, POSY
Example using vector colors.
  POSX=RANDOMU(seed,200)
  POSY=RANDOMU(seed,200)
  VELX=RANDOMU(seed,200)-0.5
  VELY=RANDOMU(seed,200)-0.5
  magnitude = SQRT(velx^2 + vely^2)
  LOADCT, 5, NCOLORS=254, BOTTOM=1 ; Load vector colors
  colors = BytScl(magnitude, Top=254) + 1B
  PARTVELVEC, VELX, VELY, POSX, POSY, COLOR='green', VECCOLORS=colors
MODIFICATION HISTORY
Written by:  Joop Schaye (jschaye@astro.rug.nl), Sep 1996.
Added /OVER keyword   Theo Brauers (th.brauers@fz-juelich.de) Jul 2002
Added VECCOLORS keyword. David Fanning (david@dfanning.com) March, 2005
Incorporate the Coyote Graphics (cg) plot programs  WL  January 2011
Allow VELX, VELY to include NaN values P. Blitzer/WL March 2013
Allow NOCLIP=0 when overplotting  A. Negri    October 2014