FUNCTION evaluate_plasmastruct, a, atags, labels=labels, symsize=symsize,$
xsymsize=xsymsize, ysymsize=ysymsize, thumbsize=thumbsize
b = size(a)
if (b[n_elements(b)-2] ne 8) then begin
print,'ERROR=Input parameter is not a valid structure.' & return,-1
endif
if (keyword_set(symsize)) then sym_size = -1
if (keyword_set(xsymsize)) then x_size = -1
if (keyword_set(ysymsize)) then y_size = -1
if (keyword_set(THUMBSIZE)) then thumb_size = 50
b = tagindex('DISPLAY_TYPE',atags)
if (b[0] ne -1) then begin
c = break_mystring(a.(b[0]),delimiter='>')
csize = size(c)
rest = 1
wc=where(c eq 'THUMBSIZE',wcn)
if(wcn ne 0) then begin
thumb_size = fix(c[wc[0]+1])
rest = 3
if (keyword_set(THUMBSIZE)) then return, thumb_size
endif
if (csize[1] ge 2)then begin
d = break_mystring(c[rest], delimiter=',')
if (n_elements(d) ge 1)then begin
vars = make_array(n_elements(d),/string,value=' ')
num_found = -1
for i=0L, n_elements(d)-1 do begin
e = break_mystring(d[i], delimiter='=')
if (n_elements(e) ge 1) then begin
if keyword_set(labels) then begin
if (strpos(e[0],'labl',0) ne -1) then begin
num_found=num_found+1
vars(num_found) = e[1]
endif
endif else begin
if keyword_set(symsize) then begin
if (strpos(e[0],'symsize',0) ne -1) then sym_size = e[1]
endif
if keyword_set(xsymsize) then begin
if (strpos(e[0],'xsz',0) ne -1) then x_size = e[1]
endif
if keyword_set(ysymsize) then begin
if (strpos(e[0],'ysz',0) ne -1) then y_size = e[1]
endif
endelse
endif
endfor
endif
endif
endif
if keyword_set(symsize) then return, sym_size
if keyword_set(xsymsize) then return, x_size
if keyword_set(ysymsize) then return, y_size
if keyword_set(thumbsize) then return, thumb_size
if (num_found ge 0) then begin
t = where(vars ne ' ', t_cnt)
if (t_cnt ge 1) then vars = vars[t]
endif else begin
vars = 'none'
endelse
return, vars
end
FUNCTION plot_plasmagram, astruct, zname, $
THUMBSIZE=THUMBSIZE, FRAME=FRAME, $
XSIZE=XSIZE, YSIZE=YSIZE, GIF=GIF, REPORT=REPORT,$
TSTART=TSTART,TSTOP=TSTOP,NONOISE=NONOISE,$
CDAWEB=CDAWEB,DEBUG=DEBUG,COLORBAR=COLORBAR, $
MOVIE=MOVIE
atags = tag_names(astruct)
z_ax = tagindex(zname,atags)
b = astruct.(z_ax).DEPEND_0 & epoch = tagindex(b[0],atags)
b = astruct.(z_ax).DEPEND_1 & x_ax = tagindex(b[0],atags)
b = astruct.(z_ax).DEPEND_2 & y_ax = tagindex(b[0],atags)
alt = tagindex('ALT_CDAWEB_DEPEND_1',tag_names(astruct.(z_ax)))
if (alt[0] ne -1) then begin
if (astruct.(z_ax).ALT_CDAWEB_DEPEND_1 ne '') then begin
b = astruct.(z_ax).ALT_CDAWEB_DEPEND_1
x_ax = tagindex(b[0],atags)
endif
endif
alt = tagindex('ALT_CDAWEB_DEPEND_2',tag_names(astruct.(z_ax)))
if (alt[0] ne -1) then begin
if (astruct.(z_ax).ALT_CDAWEB_DEPEND_2 ne '') then begin
b = astruct.(z_ax).ALT_CDAWEB_DEPEND_2
y_ax = tagindex(b[0],atags)
endif
endif
estruct = astruct.(epoch)
xstruct = astruct.(x_ax)
ystruct = astruct.(y_ax)
zstruct = astruct.(z_ax)
b = tagindex('DISPLAY_TYPE',tag_names(astruct.(z_ax)))
if (b[0] ne -1) then begin
e = examine_spectrogram_dt(astruct.(z_ax).DISPLAY_TYPE) & esize=size(e)
if (esize[n_elements(esize)-2] eq 8) then begin
if (e.x ne '') then x_ax = tagindex(e.x,atags)
if (e.y ne '') then y_ax = tagindex(e.y,atags)
endif
endif
vname = zstruct.VARNAME
tip = tagindex('DESCRIPTOR',tag_names(zstruct))
if (tip ne -1) then begin
descriptor=str_sep(zstruct.descriptor,'>')
endif
rpi = 0
if (descriptor[0] eq "RPI") then begin
rpi = 1
a = tagindex('COMPONENT_1',tag_names(astruct.(z_ax)))
if(a[0] ne -1) then begin
d = astruct.(z_ax).COMPONENT_1 & p_ax = tagindex(d[0],atags)
pstruct = astruct.(p_ax)
a = tagindex('DAT',tag_names(pstruct))
if (a[0] ne -1) then pdat = pstruct.DAT $
else begin
a = tagindex('HANDLE',tag_names(pstruct))
if (a[0] ne -1) then handle_value,pstruct.HANDLE,pdat $
else begin
print,'ERROR= ProgramSpecs variable does not have DAT or HANDLE tag' & return,-1
endelse
endelse
endif
endif
if keyword_set(COLORBAR) then COLORBAR=1L else COLORBAR=0L
if COLORBAR then xco=80 else xco=0
if keyword_set(REPORT) then reportflag=1L else reportflag=0L
a = size(zstruct)
if (a[n_elements(a)-2] ne 8) then begin
print,'ERROR= Z parameter to plot_plasmagram not a structure' & return,-1
endif else begin
a = tagindex('DAT',tag_names(zstruct))
if (a[0] ne -1) then idat = zstruct.DAT $
else begin
a = tagindex('HANDLE',tag_names(zstruct))
if (a[0] ne -1) then handle_value,zstruct.HANDLE,idat $
else begin
print,'ERROR= Z parameter does not have DAT or HANDLE tag' & return,-1
endelse
endelse
endelse
d = tagindex('DAT',tag_names(estruct))
if (d[0] ne -1) then edat = estruct.DAT $
else begin
d = tagindex('HANDLE',tag_names(estruct))
if (d[0] ne -1) then handle_value,estruct.HANDLE,edat $
else begin
print,'ERROR= Time parameter does not have DAT or HANDLE tag' & return,-1
endelse
endelse
xtags = tag_names(xstruct)
d = tagindex('DAT',xtags)
if (d[0] ne -1) then xdat = xstruct.DAT $
else begin
d = tagindex('HANDLE',xtags)
if (d[0] ne -1) then handle_value,xstruct.HANDLE,xdat $
else begin
print,'ERROR= X variable does not have DAT or HANDLE tag' & return,-1
endelse
endelse
xlog = 1L
a = tagindex('SCALETYP',xtags)
if (a[0] ne -1) then begin
if (strupcase(Xstruct.SCALETYP) eq 'LINEAR') then xlog = 0L
endif
a = tagindex('VALIDMIN',xtags)
if (a[0] ne -1) then begin & b=size(xstruct.VALIDMIN)
if (b[0] eq 0) then xvmin = xstruct.VALIDMIN $
else begin
xvmin = 0
print,'WARNING=Unable to determine validmin for ',xstruct.varname
endelse
endif
a = tagindex('VALIDMAX',xtags)
if (a[0] ne -1) then begin & b=size(xstruct.VALIDMAX)
if (b[0] eq 0) then xvmax = xstruct.VALIDMAX $
else begin
xvmax = 2000
print,'WARNING=Unable to determine validmax for ',xstruct.varname
endelse
endif
a = tagindex('LABLAXIS',xtags)
if (a[0] ne -1) then begin & b=size(xstruct.LABLAXIS)
if (b[0] eq 0) then xtitle = xstruct.LABLAXIS $
else begin
xtitle = ' x axis'
print,'WARNING=Unable to determine xtitle for ',xstruct.varname
endelse
endif
a = tagindex('UNITS',xtags)
if (a[0] ne -1) then begin & b=size(xstruct.UNITS)
if (b[0] eq 0) then xtitle = xtitle + ' in '+ xstruct.UNITS $
else begin
xtitle = xtitle
print,'WARNING=Unable to determine units for ',xstruct.varname
endelse
endif
ytags = tag_names(ystruct)
d = tagindex('DAT',ytags)
if (d[0] ne -1) then ydat = ystruct.DAT $
else begin
d = tagindex('HANDLE',ytags)
if (d[0] ne -1) then handle_value,ystruct.HANDLE,ydat $
else begin
print,'ERROR= Y variable does not have DAT or HANDLE tag' & return,-1
endelse
endelse
ylog = 1L
a = tagindex('SCALETYP',ytags)
if (a[0] ne -1) then begin
if (strupcase(Ystruct.SCALETYP) eq 'LINEAR') then ylog = 0L
endif
a = tagindex('VALIDMIN',ytags)
if (a[0] ne -1) then begin & b=size(ystruct.VALIDMIN)
if (b[0] eq 0) then yvmin = ystruct.VALIDMIN $
else begin
yvmin = 0
print,'WARNING=Unable to determine validmin for ',ystruct.varname
endelse
endif
a = tagindex('VALIDMAX',ytags)
if (a[0] ne -1) then begin & b=size(ystruct.VALIDMAX)
if (b[0] eq 0) then yvmax = ystruct.VALIDMAX $
else begin
yvmax = 2000
print,'WARNING=Unable to determine validmax for ',ystruct.varname
endelse
endif
yscales = -1
a = tagindex('SCALEMIN',ytags)
if (a[0] ne -1) then begin & b=size(ystruct.SCALEMIN)
if (b[0] eq 0) then begin
ysmin = ystruct.SCALEMIN
if (ysmin ne '') then yscales = 1
endif
endif
a = tagindex('SCALEMAX',ytags)
if (a[0] ne -1) then begin & b=size(ystruct.SCALEMAX)
if (b[0] eq 0) then ysmax = ystruct.SCALEMAX
endif
a = tagindex('LABLAXIS',ytags)
if (a[0] ne -1) then begin & b=size(ystruct.LABLAXIS)
if (b[0] eq 0) then ytitle = ystruct.LABLAXIS $
else begin
ytitle = ' y axis'
print,'WARNING=Unable to determine ytitle for ',ystruct.varname
endelse
endif
a = tagindex('UNITS',ytags)
if (a[0] ne -1) then begin & b=size(ystruct.UNITS)
if (b[0] eq 0) then ytitle = ytitle + ' in '+ ystruct.UNITS $
else begin
ytitle = ytitle
print,'WARNING=Unable to determine units for ',ystruct.varname
endelse
endif
ztags = tag_names(zstruct)
a = tagindex('FIELDNAM',ztags)
if (a[0] ne -1) then fn = '> ' + zstruct.FIELDNAM else fn = ''
a = tagindex('SOURCE_NAME',ztags)
if (a[0] ne -1) then begin
sn = break_mystring(zstruct.SOURCE_NAME,delimiter='>')
b = sn[0]
endif else b = ''
a = tagindex('DESCRIPTOR',ztags)
if (a[0] ne -1) then b = b + ' ' + zstruct.DESCRIPTOR
window_title = b + fn
if keyword_set(nonoise) then window_title = window_title+'!CFiltered to remove values >3-sigma from mean of all plotted values'
idx = -1
label_vars = evaluate_plasmastruct(zstruct, ztags, /labels)
thumbsize = evaluate_plasmastruct(zstruct, ztags, /thumbsize)
if (n_elements(label_vars) ge 1 and label_vars[0] ne 'none') then begin
for l = 0L, n_elements(label_vars)-1 do begin
idx_flag = 0
d = break_mystring(label_vars[l],delimiter='(')
if (n_elements(d) eq 2) then begin
idx_flag = 1
label_vars[l] = d[0]
c = strmid(d[1],0,(strlen(d[1])-1))
idx = long(c)
endif
l_str = strtrim(string(l),2)
lab = tagindex(label_vars(l),atags)
comm=execute('lstruct'+l_str+' = astruct.(lab)')
comm=execute('ltags = tag_names(lstruct'+l_str+')')
d = tagindex('DAT',ltags)
if (d[0] ne -1) then comm=execute('ldat = lstruct'+l_str+'.DAT') $
else begin
d = tagindex('HANDLE',ltags)
if (d[0] ne -1) then comm=execute('handle_value,lstruct'+l_str+'.HANDLE,ldat'+l_str) $
else begin
print,'ERROR= Label variable does not have DAT or HANDLE tag' & return,-1
endelse
endelse
if (not comm) then print, 'Error=execute for labels failed'
comm = execute('ltitle'+l_str+'=''')
a = tagindex('FIELDNAM',ltags)
if (a[0] ne -1) then comm = execute('ltitle'+l_str+' = lstruct'+l_str+'.FIELDNAM')
a = tagindex('LABLAXIS',ltags)
if (a[0] ne -1) then begin
comm = execute('temp = lstruct'+l_str+'.LABLAXIS')
if(temp[0] ne '') then comm = execute('ltitle'+l_str+' = lstruct'+l_str+'.LABLAXIS')
endif
a = tagindex('LABL_PTR_1',ltags)
if (a[0] ne -1) then begin
comm = execute('temp = lstruct'+l_str+'.LABL_PTR_1')
if (temp[0] ne '') then comm = execute('ltitle'+l_str+' = lstruct'+l_str+'.LABL_PTR_1')
endif
if (idx_flag and (idx ge 0)) then begin
comm = execute('title = strtrim(ltitle'+l_str+',2)')
comm = execute('ltitle'+l_str+' = title[idx]')
comm = execute('ldata = strtrim(ldat'+l_str+',2)')
if (size(ldata, /n_dimensions) eq 2) then begin
comm = execute('ldat'+l_str+' = ldata[idx,*]')
comm = execute('ldat'+l_str+' = reform(ldat'+l_str+')')
endif else begin
comm = execute('ldat'+l_str+' = ldata[idx]')
endelse
endif
endfor
endif
if(COLORBAR) then begin
ctitle=''
a = tagindex('LABLAXIS',ztags)
if (a[0] ne -1) then ctitle = zstruct.LABLAXIS
a=tagindex('UNITS',ztags)
if(a[0] ne -1) then ctitle = ctitle + ' in ' + zstruct.UNITS
endif
if keyword_set(XSIZE) then xs=XSIZE else xs=560
if keyword_set(YSIZE) then ys=YSIZE else ys=560
isize = size(idat)
if (isize[0] eq 2) then n_images=1 else n_images=isize(isize[0])
if (n_images eq 1) then FRAME=1
if keyword_set(FRAME) then begin
if ((FRAME ge 1)AND(FRAME le n_images)) then begin
idat = idat[*,*,(FRAME-1)]
idat = reform(idat)
if(descriptor[0] eq 'MERGEDSTATIONS') then begin
idat2 = rotate(idat[*,*], 4)
idat = idat2
idat2 = 0
endif
if (size(xdat, /n_dimensions) eq 2) then begin
xdat = xdat[*,(FRAME-1)]
endif
xdat = reform(xdat)
if (size(ydat, /n_dimensions) eq 2) then begin
ydat = ydat[*,(FRAME-1)]
endif
ydat = reform(ydat)
isize = size(idat)
if (xlog eq 1L) then begin
if (xvmin gt 0.0) then amin = xvmin else amin = 0.0
w = where(xdat le amin,wc)
if (wc gt 0) then begin
w = where(xdat gt amin,wc)
if (wc gt 0) then begin
if keyword_set(DEBUG) then print,'Screening X ',wc, 'non-positive values.'
xvmin = min(xdat[w], max=xvmax)
if (xlog eq 1L and xvmin le 0) then xvmin = .0001
endif
endif
endif else begin
w = where((xdat gt xvmin and xdat lt xvmax), wc)
if (wc gt 0) then xvmin = min(xdat[w], max=xvmax)
if (wc le 0) then begin
xvmin = 0 & xvmax = 1
endif
endelse
if keyword_set(DEBUG) then print, 'DEBUG,X min and max scales = ',xvmin, xvmax
if (ylog eq 1L) then begin
if (yvmin gt 0.0) then amin = yvmin else amin = 0.0
w = where(ydat le amin,wc)
if (wc gt 0) then begin
w = where(ydat gt amin,wc)
if (wc gt 0) then begin
if keyword_set(DEBUG) then print,'Screening Y ',wc, 'non-positive values.'
yvmin = min(ydat[w], max=yvmax)
if (ylog eq 1L and yvmin le 0) then yvmin = .0001
endif
endif
endif else begin
w = where((ydat gt yvmin and ydat lt yvmax), wc)
if (wc gt 0) then yvmin = min(ydat[w], max=yvmax)
if (wc le 0) then begin
yvmin = 0 & yvmax = 1
endif
endelse
if keyword_set(DEBUG) then print, 'DEBUG, Y min and max scales = ',yvmin, yvmax
a = tagindex('VALIDMIN',ztags)
if (a[0] ne -1) then begin & b=size(zstruct.VALIDMIN)
if (b[0] eq 0) then zvmin = zstruct.VALIDMIN $
else begin
zvmin = 0
print,'WARNING=Unable to determine validmin for ',vname
endelse
endif
a = tagindex('VALIDMAX',ztags)
if (a[0] ne -1) then begin & b=size(zstruct.VALIDMAX)
if (b[0] eq 0) then zvmax = zstruct.VALIDMAX $
else begin
zvmax = 2000
print,'WARNING=Unable to determine validmax for ',vname
endelse
endif
a = tagindex('FILLVAL',tag_names(zstruct))
if (a[0] ne -1) then begin & b=size(zstruct.FILLVAL)
if (b[0] eq 0) then zfill = zstruct.FILLVAL $
else begin
zfill = -1
print,'WARNING=Unable to determine the fillval for ',vname
endelse
endif
logz = 0L
a = tagindex('SCALETYP',ztags)
if (a[0] ne -1) then begin
if (strupcase(Zstruct.SCALETYP) eq 'LOG') then logz = 1L
endif
outofrange = where(idat lt zvmin or idat gt zvmax, ocnt)
if (ocnt gt 0) then idat[outofrange] = zfill
if keyword_set(DEBUG) then print,'WARNING=Number of Z values outside of validmin/max range = ',ocnt
fdat = where(idat ne zfill, fc)
if (fc gt 0) then begin
wmin = min(idat[fdat],MAX=wmax)
endif else begin
if keyword_set(DEBUG) then print,'WARNING=No data found - all data is fill or out of range!!'
wmin=1 & wmax = 1.1
endelse
if (logz and (wmin le 0.0)) then begin
w = where((idat le 0.0 and idat ne zfill), wc)
z = where((idat gt 0.0 and idat ne zfill), zc)
if (wc gt 0 and zc gt 0) then begin
if keyword_set(DEBUG) then print, 'Z log scaling and min values being adjusted, '
wmin = min(idat[z])
idat[w] = wmin
endif
endif
w = where(((idat lt zvmin) and (idat ne zfill)),wc)
if wc gt 0 then begin
if keyword_set(DEBUG) then print, 'Setting ',wc,' out of range values in image data to lowest data value= ', wmin
idat[w] = wmin
w = 0
endif
w = where((idat gt zvmax and idat ne zfill),wc)
if wc gt 0 then begin
if keyword_set(DEBUG) then print, 'Number of values above the valid max = ',wc, '. Setting them to red...'
diff = zvmax - zvmin
coffset = red_offset(GIF=GIF,diff)
idat[w] = zvmax - coffset
w = 0
endif
if keyword_set(DEBUG) then begin
print, 'Defined in CDF/master, valid min and max: ',zvmin, ' ',zvmax
wmin = min(idat,MAX=wmax)
print, 'Actual min and max of image data',wmin,' ', wmax
print, 'Image fill value = ',zfill
endif
if keyword_set(DEBUG) then begin
print, 'Statistics about the data distribution'
w = where(((idat lt zvmax) and (idat ge (zvmax-10))),wc)
if wc gt 0 then print, 'Number of values between ',zvmax,' and ',zvmax-10,' = ',wc
w = where(((idat lt zvmax-10) and (idat ge (zvmax-20))),wc)
if wc gt 0 then print, 'Number of values between ',zvmax-10,' and ',zvmax-20,' = ',wc
w = where(((idat lt zvmax-20) and (idat ge (zvmax-30))),wc)
if wc gt 0 then print, 'Number of values between ',zvmax-20,' and ',zvmax-30,' = ',wc
w = where(((idat lt zvmax-30) and (idat ge (zvmax-40))),wc)
if wc gt 0 then print, 'Number of values between ',zvmax-30,' and ',zvmax-40,' = ',wc
w = where(((idat lt zvmax-40) and (idat ge (zvmax-50))),wc)
if wc gt 0 then print, 'Number of values between ',zvmax-40,' and ',zvmax-50,' = ',wc
w = where(((idat lt zvmax-50) and (idat ge (zvmax-60))),wc)
if wc gt 0 then print, 'Number of values between ',zvmax-50,' and ',zvmax-60,' = ',wc
endif
if keyword_set(NONOISE) then begin
semiMinMax,idat,zvmin,zvmax
w = where((idat lt zvmin),wc)
if wc gt 0 then begin
if keyword_set(DEBUG) then print,'WARNING=filtering values less than 3-sigma from image data...'
idat[w] = zvmin
w = 0
endif
w = where((idat gt zvmax),wc)
if wc gt 0 then begin
if keyword_set(DEBUG) then print,'WARNING=filtering values greater than 3-sigma from image data...'
diff = zvmax - zvmin
coffset = red_offset(GIF=GIF,diff)
print, 'DEBUG diff = ',diff, ' coffset = ',coffset
idat[w] = zvmax - coffset
w = 0
endif
endif
idmin = .00001
idmax = idmin+1
wfill = where((idat ne zfill),wcfill)
if (wcfill gt 0) then idmax=max(idat[wfill], /nan, min=idmin) else print, 'all image data is fill'
if (idmin eq idmax) then begin
if (logz) then idmin = .00001
idmax = idmin+1
endif
if keyword_set(GIF) then begin
atags=tag_names(zstruct)
b = tagindex('LOGICAL_SOURCE',atags)
b1 = tagindex('LOGICAL_FILE_ID',atags)
b2 = tagindex('Logical_file_id',atags)
if (b[0] ne -1) then psrce = strupcase(zstruct.LOGICAL_SOURCE)
if not keyword_set(MOVIE) then begin
print, 'DATASET=',psrce
GIF=strmid(GIF,0,(strpos(GIF,'.gif')))+'_f000.gif'
if(FRAME lt 100) then gifn='0'+strtrim(string(FRAME),2)
if(FRAME lt 10) then gifn='00'+strtrim(string(FRAME),2)
if(FRAME ge 100) then gifn=strtrim(string(FRAME),2)
GIF=strmid(GIF,0,(strpos(GIF,'.gif')-3))+gifn+'.gif'
endif
deviceopen,6,fileOutput=GIF,sizeWindow=[xs+xco,ys+30]
if not keyword_set(MOVIE) then begin
split=strsplit(gif,'/',/extract)
outdir='/'
for k=0L,n_elements(split)-2 do outdir=outdir+split[k]+'/'
print, 'GIF_OUTDIR=',outdir
print, 'LONG_GIF=',split[k]
if (reportflag eq 1) then begin
printf,1,'GIF_OUTDIR=',outdir
printf,1,'LONG_GIF=',split[k] & close,1
endif
endif
endif else begin
window,/FREE,XSIZE=xs+xco,YSIZE=ys+30,TITLE=window_title
endelse
fill_idx = where((idat eq zfill),fillwc)
image2 = idat
if (logZ) then begin
idat = alog(image2)
logidmax=max(idat, /nan, min=logidmin)
idat = bytscl(idat,min=logidmin, max=logidmax, top=!d.table_size-2)
endif else begin
idat = bytscl(idat,min=idmin, max=idmax, top=!d.table_size-2)
endelse
if fillwc gt 0 then begin
idat[fill_idx] = 0
endif
xmargin=!x.margin
ymargin=!y.margin
default_right = 14
if keyword_set(nonoise) then !y.margin[1] = 3
if (logz) then default_right = 20
if COLORBAR then begin
if (!x.omargin[1]+!x.margin[1]) lt default_right then !x.margin[1] = default_right
!x.margin[1] = default_right
!x.margin[0] = 10
!y.margin[0] = 8
if (label_vars[0] ne 'none') then begin
!y.margin[0] = 13
!y.margin[1] = 3
endif
plot,[0,1],[0,1],/noerase,/nodata,xstyle=4,ystyle=4
endif
if (ylog eq 1) then begin
lblv = loglevels([yvmin,yvmax])
if (n_elements(lblv) ge 3) then begin
if (lblv[0] lt yvmin) then lblv=lblv[1:*]
if (lblv(n_elements(lblv)-1) gt yvmax) then lblv=lblv[0:n_elements(lblv)-2]
endif
axis, yaxis=0, color=!d.table_size,ylog=ylog, /nodata, yrange=[yvmin,yvmax], $
ytitle=ytitle, ystyle=1+8, yticks=n_elements(lblv)-1, ytickv=lblv, /save
endif else begin
if (yscales eq -1) then begin
axis, yaxis=0, color=!d.table_size,ylog=ylog, /nodata, yrange=[yvmin,yvmax], $
ytitle=ytitle, ystyle=1+8, /save
endif else begin
axis, yaxis=0, color=!d.table_size,ylog=ylog, /nodata, yrange=[ysmin,ysmax], $
ytitle=ytitle, ystyle=1+8, /save
endelse
endelse
if (xlog eq 1) then begin
lblv = loglevels([xvmin,xvmax])
if (n_elements(lblv) ge 3) then begin
if (lblv[0] lt xvmin) then lblv=lblv[1:*]
if (lblv(n_elements(lblv)-1) gt xvmax) then lblv=lblv[0:n_elements(lblv)-2]
endif
axis, xaxis=0, color=!d.table_size, xlog=xlog, /nodata, xrange=[xvmin,xvmax], $
xtitle=xtitle, xstyle=1+8, xticks=n_elements(lblv)-1, xtickv=lblv, /save
endif else begin
axis, xaxis=0, color=!d.table_size, xlog=xlog, $
/nodata, xrange=[xvmin,xvmax], xtitle=xtitle, xstyle=1+8, /save
endelse
txmin = xdat[0] & txmax = xdat[0]
tymin = ydat[0] & tymax = ydat[0]
symbol = evaluate_plasmastruct(zstruct, ztags, /symsize)
x_symbol = evaluate_plasmastruct(zstruct, ztags, /xsymsize)
y_symbol = evaluate_plasmastruct(zstruct, ztags, /ysymsize)
if (x_symbol gt 0 or y_symbol gt 0) then begin
xsym = [-1.2,1.2,1.2,-1.2,-1.2] & ysym = [-1.4,-1.4,1.4,1.4,-1.4]
if (x_symbol gt 0) then xsym = xsym*x_symbol
if (y_symbol gt 0) then ysym = ysym*y_symbol
noclip=0
endif else begin
if (ylog eq 1L and symbol eq -1) then symbol = 2
noclip=1
case (symbol) of
'1': begin
xsym = [-.4,.4,.4,-.4,-.4] & ysym = [-.4,-.4,.4,.4,-.4]
end
'2': begin
xsym = [-1.2,1.2,1.2,-1.2,-1.2] & ysym = [-1.4,-1.4,1.4,1.4,-1.4]
noclip = 0
end
'3': begin
xsym = [-1.8,1.8,1.8,-1.8,-1.8] & ysym = [-1.8,-1.8,1.8,1.8,-1.8]
noclip = 0
end
'4': begin
xsym = [-3.2,3.2,3.2,-3.2,-3.2] & ysym = [-3.2,-3.2,3.2,3.2,-3.2]
noclip = 0
end
'8': begin
xsym = [-1.2,1.2,1.2,-1.2,-1.2] & ysym = [-8.4,-8.4,8.4,8.4,-8.4]
noclip = 0
end
'28': begin
xsym = [-2.4,2.4,2.4,-2.4,-2.4] & ysym = [-8.4,-8.4,8.4,8.4,-8.4]
noclip = 0
end
else:begin
xsym = [-1.2,1.2,1.2,-1.2,-1.2] & ysym = [-1.4,-1.4,1.4,1.4,-1.4]
end
endcase
endelse
log_lin = 0
if (rpi) then begin
if (n_elements(pdat) gt 0) then log_lin = pdat(3,(frame-1))
xsym_temp = xsym
ysym_temp = ysym
noclip = 0
endif
ysym_save = ysym
for x=0L, n_elements(xdat)-1 do begin
for y=0L, n_elements(ydat)-1 do begin
if ((idat[x,y] gt 0) and (xdat[x] ge xvmin) and (ydat[y] ge yvmin)) then begin
if((rpi) and (log_lin gt 0) and (xdat[x] ge 20) and (xdat[x] lt 30)) then begin
xsym = xsym_temp*1.4
endif
if((rpi) and (log_lin gt 0) and (xdat[x] ge 30) and (xdat[x] lt 40)) then begin
xsym = xsym_temp*1.6
endif
if((rpi) and (log_lin gt 0) and (xdat[x] ge 40) and (xdat[x] lt 50)) then begin
xsym = xsym_temp*2.1
endif
if((rpi) and (log_lin gt 0) and (xdat[x] ge 50) and (xdat[x] lt 60)) then begin
xsym = xsym_temp*2.5
endif
if((rpi) and (log_lin gt 0) and (ydat[y] ge 40) and (ydat[y] lt 50)) then begin
ysym = ysym_temp*2.1
endif
if((rpi) and (log_lin gt 0) and (ydat[y] ge 50) and (ydat[y] lt 60)) then begin
ysym = ysym_temp*2.5
endif
usersym, xsym, ysym, color=idat[x,y], /fill
plots, xdat[x],ydat[y], psym=8, noclip=noclip
if (xdat[x] lt txmin) then txmin = xdat[x]
if (xdat[x] gt txmax) then txmax = xdat[x]
if (ydat[y] lt tymin) then tymin = ydat[y]
if (ydat[y] gt tymax) then tymax = ydat[y]
ysym=ysym_save
endif
endfor
endfor
if (ylog eq 1) then begin
lblv = loglevels([yvmin,yvmax])
if (n_elements(lblv) ge 3) then begin
if (lblv[0] lt yvmin) then lblv=lblv[1:*]
if (lblv(n_elements(lblv)-1) gt yvmax) then lblv=lblv[0:n_elements(lblv)-2]
endif
axis, yaxis=0, color=!d.table_size,ylog=ylog, /nodata, yrange=[yvmin,yvmax], $
ytitle=ytitle, ystyle=1+8, yticks=n_elements(lblv)-1, ytickv=lblv, /save
endif else begin
if (yscales eq -1) then begin
axis, yaxis=0, color=!d.table_size,ylog=ylog, /nodata, yrange=[yvmin,yvmax], $
ytitle=ytitle, ystyle=1+8, /save
endif else begin
axis, yaxis=0, color=!d.table_size,ylog=ylog, /nodata, yrange=[ysmin,ysmax], $
ytitle=ytitle, ystyle=1+8, /save
endelse
endelse
if (xlog eq 1) then begin
lblv = loglevels([xvmin,xvmax])
if (n_elements(lblv) ge 3) then begin
if (lblv[0] lt xvmin) then lblv=lblv[1:*]
if (lblv(n_elements(lblv)-1) gt xvmax) then lblv=lblv[0:n_elements(lblv)-2]
endif
axis, xaxis=0, color=!d.table_size, xlog=xlog, /nodata, xrange=[xvmin,xvmax], $
xtitle=xtitle, xstyle=1+8, xticks=n_elements(lblv)-1, xtickv=lblv, /save
endif else begin
axis, xaxis=0, color=!d.table_size, xlog=xlog, $
/nodata, xrange=[xvmin,xvmax], xtitle=xtitle, xstyle=1+8, /save
endelse
num_columns=1
x_fourth = !d.x_size/4
extra_labels = 6
if (n_elements(label_vars) ge 1 and label_vars[0] ne 'none') then begin
if (n_elements(label_vars) ge extra_labels) then num_columns=2
for l = 0L, n_elements(label_vars)-1 do begin
l_str = strtrim(string(l),2)
comm = execute('labl_val = ldat'+l_str)
l_size = size(labl_val)
if (l_size[0] eq 2) then comm = execute('labl_val = ldat'+l_str+'(*,FRAME-1)')
if (l_size[0] eq 1) then comm = execute('labl_val = ldat'+l_str+'(FRAME-1)')
if (not comm) then print, 'Error=execute for labels failed'
comm = execute('title = strtrim(ltitle'+l_str+',2)')
new_title=''
l_struct = size(labl_val, /structure)
if (l_struct.type eq 1 and l_struct.n_elements eq 1) then begin
new_title = new_title +' '+title+': '+strtrim(string(labl_val,/print),2)
endif else begin
new_title = new_title +' '+title+': '+strtrim(string(labl_val),2)
endelse
line = l+1
alignment = 0.0
if (num_columns eq 2) then begin
if (l le extra_labels-1) then begin
xl = 0.0
endif else begin
xl = !d.x_size/2
line = l - (extra_labels-1)
alignment = 0.0
endelse
endif
xyouts,xl, (!d.y_ch_size*(line+2)+3), new_title,/DEVICE,ALIGNMENT=alignment, color=244
endfor
endif
project_subtitle,zstruct,window_title,/IMAGE,TIMETAG=edat[FRAME-1]
if COLORBAR then begin
if (n_elements(cCharSize) eq 0) then cCharSize = 0.
cscale = [idmin, idmax]
xwindow = !x.window
offset = 0.01
colorbar, cscale, ctitle, logZ=logZ, cCharSize=cCharSize, $
position=[!x.window[1]+offset, !y.window[0],$
!x.window[1]+offset+0.03, !y.window[1]],$
fcolor=244, /image
!x.window = xwindow
endif
!x.margin=xmargin
!y.margin=ymargin
if keyword_set(GIF) then deviceclose
endif
endif else begin
if(descriptor[0] eq 'MERGEDSTATIONS') then begin
for j=0,n_images-1 do begin
if (j eq 0 ) then begin
dims = size(idat,/dimensions)
idat2 = bytarr(dims[1],dims[0],dims[2])
idat2[*,*,j] = rotate(idat[*,*,j], 3)
endif else begin
idat2[*,*,j] = rotate(idat[*,*,j],3)
endelse
endfor
idat = idat2
idat2 = 0
endif
if keyword_set(THUMBSIZE) then tsize = THUMBSIZE else tsize = 50
isize = size(idat)
if (isize[0] eq 2) then begin
nimages = 1 & npixels = double(isize[1]*isize[2])
endif else begin
nimages = isize(isize[0]) & npixels = double(isize[1]*isize[2]*nimages)
endelse
if((nimages gt 300) and (tsize gt 50)) then begin
print, 'ERROR= Too many plasmagram frames '
print, 'STATUS= Plasmagrams limited to 300 frames; select a shorter time range.'
return, -1
endif
if NOT keyword_set(TSTART) then start_frame = 0 $
else begin
w = where(edat ge TSTART,wc)
if wc eq 0 then begin
print,'ERROR=No image frames after requested start time.' & return,-1
endif else start_frame = w[0]
endelse
if NOT keyword_set(TSTOP) then stop_frame = nimages $
else begin
w = where(edat le TSTOP,wc)
if wc eq 0 then begin
print,'ERROR=No image frames before requested stop time.' & return,-1
endif else stop_frame = w(wc-1)
endelse
if (start_frame gt stop_frame) then no_data_avail = 1L $
else begin
no_data_avail = 0L
if ((start_frame ne 0)OR(stop_frame ne nimages)) then begin
idat = idat[*,*,start_frame:stop_frame]
isize = size(idat)
if (isize[0] eq 2) then nimages = 1 else nimages = isize[isize[0]]
edat = edat[start_frame:stop_frame]
endif
endelse
ncols = xs / tsize & nrows = (nimages / ncols) + 1
label_space = 12
boxsize = tsize+label_space
ys = (nrows*boxsize) + 15
if (no_data_avail eq 0) then begin
a = tagindex('VALIDMIN',tag_names(zstruct))
if (a[0] ne -1) then begin & b=size(zstruct.VALIDMIN)
if (b[0] eq 0) then zvmin = zstruct.VALIDMIN $
else begin
zvmin = 0
print,'WARNING=Unable to determine validmin for ',vname
endelse
endif
a = tagindex('VALIDMAX',tag_names(zstruct))
if (a[0] ne -1) then begin & b=size(zstruct.VALIDMAX)
if (b[0] eq 0) then zvmax = zstruct.VALIDMAX $
else begin
zvmax = 2000
print,'WARNING=Unable to determine validmax for ',vname
endelse
endif
a = tagindex('FILLVAL',tag_names(zstruct))
if (a[0] ne -1) then begin & b=size(zstruct.FILLVAL)
if (b[0] eq 0) then zfill = zstruct.FILLVAL $
else begin
zfill = 2000
print,'WARNING=Unable to determine the fillval for ',vname
endelse
endif
logz = 0L
a = tagindex('SCALETYP',ztags)
if (a[0] ne -1) then begin
if (strupcase(zstruct.SCALETYP) eq 'LOG') then logz = 1L
endif
outofrange = where(idat lt zvmin or idat gt zvmax, ocnt)
if (ocnt gt 0) then idat[outofrange] = zfill
if keyword_set(DEBUG) then print,'WARNING=Number of Z values outside of validmin/max range = ',ocnt
wmin = min(idat,MAX=wmax)
fdat = where(idat ne zfill, fc)
if (fc gt 0) then begin
wmin = min(idat[fdat],MAX=wmax)
endif else begin
if keyword_set(DEBUG) then print,'WARNING=No data found - all data is fill or out of range!!'
wmin=1 & wmax = 1.1
endelse
if (logz and (wmin le 0.0)) then begin
w = where((idat le 0.0 and idat ne zfill), wc)
z = where((idat gt 0.0 and idat ne zfill), zc)
if (wc gt 0 and zc gt 0) then begin
if keyword_set(DEBUG) then print, 'Z log scaling and min values being adjusted, '
wmin = min(idat[z])
idat[w] = wmin
endif
endif
w = where(((idat lt zvmin) and (idat ne zfill)),wc)
if wc gt 0 then begin
if keyword_set(DEBUG) then print, 'Setting ',wc,' out of range values in image data to lowest data value= ', wmin
idat[w] = wmin
w = 0
endif
wfill = where((idat ne zfill),wcfill)
if (wcfill gt 0) then idmax=max(idat[wfill], /nan, min=idmin) else print, 'all image data is fill'
if (idmin eq idmax) then begin
if (logz) then idmin = .00001
idmax = idmin+1
endif
w = where((idat gt zvmax and idat ne zfill),wc)
if wc gt 0 then begin
if keyword_set(DEBUG) then print, 'Number of values above the valid max = ',wc, '. Setting them to red...'
diff = zvmax - zvmin
coffset = red_offset(GIF=GIF,diff)
print, 'diff = ',diff, ' coffset = ',coffset
idat[w] = zvmax - coffset
w = 0
if wc eq npixels then print,'WARNING=All data outside min/max!!'
endif
if keyword_set(DEBUG) then begin
print, 'Image valid min and max: ',zvmin, ' ',zvmax
print, 'Actual min and max of data',wmin,' ', wmax
print, 'Image fill values = ',zfill
endif
if keyword_set(DEBUG) then begin
print, 'Statistics about the data distribution'
w = where(((idat lt zvmax) and (idat ge (zvmax-10))),wc)
if wc gt 0 then print, 'Number of values between ',zvmax,' and ',zvmax-10,' = ',wc
w = where(((idat lt zvmax-10) and (idat ge (zvmax-20))),wc)
if wc gt 0 then print, 'Number of values between ',zvmax-10,' and ',zvmax-20,' = ',wc
w = where(((idat lt zvmax-20) and (idat ge (zvmax-30))),wc)
if wc gt 0 then print, 'Number of values between ',zvmax-20,' and ',zvmax-30,' = ',wc
w = where(((idat lt zvmax-30) and (idat ge (zvmax-40))),wc)
if wc gt 0 then print, 'Number of values between ',zvmax-30,' and ',zvmax-40,' = ',wc
w = where(((idat lt zvmax-40) and (idat ge (zvmax-50))),wc)
if wc gt 0 then print, 'Number of values between ',zvmax-40,' and ',zvmax-50,' = ',wc
w = where(((idat lt zvmax-50) and (idat ge (zvmax-60))),wc)
if wc gt 0 then print, 'Number of values between ',zvmax-50,' and ',zvmax-60,' = ',wc
endif
if (nimages eq 1) then idat = congrid(idat,tsize,tsize,cubic=0) $
else begin
sidat=idat
data_type = size(idat,/type)
idat=make_array(tsize,tsize,nimages,type=data_type)
for ii=0L,nimages-1 do $
idat[*,*,ii] = congrid(sidat[*,*,ii],tsize,tsize,cubic=0)
endelse
if keyword_set(NONOISE) then begin
semiMinMax,idat,zvmin,zvmax
w = where((idat lt zvmin),wc)
if wc gt 0 then begin
print,'WARNING=filtering values less than 3-sigma from image data...'
idat[w] = zvmin
w = 0
endif
w = where((idat gt zvmax),wc)
if wc gt 0 then begin
print,'WARNING=filtering values greater than 3-sigma from image data...'
diff = zvmax - zvmin
coffset = red_offset(GIF=GIF,diff)
print, 'diff = ',diff, ' coffset = ',coffset
idat[w] = zvmax - coffset
w = 0
endif
endif
axis_size = 0
if keyword_set(GIF) then begin
deviceopen,6,fileOutput=GIF,sizeWindow=[xs+xco+axis_size,ys+40+axis_size]
if (no_data_avail eq 0) then begin
if(reportflag eq 1) then printf,1,'IMAGE=',GIF
print,'IMAGE=',GIF
endif else begin
split=strsplit(gif,'/',/extract)
outdir='/'
for k=0L,n_elements(split)-2 do outdir=outdir+split[k]+'/'
print, 'GIF_OUTDIR=',outdir
print, 'LONG_GIF=',split[k]
if(reportflag eq 1) then begin
printf,1,'GIF_OUTDIR=',outdit
printf,1,'LONG_GIF=',split[k]
endif
endelse
endif else begin
window,/FREE,XSIZE=xs+xco+axis_size,YSIZE=ys+40+axis_size,TITLE=window_title
endelse
fill_idx = where((idat eq zfill),fillwc)
image2 = idat
if (logZ) then begin
idat = alog(image2)
logidmax=max(idat, /nan, min=logidmin)
idat = bytscl(idat,min=logidmin, max=logidmax, top=!d.table_size-2)
endif else begin
idat = bytscl(idat,min=idmin, max=idmax, top=!d.table_size-2)
endelse
if fillwc gt 0 then begin
idat[fill_idx] = 0
endif
xmargin=!x.margin
ymargin=!y.margin
if COLORBAR then begin
if (!x.omargin[1]+!x.margin[1]) lt 10 then !x.margin[1] = 10
!x.margin[1] = 3
plot,[0,1],[0,1],/noerase,/nodata,xstyle=4,ystyle=4
endif
irow=0
icol=0
for j=0L,nimages-1 do begin
if(icol eq ncols) then begin
icol=0
irow=irow+1
endif
xpos=icol*tsize+axis_size
ypos=ys-(irow*tsize+30)
if (irow gt 0) then ypos = ypos-(label_space*irow)
xthb=tsize
ythb=tsize+label_space
xsp=float(xthb)/float(xs+80)
ysp=float(ythb)/float(ys+30)
yi= 1.0 - 10.0/ys
x0i=0.0095
y0i=yi-ysp
x1i=0.0095+xsp
y1i=yi
x0=x0i+icol*xsp
y0=y0i-irow*ysp
x1=x1i+icol*xsp
y1=y1i-irow*ysp
xpimg=xthb
ypimg=ythb-label_space
xspm=float(xthb)
yspm=float(ythb-label_space)
yi= (ys+30) - label_space
x0i=2.5
y0i=yi-yspm
x1i=2.5+xspm
y1i=yi
x0=x0i+icol*xspm
y0=y0i-(irow*yspm+irow*label_space)
x1=x1i+icol*xspm
y1=y1i-(irow*yspm+irow*label_space)
position=[x0,y0,x1,y1]
xpos=x0
ypos=y0
tv,idat[*,*,j],xpos,ypos,/DEVICE
edate = decode_cdfepoch(edat(j))
shortdate = strtrim(strmid(edate, 10, strlen(edate)), 2)
xyouts, xpos, ypos-10, shortdate, color=!d.table_size-1, /DEVICE
icol=icol+1
endfor
if ((reportflag eq 1)AND(no_data_avail eq 0)) then begin
PRINTF,1,'VARNAME=',zstruct.varname
PRINTF,1,'NUMFRAMES=',nimages
PRINTF,1,'NUMROWS=',nrows & PRINTF,1,'NUMCOLS=',ncols
PRINT,1,'THUMB_HEIGHT=',tsize+label_space
PRINT,1,'THUMB_WIDTH=',tsize
PRINTF,1,'START_REC=',start_frame
PRINTF,1,'PLASMAGRAM=1'
endif
if (no_data_avail eq 0) then begin
PRINT,'VARNAME=',zstruct.varname
PRINT,'NUMFRAMES=',nimages
PRINT,'NUMROWS=',nrows & PRINT,'NUMCOLS=',ncols
PRINT,'THUMB_HEIGHT=',tsize+label_space
PRINT,'THUMB_WIDTH=',tsize
PRINT,'START_REC=',start_frame
PRINT,'PLASMAGRAM=1'
endif
if ((keyword_set(CDAWEB))AND(no_data_avail eq 0)) then begin
fname = GIF + '.sav' & save_mystruct,astruct,fname
endif
project_subtitle,zstruct,window_title,/IMAGE, $
TIMETAG=[edat[0],edat(nimages-1)]
if COLORBAR then begin
if (n_elements(cCharSize) eq 0) then cCharSize = 0.
cscale = [idmin, idmax]
xwindow = !x.window
!x.window[1]=0.858
!y.window=[0.13,0.9]
offset = 0.01
if (logZ) then offset = -0.03
colorbar, cscale, ctitle, logZ=logz, cCharSize=cCharSize, $
position=[!x.window[1]+offset, !y.window[0],$
!x.window[1]+offset+0.03, !y.window[1]],$
fcolor=244, /image
!x.window = xwindow
endif
!x.margin=xmargin
!y.margin=ymargin
if keyword_set(GIF) then deviceclose
endif else begin
print,'STATUS=No data in specified time period.'
if keyword_set(GIF) then begin
xyouts,xs/2,ys/2,/device,alignment=0.5,color=244,$
'NO DATA IN SPECIFIED TIME PERIOD'
deviceclose
endif else begin
xyouts,xs/2,ys/2,/device,alignment=0.5,'NO DATA IN SPECIFIED TIME PERIOD'
endelse
endelse
endelse
if keyword_set(GIF) then device,/close
return,0
end