Exemple #1
0
    def test_that_time_difference_adds_correct_optional_shift(self):
         # Arrange
        names =['ws1', 'ws2']
        out_ws_name = 'out_ws'

        start_time_1 = "2010-01-01T00:00:00"
        event_ws_1 = provide_event_ws(names[0],start_time_1, extra_time_shift = 0.0)

        # Extra shift in seconds
        optional_time_shift = 1000
        start_time_2 = "2012-01-01T00:00:00"
        event_ws_2 = provide_event_ws(names[1],start_time_2, extra_time_shift = optional_time_shift)

        # Act
        overlayWorkspaces = su.OverlayWorkspaces()
        time_difference = overlayWorkspaces._extract_time_difference_in_seconds(event_ws_1, event_ws_2)

        # Assert
        expected_time_difference = time_duration.total_nanoseconds(DateAndTime(start_time_1)- DateAndTime(start_time_2))/1e9
        expected_time_difference -= optional_time_shift # Need to subtract as we add the time shift to the subtrahend
        self.assertEqual(time_difference, expected_time_difference)

        # Clean up 
        self._clean_up(names)
        self._clean_up(out_ws_name)
Exemple #2
0
    def _compare_time_series(self, prop_out, prop_in1, prop_in2, time1, time2, extra_time_shift, isOverlay):
        times_out = prop_out.times
        times1 = prop_in1.times
        times2 = prop_in2.times

        # Total time differnce is TIME1 - (TIME2 + extraShift)
        shift = 0.0
        if isOverlay:
            shift = time_duration.total_nanoseconds(DateAndTime(time1)- DateAndTime(time2))/1e9 - extra_time_shift

        # Check ws1 against output
        # We shift the second workspace onto the first workspace
        shift_ws1 = 0
        self._assert_times(times1, times_out, shift_ws1)
        # Check ws2 against output
        self._assert_times(times2, times_out, shift)
        # Check overlapping times
        self._compare_overlapping_times(prop_in1, prop_out, times1, times2, times_out, shift)
Exemple #3
0
    def test_time_from_proton_charge_log_is_recovered(self):
        # Arrange
        names =['ws1', 'ws2']
        out_ws_name = 'out_ws'

        start_time_1 = "2010-01-01T00:00:00"
        event_ws_1 = provide_event_ws(names[0],start_time_1, extra_time_shift = 0.0)

        start_time_2 = "2012-01-01T00:00:00"
        event_ws_2 = provide_event_ws(names[1],start_time_2, extra_time_shift = 0.0)

        # Act
        overlayWorkspaces = su.OverlayWorkspaces()
        time_difference = overlayWorkspaces._extract_time_difference_in_seconds(event_ws_1, event_ws_2)

        # Assert
        expected_time_difference = time_duration.total_nanoseconds(DateAndTime(start_time_1)- DateAndTime(start_time_2))/1e9
        self.assertEqual(time_difference, expected_time_difference)

        # Clean up 
        self._clean_up(names)
        self._clean_up(out_ws_name)
Exemple #4
0
    def _extract_time_difference_in_seconds(self, ws1, ws2):
        # The times which need to be compared are the first entry in the proton charge log
        time_1 = self._get_time_from_proton_charge_log(ws1)
        time_2 = self._get_time_from_proton_charge_log(ws2)

        return time_duration.total_nanoseconds(time_1- time_2)/1e9