pro CATREND,SDEN,THRESH,SCALE,CUT_THRESH,SLCTYP,AX,AZ,LOW,RES,PER,VIDEO,TYPE,FILE,DEV @compile_opt.pro ; On error, return to caller ;+ ; NAME: ; CATREND ; PURPOSE: ; Renders a 3D to 2D projection of a constant density surface of the ; volume contained in SDEN. ; CATEGORY: ; Graphics ; CALLING SEQUENCE: ; CATREND,SDEN,THRESH,SCALE,CUT_THRESH,SLCTYP,AX,AZ,LOW,RES,PER, ; VIDEO,TYPE,FILE ; INPUTS: ; SDEN The 3D density array to be imaged. ; HRESH The surface contouring threshold value. ; SCALE Scaling factor for size of volume relative to coordinates ; CUT_THRESH Indicates where to slice volume. ; SLCTYP If CUT_THRESH > 0. then this determines what kind of ; slice to make. ; + or - 1 = Positive or Negative X-Axis slice. ; + or - 2 = Positive or Negative Y-Axis slice. ; + or - 3 = Positive or Negative Z-Axis slice. ; AX Rotation about the X-axis in degrees. ; AZ Rotation about the Z-axis in degrees. ; LOW Switch which indicates whether to show low or high side ; of surface. ; RES Scalar which determines the resolution in ; pixels at which the image is rendered. ; PER Scalar which determines perspective distance. ; FILE String which contains name of output TIFF file. ; TYPE = 0 40x10x10 matrix where the unit cell is (.03 AU/cell)^3 ; = 1 40x20x10 matrix where the unit cell is (.03 AU/cell)^3 ; = 2 40x20x10 matrix where the unit cell is (.05 AU/cell)^3 ; (For May 24th event only) ; KEYWORDS: ; /video If set, the image is rendered as a negative image of a black ; background with white axes so as to make videos easier ; to see. Otherwise, the image is rendered with black axes on ; a white background for hardcopy output. ; OUTPUTS: ; A TIFF (Tagged Image Format File) for exporting to the Amiga or ??? ; for printing, videos, or further processing. ; COMMON BLOCKS: ; NONE ; SIDE EFFECTS: ; NONE ; RESTRICTIONS: ; PROCEDURE: ; EXAMPLES: ; MODIFICATION HISTORY: ; May 1993 - Tom Davidson (UCSD/CASS) ;- s = size(SDEN) if s(0) NE 3 then message,'First argument must be a 3d array!' if TYPE eq 0 then begin ; 40x10x10 (May 7 and test cases) title_str = 'May 7 CME 40x10x10' N_XOFF = -.5 N_YOFF = 0. XMIN = 0 & XMAX = 19 YMIN = 0 & YMAX = 9 ZMIN = 0 & ZMAX = 9 XZERO = (XMAX - XMIN)/2.0 YZERO = 0 XPOS_LOW = 0.0 XPOS_HIGH = 1.0 YPOS_LOW = 0.0 YPOS_HIGH = 0.5 ZPOS_LOW = 0.0 ZPOS_HIGH = 0.5 nx = 6 XLEN = 0.6 XSTART = -0.3 xt = string(findgen(nx+1)/nx*XLEN + XSTART,format='(f4.1)') ny = 3 YLEN = 0.3 YSTART = 0.0 yt = string(findgen(ny+1)/ny*YLEN + YSTART,format='(f4.1)') yt(0) = ' ' nz = 3 ZLEN = 0.3 ZSTART = 0.0 zt = string(findgen(nz+1)/(nz)*ZLEN + ZSTART,format='(f4.1)') zt(0) = ' ' endif else if TYPE eq 1 then begin ; 40x20x10 (May 7 and test cases) title_str = 'May 7 CME 40x20x10' N_XOFF = -.5 N_YOFF = -.5 XMIN = 0 & XMAX = 19 YMIN = 0 & YMAX = 19 ZMIN = 0 & ZMAX = 9 XZERO = (XMAX - XMIN)/2.0 YZERO = (YMAX - YMIN)/2.0 XPOS_LOW = 0.0 XPOS_HIGH = 1.0 YPOS_LOW = 0.0 YPOS_HIGH = 1.0 ZPOS_LOW = 0.0 ZPOS_HIGH = 0.5 nx = 6 XLEN = 0.6 XSTART = -0.3 xt = string(findgen(nx+1)/nx*XLEN + XSTART,format='(f4.1)') ny = 6 YLEN = 0.6 YSTART = -0.3 yt = string(findgen(ny+1)/ny*YLEN + YSTART,format='(f4.1)') yt(3) = ' ' nz = 3 ZLEN = 0.3 ZSTART = 0.0 zt = string(findgen(nz+1)/nz*ZLEN + ZSTART,format='(f4.1)') zt(0) = ' ' endif else begin ; 40x20x10 (May 24th CME only) title_str = 'May 24 CME 40x20x10' N_XOFF = -.5 N_YOFF = -.5 XMIN = 0 & XMAX = 19 YMIN = 0 & YMAX = 19 ZMIN = 0 & ZMAX = 9 XZERO = (XMAX-XMIN)/2.0 YZERO = (YMAX-YMIN)/2.0 XPOS_LOW = 0.0 XPOS_HIGH = 1.0 YPOS_LOW = 0.0 YPOS_HIGH = 1.0 ZPOS_LOW = 0.0 ZPOS_HIGH = 0.5 nx = 10 XLEN = 1.0 XSTART = -0.5 xt = string(findgen(nx+1)/nx*XLEN + XSTART,format='(f4.1)') ny = 10 YLEN = 1.0 YSTART = -0.5 yt = string(findgen(ny+1)/ny*YLEN + YSTART,format='(f4.1)') yt(5) = ' ' nz = 5 ZLEN = 0.5 ZSTART = 0.0 zt = string(findgen(nz+1)/nz*ZLEN + ZSTART,format='(f4.1)') zt(0) = ' ' endelse pos=[XPOS_LOW,YPOS_LOW,XPOS_HIGH,YPOS_HIGH,ZPOS_LOW,ZPOS_HIGH] set_plot,'Z' device,set_resolution=[RES,RES],set_colors=256 surface,fltarr(2,2), $ ; Setup plot scaling /nodata, $ xst = 5, $ ; Exact, suppress yst = 5, $ zst = 5, $ xrange=[XMIN,XMAX], $ yrange=[YMIN,YMAX], $ zrange=[ZMIN,ZMAX], $ pos = pos, $ /save t3d, /reset t3d, transl = [N_XOFF,N_YOFF,0.] t3d, rotate = [-90.,AZ,0.] t3d, rotate = [AX,0.,0.] if n_elements(PER) ne 0 then t3d, per = PER t3d, transl = [.5,.25,.5] ; choose colors for video or hardcopy if keyword_set(VIDEO) then begin COLOR = 255 ; white lines BACK = 0 ; black background CHARTHICK = 2 !X.thick = 2 !Y.thick = 2 !Z.thick = 2 CHARSIZE = 2 endif else begin COLOR = 0 ; black lines BACK = 255 ; white background CHARTHICK = 2 !X.thick = 2 !Y.thick = 2 !Z.thick = 2 CHARSIZE = res/400.0 endelse erase, back ; Erase with background color axis,XZERO,YZERO,xax=0,/t3d,xticks=nx,xtickname=xt,xcharsize=CHARSIZE, $ xrange=[XMIN,XMAX], /data, color=COLOR, xtitle=' X', xst=1, $ charthick=CHARTHICK,/save;,pos=pos axis,XZERO,YZERO,yax=0,/t3d,yticks=ny,ytickname=yt,ycharsize=CHARSIZE, $ yrange=[YMIN,YMAX], /data, color=COLOR, ytitle=' Y', yst=1, $ charthick=CHARTHICK,/save;,pos=pos axis,XZERO,YZERO,zax=1,/t3d,zticks=nz,ztickname=zt,zcharsize=CHARSIZE, $ zrange=[ZMIN,ZMAX], /data, color=COLOR, ztitle=' Z', zst=1, $ charthick=CHARTHICK,/save;,pos=pos radeg = 180./!pi if (type eq 0 or type eq 1) then begin phi = -170.265/radeg ; position of HELIOS S/C theta = 5.5/radeg ; in spherical coordinates x = 9.5 - 9.5*sin(phi)*cos(theta) y = -9.*cos(phi)*cos(theta) z = 9.*sin(theta) endif else begin phi = -238.1/radeg ; position of HELIOS S/C theta = 5.4/radeg ; in spherical coordinates x = 9.5 - 9.5*sin(phi)*cos(theta) y = 9.5 - 9.5*cos(phi)*cos(theta) z = 9.*sin(theta) endelse plots,x,y,z,psym=1,/t3d,color=color,thick=1.0,symsize=res/400 if n_elements(low) eq 0 then low = 0 shade_volume,SDEN,thresh,v,p,LOW = low if CUT_THRESH gt 0. then begin x = v(abs(SLCTYP)-1,*) if SLCTYP gt 0 then x = x < CUT_THRESH else x = x > CUT_THRESH v(abs(SLCTYP)-1,*) = x endif if scale ne 1.0 then begin t3d, transl=[-.5,-.25,-.5] t3d, scale =[scale,scale,scale] t3d, transl=[.5,.25,.5] endif a = polyshade(v,p,/t3d) ; Merges with Z-buffer, returns dummy a = tvrd() ; Read merged image if DEV eq 'TIFF' then begin ; if keyword_set(VIDEO) then a = 255B - a ; make a negative image ; a = 255B - a print,'Writing output to: ' + FILE a = reverse(a,2) tiff_write,FILE,a endif else begin set_plot, DEV if dev eq 'X' then window,title=title_str,xsize=res,ysize=res tv, a ; Display merged image if dev eq 'PCL' then begin device, /close spawn,'prn idl.pcl' endif endelse return & end