;+ ; NAME: ; WhatIs0 ; PURPOSE: ; (Internal use only) ; CALLING SEQUENCE: PRO WhatIs0, a, type, scalar, dims, amin, amax, cone, name, finiteratio, zeroratio ; INPUTS: ; a any variable ; type variable type ; scalar 0 if var is array, 1 if var is scalar ; dims string containing dimensions ; amin minimum value ; amax maximum value ; cone start of first element of string var ; INCLUDE: @compile_opt.pro ; On error, return to caller ; CALLS: ; IsType ; RESTRICTIONS: ; PROCEDURE: ; MODIFICATION HISTORY: ; MAY-1995, Paul Hick (UCSD/CASS; pphick@ucsd.edu) ;- as = size(a) type = IsType(a, name=name) IF IsType(a, /generic_int) THEN BEGIN ; Byte, ..., long integer amin = strcompress(1L*min([a],imin),/rem) amax = strcompress(1L*max([a],imax),/rem) zeroratio = strcompress(round(total(a EQ 0)),/rem )+'/'+strcompress(n_elements(a),/rem) ENDIF ELSE IF IsType(a, /generic_float) THEN BEGIN ; Single, double amin = strcompress(min([a],imin,/nan),/rem) amax = strcompress(max([a],imax,/nan),/rem) finiteratio = strcompress(round(total(finite(a))),/rem )+'/'+strcompress(n_elements(a),/rem) zeroratio = strcompress(round(total(a EQ 0 AND finite(a))),/rem )+'/'+strcompress(n_elements(a),/rem) ENDIF ELSE IF IsType(a, /complex_float) THEN BEGIN ; Complex amin = [min(float(a)),min(imaginary(a)),min(sqrt(float(a)^2+imaginary(a)^2)) ] amax = [max(float(a)),max(imaginary(a)),max(sqrt(float(a)^2+imaginary(a)^2)) ] amin = strcompress(1*amin,/rem) & amax = strcompress(1*amax,/rem) finiteratio = strcompress(round(total(finite(a))),/rem )+'/'+strcompress(n_elements(a),/rem) zeroratio = strcompress(round(total(a EQ 0 AND finite(a))),/rem )+'/'+strcompress(n_elements(a),/rem) ENDIF ELSE IF IsType(a, /string) THEN BEGIN ; String cone = strmid(a[0],0,51) if strlen(cone) lt strlen(a[0]) THEN cone += '...' ENDIF ELSE IF IsType(a, /structure) THEN BEGIN help, a ENDIF ELSE IF IsType(a, /complex_double) THEN BEGIN amin = [min(double(a)),min(imaginary(a)),min(sqrt(double(a)^2+imaginary(a)^2)) ] amax = [max(double(a)),max(imaginary(a)),max(sqrt(double(a)^2+imaginary(a)^2)) ] amin = strcompress(1*amin,/rem) & amax = strcompress(1*amax,/rem) finiteratio = strcompress(round(total(finite(a))),/rem )+'/'+strcompress(n_elements(a),/rem) zeroratio = strcompress(round(total(a EQ 0 AND finite(a))),/rem )+'/'+strcompress(n_elements(a),/rem) ENDIF ELSE IF IsType(a, /pointer) OR IsType(a, /object) THEN BEGIN help, a ENDIF scalar = as[0] EQ 0 ; 1 if scalar or undefined; otherwise 0 dims = '' IF NOT scalar THEN dims = '('+strjoin(strcompress(as[1:as[0]],/rem),',')+')' RETURN & END ;+ ; NAME: ; WhatIs ; PURPOSE: ; Get info about variables ; CALLING SEQUENCE: PRO WhatIs, a,b,c,d,e,f,g,h, title=title ; INPUTS: ; a,b,c,d,e,f,g,h ; any type of variable ; OPTIONAL INPUTS: ; title=title informational message to be printed first ; INCLUDE: @compile_opt.pro ; On error, return to caller ; CALLS: ; WhatIs0 ; RESTRICTIONS: ; Number of arguments is restricted to a maximum of 8 ; PROCEDURE: ; The routine WhatIs0 is used as an internal procedure ; (code included with WhatIs) ; ; WhatIs0, a, type, scalar, dims, amin, amax, cone ; a any variable ; type variable type ; scalar 0 if var is array, 1 if var is scalar ; dims string containing dimensions ; amin minimum value ; amax maximum value ; cone start of first element of string var ; MODIFICATION HISTORY: ; MAY-1995, Paul Hick (UCSD/CASS) ; DEC-2009, Paul Hick (UCSD/CASS; pphick@ucsd.edu) ; Added keyword /title ;- ; Print name of caller IF IsType(title,/defined) THEN print, '>>>>> '+title help, calls=calls print, calls[ !idl_mode ] IF n_params() EQ 0 THEN RETURN type0 = ' '+['Array','Scalar'] FOR n=0,(n_params()-1) < 7 DO BEGIN case n of 0: whatis0, a, type, scalar, dims, amin, amax, cone, name, finiteratio, zeroratio 1: whatis0, b, type, scalar, dims, amin, amax, cone, name, finiteratio, zeroratio 2: whatis0, c, type, scalar, dims, amin, amax, cone, name, finiteratio, zeroratio 3: whatis0, d, type, scalar, dims, amin, amax, cone, name, finiteratio, zeroratio 4: whatis0, e, type, scalar, dims, amin, amax, cone, name, finiteratio, zeroratio 5: whatis0, f, type, scalar, dims, amin, amax, cone, name, finiteratio, zeroratio 6: whatis0, g, type, scalar, dims, amin, amax, cone, name, finiteratio, zeroratio 7: whatis0, h, type, scalar, dims, amin, amax, cone, name, finiteratio, zeroratio ELSE: RETURN ENDCASE ; This seems to work only if called from the IDL main level ; case n of ; 0: name = routine_names(a, /ARG_NAME) ; 1: name = routine_names(b, /ARG_NAME) ; 2: name = routine_names(c, /ARG_NAME) ; 3: name = routine_names(d, /ARG_NAME) ; 4: name = routine_names(e, /ARG_NAME) ; 5: name = routine_names(f, /ARG_NAME) ; 6: name = routine_names(g, /ARG_NAME) ; 7: name = routine_names(h, /ARG_NAME) ; else: return ; endcase ; if name ne '' then $ ; pre = string(format='(A15)',name[0])+' >> ' $ ; else $ pre = ' '+' >> ' CASE type OF 0: BEGIN ; Undefined print, pre, name END 1: BEGIN ; Byte print, pre, name,type0[scalar],dims,', min=',amin,', max=',amax, ' Zero: '+ZeroRatio END 2: BEGIN ; Short integer print, pre, name,type0[scalar],dims,', min=',amin,', max=',amax, ' Zero: '+ZeroRatio END 3: BEGIN ; Long integer print, pre, name,type0[scalar],dims,', min=',amin,', max=',amax, ' Zero: '+ZeroRatio END 4: BEGIN ; Floating point print, pre, name,type0[scalar],dims,', min=',amin,', max=',amax, ' Finite: '+FiniteRatio,' Zero: '+ZeroRatio END 5: BEGIN ; Double precision floating point print, pre, name,type0[scalar],dims,', min=',amin,', max=',amax, ' Finite: '+FiniteRatio,' Zero: '+ZeroRatio END 6: BEGIN ; Complex floating point print, pre, name,type0[scalar],dims,', min=',amin[2],', max=',amax[2] print, pre,' real (min=',amin[0],', max=',amax[0],'), imaginary (min=',amin[1],', max=',amax[1],')', ' Finite: '+FiniteRatio,' Zero: '+ZeroRatio END 7: BEGIN ; String print, pre, name,type0[scalar],dims,' "',cone,'"' END 8: BEGIN ; Structure END 9: BEGIN ; Complex double print, pre, name,type0[scalar],dims,', min=',amin[2],', max=',amax[2] print, pre,' real (min=',amin[0],', max=',amax[0],'), imaginary (min=',amin[1],', max=',amax[1],')', ' Finite: '+FiniteRatio,' Zero: '+ZeroRatio END 10: BEGIN ; Pointer END 11: BEGIN ; Object reference END 12: BEGIN ; Unsigned integer print, pre, name,type0[scalar],dims,', min=',amin,', max=',amax, ' Zero: '+ZeroRatio END 13: BEGIN ; Unsigned long integer print, pre, name,type0[scalar],dims,', min=',amin,', max=',amax, ' Zero: '+ZeroRatio END 14: BEGIN ; 64 bit integer print, pre, name,type0[scalar],dims,', min=',amin,', max=',amax, ' Zero: '+ZeroRatio END 15: BEGIN ; Unsigned 64 bit integer print, pre, name,type0[scalar],dims,', min=',amin,', max=',amax, ' Zero: '+ZeroRatio END ENDCASE ENDFOR RETURN & END