File indexing completed on 2026-04-09 07:49:07
0001
0002 """
0003 reflect_diffuse_cf.py
0004 ===================================
0005
0006 Hmm direction is flipped ?::
0007
0008 In [1]: a[0]
0009 Out[1]:
0010 array([[ 1. , 0. , 0. , 1. ],
0011 [ 0.244, -0.067, 0.967, 1. ],
0012 [ 0.067, -0.994, -0.086, 500. ],
0013 [ 0. , 1. , 0. , 500. ]], dtype=float32)
0014
0015 In [2]: b[0]
0016 Out[2]:
0017 array([[ 1. , 0. , 0. , 0.157],
0018 [ -0.244, 0.067, -0.967, 0. ],
0019 [ -0.067, -0.996, -0.052, 500. ],
0020 [ 0. , 1. , 0. , 0. ]], dtype=float32)
0021
0022
0023 After the flip, done with orient float in qsim, get match at 3-in-a-million level::
0024
0025 In [3]: np.where( np.abs( a[:,1,:3] - b[:,1,:3] ) > 2e-5 ) # mom
0026 Out[3]: (array([780419, 780419, 800478, 947557]), array([0, 1, 1, 0]))
0027
0028 In [4]: np.where( np.abs( a[:,2,:3] - b[:,2,:3] ) > 2e-5 ) # pol
0029 Out[4]: (array([780419, 780419, 800478, 800478]), array([0, 2, 0, 2]))
0030
0031
0032 """
0033 import os, numpy as np
0034
0035 def eprint( expr, lprefix="", rprefix="", tail="" ):
0036 ret = eval(expr)
0037 lhs = "%s%s" % (lprefix, expr)
0038 rhs = "%s%s" % (rprefix, ret )
0039 print("%-50s : %s%s" % ( lhs, rhs, tail ) )
0040 return ret
0041
0042 def epr(arg, **kwa):
0043 p = arg.find("=")
0044 if p > -1:
0045 var_eq = arg[:p+1]
0046 expr = arg[p+1:]
0047 label = var_eq
0048 else:
0049 label, expr = "", arg
0050 pass
0051 return eprint(expr, lprefix=label, **kwa)
0052
0053
0054 a_key = "A_FOLD"
0055 b_key = "B_FOLD"
0056
0057 A_FOLD = os.environ[a_key]
0058 B_FOLD = os.environ[b_key]
0059 NPY_NAME = os.environ["NPY_NAME"]
0060
0061
0062 if __name__ == '__main__':
0063 print("a_key : %20s A_FOLD : %s" % ( a_key, A_FOLD) )
0064 print("b_key : %20s B_FOLD : %s" % ( b_key, B_FOLD) )
0065 a_path = os.path.join(A_FOLD, NPY_NAME)
0066 b_path = os.path.join(B_FOLD, NPY_NAME)
0067
0068 a = np.load(a_path)
0069 b = np.load(b_path)
0070 print("a.shape %10s : %s " % (str(a.shape), a_path) )
0071 print("b.shape %10s : %s " % (str(b.shape), b_path) )
0072
0073