;+ ; NAME: ; c2r ; PURPOSE: (one line) ; Complex to real ; DESCRIPTION: ; Complex to real (pull out the real, imaginary, amplitude, phase ; from a complex number) ; CATEGORY: ; math ; CALLING SEQUENCE: ; our = c2r(c) ; INPUTS: ; c - complex numbe or array, a + i b = c * exp(i * p) ; KEYWORDS ; real: (a, in a + i b) ; imaginary: (b, in a + i b) ; amplitude: (c, in c * exp(i * p) ; phase: (p, in c * exp(i * p) ; oreal: if set, output real ; oimaginary: if set, output imaginary ; oamplitude: if set, output amplitude ; ophase: if set, output phase ; OUTPUTS: ; real (default), imaginary, amplitude, or phase ; OPTIONAL OUTPUTS: ; MODIFICATION HISTORY: ; Written 2012 Sep 29, by Leslie Young, SwRI ; 2016 Mar 22 LAY. Modified for inclusion in math library. ;- ; c2r - complex to reals (should change this name!) ; INPUT ; c - array of complex ; OUTPUT ; real, imaginary, amplitude, or phase ; phase P s.t. c = |c| exp(i * p) function c2r, c, real=real, imaginary=imaginary, amplitude=amplitude, phase=phase, $, oreal=oreal, oimaginary=oimagninary, oamplitude=oamplitude, ophase=ophase real = float(c) imaginary = imaginary(c) amplitude = abs(c) phase = atan(imaginary, real) if keyword_set(oimaginary) then return, imaginary if keyword_set(oamplitude) then return, amplitude if keyword_set(ophase) then return, phase return, real end