FUNCTION plot_stack, Xvar, Yvar, Zvar,$
TSTART=TSTART,TSTOP=TSTOP,ELEMENTS=ELEMENTS,$
POSITION=POSITION,PANEL_HEIGHT=PANEL_HEIGHT,$
FIRSTPLOT=FIRSTPLOT,LASTPLOT=LASTPLOT,$
CDAWEB=CDAWEB,GIF=GIF,COMBINE=COMBINE,$
XSIZE=XSIZE,YSIZE=YSIZE,$
AUTO=AUTO,NOGAPS=NOGAPS,NOVALIDS,$
IGNORE_DISPLAY_TYPE=IGNORE_DISPLAY_TYPE,$
NONOISE=NONOISE,DEBUG=DEBUG,REPORT=REPORT,$
COLORBAR=COLORBAR, NOSUBTITLE=NOSUBTITLE, $
SCATTER=SCATTER, REVERSE_ORDER=REVERSE_ORDER,$
_EXTRA=EXTRAS
if keyword_set(REPORT) then begin & reportflag=1L
a=size(REPORT) & if (a[n_elements(a)-2] eq 7) then $
OPENW,1,REPORT,132,WIDTH=132
endif else reportflag=0L
if keyword_set(SCATTER) then begin
psym=2 & symsize=.25
endif else begin
psym=0 & symsize=1.0
endelse
if (n_params() ne 3) then begin
print,'ERROR=Missing parameter to plot_stack function' & return,-1
endif
a = size(Xvar)
if (a[n_elements(a)-2] ne 8) then begin
print,'ERROR=1st parameter to plot_stack not a structure' & return,-1
endif else begin
a = tagindex('DAT',tag_names(Xvar))
if (a[0] ne -1) then times = Xvar.DAT $
else begin
a = tagindex('HANDLE',tag_names(Xvar))
if (a[0] ne -1) then handle_value,Xvar.HANDLE,times $
else begin
print,'ERROR=1st parameter does not have DAT or HANDLE tag' & return,-1
endelse
b = size(times)
if ((b[n_elements(b)-2] eq 5) or (b[n_elements(b)-2] eq 9) or $
(b[n_elements(b)-2] eq 14)) then begin
endif else begin
print,'ERROR=1st parameter datatype not a CDF TIME related type' & return,-1
endelse
endelse
endelse
szck=size(times)
if(szck[szck[0]+2] ne 1) then $
times = reform(times)
a = size(Yvar)
if (a[n_elements(a)-2] ne 8) then begin
print,'ERROR=2nd parameter to plot_stack not a structure' & return,-1
endif else begin
YTAGS = tag_names(Yvar)
a = tagindex('DAT',YTAGS)
if (a[0] ne -1) then THEDATA = Yvar.DAT $
else begin
a = tagindex('HANDLE',YTAGS)
if (a[0] ne -1) then handle_value,Yvar.HANDLE,THEDATA $
else begin
print,'ERROR=2nd parameter does not have DAT or HANDLE tag' & return,-1
endelse
endelse
endelse
szck=size(thedata)
if(szck[szck[0]+2] ne 1) then $
thedata = reform(thedata)
a = size(Zvar)
if (a[n_elements(a)-2] ne 8) then begin
print,'ERROR=3rd parameter to plot_stack not a structure' & return,-1
endif else begin
ZTAGS = tag_names(Zvar)
a = tagindex('DAT',ZTAGS)
if (a[0] ne -1) then THECOLOR = Zvar.DAT $
else begin
a = tagindex('HANDLE',ZTAGS)
if (a[0] ne -1) then handle_value,Zvar.HANDLE,THECOLOR $
else begin
print,'ERROR=3rd parameter does not have DAT or HANDLE tag' & return,-1
endelse
endelse
endelse
szck=size(thecolor)
if(szck[szck[0]+2] ne 1) then $
thecolor = reform(thecolor)
a = size(thedata) & b = a[n_elements(a)-2] & thedata_size = a
if ((b eq 0) OR (b gt 5)) then begin
print,'STATUS=datatype indicates that data is not plottable' & return,-1
endif else begin
case a[0] of
0 : begin
print,'STATUS=Re-select longer time interval. Single data points are not plottable' & return,-1
end
1 : begin
print,'STATUS=Re-select longer time interval. Single data points are not plottable' & return,-1
end
2 : begin
elist=indgen(a[1])
if keyword_set(ELEMENTS) then elist = ELEMENTS $
else begin
if NOT keyword_set(IGNORE_DISPLAY_TYPE) then begin
b = tagindex('DISPLAY_TYPE',YTAGS)
if (b[0] ne -1) then begin
c = strupcase(Yvar.(b[0])) & c = break_mystring(c,delimiter='>')
if ((c[0] eq 'STACK_PLOT')AND(n_elements(c) gt 1)) then begin
d = break_mystring(c[1],delimiter=',')
elist = long(d) & elist = elist -1
endif
endif
endif
endelse
end
else: begin
print,'ERROR=Cannot plot data with > 2 dimensions' & return,-1
end
endcase
endelse
num_plots = n_elements(elist)
tbegin = times[0] & tend = times[n_elements(times)-1]
if keyword_set(TSTART) then begin
tbegin = TSTART & tbegin16 = TSTART & tbegintt = TSTART & a = size(TSTART)
if (a[n_elements(a)-2] eq 7) then begin
split_ep=strsplit(TSTART,'.',/extract)
tbegin = encode_CDFEPOCH(TSTART)
tbegin16 = encode_CDFEPOCH(TSTART,/EPOCH16,msec=split_ep[1])
tbegintt = encode_cdfepoch(TSTART, /TT2000, MSEC=split_ep[1])
endif
endif
if keyword_set(TSTOP) then begin
tend = TSTOP & tend16 = TSTOP & tendtt = TSTOP & a = size(TSTOP)
if (a[n_elements(a)-2] eq 7) then begin
split_ep=strsplit(TSTOP,'.',/extract)
tend = encode_CDFEPOCH(TSTOP)
tend16 = encode_CDFEPOCH(TSTOP,/EPOCH16,msec=split_ep[1])
tendtt = encode_cdfepoch(TSTOP, /TT2000, MSEC=split_ep[1])
endif
endif
pad_front = 0L & pad_end = 0L
ep16 = 0 & eptt=0
if (size(times[0],/tname) eq 'DCOMPLEX')then begin
ep16 = 1
tend = tend16
tbegin = tbegin16
endif
if (size(times[0],/tname) eq 'LONG64')then begin
eptt = 1
tend = tendtt
tbegin = tbegintt
endif
print, 'DEBUG in plot_stack, ep16 and eptt = ',ep16, eptt
if (!version.release ge '6.2' and (ep16 or eptt)) then begin
if (cdf_epoch_compare(times[0], tbegin)) then begin
if keyword_set(DEBUG) then print,'Padding front of times...'
times = [tbegin,times] & pad_front = 1L
endif
if (cdf_epoch_compare(tend, times[n_elements(times)-1])) then begin
if keyword_set(DEBUG) then print,'Padding end of times...'
times = [times,tend] & pad_end = 1L
endif
endif else begin
if (tbegin lt times[0]) then begin
if keyword_set(DEBUG) then print,'Padding front of times...'
times = [tbegin,times] & pad_front = 1L
endif
if (tend gt times[n_elements(times)-1]) then begin
if keyword_set(DEBUG) then print,'Padding end of times...'
times = [times,tend] & pad_end = 1L
endif
endelse
rbegin = 0L & w = where(times ge tbegin,wc)
if (wc gt 0) then rbegin = w[0]
rend = n_elements(times)-1 & w = where(times le tend,wc)
if (wc gt 0) then rend = w[n_elements(w)-1]
if (rbegin ge rend) then begin
print,'STATUS=No data within specified time range.' & return,-1
endif
if not (keyword_set(nosubtitle)) then begin
if (not eptt) then begin
CDF_EPOCH,tbegin,byear,bmonth,bday,hour,minute,second,milli,/BREAK
CDF_EPOCH,tend,eyear,emonth,eday,hour,minute,second,milli,/BREAK
endif else begin
CDF_EPOCH,tbegin,byear,bmonth,bday,hour,minute,second,milli,/TOINTEGER,/BREAK
CDF_EPOCH,tend,eyear,emonth,eday,hour,minute,second,milli,/TOINTEGER,/BREAK
endelse
ical,byear,doy,bmonth,bday,/idoy
subtitle = 'TIME RANGE='+strtrim(string(byear),2)+'/'+strtrim(string(bmonth),2)
subtitle = subtitle + '/' + strtrim(string(bday),2)
subtitle = subtitle + ' (' + strtrim(string(doy),2) + ') to '
ical,eyear,doy,emonth,eday,/idoy
subtitle = subtitle + strtrim(string(eyear),2)+'/'+strtrim(string(emonth),2)
subtitle = subtitle + '/' + strtrim(string(eday),2)
subtitle = subtitle + ' (' + strtrim(string(doy),2) + ')'
endif else subtitle=''
if (not eptt) then begin
CDF_EPOCH,tbegin,year,month,day,hour,minute,second,milli,/BREAK
CDF_EPOCH,a,year,month,day,0,0,0,0,/COMPUTE_EPOCH
endif else begin
CDF_EPOCH,tbegin,year,month,day,hour,minute,second,milli,/BREAK, /TOINTEGER
CDF_EPOCH,a,year,month,day,0,0,0,0,/COMPUTE,/TT2000
endelse
if (ep16)then begin
CDF_EPOCH16,b,year,month,day,0,0,0,0,0,0,0,/COMPUTE_EPOCH
if keyword_set(DEBUG) then tatime = systime(1)
ep_diff = cdf_epoch_diff (times, b, /micro_seconds)
temp2 = ep_diff/1000000.d0
times = temp2
endif else if (eptt) then begin
times = (times - a) / 1000000000.d0
endif else begin
times = (times - a) / 1000.d0
endelse
julday = ymd2jd(year,month,day)
xranger = dblarr(2)
if (ep16 or eptt) then begin
xranger[0] = times[0]
xranger[1] = times[n_elements(times)-1]
endif else begin
xranger[0] = (tbegin-a)/1000
if ((tbegin-a) eq 0 and (n_elements(times) le 50)) then xranger[0] = times[1]
xranger[1] = (tend-a)/1000
endelse
trange = xranger[1] - xranger[0]
if (trange gt 0.0 and trange lt 1.0) then tform='h$:m$:s$.f$@y$ n$ d$' $
else tform='h$:m$:s$@y$ n$ d$'
new_window = 1L
if keyword_set(POSITION) then begin
a = size(POSITION) & b = n_elements(a)
if ((a[b-1] ne 4)OR(a[b-2] ne 3)) then begin
print,'ERROR=Invalid value for POSITION keyword' & return,-1
endif
if keyword_set(PANEL_HEIGHT) then begin
a = size(PANEL_HEIGHT) & b = n_elements(a)
if ((a[b-2] le 1)OR(a[b-2] gt 5)) then begin
print,'ERROR=Invalid value for PANEL_HEIGHT keyword' & return,-1
endif else psize = PANEL_HEIGHT
endif else begin
print,'ERROR=PANEL_HEIGHT keyword must be specified with POSITION keyword'
return,-1
endelse
if keyword_set(FIRSTPLOT) then clear_plot = 0L else clear_plot = 1L
new_window = 0L
endif
if (new_window eq 1) then begin
if keyword_set(GIF) then begin
xs = 640 & ys = 512 & psize = 100
if keyword_set(XSIZE) then xs = XSIZE
if keyword_set(YSIZE) then ys = YSIZE
if keyword_set(PANEL_HEIGHT) then begin
psize = PANEL_HEIGHT & ys = psize + 200
endif else psize = ((ys-100) / num_plots)
endif else begin
a = lonarr(2) & DEVICE,GET_SCREEN_SIZE=a
xs = (a[0]*0.66) & ys = (a[1]*0.66)
if keyword_set(XSIZE) then xs = XSIZE
if keyword_set(YSIZE) then ys = YSIZE
if keyword_set(PANEL_HEIGHT) then begin
psize = PANEL_HEIGHT
ys = psize + 200
if (ys gt a[1]) then begin
print,'ERROR=Computed window Ysize greater than device resolution'
return,-1
endif
endif else psize = ((ys-100) / num_plots)
endelse
if (psize lt 50) then begin
print,'ERROR=Insufficient resolution for a ',num_plots,' stack plot'
return,-1
endif
endif
if keyword_set(POSITION) then ppos = POSITION $
else begin
ppos = fltarr(4)
ppos[0] = 100
ppos[1] = 100
ppos[2] = (xs - 40)
ppos[3] = (ys - 30)
if keyword_set(CDAWEB) then ppos[2] = xs - 100
endelse
if (new_window eq 1) then begin
a = tagindex('SOURCE_NAME',YTAGS)
if (a[0] ne -1) then b = Yvar.SOURCE_NAME else b = ''
a = tagindex('DESCRIPTOR',YTAGS)
if (a[0] ne -1) then b = b + ' ' + Yvar.DESCRIPTOR
window_title = b
endif
if (new_window eq 1) then begin
if keyword_set(GIF) then begin
a = size(GIF) & if (a[n_elements(a)-2] ne 7) then GIF = 'idl.gif'
fcolor = 0
endif else begin
clear_plot = 0L
fcolor = 0
endelse
endif
xmargin=!x.margin
if (!x.omargin[1]+!x.margin[1]) lt 14 then !x.margin[1] = 14
!x.margin[1] = 14
plot,[0,1],[0,1],/noerase,/nodata,xstyle=4,ystyle=4
a = tagindex('FILLVAL',YTAGS)
if (a[0] ne -1) then Yfillval = Yvar.FILLVAL else Yfillval = 1.0e31
if (a[0] ne -1) then Zfillval = Zvar.FILLVAL else Zfillval = 1.0e31
colr_dims = size(thecolor, /n_dimensions)
edata = thedata[elist,*]
all = where(edata ne Yfillval,no_fill)
mytimes = times[rbegin:rend]
if (no_fill ne 0) then begin
scaledata = edata[all] & all=0
endif else begin
if(no_fill eq 0) then begin
all=0
ylabel = ''
a = tagindex('FIELDNAM',YTAGS)
if (a[0] ne -1) then ylabel = Yvar.(a[0])
print, 'STATUS=No non-fill data to display for ',ylabel
return, -2
endif
endelse
edata = 0
ymax = 1.0 & ymin = 0.0
a = tagindex('VALIDMIN',YTAGS)
if (a[0] ne -1) then begin & b=size(Yvar.VALIDMIN)
if (string(Yvar.VALIDMIN[0]) ne '') then begin
if (b[0] eq 0) then ymin = Yvar.VALIDMIN $
else ymin = min(Yvar.VALIDMIN[elist])
endif
endif
a = tagindex('VALIDMAX',YTAGS)
if (a[0] ne -1) then begin & b=size(Yvar.VALIDMAX)
if (string(Yvar.VALIDMAX[0]) ne '') then begin
if (b[0] eq 0) then ymax = Yvar.VALIDMAX $
else ymax = max(Yvar.VALIDMAX[elist])
endif
endif
a = tagindex('SCALEMIN',YTAGS)
if (a[0] ne -1) then begin & b=size(Yvar.SCALEMIN)
if (string(Yvar.SCALEMIN[0]) ne '') then begin
if (b[0] eq 0) then ymin = Yvar.SCALEMIN $
else ymin = min(Yvar.SCALEMIN[elist])
endif
endif
a = tagindex('SCALEMAX',YTAGS)
if (a[0] ne -1) then begin & b=size(Yvar.SCALEMAX)
if (string(Yvar.SCALEMAX[0]) ne '') then begin
if (b[0] eq 0) then ymax = Yvar.SCALEMAX $
else ymax = max(Yvar.SCALEMAX[elist])
endif
endif
all_ymin = ymin & all_ymax = ymax
if (keyword_set(DEBUG)) then print, 'all_ymin/max = ',all_ymin, all_ymax
w = where(((scaledata gt ymax)OR(scaledata lt ymin)),wc)
if (wc gt 0) then begin
if keyword_set(DEBUG) then print,wc,' values outside VALIDMIN/MAX'
w = where(((scaledata le ymax)AND(scaledata ge ymin)),wb)
if (wb gt 0) then begin
scaledata=scaledata[w]
endif
endif
if (keyword_set(AUTO)) then begin
if (no_fill gt 0) then begin
all_ymax = 0.0 & all_ymin = min(scaledata,MAX=all_ymax)
endif
endif
if (keyword_set(DEBUG)) then print, 'after applied to data all_ymin/max = ',all_ymin, all_ymax
if ((all_ymax eq all_ymin) and (round(all_ymin,/L64) eq round(Yfillval,/L64))) then begin
ylabel = ''
a = tagindex('FIELDNAM',YTAGS)
if (a[0] ne -1) then ylabel = Yvar.(a[0])
print, 'STATUS=All data is fill, please select another time range for ',ylabel
plot,[0,1],[0,1],/nodata,ystyle=8+4,xstyle=8+4
return, -2
endif
if (all_ymax eq all_ymin) then begin
all_ymax = all_ymax + 1
all_ymin = all_ymin - 1.
endif
yranger = fltarr(2) & yranger[0] = all_ymin & yranger[1] = all_ymax
yscaletype = 0L
a = tagindex('SCALETYP',YTAGS)
if (a[0] ne -1) then begin
if (strupcase(Yvar.SCALETYP) eq 'LOG') then yscaletype = 1L
endif
if ((yscaletype eq 1)AND(yranger[0] le 0)) then yranger[0] = 0.00001
scaledata = 0
zmax = 1.0 & zmin = 0.0
a = tagindex('VALIDMIN',ZTAGS)
if (a[0] ne -1) then begin & b=size(Zvar.VALIDMIN)
if (b[0] eq 0) then zmin = Zvar.VALIDMIN $
else zmin = min(Zvar.VALIDMIN)
endif
a = tagindex('VALIDMAX',ZTAGS)
if (a[0] ne -1) then begin & b=size(Zvar.VALIDMAX)
if (b[0] eq 0) then zmax = Zvar.VALIDMAX $
else zmax = max(Zvar.VALIDMAX)
endif
a = tagindex('SCALEMIN',ZTAGS)
if (a[0] ne -1) then begin & b=size(Zvar.SCALEMIN)
if (string(Zvar.SCALEMIN[0]) ne '') then begin
if (b[0] eq 0) then zmin = Zvar.SCALEMIN $
else zmin = min(Zvar.SCALEMIN)
endif
endif
a = tagindex('SCALEMAX',ZTAGS)
if (a[0] ne -1) then begin & b=size(Zvar.SCALEMAX)
if (string(Zvar.SCALEMAX[0]) ne '') then begin
if (b[0] eq 0) then zmax = Zvar.SCALEMAX $
else zmax = max(Zvar.SCALEMAX)
endif
endif
zscaletype = 1L
a = tagindex('SCALETYP',ZTAGS)
if (a[0] ne -1) then begin
if (string(Zvar.SCALETYP[0]) ne '') then begin
if (strupcase(Zvar.SCALETYP) eq 'LINEAR') then zscaletype = 0L
endif
endif
if (keyword_set(AUTO)) then begin
if (colr_dims eq 2) then begin
tmpcolor = thecolor[elist,*]
good_color = where(((tmpcolor ne Zfillval) and (tmpcolor ge zmin) and (tmpcolor le zmax)),color_fill)
endif else begin
tmpcolor = thecolor[elist]
good_color = where(((tmpcolor ne Zfillval) and (tmpcolor ge zmin) and (tmpcolor le zmax)),color_fill)
endelse
if (color_fill gt 0) then begin
zmax = 0.0 & zmin = min(tmpcolor[good_color],MAX=zmax)
endif
endif
goodmin = -1
if (yscaletype) then begin
edata = thedata[elist,*]
w = where(edata ne Yfillval,non_fillcount)
if (non_fillcount ne 0) then begin
gooddata = edata[w]
endif else w=0
if ((NOT keyword_set(NOVALIDS))AND(non_fillcount gt 0)) then begin
a = tagindex('VALIDMIN',YTAGS)
if (a[0] ne -1) then begin & b=size(Yvar.VALIDMIN)
if (b[0] eq 0) then Yvmin = Yvar.VALIDMIN $
else Yvmin = Yvar.VALIDMIN[elist[0]]
endif else Yvmin = 1.0e31
a = tagindex('VALIDMAX',YTAGS)
if (a[0] ne -1) then begin & b=size(Yvar.VALIDMAX)
if (b[0] eq 0) then Yvmax = Yvar.VALIDMAX $
else Yvmax = Yvar.VALIDMAX[elist[0]]
endif else Yvmax = 1.0e31
w = where(((gooddata gt Yvmax)OR(gooddata lt Yvmin)),wc)
if (wc gt 0) then begin
if keyword_set(DEBUG) then print,wc,' values outside VALIDMIN/MAX'
w = where(((gooddata le Yvmax)AND(gooddata ge Yvmin)),wb)
if (wb gt 0) then begin
gooddata=gooddata[w]
endif
endif
endif
if keyword_set(NONOISE) then begin
sigminmax=three_sigma(gooddata)
sigmin=sigminmax.(0)
sigmax=sigminmax.(1)
w = where(((gooddata gt Sigmax)OR(gooddata lt Sigmin)),wc)
if (wc gt 0) then begin
w = where(((gooddata le Sigmax)AND(gooddata ge Sigmin)),wb)
if (wb gt 0) then begin
gooddata=gooddata[w]
endif
endif
endif
wle = where(gooddata le 0.0,wcle)
if (wcle gt 0) then begin
w = where(gooddata gt 0.0,wc)
if (wc gt 0) then begin
goodmin = min(gooddata[w])/2
if (keyword_set(AUTO)) then yranger[0] = goodmin
endif
endif
gooddata = 0
endif
if keyword_set(REVERSE_ORDER) then begin
start = num_plots-1
stop = 0
incr = -1
endif else begin
start = 0
stop = num_plots-1
incr = 1
endelse
for i=start, stop, incr do begin
if (thedata_size[0] eq 1) then mydata = thedata $
else mydata = thedata[[elist[i]],*]
mydata = reform(mydata)
if (pad_front) then mydata = [Yfillval,mydata]
if (pad_end) then mydata = [mydata,Yfillval]
rrend=n_elements(mydata)
if(rrend lt rend) then begin
print, "STATUS=No Data Available"
return, -1
endif
mytimes = times[rbegin:rend]
mydata = mydata[rbegin:rend]
w = where(mydata ne Yfillval,non_fillcount)
if (non_fillcount ne 0) then begin
mydata = mydata[w] & mytimes = mytimes[w] & w=0
endif else w=0
if ((NOT keyword_set(NOVALIDS))AND(non_fillcount gt 0)) then begin
a = tagindex('VALIDMIN',YTAGS)
if (a[0] ne -1) then begin & b=size(Yvar.VALIDMIN)
if (b[0] eq 0) then Yvmin = Yvar.VALIDMIN $
else Yvmin = Yvar.VALIDMIN[elist[i]]
endif else Yvmin = 1.0e31
a = tagindex('VALIDMAX',YTAGS)
if (a[0] ne -1) then begin & b=size(Yvar.VALIDMAX)
if (b[0] eq 0) then Yvmax = Yvar.VALIDMAX $
else Yvmax = Yvar.VALIDMAX[elist[i]]
endif else Yvmax = 1.0e31
w = where(((mydata gt Yvmax)OR(mydata lt Yvmin)),wc)
if (wc gt 0) then begin
if keyword_set(DEBUG) then print,wc,' values outside VALIDMIN/MAX'
w = where(((mydata le Yvmax)AND(mydata ge Yvmin)),wb)
if (wb gt 0) then begin
mydata=mydata[w] & mytimes=mytimes[w]
endif else begin
a = tagindex('FIELDNAM',YTAGS)
if(n_elements(ytlabel) eq 0) then begin
if (a[0] ne -1) then ytlabel = Yvar.(a[0]) else ytlabel = ' '
print, 'STATUS=All data from at least one element of ',ytlabel,' is fill'
endif
if (keyword_set(FIRSTPLOT) and i eq 0)then plot,[0,1],[0,1],/nodata,ystyle=8+4,xstyle=8+4
endelse
endif
endif
if keyword_set(NONOISE) then begin
sigminmax=three_sigma(mydata)
sigmin=sigminmax.(0)
sigmax=sigminmax.(1)
w = where(((mydata gt Sigmax)OR(mydata lt Sigmin)),wc)
if (wc gt 0) then begin
if keyword_set(DEBUG) then print,wc,' values outside 3-sigma...'
w = where(((mydata le Sigmax)AND(mydata ge Sigmin)),wb)
if (wb gt 0) then begin
mydata=mydata[w] & mytimes=mytimes[w]
endif
endif
endif
if (yscaletype eq 1) then begin
wle = where(mydata le 0.0,wcle)
if (wcle gt 0) then begin
w = where(mydata gt 0.0,wc)
if (wc gt 0) then begin
wmin = min(mydata[w])
mydata[wle] = goodmin
w=0
endif
endif
endif
ylabel = '' & yunits = ''
if keyword_set(COMBINE) then begin
a = tagindex('LOGICAL_SOURCE',YTAGS)
if (a[0] ne -1) then yds = strupcase(Yvar.(a[0]))
endif
a = tagindex('FIELDNAM',YTAGS)
if (a[0] ne -1) then ylabel = Yvar.(a[0])
a = tagindex('LABLAXIS',YTAGS)
if (a[0] ne -1) then ylabel = Yvar.(a[0])
a = tagindex('UNITS',YTAGS)
if (a[0] ne -1) then yunits = Yvar.(a[0])
if (n_elements(yds) gt 0) then begin
ylabel = yds + '!C' + ylabel + '!C' + yunits
endif else ylabel = ylabel + '!C' + yunits
ycsize = 1.0 & ylength = max([strlen(ylabel),strlen(yunits)])
if ((!d.x_ch_size * ylength) gt psize) then begin
ratio = float(!d.x_ch_size * ylength) / float(psize)
ycsize = 1.0 - (ratio/8.0) + 0.1
endif
zlabel = '' & zunits = ''
a = tagindex('FIELDNAM',ZTAGS)
if (a[0] ne -1) then zlabel = Zvar.(a[0]) $
else zlabel = 'Energy'
a = tagindex('UNITS',ZTAGS)
if (a[0] ne -1) then zunits = Zvar.(a[0])
a = tagindex('UNIT_PTR',ZTAGS)
if (a[0] ne -1) then begin
if (Zvar.(a[0])[0] ne '') then zunits = Zvar.(a[0])
endif
zlabel = zlabel + '!C' + zunits
zcsize = 1.0 & zlength = max([strlen(zlabel),strlen(zunits)])
if ((!d.x_ch_size * zlength) gt psize) then begin
ratio = float(!d.x_ch_size * zlength) / float(psize)
zcsize = 1.0 - (ratio/8.0) + 0.1
endif
if keyword_set(NOGAPS) then datagaps = -1 else datagaps = find_gaps(mytimes)
if (i eq start) then begin
plot,mytimes,mydata,/DEVICE,/NODATA,YTITLE=ylabel,YRANGE=yranger,YSTYLE=2+4,$
YLOG=yscaletype,XSTYLE=4+1,XRANGE=xranger,POSITION=ppos,$
NOERASE=clear_plot,CHARSIZE=ycsize,_EXTRA=EXTRAS,ytick_get=yticks
if (n_elements(yticks) gt 0) then begin
yranger[0] = min(yticks)
yranger[1] = max(yticks)
endif
plot,mytimes,mydata,/DEVICE,/NODATA,YTITLE=ylabel,YRANGE=yranger,YSTYLE=1,$
YLOG=yscaletype,XSTYLE=4+1,XRANGE=xranger,POSITION=ppos,$
NOERASE=clear_plot,CHARSIZE=ycsize,_EXTRA=EXTRAS
timeaxis_text,JD=julday,/NOLABELS,TICKLEN=-2.0
endif
if (goodmin ne -1) then begin
wle = where(mydata eq goodmin, wcle)
if (wcle gt 0) then begin
mydata[wle] = yticks[0]
if keyword_set(DEBUG) then print,'Y Log scaling - reassigning values le 0 to lowest tick value above zero',yticks[0]
endif
endif
if (colr_dims eq 2) then begin
colr_size = size(thecolor, /dimensions)
clr = 0
good_index = -1
while ((good_index eq -1) and (clr le colr_size[1]-1)) do begin
bad_clr = where(thecolor[elist,clr] eq Zfillval, n_fill)
if (n_fill le 0) then good_index = clr else clr = clr + 1
endwhile
colors = thecolor[elist,clr]
Zt = thecolor[elist,clr]
endif else begin
colors = thecolor[elist]
Zt = thecolor[elist]
endelse
if (zscaletype) then begin
wh = where(colors le 0, wc)
if (wc eq 0) then begin
Zt = alog10(colors)
endif else begin
Zt = colors*0
wh = where(colors gt 0, wc)
if (wc gt 0) then Zt[wh] = alog10(colors[wh])
endelse
if (zmin le 0.) then minZ1 = 0. else minZ1 = alog10(zmin)
if (zmax le 0.) then maxZ1 = 0. else maxZ1 = alog10(zmax)
endif else begin
minZ1 = zmin
maxZ1 = zmax
endelse
Zt = bytscl(Zt, min=minZ1, max=maxZ1, top=!d.table_size-3)+1B
color = Zt[i]
if (non_fillcount ne 0) then begin
if (datagaps[0] eq -1) then oplot,mytimes,mydata, color=color, psym=psym, symsize=symsize $
else begin
start = 0L
for j=0,n_elements(datagaps)-1 do begin
stop = datagaps[j]
oplot,mytimes[start:stop],mydata[start:stop], color=color, psym=psym, symsize=symsize
start = stop + 1
endfor
oplot,mytimes[start:*],mydata[start:*],color=color, psym=psym, symsize=symsize
endelse
if ((colorbar eq 0) and (num_plots gt 9 and psize eq 100) or (num_plots gt 18 and psize eq 200)) then begin
colorbar = 1
if keyword_set(DEBUG) then print, 'DEBUG There are',num_plots,'values on the Z axis which exceeds the available space: making colorbar'
endif
if (colorbar eq 0) then begin
zidx = strtrim(string(tmpcolor[i],format='(F0.1)'),2)+' '
xl = ppos[2] + 6
yl = ppos[3] - (10 + (i*!d.y_ch_size))
xyouts, xl, yl, zidx, color=color, /device
endif
endif
endfor
if COLORBAR then begin
if (n_elements(cCharSize) eq 0) then cCharSize = 0.
xwindow = !x.window
cscale = [zmax, zmin]
offset = 0.01
ctitle = zlabel
cpos=[!x.window[1]+offset,!y.window[0],$
!x.window[1]+offset+0.03, !y.window[1]]
colorbar, cscale, ctitle, logZ=zscaletype, cCharSize=zcsize, $
position=cpos, fcolor=fcolor, /reverse
!x.window = xwindow
endif else begin
xl = xl + (strlen(zidx)*!d.x_ch_size) + 8
yl = (ppos[3]+ppos[1])/2
xyouts, xl, yl, zlabel, color=2, orientation=90, alignment=0.5, charsize=zcsize, /device
endelse
if keyword_set(POSITION) then begin
if keyword_set(LASTPLOT) then begin
timeaxis_text,FORM=tform,JD=julday,title=subtitle,CHARSIZE=0.9
endif
endif else begin
timeaxis_text,FORM=tform,JD=julday,title=subtitle,CHARSIZE=0.9
if keyword_set(GIF) then begin
deviceclose
endif
endelse
ytlabel = ''
return,0
end