Back to home page

EIC code displayed by LXR

 
 

    


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

0001 #!/usr/bin/env python
0002 """
0003 
0004 """
0005 import numpy as np
0006 import pyvista as pv
0007 pv = None
0008 
0009 import matplotlib.pyplot as mp                                                                                                                                                                                         
0010 
0011 if __name__ == '__main__':
0012 
0013     path = os.path.expandvars(os.path.join("/tmp/$USER/opticks/CSGTargetGlobalTest/$MOI", "ce.npy")) 
0014     ce = np.load(path)
0015 
0016     SIZE = np.array([1280, 720])
0017 
0018 
0019     moi = os.environ.get("MOI","-")
0020 
0021     print("moi %s " % moi )
0022     print("path %s " % path )
0023     print("ce.shape %s " % str(ce.shape))
0024 
0025     r = np.sqrt(np.sum(ce[:,:3]*ce[:,:3], axis=1))                                                                                                                                                    
0026     rmin = r.min()
0027     rmax = r.max()
0028     print("rmin %s rmax %s rmax-rmin %s " % (rmin, rmax, rmax-rmin))
0029 
0030 
0031     if not pv is None:
0032         pl = pv.Plotter(window_size=2*SIZE)
0033         pl.add_points(ce[:,:3])
0034         pl.show_grid()
0035         cp = pl.show()                                   
0036     pass
0037 
0038     from j.PosFile.RadiusTest import RadiusTest
0039     rt = RadiusTest()
0040 
0041 
0042 
0043     title = [
0044           "opticks/CSG/tests/CSGTargetGlobalTest.sh MOI %s" % moi, 
0045           "radii from axis aligned CE center-extents (wobbles expected as using global frame CE)" 
0046           ]
0047 
0048     if not mp is None:
0049         fig, ax = mp.subplots(figsize=SIZE/100.)
0050         fig.suptitle("\n".join(title))
0051 
0052         i = range(len(r))
0053         ax.scatter( i, r )
0054         xlim = ax.get_xlim() 
0055 
0056         kk = "fastener_r xjfixture_r xjanchor_r sjfixture_r sjreceiver_fastener_r".split()
0057 
0058         rr = list(map(lambda k:rt.d[k], kk))
0059         for i in range(len(kk)):
0060             ax.plot( xlim, [rr[i],rr[i]], label=kk[i] ) 
0061         pass
0062         ax.legend()
0063         fig.show()
0064         outpath = os.path.expandvars("/tmp/$USER/opticks/CSG/tests/CSGTargetGlobalTest/${MOI}_radii.png")
0065         outdir = os.path.dirname(outpath)
0066         if not os.path.isdir(outdir):
0067             os.makedirs(outdir)
0068         pass
0069         print("save to %s " % outpath)
0070         fig.savefig(outpath)
0071     pass
0072   
0073