Back to home page

EIC code displayed by LXR

 
 

    


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

0001 #!/usr/bin/env python
0002 """
0003 CSGFoundry_MakeCenterExtentGensteps_Test.py
0004 =============================================
0005 
0006 
0007 Mysterious issue with pvplt_polarized yielding 
0008 only arrows in one direction. 
0009 
0010 When use add_arrows succeed to get them in 
0011 all directions, but the issue is not resolved. 
0012 
0013 With add_arrows it was necessary to tune mag 
0014 to get something visible depending 
0015 on the size of the region that is plotted
0016 
0017 """
0018 import numpy as np
0019 from opticks.ana.fold import Fold
0020 from opticks.ana.pvplt import * 
0021 from opticks.sysrap.sframe import sframe 
0022 
0023 import pyvista as pv 
0024 
0025 if __name__ == '__main__':
0026     t = Fold.Load(symbol="t")
0027      
0028     print(repr(t))
0029 
0030     gs = t.genstep
0031     p = t.photon
0032     frame = sframe.Load(t.base)
0033     print(frame)
0034 
0035     pos = p[:,0,:3] 
0036     mom = p[:,1,:3] 
0037     pol = p[:,2,:3] 
0038 
0039     pl = pv.Plotter(window_size=2*np.array([1280, 720]))
0040 
0041     pl.add_points( pos, color="magenta", point_size=1.0 )
0042 
0043     #sphere = pv.Sphere(radius=17800)
0044     #pl.add_mesh(sphere, color="white", show_edges=True, style="wireframe")
0045 
0046     pl.add_arrows( pos, mom, mag=50, show_scalar_bar=False, color="red" )
0047 
0048     #pvplt_arrows( pl, pos, mom, factor=1000 )    
0049     #pvplt_polarized( pl, pos, mom, pol, factor=2000 )    
0050 
0051 
0052     pl.show_grid()
0053     cp = pl.show()           
0054 
0055 
0056