コード例 #1
0
# limitations under the License.
#


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
コード例 #2
0
ファイル: tboolean.py プロジェクト: hanswenzel/opticks
when using the option  "--anakey tboolean".  See optickscore/OpticksAna.cc.
It compares Opticks and G4 event history categories and deviations.


"""
from __future__ import print_function
import os, sys, logging, numpy as np
log = logging.getLogger(__name__)

from opticks.ana.main import opticks_main
from opticks.ana.nload import np_load
from opticks.ana.ab import AB
from opticks.ana.seq import seq2msk

if __name__ == '__main__':
    ok = opticks_main(doc=__doc__)

    log.info(ok.brief)

    ab = AB(ok)
    ab.dump()

    rc = ab.RC

    level = "fatal" if rc > 0 else "info"
    getattr(log, level)(" RC 0x%.2x %s " % (rc, bin(rc)))

    if not ok.ipython:
        log.info("early exit as non-interactive")
        sys.exit(rc)
    else:
コード例 #3
0
        pass

        for stem in self.stems:
            ap = A.path_(stem, ok.src, atag_c, ok.det, ok.pfx)
            bp = A.path_(stem, ok.src, btag_c, ok.det, ok.pfx)

            aa_ = tuple(self.aa[stem])
            if len(aa_) > 0:
                ac = np.concatenate(aa_)
                log.info("save %s " % ap)
                np.save(ap, ac)
                globals()["a_" + stem] = ac
            pass

            bb_ = tuple(self.bb[stem])
            if len(bb_) > 0:
                bc = np.concatenate(bb_)
                log.info("save %s " % bp)
                np.save(bp, bc)
                globals()["b_" + stem] = bc
            pass
        pass


if __name__ == '__main__':
    from opticks.ana.main import opticks_main
    ok = opticks_main()
    ec = EvtConcatenate(ok)
    ec.load_all(7)  # load tags 1 to 7
    ec.save_concat(100)  # save into new tag 100
コード例 #4
0
    poly = pv.PolyData()
    poly.points = points
    cells = np.full((len(points) - 1, 3), 2, dtype=np.int_)
    cells[:, 1] = np.arange(0, len(points) - 1, dtype=np.int_)
    cells[:, 2] = np.arange(1, len(points), dtype=np.int_)
    poly.lines = cells
    return poly


if __name__ == '__main__':
    from opticks.ana.main import opticks_main

    #pfx = "tds3ip"
    pfx = "tds3gun"

    ok = opticks_main(pfx=pfx, src="natural")
    ab = AB(ok)
    a = ab.a  # dx only filled for G4:b
    b = ab.b

    #a_sel = "TO SC BT SR BT SA"     # 0x8cac6d
    #b_sel = "TO SC BT SR BT BT SA"  # 0x8ccac6d

    #sel = "TO SC BT BT AB"   # scatters that get back into the LS from the Water

    sel = "SI BT BT BT BT SD"

    n = len(sel.split())

    a.sel = sel
    b.sel = sel
コード例 #5
0
ファイル: material.py プロジェクト: simoncblyth/opticks
    @classmethod
    def Hdr(cls):
        labels = "wavelen rindex abslen scatlen reemprob groupvel"
        hdr = "   " + "".join(list(map(lambda _: "%12s" % _, labels.split())))
        return hdr

    def hdr(self):
        return self.Hdr() + " " + self.name


if __name__ == '__main__':

    logging.basicConfig(level=logging.INFO)
    dmat = "Water"
    args = opticks_main(mat=dmat)
    log.info("mat %s " % args.mat)

    wl = np.linspace(300., 600., 4)
    for name in list(map(lambda _: _.decode("utf-8"), mlib._names)):
        mat = Material(name)
        tab = mat.table(wl)
        print(mat.hdr())
        print(tab)
    pass

if 0:
    import matplotlib.pyplot as plt
    plt.ion()
    plt.plot(wl, al, "*", label="Absorption Length")
    plt.plot(wl, sl, "+", label="Scattering Length")
コード例 #6
0
ファイル: evtplt.py プロジェクト: simoncblyth/opticks
::

   run evtplt.py --tag -1  


TODO: for G4 only (-ve itag) could use the deluxe buffer dx.npy for double precision step points 


"""
import numpy as np
from opticks.ana.evt import Evt
import pyvista as pv

if __name__ == '__main__':
    from opticks.ana.main import opticks_main
    ok = opticks_main(pfx="tds3ip", src="natural")

    itag = int(ok.utag)

    a = Evt(tag="%d"%itag, src=ok.src, det=ok.det, pfx=ok.pfx, args=ok)
    if hasattr(a, 'seqhis_ana'):
        expr="a.seqhis_ana.table[0:20]"
        print(expr)
        print(eval(expr))
    pass 

    if itag < 0:
        a.sel = "TO BT BT BT BT SD"  # 0x7ccccd 
        #        -6 -5 -4 -3 -2 -1
        #         Y  M  C  B  G  R
    elif itag > 0:
コード例 #7
0
                                            un 4                     in 1         cy 0     !cy 0                
                            un 3                     in 1         cy 0     !cy 0                                
            un 2                     in 1         cy 0     !cy 0                                                
    in 1             in 1         cy 0     !cy 0                                                                
cy 0     !cy 0     cy 0     !cy 0                                                                                
delta:analytic blyth$ 



"""

import logging
log = logging.getLogger(__name__)
from opticks.ana.main import opticks_main
from opticks.analytic.csg import CSG
args = opticks_main(csgpath="$TMP/analytic/deep_py")

CSG.boundary = args.testobject
CSG.kwa = dict(verbosity="1")

a = CSG("cylinder",
        param=[0.000, 0.000, 0.000, 660.000],
        param1=[-5.000, 5.000, 0.000, 0.000])
b = CSG("cylinder",
        param=[0.000, 0.000, 0.000, 31.500],
        param1=[-5.050, 5.050, 0.000, 0.000],
        complement=True)
ab = CSG("intersection", left=a, right=b)

c = CSG("cylinder",
        param=[0.000, 0.000, 0.000, 46.500],
コード例 #8
0
        dd.xmlpath = path
        dd.init()
        return dd

    def init(self):
        cat = self.find1_("./catalog")
        if cat is not None:
            print(cat)
            cat.xmldir = self.xmldir
            for ref in cat.refs():
                print("%s %s " % (ref, ref.ddpath))
                self.g.ddr[ref.ddpath] = DD.parse(ref.xmlpath)

    def __repr__(self):
        return "%20s %s %s " % (self.typ, self.xmlpath, self.xmldir)


if __name__ == '__main__':
    args = opticks_main(apmtidx=2)

    xmlpath = args.apmtddpath
    log.info("parsing %s -> %s " % (xmlpath, os.path.expandvars(xmlpath)))

    g = Dddb.parse(xmlpath)

    lv = g.logvol_("lvPmtHemi")

    dd = DD.parse(args.addpath)

    print(dd)