Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2026-04-09 07:48:51

0001 #!/usr/bin/env python
0002 """
0003 vtk_oxplt.py
0004 ==============
0005 
0006 Plot final photon positions 
0007 
0008 This requires vtk, pyvista, ipython. 
0009 
0010 
0011 * https://docs.pyvista.org/plotting/plotting.html
0012 
0013 
0014 Usage
0015 ------
0016 
0017 Invoke from directory with ox.npy::
0018 
0019     cd /tmp/$USER/opticks/OKTest/evt/g4live/torch/1
0020     vtk_oxplt.py 
0021     ipython -i -- $(which vtk_oxplt.py)
0022 
0023 
0024 OR give the directory as first argument::
0025 
0026     vtk_oxplt.py /tmp/blyth/opticks/G4OKTest/evt/g4live/natural/1/
0027 
0028 
0029 GUI
0030 ----
0031 
0032 shift+drag 
0033     pan
0034 two-finger-slide
0035     zoom 
0036 
0037 """
0038 import logging 
0039 log = logging.getLogger(__name__)
0040 import sys
0041 import numpy as np, os
0042 import pyvista as pv   
0043 
0044 if __name__ == '__main__':
0045     logging.basicConfig(level=logging.INFO)
0046     if len(sys.argv) > 1 and os.path.isdir(sys.argv[1]):
0047         os.chdir(sys.argv[1])
0048         log.info("chdir %s " % os.getcwd())
0049     pass
0050     np.set_printoptions(suppress=True, linewidth=200)
0051 
0052     name = "ox"
0053     #name = "ht"
0054 
0055     a = np.load("%s.npy" % name)
0056     size = 2*np.array([1024,768], dtype=np.int32)
0057     pl = pv.Plotter(window_size=size)
0058     pl.add_points(a[:,0,:3] )
0059     pl.show_grid()
0060     log.info("Showing the VTK/pyvista plotter window, it may be hidden behind other windows. Enter q to quit.")
0061     cpos = pl.show()
0062     log.info(cpos)
0063 
0064 
0065 
0066