;+ ; NAME: ; WhatIs0 ; PURPOSE: ; (Internal use only) ; CALLING SEQUENCE: ; WhatIs0, a, type, scalar, dims, amin, amax, cone ; 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 ; CALLS: ; IsType ; RESTRICTIONS: ; PROCEDURE: ; MODIFICATION HISTORY: ; MAY-1995, Paul Hick (UCSD/CASS; pphick@ucsd.edu) ;- pro WhatIs0, a, type, scalar, dims, amin, amax, cone, name, finiteratio, zeroratio @compile_opt.pro ; On error, return to caller 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 = 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: ; WhatIs, a [,b,c,d,e,f,g,h] ; INPUTS: ; a,b,c,d,e,f,g,h ; any type of variable ; 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; pphick@ucsd.edu) ;- pro WhatIs, a,b,c,d,e,f,g,h @compile_opt.pro ; On error, return to caller ; Print name of caller help, calls=calls print, calls[1] 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 end 13: begin ; Unsigned long integer print, pre, name,type0[scalar],dims,', min=',amin,', max=',amax end 14: begin ; 64 bit integer print, pre, name,type0[scalar],dims,', min=',amin,', max=',amax end 15: begin ; Unsigned 64 bit integer print, pre, name,type0[scalar],dims,', min=',amin,', max=',amax end endcase endfor return & end