Esempio n. 1
0
def run(eventfile, tofbinsize, nxsfile, type, instrument):
    print(eventfile, nxsfile)
    from mccomponents.detector.event_utils import readEvents
    events = readEvents(eventfile)

    prefix = 'mcvine.instruments.%s.nxs' % instrument.upper()
    mod = '%s.%s' % (prefix, type)
    mod = __import__(mod, fromlist=[''])
    mod.write(events, tofbinsize, nxsfile)
    return
Esempio n. 2
0
def run(eventfile, nxsfile, tofbinsize, type):
    print (eventfile, nxsfile)
    from mccomponents.detector.event_utils import readEvents
    events = readEvents(eventfile)
    
    prefix = 'mcvine.instruments.SEQUOIA.nxs'
    mod = '%s.%s' % (prefix, type)
    mod = __import__(mod, fromlist = [''])
    mod.write(events, tofbinsize, nxsfile)
    return
Esempio n. 3
0
 def test2(self):
     "ARCS detector system. A neutron missing all pixels."
     # cmd = './sd --source.velocity=1000,0,-2000 --ncount=1 --output-dir=out2'
     cmd = './sd --source.position=-0.00875,0.00462,0.005  --source.velocity=5713.19,-765.203,9068.39 --ncount=1 --output-dir=out2'
     import os
     if os.system(cmd):
         raise RuntimeError, "%s failed" % cmd
     eventdata = 'out2/events.dat'
     from mccomponents.detector.event_utils import readEvents
     events = readEvents(eventdata)
     print events
     # self.assertEqual(len(events), 0)
     return
 def test2(self):
     "ARCS detector system. A neutron missing all pixels."
     # cmd = './sd --source.velocity=1000,0,-2000 --ncount=1 --output-dir=out2'        
     cmd = './sd --source.position=-0.00875,0.00462,0.005  --source.velocity=5713.19,-765.203,9068.39 --ncount=1 --output-dir=out2'
     import os
     if os.system(cmd):
         raise RuntimeError, "%s failed" % cmd
     eventdata = 'out2/events.dat'
     from mccomponents.detector.event_utils import readEvents
     events = readEvents(eventdata)
     print events
     # self.assertEqual(len(events), 0)
     return
Esempio n. 5
0
def run(eventfile, nxsfile, tofbinsize=0.1, type="processed", Ei = None):
    """tofbinsize: in microsecond
    type: processed or raw. processed is obsolete but kept for backward compatibility
    Ei: nominal incident energy in meV    
    """
    print (eventfile, nxsfile)
    from mccomponents.detector.event_utils import readEvents
    events = readEvents(eventfile)
    
    prefix = 'mcvine.instruments.ARCS.nxs'
    mod = '%s.%s' % (prefix, type)
    mod = __import__(mod, fromlist = [''])
    mod.write(events, tofbinsize, nxsfile, Ei=Ei)
    return
Esempio n. 6
0
def run(eventfile, nxsfile, tofbinsize=0.1, type="processed", Ei = None):
    """tofbinsize: in microsecond
    type: processed or raw. processed is obsolete but kept for backward compatibility
    Ei: nominal incident energy in meV    
    """
    print((eventfile, nxsfile))
    from mccomponents.detector.event_utils import readEvents
    events = readEvents(eventfile)
    
    prefix = 'mcvine.instruments.ARCS.nxs'
    mod = '%s.%s' % (prefix, type)
    mod = __import__(mod, fromlist = [''])
    mod.write(events, tofbinsize, nxsfile, Ei=Ei)
    return
Esempio n. 7
0
 def test1a(self):
     "ARCS detector system. Neutrons shotting at one single pixel."
     cmd = './sd --mpirun.nodes=2  --output-dir=out1a'
     import os
     if os.system(cmd):
         raise RuntimeError, "%s failed" % cmd
     eventdata = 'out1a/events.dat'
     from mccomponents.detector.event_utils import readEvents
     events = readEvents(eventdata)
     # print events
     # print events['p'].sum()
     p = events['p'].sum()
     print p
     self.assert_(p > 0.9 and p < 1)
     return
 def test1a(self):
     "ARCS detector system. Neutrons shotting at one single pixel."
     cmd = './sd --mpirun.nodes=2  --output-dir=out1a'
     import os
     if os.system(cmd):
         raise RuntimeError, "%s failed" % cmd
     eventdata = 'out1a/events.dat'
     from mccomponents.detector.event_utils import readEvents
     events = readEvents(eventdata)
     # print events
     # print events['p'].sum()
     p = events['p'].sum()
     print p
     self.assert_(p>0.9 and p<1)
     return
Esempio n. 9
0
def run(eventfile, nxsfile, tofbinsize=0.1, type=None, Ei=None):
    """tofbinsize: in microsecond
    """
    assert type == 'processed', "Unsupported type %r" % type
    print((eventfile, nxsfile))
    # read events
    from mccomponents.detector.event_utils import readEvents
    events = readEvents(eventfile)
    # write nxs
    write(events, tofbinsize, nxsfile)
    #
    if Ei:
        from .nxs import setEnergyRequest
        setEnergyRequest(nxsfile, Ei)
    return
    def test(self):
        "ARCS detector system. Neutrons shotting at one single pixel."
        cmd = "MCVINE_MPI_LAUNCHER=serial ./sd"
        import os

        if os.system(cmd):
            raise RuntimeError, "%s failed" % cmd
        eventdata = "out/events.dat"
        from mccomponents.detector.event_utils import readEvents

        events = readEvents(eventdata)
        # print events
        # print events['p'].sum()
        p = events["p"].sum()
        print p
        self.assert_(p > 0.9 and p < 1)
        return
Esempio n. 11
0
def getNumberOfEvts(filename, pixelID):
    from mccomponents.detector import event_utils
    evts = event_utils.readEvents(filename)
    _ = lambda evt: evt['pixelID'] == pixelID
    return len(list(filter(_, evts)))
Esempio n. 12
0
def getNumberOfEvts(filename, pixelID):
    from mccomponents.detector import event_utils 
    evts = event_utils.readEvents(filename)
    _ = lambda evt: evt['pixelID'] == pixelID
    return len(filter(_, evts))
Esempio n. 13
0
#!/usr/bin/env python

from mccomponents.detector import event_utils as evu
f = 'out/events.dat'
print
print "* reading events from %s" % f 
events = evu.readEvents(f)
print
print "* # of events", len(events)
print
print "* events (pixelID, tofID, weight):"
print events
Esempio n. 14
0
#!/usr/bin/env python

from mccomponents.detector import event_utils as evu
f = 'out/events.dat'
print()
print(("* reading events from %s" % f))
events = evu.readEvents(f)
print()
print(("* # of events", len(events)))
print()
print("* events (pixelID, tofID, weight):")
print(events)