Change name of command line parameter to extractNeutronPulses
This commit is contained in:
@@ -25,9 +25,9 @@ class ExtractWalltime(EventDataAction):
|
||||
dataset.data.events = new_events
|
||||
|
||||
class MergeFrames(EventDataAction):
|
||||
def __init__(self, lamdaCut=None, preciseTime=False):
|
||||
def __init__(self, lamdaCut=None, extractNeutronPulses=False):
|
||||
self.lamdaCut=lamdaCut
|
||||
self.preciseTime=preciseTime
|
||||
self.extractNeutronPulses=extractNeutronPulses
|
||||
|
||||
def perform_action(self, dataset: EventDatasetProtocol)->None:
|
||||
if self.lamdaCut is None:
|
||||
@@ -37,7 +37,7 @@ class MergeFrames(EventDataAction):
|
||||
tofCut = lamdaCut*dataset.geometry.chopperDetectorDistance/const.hdm*1e-13
|
||||
total_offset = (tofCut +
|
||||
dataset.timing.tau * (dataset.timing.ch1TriggerPhase + dataset.timing.chopperPhase/2)/180)
|
||||
if self.preciseTime and 'wallTime' in dataset.data.events.dtype.names:
|
||||
if self.extractNeutronPulses and 'wallTime' in dataset.data.events.dtype.names:
|
||||
d = dataset.data
|
||||
# put events into precise sub-frame
|
||||
d.events.tof, subframes = merge_frames_w_index(d.events.tof, tofCut, dataset.timing.tau, total_offset)
|
||||
@@ -61,8 +61,8 @@ class MergeFrames(EventDataAction):
|
||||
new_pulses.monitor /= 2.0 # ~preserve total monitor counts
|
||||
d.pulses = new_pulses
|
||||
else:
|
||||
if self.preciseTime:
|
||||
logging.error(" Trying to use precise time frame separation while wallTime is not extracted, yet!")
|
||||
if self.extractNeutronPulses:
|
||||
logging.error(" Trying to separate neutron pulses while wallTime is not extracted, yet!")
|
||||
dataset.data.events.tof = merge_frames(dataset.data.events.tof, tofCut, dataset.timing.tau, total_offset)
|
||||
|
||||
|
||||
|
||||
@@ -480,10 +480,10 @@ class ReflectivityReductionConfig(ArgParsable):
|
||||
},
|
||||
)
|
||||
|
||||
preciseTiming: bool = field(
|
||||
extractNeutronPulses: bool = field(
|
||||
default=False,
|
||||
metadata={
|
||||
'short': 'pt',
|
||||
'short': 'np',
|
||||
'group': 'data manicure',
|
||||
'help': 're-assign events to actual neutron pulses => '
|
||||
'2xbetter filter resolution but extra computation (experimental)',
|
||||
|
||||
@@ -65,7 +65,7 @@ class ReflectivityReduction:
|
||||
# the filtering only makes sense if using actual monitor data, not time
|
||||
self.dataevent_actions |= eh.FilterMonitorThreshold(self.config.experiment.lowCurrentThreshold)
|
||||
self.dataevent_actions |= eh.FilterStrangeTimes()
|
||||
self.dataevent_actions |= ea.MergeFrames(preciseTime=self.config.reduction.preciseTiming)
|
||||
self.dataevent_actions |= ea.MergeFrames(extractNeutronPulses=self.config.reduction.extractNeutronPulses)
|
||||
self.dataevent_actions |= ea.AnalyzePixelIDs(self.config.experiment.yRange)
|
||||
self.dataevent_actions |= eh.TofTimeCorrection(self.config.experiment.incidentAngle==IncidentAngle.alphaF)
|
||||
self.dataevent_actions |= ea.CalculateWavelength(self.config.experiment.lambdaRange)
|
||||
|
||||
@@ -420,14 +420,14 @@ class TestSimpleActions(TestCase):
|
||||
dtype=np.int32))
|
||||
|
||||
def test_merge_frames(self):
|
||||
action = MergeFrames(lamdaCut=0.0, preciseTime=False)
|
||||
action = MergeFrames(lamdaCut=0.0, extractNeutronPulses=False)
|
||||
action.perform_action(self.d)
|
||||
self.assertEqual(self.d.data.events.tof.shape, self.d.orig_data.events.tof.shape)
|
||||
np.testing.assert_array_compare(lambda x,y: x<=y, self.d.data.events.tof, self.d.orig_data.events.tof)
|
||||
self.assertTrue((-self.d.timing.tau<=self.d.data.events.tof).all())
|
||||
np.testing.assert_array_less(self.d.data.events.tof, self.d.timing.tau)
|
||||
|
||||
action = MergeFrames(lamdaCut=2.0, preciseTime=False)
|
||||
action = MergeFrames(lamdaCut=2.0, extractNeutronPulses=False)
|
||||
self.d.data.events.tof = self.d.orig_data.events.tof[:]
|
||||
action.perform_action(self.d)
|
||||
tofCut = 2.0*self.d.geometry.chopperDetectorDistance/const.hdm*1e-13
|
||||
@@ -435,7 +435,7 @@ class TestSimpleActions(TestCase):
|
||||
self.assertTrue((self.d.data.events.tof<=tofCut+self.d.timing.tau).all())
|
||||
|
||||
def test_merge_frames_splitting(self):
|
||||
action = MergeFrames(lamdaCut=0.0, preciseTime=True)
|
||||
action = MergeFrames(lamdaCut=0.0, extractNeutronPulses=True)
|
||||
self._extract_walltime()
|
||||
action.perform_action(self.d)
|
||||
self.assertEqual(self.d.data.events.tof.shape, self.d.orig_data.events.tof.shape)
|
||||
|
||||
Reference in New Issue
Block a user