def __init__(self, ok): blib = PropLib("GBndLib") names = blib.names t = np.load(os.path.expandvars("$IDPATH/GBndLib/GBndLib.npy")) c = load(ok) assert len(t) == len(names) assert len(t) == len(c) n = len(t) self.shape = t.shape self.names = names self.t = t self.c = c self.n = n self.consistency_check("t", t)
class Material(object): def __init__(self, name): self.name = name self.mlib = PropLib("GMaterialLib") def lookup(self, prop, wavelength): return self.mlib.interp(self.name, wavelength, prop) def data(self): return self.mlib(self.name) def refractive_index(self, wavelength): return self.lookup(PropLib.M_REFRACTIVE_INDEX, wavelength) def absorption_length(self, wavelength): return self.lookup(PropLib.M_ABSORPTION_LENGTH, wavelength) def scattering_length(self, wavelength): return self.lookup(PropLib.M_SCATTERING_LENGTH, wavelength) def reemission_prob(self, wavelength): return self.lookup(PropLib.M_REEMISSION_PROB, wavelength)
import os,sys, numpy as np, logging from opticks.ana.proplib import PropLib from opticks.ana.nload import np_load log = logging.getLogger(__name__) np.set_printoptions(precision=3, suppress=True) if __name__ == '__main__': from opticks.ana.main import opticks_main args = opticks_main() base = "$TMP/interpolationTest" blib = PropLib.load_GBndLib(base) if blib is None: log.warning("failed to load blib GPropLib from base:%s " % base ) sys.exit(0) pass names = blib.names t = blib.data # boundary texture data ext, nl = "interpol", 820-60+1 #oname = "OInterpolationTest_%s.npy" % ext oname = "interpolationTest_%s.npy" % ext
elif type(arg) is slice: return map(lambda name: self(name), self.names[arg]) else: assert 0, (type(arg), "unexpected type") pass return self.check_bnd(name) def check_bnd(self, name): omat, osur, isur, imat = name.split("/") if __name__ == '__main__': ok = opticks_main() blib = PropLib("GBndLib") names = blib.names n = len(names) nam = np.zeros((n, 4), dtype="|S64") for i, name in enumerate(names): nam[i] = name.split("/") cf = CFProp(ok) if 0: for i in range(n): name = names[i] g4_omat = np.all(t[i, blib.B_OMAT, 0] == c[i, blib.B_OMAT, 0])
:: ipython -i $(which material.py) -- --mat Water ipython -i $(which material.py) -- --mat GdDopedLS """ import os, logging, numpy as np log = logging.getLogger(__name__) from opticks.ana.main import opticks_main from opticks.ana.proplib import PropLib mlib = PropLib("GMaterialLib") class Material(object): def __init__(self, name): self.name = name self.mlib = mlib def lookup(self, prop, wavelength): return self.mlib.interp(self.name, wavelength, prop) def data(self): return self.mlib(self.name) def refractive_index(self, wavelength): return self.lookup(PropLib.M_REFRACTIVE_INDEX, wavelength)
#!/usr/bin/env python """ surface.py : optical properties access ================================================== """ import os, logging, numpy as np log = logging.getLogger(__name__) from opticks.ana.main import opticks_main from opticks.ana.proplib import PropLib slib = PropLib("GSurfaceLib") class Surface(object): def __init__(self, name): self.name = name self.slib = slib def lookup(self, prop, wavelength): return self.slib.interp(self.name, wavelength, prop) def data(self): return self.slib(self.name) def detect(self, wavelength): return self.lookup(PropLib.S_DETECT, wavelength) def absorb(self, wavelength): return self.lookup(PropLib.S_ABSORB, wavelength)
""" import os, logging, numpy as np from collections import OrderedDict as odict log = logging.getLogger(__name__) from opticks.ana.base import opticks_main from opticks.ana.proplib import PropLib, Bnd idp_ = lambda _: os.path.expandvars("$IDPATH/%s" % _) if __name__ == '__main__': ok = opticks_main() # from old geocache without groupvel setup m0 = PropLib("GMaterialLib") s0 = PropLib("GSurfaceLib") b0 = PropLib("GBndLib") # persisted postcache modified bnd buffer including groupvel calc, identity wavelengths 20nm steps b1 = PropLib("GBndLib", data="$TMP/InterpolationTest/CInterpolationTest_identity.npy") b2 = PropLib("GBndLib", data="$TMP/InterpolationTest/OInterpolationTest_identity.npy") assert np.allclose(b1.data, b2.data) # after unset alignment # persisted postcache groupvel calc, interpol wavelengths 1nm steps i1 = PropLib("GBndLib", data="$TMP/InterpolationTest/CInterpolationTest_interpol.npy") i2 = PropLib("GBndLib", data="$TMP/InterpolationTest/OInterpolationTest_interpol.npy")
def __init__(self, name): self.name = name self.mlib = PropLib("GMaterialLib")