Ejemplo n.º 1
0
def _plot_impl(axes, workspace, args, kwargs):
    """
    Compute data and labels for plot. Used by workspace
    replacement handlers to recompute data. See plot for
    argument details
    """
    if 'LogName' in kwargs:
        (x, y, FullTime, LogName, units,
         kwargs) = get_sample_log(workspace, **kwargs)
        axes.set_ylabel('{0} ({1})'.format(LogName, units))
        axes.set_xlabel('Time (s)')
        if FullTime:
            axes.xaxis_date()
            axes.xaxis.set_major_formatter(
                mdates.DateFormatter('%H:%M:%S\n%b-%d'))
            axes.set_xlabel('Time')
        kwargs['drawstyle'] = 'steps-post'
    else:
        normalize_by_bin_width, kwargs = get_normalize_by_bin_width(
            workspace, axes, **kwargs)
        x, y, _, _, indices, axis, kwargs = _get_data_for_plot(
            axes, workspace, kwargs)
        if kwargs.pop('update_axes_labels', True):
            _setLabels1D(axes,
                         workspace,
                         indices,
                         normalize_by_bin_width=normalize_by_bin_width,
                         axis=axis)
    kwargs.pop('normalize_by_bin_width', None)
    return x, y, args, kwargs
Ejemplo n.º 2
0
 def test_get_sample_logs_with_relative_time_and_no_start_time(self):
     x, y, FullTime, LogName, units, kwargs = funcs.get_sample_log(
         self.ws2d_histo, LogName='my_log', FullTime=False)
     self.assertEqual(x[0], 0)
     self.assertEqual(x[1], 30 * 60)
     self.assertEqual(x[2], 50 * 60)
     np.testing.assert_allclose(y, np.array([100, 15, 100.2]))
     self.assertFalse(FullTime)
     self.assertEqual(LogName, 'my_log')
     self.assertEqual(units, '')
     self.assertEqual(kwargs, {})
Ejemplo n.º 3
0
 def test_get_sample_logs_with_full_time(self):
     x, y, FullTime, LogName, units, kwargs = funcs.get_sample_log(
         self.ws2d_histo, LogName='my_log', FullTime=True)
     self.assertEqual(x[0], datetime.datetime(2010, 1, 1, 0, 0, 0))
     self.assertEqual(x[1], datetime.datetime(2010, 1, 1, 0, 30, 0))
     self.assertEqual(x[2], datetime.datetime(2010, 1, 1, 0, 50, 0))
     np.testing.assert_allclose(y, np.array([100, 15, 100.2]))
     self.assertTrue(FullTime)
     self.assertEqual(LogName, 'my_log')
     self.assertEqual(units, '')
     self.assertEqual(kwargs, {})
Ejemplo n.º 4
0
 def test_get_sample_logs_with_relative_time_and_start_time_later_than_first_log(
         self):
     start_time = "2010-01-01T00:00:19"
     AddSampleLog(self.ws2d_histo, LogName='run_start', LogText=start_time)
     x, y, FullTime, LogName, units, kwargs = funcs.get_sample_log(
         self.ws2d_histo, LogName='my_log', FullTime=False)
     self.assertEqual(x[0], -19)
     self.assertEqual(x[1], 1781)
     self.assertEqual(x[2], 2981)
     np.testing.assert_allclose(y, np.array([100, 15, 100.2]))
     self.assertFalse(FullTime)
     self.assertEqual(LogName, 'my_log')
     self.assertEqual(units, '')
     self.assertEqual(kwargs, {})