File indexing completed on 2026-04-09 07:49:06
0001
0002 """
0003 QPropTest.py
0004 ===============
0005
0006 ::
0007
0008 ./QPropTest.sh ana
0009
0010 """
0011 import logging
0012 log = logging.getLogger(__name__)
0013 import matplotlib.pyplot as plt
0014 import os, numpy as np
0015 from opticks.ana.fold import Fold
0016
0017
0018 class QPropTest(object):
0019 def __init__(self, f ):
0020 reldir = os.path.basename(f.base)
0021 types = {"float":np.float32, "double":np.float64 }
0022
0023 assert reldir in types
0024 dtype = f.prop.dtype
0025 assert types[reldir] == dtype
0026
0027 utype = np.uint32 if dtype == np.float32 else np.uint64
0028
0029 self.f = f
0030 self.dtype = dtype
0031 self.utype = utype
0032 self.reldir = reldir
0033 self.title = "qudarap/tests/QPropTest.py %s " % f.base
0034
0035 def plot(self):
0036 f = self.f
0037 fig, ax = plt.subplots(figsize=[12.8,7.2])
0038 fig.suptitle(self.title)
0039 for i in range(len(f.prop)):
0040 lp = f.prop.view(self.utype)[i,-1,-1]
0041 ax.scatter( f.prop[i,:lp,0], f.prop[i,:lp,1], label="src-%d-lp-%d" % (i,lp) )
0042 ax.plot( f.domain, f.lookup[i], label="dst-%d" % i )
0043 pass
0044 ax.legend()
0045 fig.show()
0046 path = os.path.join(f.base, "fig.png")
0047 log.info("save to %s " % path)
0048 fig.savefig(path)
0049
0050
0051 if __name__ == '__main__':
0052 logging.basicConfig(level=logging.INFO)
0053
0054 f = Fold.Load("$FOLD/float", symbol="f")
0055 t = QPropTest(f)
0056 t.plot()
0057
0058
0059