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 import os, logging, numpy as np
0004 from opticks.ana.fold import Fold, IsRemoteSession
0005 MODE = int(os.environ.get("MODE","3"))
0006 
0007 log = logging.getLogger(__name__)
0008 
0009 
0010 if IsRemoteSession():  # HMM: maybe do this inside pvplt ?
0011     MODE = 0
0012     print("detect fold.IsRemoteSession forcing MODE:%d" % MODE)
0013 elif MODE in [2,3]:
0014     from opticks.ana.pvplt import *  # HMM this import overrides MODE, so need to keep defaults the same 
0015 pass
0016 
0017 
0018 if __name__ == '__main__':
0019     logging.basicConfig(level=logging.INFO)
0020     f = Fold.Load(symbol="f")
0021     print(repr(f))
0022     a = f.a
0023     b = f.b
0024 
0025     H,V = 0,2  # X, Z
0026     sc = 10
0027 
0028     for e in [a,b]:
0029 
0030         nrm = e[:,0,:3] 
0031         r_nrm = np.sqrt(np.sum( nrm*nrm, axis=1 ))  
0032         print(r_nrm) 
0033 
0034 
0035         label = "CSG/tests/csg_intersect_leaf_test.sh "    
0036 
0037         if MODE in [0,1]:
0038             print("not plotting as MODE %d in environ" % MODE )
0039         elif MODE == 2:
0040             pl = mpplt_plotter(label=label)
0041             fig, axs = pl
0042             assert len(axs) == 1
0043             ax = axs[0]
0044             ax.set_xlim(-120,120)
0045 
0046         elif MODE == 3:
0047             pl = pvplt_plotter(label)
0048             pvplt_viewpoint(pl)   # sensitive to EYE, LOOK, UP envvars
0049         pass
0050 
0051 
0052         spos = e[:,1,:3]
0053         snrm = e[:,0,:3]
0054 
0055 
0056         if MODE == 2:
0057             ax.scatter( spos[:,H], spos[:,V], s=0.1 )
0058 
0059             for i in range(len(spos)):
0060                 p = spos[i]
0061                 n = snrm[i]
0062                 ax.arrow( p[H], p[V], sc*n[H], sc*n[V] )
0063             pass
0064 
0065         elif MODE == 3:
0066             pl.add_points(spos[:,:3])
0067         else:
0068             pass
0069         pass
0070 
0071         if MODE == 2:
0072             fig.show()
0073         elif MODE == 3:
0074             pl.show()
0075         pass
0076     pass
0077 pass