Back to home page

EIC code displayed by LXR

 
 

    


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

0001 #!/usr/bin/env python 
0002 """
0003 
0004 ~/o/qudarap/tests/QSimTest.sh ana
0005 ~/o/qudarap/tests/QSimTest.sh pdb
0006 
0007 
0008 """
0009 import os, numpy as np, logging
0010 
0011 np.set_printoptions(suppress=True, linewidth=200)
0012 MODE = int(os.environ.get("MODE", "0"))
0013 log = logging.getLogger(__name__)
0014 
0015 try:
0016     import matplotlib.pyplot as plt
0017 except ImportError:
0018     plt = None
0019 
0020 import os
0021 
0022 class QSimTest(object):
0023     def __init__(self):
0024         pass
0025 
0026     def rng_sequence(self):
0027         fold = os.path.expandvars("$FOLD/rng_sequence_f_ni1000000_nj16_nk16_tranche100000")
0028         symbols = "abcdefghijklmnopqrstuvwxyz"
0029         names = sorted(os.listdir(fold))
0030         arrs = []
0031         for i, name in enumerate(names):
0032             sym = symbols[i]
0033             path = os.path.join(fold, name)
0034             arr = np.load(path)
0035             arrs.append(arr)
0036             msg = "%3s %20s %s" % (sym, str(arr.shape), path) 
0037             logging.info(msg)
0038             globals()[sym] = arr 
0039         pass
0040         seq = np.concatenate(arrs) 
0041         globals()["seq"] = seq
0042     pass
0043     def multifilm_lut(self):
0044         fold = os.path.expandvars("$FOLD/multifilm_lut_result.npy")
0045         interp_result = np.load(fold)
0046         sample = np.load("$FOLD/sample.npy")
0047         #bnd_range = sample.shape[1]
0048         bnd_range = 2 
0049         for bnd in range(bnd_range):
0050             sub_interp = interp_result[interp_result[:,1] == bnd ] 
0051             sub_sample = sample[sample[:,1] == bnd ]
0052             diff = sub_interp - sub_sample
0053             fig, axs = plt.subplots(2,2)
0054             axs[0,0].scatter(sub_sample[:,4],diff[:,4],s=0.5, label="R_s")
0055             axs[0,1].scatter(sub_sample[:,5],diff[:,5],s=0.5, label="T_s")
0056             axs[1,0].scatter(sub_sample[:,6],diff[:,6],s=0.5, label="R_p")
0057             axs[1,1].scatter(sub_sample[:,7],diff[:,7],s=0.5, label="T_p")
0058             for i in range(2):
0059                 for j in range(2):
0060                     axs[i,j].set_xlabel("sample value")
0061                     axs[i,j].set_ylabel("interp - sample")
0062                     axs[i,j].legend()
0063             plt.suptitle("boundary Type = {}".format(bnd),fontsize = 30 )
0064             plt.show()        
0065            
0066 
0067 if __name__ == '__main__':
0068     logging.basicConfig(level=logging.INFO)
0069     t = QSimTest()
0070 
0071     TEST = os.environ.get("TEST","")
0072     print("TEST:%s" % TEST );   
0073 
0074     if TEST == "rng_sequence":
0075         t.rng_sequence() 
0076     elif TEST == "multifilm_lut":
0077         t.multifilm_lut()
0078     else:
0079         print("TEST UNHANDLED:%s" % TEST );   
0080     pass
0081 pass