;+ ;NAME: ; PLOT3D ;PROCEDURE: plot3d, dat , latitude, longitude ;PURPOSE: ; Draws a series of 3d color plots, one plot per energy step. ;INPUT: ; dat: 3d data structure. ; latitude: latitude of center of plot ; longitude: longitude of center of plot ;KEYWORDS: ; EBINS: Specifies energy bins to plot. ; SUM_EBINS: Specifies how many bins to sum, starting with EBINS. If ; SUM_EBINS is a scaler, that number of bins is summed for ; each bin in EBINS. If SUM_EBINS is an array, then each ; array element will hold the number of bins to sum starting ; at each bin in EBINS. In the array case, EBINS and SUM_EBINS ; must have the same number of elements. ; BNCENTER: if > 0 then lat,lon set so that B direction is in center ; if < 0 then lat,lon set so that -B direction is in center ; ('magf' element must exist in dat structure. See "ADD_MAGF") ; BINS: bins to use for autoscaling. ; SMOOTH: smoothing parameter. 0=none, 2 is typical ;SEE ALSO: "PLOT3D_OPTIONS" to see how to set other options. ; ;CREATED BY: Davin Larson ;LAST MODIFICATION: @(#)plot3d.pro 1.37 98/02/23 ;- pro plt3d,data,ptmap, $ OPTIONS = opts, $ BINS=bins, $ TBINS=tbins, $ BNCENTER=bncenter, $ LABELS=labs, $ SMOOTH= smoth, $ EBINS=eb, $ SUM_EBINS=seb, $ PTLIMIT=plot_limits, $ UNITS = units, $ SETLIM = setlim, $ PROC3D = proc3d, $ ZRANGE = zrange, $ STACK = stack, $ ;!p.multi[1:2] ROW_MAJOR = row_major,$ ;!p.multi[4] NOERASE = noerase ;!p.multi[0] d={latitude:0.,longitude:0.,units:'Eflux',smooth:0,mapname:'mol' $ ,bncenter:0,compress:1,grid:[45,45]} if keyword_set(opts) then extract_tags,d,opts else opts=d str_element,bindata,'magf',value=magf if keyword_set(magf) then begin xyz_to_polar,magf,theta=th,phi=phi bdir = [th,phi] endif str_element,bindata,'vsw',value=vsw smooth_3d = 3 triang = 0 if n_elements(smoth) eq 0 then smoth = smooth_3d if keyword_set(bncenter) and n_elements(bdir) eq 2 then begin latitude = bdir(0) longitude = bdir(1) if bncenter lt 0 then begin latitude = - latitude longitude = longitude + 180 endif endif str_element,bindata,'map',value=ptmap if triang eq 0 then begin if keyword_set(ptmap) then begin np = dimen1(ptmap) ptmap = rotate(ptmap,7) ; this line and the next should be removed when ptmap = rotate(ptmap,5) ; the c-code is fixed ptmap = reverse(ptmap,2) ; assumes !order = 0 message,'Using supplied mapping',/cont,/info endif else begin ptmap = make_3dmap2(theta,phi,dtheta,dphi,64,32,bins=tbins) ptmap = shift(ptmap,32,0) ; map routine expects phi: -180 to 180 endelse endif mapname = strlowcase(strmid(d.mapname,0,3)) if keyword_set(setlim) then begin map_set, latitude,longitude,0., /WHOLE_MAP, $ /noerase, $ MOLL = mapname eq 'mol' , $ CYLIN = mapname eq 'cyl' , $ ORTHO = mapname eq 'ort' , $ AITOFF= mapname eq 'ait' , $ LAMBERT=mapname eq 'lam' , $ GNOMIC =mapname eq 'gno' , $ MERCATO=mapname eq 'mer' , $ LIMIT=plot_limits , $ TITLE=ttl, $ charsize = charsize, $ XMARGIN=[1,1], YMARGIN=[1,1] return endif if keyword_set(triang) then begin ; data = total(bindata.data(e1:e2,*),1) ; sum over energies ; range = minmax_range(data(goodbins),/pos) theta = total(bindata.theta(e1:e2,*),1)/nsteps phi = total(bindata.phi(e1:e2,*),1)/nsteps if keyword_set(tbins) then ind = where(tbins ne 0) $ else ind = where(finite(theta) and finite(phi)) if ind(0) eq -1 then message,'error' data = data(ind) theta = theta(ind) phi = phi(ind) triangulate,phi,theta,fvalue=data,sphere=sphere,/degrees image = trigrid(data,sphere=sphere,[2.,2.],[-180.,-90.,178.,90.],/deg) image = bytescale(image,log=logscale_3d, range=range) endif else begin zdata = ([!values.f_nan,data])[ptmap+1] ; make 2-dimensional if( keyword_set(d.smooth) ) then begin dim = dimen(data) * 1 * d.smooth ; increase the dimensions data = rebin(data,dim(0),dim(1)) data = smooth_periodic(data,smooth) endif image = bytescale(data,log=logscale_3d, range=range) image = congrid(image,360,180) ; assumes !order eq 0 endelse map_set, latitude,longitude,0., /advance, /WHOLE_MAP, $ MOLL = mapname eq 'mol' , $ CYLIN = mapname eq 'cyl' , $ ORTHO = mapname eq 'ort' , $ AITOFF= mapname eq 'ait' , $ LAMBERT=mapname eq 'lam' , $ GNOMIC =mapname eq 'gno' , $ MERCATO=mapname eq 'mer' , $ LIMIT=plot_limits , $ TITLE=ttl, $ charsize = charsize, $ XMARGIN=[1,1], YMARGIN=[1,1] new = map_image(image,sx,sy,xsize,ysize, $ COMPRESS=d.compress, BILIN=0) ; new = map_patch(image,xstart=sx,ystart=sy,xsize=xsize,ysize=ysize) tv,new,sx,sy,xsize=xsize,ysize=ysize,order=0 if n_elements(bdir) eq 2 then begin ; draw mag field plots,bdir(1),bdir(0),psym=1 plots,bdir(1)+180,-bdir(0),psym=4 endif if n_elements(vsw) then begin xyz_to_polar,vsw,theta=th,phi=ph plots,ph,th,psym=2 endif else plots,179.99,0.,psym=2 ; draw the sun. if keyword_set(grid_3d) then map_grid,londel=d.grid[0],latdel=d.grid[1] ; str_element,opts,'plot3d_proc',value=proc3d ; str_element,bindata,'plot3d_proc',value=proc3d ; if keyword_set(proc3d) then begin ; proc = '' ; if ndimen(proc3d) eq 0 then proc=proc3d else begin ; if plot_num lt n_elements(proc3d) then proc = proc3d(plot_num) ; endelse ; if keyword_set(proc) then call_procedure,proc,bindata,en2,plot_num ; endif ; if keyword_set(labs) then begin ; lab=strcompress(indgen(nbins),/rem) ; colorcode = [!p.background,!p.color] ; xyouts,phi,theta,lab,align=.5,COLOR=colorcode(bins) ; endif ;map_grid,/label,latdel =45,londel=45,CHARSIZE=charsize ;map_continents return end