Back to home page

EIC code displayed by LXR

 
 

    


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

0001 #!/usr/bin/env python
0002 """
0003 propagate_at_boundary_cf.py : random aligned comparison of boundary process
0004 ========================================================================================
0005 
0006 Used via scripts which sets envvars::
0007 
0008    ./G4OpBoundaryProcessTest.sh cf 
0009 
0010 """
0011 
0012 import os, numpy as np
0013 #from opticks.ana.eprint import eprint
0014 
0015 def eprint( expr, lprefix="", rprefix="", tail="" ):
0016     ret = eval(expr)
0017     lhs = "%s%s" % (lprefix, expr)
0018     rhs = "%s%s" % (rprefix, ret )
0019     print("%-50s : %s%s" % ( lhs, rhs, tail )   )   
0020     return ret 
0021 
0022 def epr(arg, **kwa):
0023     p = arg.find("=")  
0024     if p > -1: 
0025         var_eq = arg[:p+1]
0026         expr = arg[p+1:]
0027         label = var_eq
0028     else:
0029         label, expr = "", arg 
0030     pass
0031     return eprint(expr, lprefix=label,  **kwa)
0032 
0033 
0034 a_key = "A_FOLD"
0035 b_key = "B_FOLD"
0036 
0037 A_FOLD = os.environ[a_key] 
0038 B_FOLD = os.environ[b_key] 
0039 
0040 
0041 if __name__ == '__main__':
0042      print("a_key : %20s  A_FOLD : %s" % ( a_key, A_FOLD) )
0043      print("b_key : %20s  B_FOLD : %s" % ( b_key, B_FOLD) )
0044 
0045      a_path = os.path.join(A_FOLD, "p.npy")
0046      b_path = os.path.join(B_FOLD, "p.npy")
0047 
0048      aprd_path = os.path.join(A_FOLD, "prd.npy")
0049      bprd_path = os.path.join(B_FOLD, "prd.npy")
0050 
0051      a = np.load(a_path)
0052      b = np.load(b_path)
0053      print("a.shape %10s : %s  " % (str(a.shape), a_path) )
0054      print("b.shape %10s : %s  " % (str(b.shape), b_path) )
0055 
0056      aprd = np.load(aprd_path) if os.path.exists(aprd_path) else None
0057      bprd = np.load(bprd_path) if os.path.exists(bprd_path) else None
0058      if not aprd is None:
0059          print("aprd.shape %10s : %s  " % (str(aprd.shape), aprd_path) )
0060          eprint("aprd", lprefix="\n", rprefix="\n" )
0061      pass
0062 
0063      if not bprd is None:
0064          print("bprd.shape %10s : %s  " % (str(bprd.shape), bprd_path) )
0065          eprint("bprd", lprefix="\n", rprefix="\n" )
0066      pass
0067 
0068 
0069      a_flag  = epr("a_flag=a[:,3,3].view(np.uint32)")  
0070      b_flag  = epr("b_flag=b[:,3,3].view(np.uint32)")  
0071      w_flag  = epr("w_flag=np.where( a_flag != b_flag )")
0072      ua_flag = epr("ua_flag=np.unique(a_flag, return_counts=True)")
0073      ub_flag = epr("ub_flag=np.unique(b_flag, return_counts=True)")
0074 
0075      a_TransCoeff = epr("a_TransCoeff=a[:,1,3]")
0076      b_TransCoeff = epr("b_TransCoeff=b[:,1,3]")
0077      w_TransCoeff = epr("w_TransCoeff=np.where( np.abs( a_TransCoeff - b_TransCoeff) > 1e-6 )")
0078 
0079      a_flat = epr("a_flat=a[:,0,3]") 
0080      b_flat = epr("b_flat=b[:,0,3]") 
0081      w_flat = epr("w_flat=np.where(a_flat != b_flat)")
0082 
0083      expr_ = "w_ab%(i)s=np.where( np.abs(a[:,%(i)s,:3] - b[:,%(i)s,:3]) > 1e-6 )" 
0084      w_ab0 = epr(expr_ % dict(i=0) )
0085      w_ab1 = epr(expr_ % dict(i=1) )
0086      w_ab2 = epr(expr_ % dict(i=2) )
0087      w_ab3 = epr(expr_ % dict(i=3) )
0088 
0089 
0090 
0091 
0092