idlastro / FITS I/O: POSITIVITY

[Source code]

NAME
POSITIVITY
PURPOSE
Map an image uniquely and smoothly into all positive values.
EXPLANATION
Take unconstrained x (usually an image), and map it uniquely and 
smoothly into positive values.   Negative values of x get mapped to 
interval ( 0, sqrt( epsilon )/2 ], positive values go to 
( sqrt( epsilon )/2, oo ) with deriv approaching 1.  Derivative is 
always 1/2 at x=0.   Derivative is used by the MRL deconvolution 
algorithm.
CALLING SEQUENCE
result = POSITIVITY( x, [ /DERIVATIVE, EPSILON = )
INPUTS
x - input array, unconstrained
OUTPUT
result =  output array = ((x + sqrt(x^2 + epsilon))/2
        if the /DERIV keyword is set then instead the derivative of
        the above expression with respect to X is returned
OPTIONAL INPUT KEYWORDS
DERIV -  if this keyword set, then the derivative of the positivity
        mapping is returned, rather than the mapping itself
EPSILON - real scalar specifying the interval into which to map
        negative values.    If EPSILON EQ 0 then the mapping reduces to 
        positive truncation.   If EPSILON LT then the mapping reduces to
        an identity (no change).  Default is EPSILON = 1e-9 
REVISION HISTORY
F.Varosi NASA/GSFC 1992, as suggested by R.Pina UCSD.
onverted to IDL V5.0   W. Landsman   September 1997