def _convert_to_q(self, state, workspace, wavelength_adjustment_workspace, pixel_adjustment_workspace,
                      wavelength_and_pixel_adjustment_workspace):
        """
        A conversion to momentum transfer is performed in this step.

        The conversion can be either to the modulus of Q in which case the output is a 1D workspace, or it can
        be a 2D reduction where the y axis is Qy, ie it is a numeric axis.
        @param state: a SANSState object
        @param workspace: the workspace to convert to momentum transfer.
        @param wavelength_adjustment_workspace: the wavelength adjustment workspace.
        @param pixel_adjustment_workspace: the pixel adjustment workspace.
        @param wavelength_and_pixel_adjustment_workspace: the wavelength and pixel adjustment workspace.
        @return: a reduced workspace
        """
        output_dict = convert_workspace(workspace=workspace, state_convert_to_q=state.convert_to_q,
                                        wavelength_adj_workspace=wavelength_adjustment_workspace,
                                        pixel_adj_workspace=pixel_adjustment_workspace,
                                        wavelength_and_pixel_adj_workspace=wavelength_and_pixel_adjustment_workspace,
                                        output_summed_parts=True)

        output_workspace = output_dict["output"]
        sum_of_counts = output_dict["counts_summed"]
        sum_of_norms = output_dict["norm_summed"]

        return output_workspace, sum_of_counts, sum_of_norms
Пример #2
0
    def test_that_converts_wavelength_workspace_to_q_for_2d(self):
        workspace = self._get_workspace(is_adjustment=False)
        adj_workspace = self._get_workspace(is_adjustment=True)

        state = self._get_sample_state(q_xy_max=2., q_xy_step=0.5, q_xy_step_type=RangeStepType.LIN,
                                       dim=ReductionDimensionality.TWO_DIM)

        output_dict = convert_workspace(workspace=workspace, output_summed_parts=True,
                                        state_convert_to_q=state.convert_to_q, wavelength_adj_workspace=adj_workspace)

        output_workspace = output_dict["output"]
        sum_of_counts = output_dict["counts_summed"]
        sum_of_norms = output_dict["norm_summed"]

        # We expect a q-based workspace with 8 histograms and 8 bins
        self.assertEqual(output_workspace.getNumberHistograms(), 8)
        self.assertEqual(len(output_workspace.dataX(0)), 9)
        self.assertEqual(output_workspace.getAxis(0).getUnit().unitID(), "MomentumTransfer")
        self.assertEqual(output_workspace.getAxis(1).getUnit().unitID(), "MomentumTransfer")
        self.assertFalse(output_workspace.hasDx(0))
        self.assertTrue(output_workspace.getAxis(0).isNumeric())
        self.assertTrue(output_workspace.getAxis(1).isNumeric())
        self.assertEqual(sum_of_counts.getAxis(0).getUnit().unitID(), "MomentumTransfer")
        self.assertEqual(sum_of_norms.getAxis(0).getUnit().unitID(), "MomentumTransfer")

        DeleteWorkspace(workspace)
        DeleteWorkspace(adj_workspace)
        DeleteWorkspace(output_workspace)
        DeleteWorkspace(sum_of_counts)
        DeleteWorkspace(sum_of_norms)
Пример #3
0
    def test_that_converts_wavelength_workspace_to_q_for_1d_and_no_q_resolution(self):
        # Arrange
        workspace = self._get_workspace(is_adjustment=False)
        adj_workspace = self._get_workspace(is_adjustment=True)

        state = self._get_sample_state(q_min=1., q_max=2., q_step=0.1, q_step_type=RangeStepType.LIN)

        # Act
        output_dict = convert_workspace(workspace=workspace, output_summed_parts=True,
                                        state_convert_to_q=state.convert_to_q, wavelength_adj_workspace=adj_workspace)

        output_workspace = output_dict["output"]
        sum_of_counts = output_dict["counts_summed"]
        sum_of_norms = output_dict["norm_summed"]

        # Assert
        # We expect a q-based workspace with one histogram and 10 bins.
        self.assertEqual(output_workspace.getNumberHistograms(), 1)
        self.assertEqual(len(output_workspace.dataX(0)), 11)
        self.assertEqual(output_workspace.getAxis(0).getUnit().unitID(), "MomentumTransfer")
        self.assertFalse(output_workspace.hasDx(0))
        self.assertTrue(output_workspace.getAxis(0).isNumeric())
        self.assertTrue(output_workspace.getAxis(1).isSpectra())
        self.assertEqual(sum_of_counts.getAxis(0).getUnit().unitID(), "MomentumTransfer")
        self.assertEqual(sum_of_norms.getAxis(0).getUnit().unitID(), "MomentumTransfer")

        DeleteWorkspace(workspace)
        DeleteWorkspace(adj_workspace)
        DeleteWorkspace(output_workspace)
        DeleteWorkspace(sum_of_counts)
        DeleteWorkspace(sum_of_norms)
Пример #4
0
    def _convert_to_q(
        self, state, workspaces: WsList,
        adjustment_dict: Dict[WavRange, AdjustmentStruct]
    ) -> Dict[WavRange, SumsStruct]:
        """
        A conversion to momentum transfer is performed in this step.

        The conversion can be either to the modulus of Q in which case the output is a 1D workspace, or it can
        be a 2D reduction where the y axis is Qy, ie it is a numeric axis.
        @param state: a SANSState object
        @param workspace: the workspace to convert to momentum transfer.
        @param wavelength_adjustment_workspace: the wavelength adjustment workspace.
        @param pixel_adjustment_workspace: the pixel adjustment workspace.
        @param wavelength_and_pixel_adjustment_workspace: the wavelength and pixel adjustment workspace.
        @return: a reduced workspace
        """
        sums = {}
        for wav_range in workspaces.keys():
            adjustment = adjustment_dict[wav_range]

            output_dict = \
                convert_workspace(workspace=workspaces[wav_range], state_convert_to_q=state.convert_to_q,
                                  wavelength_adj_workspace=adjustment.wavelength_adjustment,
                                  wavelength_and_pixel_adj_workspace=adjustment.wavelength_and_pixel_adjustment,
                                  pixel_adj_workspace=adjustment.pixel_adjustment, output_summed_parts=True)

            sums[wav_range] = SumsStruct(counts=output_dict["counts_summed"],
                                         norm=output_dict["norm_summed"])
            workspaces[wav_range] = output_dict["output"]
        return sums