pro cdfx_showstats_Event, event
end
pro cdfx_showstats, a, GROUP=GROUP
common cdfxcom, CDFxwindows, CDFxprefs
text = ''
as = size(a) & nas = n_elements(as)
if (as[nas-2] ne 8) then begin
ok = dialog_message(/error, 'showstats:input parameter is not a structure.')
return
endif else atags = tag_names(a)
ti = tagindex('VAR_TYPE',atags)
if (ti ne -1) then begin
if strupcase(a.VAR_TYPE eq 'METADATA') then begin
ok = dialog_message(/error, $
'Can only produce stats for record-varying variables!')
return
endif
endif
ti = tagindex('HANDLE',atags)
if (ti ne -1) then handle_value,a.HANDLE,d $
else begin
ti = tagindex('DAT',atags)
if (ti ne -1) then d = a.DAT $
else begin
ok = dialog_message(/error, $
'showstats:variable has no .DAT or .HANDLE tag!')
return
endelse
endelse
d = reform(d) & ds = size(d) & nds = n_elements(ds)
if ds[nds-2] eq 7 then begin
ok = dialog_message(/error, 'showstats:no status for character data.')
return
endif
help, d, output=h & h = strtrim(strmid(h[0],1,strlen(h[0])-1),2)
s = str_sep(h[0],'=') & text = 'Variable name : ' + a.VARNAME
text = [text,('Variable type : ' + strtrim(s[0],2))]
text = [text,('Dimensionality: ' + strtrim(s[1],2))]
ti = tagindex('FILLVAL',tag_names(a))
if (ti ne -1) then fill = a.FILLVAL else fill = 'n/a'
s = 'fill value=' + string(fill)
text = [text,' '] & text = [text,s]
if ds[0] eq 1 then begin
w = where(d eq fill,fc) & w = where(d ne fill,wc)
if (wc ne 0) then d = d[w]
dmin = min(d) & dmax = max(d)
davg = total(d)/n_elements(d)
text = [text,('fill count= ' + string(fc))]
text = [text,('minimum = ' + string(dmin))]
text = [text,('maximum = ' + string(dmax))]
text = [text,('average = ' + string(davg))]
endif
if ds[0] eq 2 then begin
w = where(d eq fill,fc) & w = where(d ne fill,wc)
if (wc ne 0) then e = d[w]
dmin = min(e) & dmax = max(e)
davg = total(e)/n_elements(e) & e=0
text = [text,('fill count= ' + strtrim(string(fc),2))]
text = [text,('minimum = ' + strtrim(string(dmin),2))]
text = [text,('maximum = ' + strtrim(string(dmax),2))]
text = [text,('average = ' + strtrim(string(davg),2))]
text = [text,' '] & text = [text,' Element by Element Checking:']
for i=0,ds[1]-1 do begin
e = d[i,*] & w = where(e eq fill,fc)
w = where(e ne fill,wc) & if (wc ne 0) then e = e[w]
dmin = min(e) & dmax = max(e) & davg = total(e)/n_elements(e) & e=0
text = [text,('Element ' + strtrim(string(i+1),2))]
text = [text,(' fill count= ' + strtrim(string(fc),2))]
text = [text,(' minimum = ' + strtrim(string(dmin),2))]
text = [text,(' maximum = ' + strtrim(string(dmax),2))]
text = [text,(' average = ' + strtrim(string(davg),2))]
endfor
endif
if ds[0] ge 3 then begin
ok = dialog_message(/error, $
'Cannot produce stats for 3D+ variables!')
return
endif
net = n_elements(text)
base1 = widget_base(/Column,Title='Variable Stats',/frame)
if net le 30 then $
txt1 = widget_text(base1,value=text,ysize=net,xsize=max(strlen(text)))$
else $
txt1 = widget_text(base1,value=text,ysize=30,xsize=max(strlen(text)),/scroll)
add_cdfxwindow,'Variable Stats',base1
widget_control,base1,/realize
Xmanager,'VarStats', base1, Event='cdfx_showstats_Event',$
GROUP=GROUP, Cleanup='cdfx_cleanup_and_remove'
end