Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2026-04-10 07:50:28

0001 #!/usr/bin/env python 
0002 """
0003 U4RecorderTest_ab.py
0004 ======================
0005 
0006 Usage::
0007 
0008    cd ~/opticks/u4/tests   # u4t
0009    ./U4RecorderTest_ab.sh  
0010 
0011 """
0012 import numpy as np
0013 
0014 from opticks.ana.fold import Fold
0015 from opticks.ana.p import * 
0016 from opticks.ana.eprint import eprint, epr
0017 
0018 from opticks.sysrap.xfold import XFold
0019 from opticks.sysrap.stag import stag  
0020 from opticks.u4.U4Stack import U4Stack
0021 
0022 np.set_printoptions(edgeitems=16) 
0023 
0024 tag = stag()
0025 stack = U4Stack()
0026 
0027 
0028 if __name__ == '__main__':
0029 
0030     quiet = True 
0031     a = Fold.Load("$A_FOLD", symbol="a", quiet=quiet) if "A_FOLD" in os.environ else None
0032     b = Fold.Load("$B_FOLD", symbol="b", quiet=quiet) if "B_FOLD" in os.environ else None
0033 
0034     print("-------- after Fold.Load" )
0035 
0036     A = XFold(a, symbol="A") if not a is None else None
0037     B = XFold(b, symbol="B") if not b is None else None
0038 
0039     print("-------- after XFold" )
0040 
0041 
0042     ab = (not a is None) and (not b is None)
0043     if ab: 
0044         im = epr("im = np.abs(a.inphoton - b.inphoton).max()", globals(), locals() )  
0045         pm = epr("pm = np.abs(a.photon - b.photon).max()",     globals(), locals() )  
0046         rm = epr("rm = np.abs(a.record - b.record).max()",     globals(), locals() )  
0047         sm = epr("sm = np.all( a.seq[:,0] == b.seq[:,0] )",    globals(), locals() )  
0048 
0049         eprint("np.all( A.ts == B.ts2 )", globals(), locals() )
0050         eprint("np.all( A.ts2 == B.ts )", globals(), locals() )
0051 
0052         assert (a.inphoton - b.inphoton).max() < 1e-5 
0053         #assert np.all( A.ts == B.ts2 ) 
0054         #assert np.all( A.ts2 == B.ts )  
0055     pass
0056 
0057     print("./U4RecorderTest_ab.sh ## u4t ")
0058     w = epr("w = np.unique(np.where( np.abs(a.photon - b.photon) > 0.1 )[0])", globals(), locals() )
0059     s = epr("s = a.seq[w,0]", globals(), locals() )  
0060     o = epr("o = cuss(s,w)", globals(), locals() , rprefix="\n")
0061 
0062     #epr("w1", globals(), locals() )
0063     #abw0 = epr("abw0 = a.photon[w0,:4] - b.photon[w0,:4]", globals(), locals(), rprefix="\n" ) 
0064 
0065     epr("a.base", globals(), locals() )
0066     epr("b.base", globals(), locals() )
0067 
0068 
0069 
0070 
0071