

Summary
The v3d routines,
v3d.sl (version 1.2.1)
provide a way to define and visualize
3D cubes of scalar values, with application to
volumefilling geometries. The v3d routines described here are basic building blocks and
can be used in a variety of contexts. The routines are written in
SLang and can be added to SLangbased systems, e.g., ISIS, with the
usual commands: require("v3d") or ()=evalfile("v3d.sl") .
Docmentation on the routines is available in this
v3d Command Reference
document as well as in the comments in the source file
v3d.sl .
At the command line ``v3d_help; '' will list a brief
summary of the available routines; typing a routine's name without
arguments will generally give a very brief usage message.
Applications
In an astrophysical modeling context, the scalar values in the 3D array can
represent a local physical quantity that gives rise to observed emission.
As an example, for thermal Xrays the product n_e*n_i fulfills this role at
the local level and is related to the overall ``emission measure''
or ``norm'' of the model. In this way, the v3d routines are used to
defined the geometric properties
of model components as part of the
Xrayfocussed modeling and analysis system:
Other smaller and more custom examples of using v3d routines are
(i) as a frontend for Chandra's MARX
simulator, and (ii) as part of a custom isis model:
These example also shows how the use of SLang allows for convenient user customization
and extension.
The remainder of this page provides examples of the v3d routines
and their capabilities.
An Astrophysical Geometry Example
The 20yearold supernova remnant, SNR 1987A,
is made up of several geometric components as shown
here in solid crosssection (left) and projected on the sky (right.)
These include: the expanding SN ejecta (purple), the dense
``inner ring'' with protrusions (red), the toruslike HII region around the
ring (green) and an expanding blastwave out of the equatorial plane (blue).
The images were created with the commands in:

v3d_view, uses volview() 
v3d_project, uses imdisplay() 
Monte Carlo ``events'' with Doppler Effects
Routines are provided to generate Monte Carlo (MC) samples from
a v3d volume array with the probability of the event proportional to the
values of the array cell. The set of 3D locations, ``points'', created
can be used as input to a raytrace code. A routine is provided to
calculate Lineofsight Doppler shifts
(photon energy factors) based on a velocity field for the points.
The v3d routines also
provide a primative eventimaging capapility which can show the events
colorcoded by the Doppler velocity. The simple examples below were
made with the commands in v3dex_mc_vels.sl.

Solid 3D view 
MC events on sky 
vtype=0 const*r_hat 
vtype=1 const*r_vec 
vtype=2 rigid rotation v ~ r 
vtype=3 Kepler rotation v ~ 1/sqrt(r) 
Some other examples...
Some other example images and the files used to create them are given here:
Basic V3D Routines
Below are examples of some basic shapes available in the
v3d.sl routines; these examples were
made with the codesnippets indicated and given in full
in v3d_shape_demo.sl .
v3d_sphere v3d_sphere (20.0, 40.0, [20.,40.,20.]) +
v3d_sphere (0.0, 20.0, [0.,0.,50.0])   
v3d_spheroid v3d_spheroid (40.0, 50.0, 1.8, ,[20.0,70.])   
v3d_cylinder v3d_cylinder (10.0,20.0, 0.0,80.0, , [290.0,0.0])
+ v3d_cylinder (40.0, 90.0, 10.0, 10.0, ,[55.0, 30.0])   
v3d_cone v3d_cone (20.0, 30.0, 30.0, 80.0, , [40.,10.]) +
2.0* v3d_cone (0.0, 3.0, 200.0,200.0, , [50.0,60.0] )   
v3d_torus ( v3d_torus (30.0,70.0, [20.0,0.,0.],[40.,10.0]) 
v3d_torus (45.0,55.0, [20.,0.,0.], [40.,10.0]) ) +
v3d_torus (30.0,50.0, [10.,0.,40.], [140.0,80.0])   
v3d_cubeslice v3d_cube (100.0,[70.,0.,100.]) *
v3d_sphere (50.0,80.0)   
v3d_roche v3d_roche (90., 0.333, 1.0, [75.0,0.,.0],[0.0,0.0])
+
( v3d_roche (90., 3.0, 1.0, [15.0,0.,0.0],[180.0,0.0]) 
v3d_sphere (0.0, 20.0, [15.0,0.,0.0]) )   
v3d_sphere_ring v3d_sphere_ring (70.0, 5.0, 17, , [260.0, 44.0])   
v3d_sphere_rlup v3d_sphere_rlup (1.0,90.0, [0.0,3.0,10.0,30.0,100.0], [10.0,5.0,1.0,3.0,0.5])   
v3d_cyl_azlup v3d_cyl_azlup (70.0, 90.0, 40.0, 40.0, ,
[70.0,30.0], azlups,vlups)
with:
azlups = 9.0*[10:20:1];
vlups = 0.3 + cos(5.0*azlups*PI/180.0)^2;   
v3d_2dto3d v3d_2dto3d (arr2d, 20.0, 90.0, , [20.0, 30.0])
with
arr2d = Float_Type [91,100];
% from 0 to 10 degrees: 1/5 radius:
arr2d[[0:9],[0:20]] = 1.0;
% from 10 to 45 degrees: 1/2 radius:
arr2d[[10:45],[0:49]] = 1.0;
% from 46 to 90 degrees: full radius:
arr2d[[46:90],*] = 1.0;   
v3d_2dto3dRThydro v3d_2dto3d (arrRT, 22.0, 90.0, ,
[90.0,80.0]) with:
arr2d = h5_read("wrbub_1026.h5");
...etc...   
v3d_r3dsq 10.0*(1./30.0^3)* exp(1.0*v3d_r3dsq([0.,0.,0.])
/(30.0^2)) +
(1./10.^3)* exp(1.0* v3d_r3dsq([60.,50.,30.]) /(10.0^2))   
v3d_f_generic v3d_f_generic ("custom function", ,
[25.0,15.0])
Here, values = (cos(3.0*azimuth))^2 * (sin(5.0*lattitude))^2 * exp(1.0*rad3dsq/(40.0)^2);
  
v3d_histxy % v3d_histxy: bin x, y values into the central (z=0) xy plane of the
cube:
e0102_flat = v3d_histxy (e2d_data[15].dxs,
e2d_data[15].dys);
The above line was executed after doing:
e2di=15;
e2d_load_data("../Data/obs_3828/evt2", "X", "Y", [4094.1,4166.1], [0,0], [0.5,5.0]);
v3d_setup(25.0, 27);
  
v3d_reproject % continuing from the e0102_flat array
above,
% make it 3D by reprojecting it to a sphere:
e0102_sphere = v3d_reproject (e0102_flat, v3d_sphere(20.0,25.0));
  
