Functions
depo2tvtk Namespace Reference

Functions

def main (infile, outname=None, toffset=1 *units.us, speed=1.6 *units.mm/units.us)
 

Detailed Description

Convert a Numpy file produced by NumpyDepoSaver into a vtk file which
can be visualized with paraview.

Function Documentation

def depo2tvtk.main (   infile,
  outname = None,
  toffset = 1*units.us,
  speed = 1.6*units.mm/units.us 
)

Definition at line 17 of file depo2tvtk.py.

17 def main(infile, outname=None, toffset=1*units.us, speed=1.6*units.mm/units.us):
18  if outname is None or outname == "-":
19  outname = os.path.splitext(infile)[0]
20 
21  if type(speed) == type(""):
22  speed = eval(speed)
23  if type(toffset) == type(""):
24  toffset = eval(toffset)
25 
26 
27  print("toffset=%f us, speed=%f mm/us" %
28  (toffset/units.us, speed/(units.mm/units.us)))
29 
30  arrs = numpy.load(infile)
31  depos = arrs['depo_data_0']
32 
33 
34  # depos is a 7xN array
35  # (t,q,x,y,z,dl,dt)
36 
37  #
38  # pack into array of : dict(
39  # point= [x,y,z],
40  # values=dict(name1=val1, name2=val2, ...)
41  # )
42 
43  points = list()
44  for one in depos.T:
45  t,q,x,y,z,dl,dt = one
46  rx = x + (t-toffset)*speed
47  # size=(dl,dt,dt)
48  p = dict(point=[-rx,y,z], values=dict(time=t,charge=q))
49  points.append(p)
50 
51  pointdata = rendertvtk.points(points)
52  ofile = outname + "-depos.vtp"
53  print(ofile)
54  write_data(pointdata, ofile)
55 
56 
std::enable_if< internal::is_string< String >::value >::type print(std::FILE *f, const text_style &ts, const String &format_str, const Args &...args)
Definition: color.h:549
def main(infile, outname=None, toffset=1 *units.us, speed=1.6 *units.mm/units.us)
Definition: depo2tvtk.py:17
def points(jdat)
Definition: rendertvtk.py:105