;+ ; NAME: ; re ; PURPOSE: ; Return the real part of a number ; EXPLANATION: ; CALLING SEQUENCE ; r = re(x) ; INPUTS: ; X - number or array of type complex, dcomplex ; (other types returned unchanged) ; OUTPUT: ; result - real part of x ; float for x is complex ; double for x is dcomplex ; original type for all others ; METHOD: ; IDL routines float and dfloat; ; REVISION HISTORY: ; 2012-01-08 Leslie Young, SwRI ;- function re,x On_error,2 res = size(x, /tname) ; use switch to "fall through" to the next statement ; making the byte, int etc simpler switch res of 'COMPLEX': return, float(x) 'DCOMPLEX': return, double(x) 'BYTE': 'INT': 'LONG': 'FLOAT': 'DOUBLE': 'UNIT': 'ULONG': 'LONG64': 'ULONG64': return, x else : message,'Struct expression not allowed in this context.' endswitch end