def load_GBndLib(cls, base): t = np_load(base, "GBndLib/GBndLib.npy") o = np_load(base, "GBndLib/GBndLibOptical.npy") if t is None or o is None: log.warning("missing GBndLib data : cannot create blib Proplib") blib = None else: blib = cls("GBndLib", data=t, names=os.path.join(base, "GItemList/GBndLib.txt"), optical=o) pass return blib
def init_random(self, num): rnd, paths = np_load(self.random_path) if len(paths) == 0: log.fatal( "failed to find any precooked randoms, create them with : TEST=F QSimTest" ) assert 0 pass if num is None: num = len(rnd) else: enough = num <= len(rnd) if not enough: log.fatal("not enough precooked randoms len(rnd) %d num %d " % (len(rnd), num)) pass assert enough pass cursors = np.zeros(num, dtype=np.int32) self.cursors = cursors self.rnd_paths = paths self.rnd = rnd self.num = num
def np_load(self, reldir): dirpath = os.path.join(self.FOLD, reldir) a, paths = np_load(dirpath) print("QCtxTest.np_load dirpath %s loaded %d paths " % (dirpath, len(paths))) print("\n".join(paths)) return a
def load_u(self): """ This array of randoms is used by below check_utaildebug. Default u array is (100k,16,16) containing doubles. To generate an extra large array (1M,16,16):: TRngBuf_NI=1000000 TRngBufTest Which creates a 2GB file:: In [6]: 16*16*1000000*8/1e9 Out[6]: 2.048 [blyth@localhost sysrap]$ ls -l "$TMP/TRngBufTest_0_1000000.npy" -rw-rw-r--. 1 blyth blyth 2048000096 Jul 28 12:02 /home/blyth/local/opticks/tmp/TRngBufTest_0_1000000.npy """ log.debug("[") upath0 = "$TMP/TRngBufTest_0.npy" upath1 = "$TMP/TRngBufTest_0_1000000.npy" if os.path.exists(os.path.expandvars(upath1)): upath = upath1 log.debug("using the extra large random array %s " % upath) else: upath = upath0 pass u, u_paths = np_load(upath) log.info("\n".join(u_paths)) u = None if u is None else u.astype(np.float32) self.u = u log.debug("]")
ipython -i $(which GScintillatorLib.py) """ from opticks.ana.nload import np_load import matplotlib.pyplot as plt if __name__ == '__main__': #f = np_load("$IDPATH/GScintillatorLib/LiquidScintillator/FASTCOMPONENT.npy") #print f #plt.plot( f[:,0], f[:,1] ) #plt.show() aa = np_load("$IDPATH/GScintillatorLib/GScintillatorLib.npy") assert aa.shape == (2, 4096, 1) assert np.all(aa[0] == aa[1]) a = aa[0, :, 0] assert a.shape == (4096, ) b = np.linspace(0, 1, len(a)) fig = plt.figure() plt.title( "Inverted Cumulative Distribution Function : for Scintillator Reemission " )
ipython -i tests/reemissionTest.py """ import os, sys, logging, numpy as np import matplotlib.pyplot as plt from opticks.ana.nload import np_load from opticks.ana.key import keydir log = logging.getLogger(__name__) if __name__ == '__main__': ok = os.environ["OPTICKS_KEY"] kd = keydir(ok) aa = np_load(os.path.join(kd, "GScintillatorLib/GScintillatorLib.npy")) fc = np_load(os.path.join(kd, "GScintillatorLib/LS/FASTCOMPONENT.npy")) sc = np_load(os.path.join(kd, "GScintillatorLib/LS/SLOWCOMPONENT.npy")) print("aa:%s" % str(aa.shape)) print("fc:%s" % str(fc.shape)) print("sc:%s" % str(sc.shape)) assert aa.shape == (1, 4096, 1) assert np.all(fc == sc) path = os.path.expandvars("$TMP/optixrap/reemissionTest/out.npy") w = np.load(path) plt.ion() wd = np.linspace(60, 820, 256) - 1.