Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2026-04-09 07:49:19

0001 #!/usr/bin/env python
0002 """
0003 tests/sphoton_test.py
0004 ======================
0005 
0006 ~/o/sysrap/tests/sphoton_test.sh
0007 
0008 
0009 """
0010 
0011 import numpy as np, os, sys
0012 from opticks.ana.fold import Fold
0013 from opticks.sysrap.sphoton import SPhoton
0014 
0015 import matplotlib.pyplot as plt
0016 SIZE = np.array([1280,720])
0017 
0018 
0019 
0020 def test_dot_pol_cross_mom_nrm(a):
0021     title = "test_dot_pol_cross_mom_nrm"
0022     fig, ax = plt.subplots(1, figsize=SIZE/100.)
0023     fig.suptitle(title)
0024 
0025     ax.scatter(  a[:,0], a[:,1], label="a[:,0] [:,1]  fr, pot " )
0026     ax.scatter(  a[:,0], a[:,2], label="a[:,0] a[:,2] fr, pot/mct " )
0027     ax.scatter(  a[:,0], a[:,3], label="a[:,0] a[:,3] fr, pot/st " )
0028 
0029     ax.plot( [0,1], [-1,-1],  label="-1" )
0030     ax.plot( [0,1], [+1,+1],  label="+1" )
0031 
0032     ax.legend()
0033     fig.show()
0034 
0035 
0036 def test_make_record_array(a):
0037     title = "test_make_record_array"
0038 
0039     fig, ax = plt.subplots(1, figsize=SIZE/100.)
0040     fig.suptitle(title)
0041     ax.set_aspect(1)
0042 
0043     X,Y,Z = 0,1,2
0044     H,V = X,Z
0045 
0046     for j in range(10):
0047         ax.scatter( a[:,j,0,H], a[:,j,0,V], label=str(j) )
0048     pass
0049     ax.legend()
0050     fig.show()
0051 
0052 
0053 def test_demoarray(a):
0054     print("[test_demoarray repr(a): ", repr(a))
0055     print("]test_demoarray")
0056 
0057 
0058 if __name__ == '__main__':
0059     t = Fold.Load(symbol="t")
0060     print(repr(t))
0061 
0062     TEST = os.environ.get("TEST", "demoarray")
0063     a = getattr(t,TEST, None)
0064     if a is None: sys.exit(0)
0065 
0066     if TEST == "dot_pol_cross_mom_nrm":
0067          test_dot_pol_cross_mom_nrm(a)
0068     elif TEST == "record":
0069         test_make_record_array(a)
0070     elif TEST == "demoarray":
0071         #test_demoarray(a)
0072         p = SPhoton.view(a)
0073     else:
0074         print("TEST:%s unhandled " % TEST)
0075     pass
0076 pass
0077 
0078