Beispiel #1
0
def _get_data_for_plot(axes, workspace, kwargs, with_dy=False, with_dx=False):
    if isinstance(workspace, mantid.dataobjects.MDHistoWorkspace):
        (normalization, kwargs) = get_normalization(workspace, **kwargs)
        indices, kwargs = get_indices(workspace, **kwargs)
        (x, y, dy) = get_md_data1d(workspace, normalization, indices)
        dx = None
        axis = None
    else:
        axis = MantidAxType(kwargs.pop("axis", MantidAxType.SPECTRUM))
        normalize_by_bin_width, kwargs = get_normalize_by_bin_width(
            workspace, axes, **kwargs)
        workspace_index, distribution, kwargs = get_wksp_index_dist_and_label(
            workspace, axis, **kwargs)
        if axis == MantidAxType.BIN:
            # Overwrite any user specified xlabel
            axes.set_xlabel("Spectrum")
            x, y, dy, dx = get_bins(workspace, workspace_index, with_dy)
        elif axis == MantidAxType.SPECTRUM:
            x, y, dy, dx = get_spectrum(workspace, workspace_index,
                                        normalize_by_bin_width, with_dy,
                                        with_dx)
        else:
            raise ValueError(
                "Axis {} is not a valid axis number.".format(axis))
        indices = None
    return x, y, dy, dx, indices, axis, kwargs
Beispiel #2
0
    def test_get_bins_with_a_ragged_workspace(self):
        x, y, dy, dx = funcs.get_bins(self.ws2d_point_uneven, 3, withDy=True)

        self.assertTrue(np.array_equal([1], x))
        self.assertTrue(np.array_equal([4.0], y))
        self.assertTrue(np.array_equal([0.0], dy))
Beispiel #3
0
 def test_get_bins_with_dy(self, ws):
     x, y, dy, dx = funcs.get_bins(ws, 1, withDy=True)
     self.assertTrue(np.array_equal([0, 1, 2, 3], x))
     self.assertTrue(np.array_equal([2.0, 5.0, 8.0, 11.0], y))
     self.assertTrue(np.array_equal([2.0, 5.0, 8.0, 11.0], dy))