Example #1
0
def _createDiagnosticsReportTable(reportWSName, numberHistograms, algorithmLogging):
    """Return a table workspace for detector diagnostics reporting."""
    if mtd.doesExist(reportWSName):
        reportWS = mtd[reportWSName]
    else:
        reportWS = CreateEmptyTableWorkspace(OutputWorkspace=reportWSName,
                                             EnableLogging=algorithmLogging)
    existingColumnNames = reportWS.getColumnNames()
    if 'WorkspaceIndex' not in existingColumnNames:
        reportWS.addColumn('int', 'WorkspaceIndex', _PLOT_TYPE_X)
    reportWS.setRowCount(numberHistograms)
    for i in range(numberHistograms):
        reportWS.setCell('WorkspaceIndex', i, i)
    return reportWS
Example #2
0
def _createDiagnosticsReportTable(reportWSName, numberHistograms, algorithmLogging):
    """Return a table workspace for detector diagnostics reporting."""
    if mtd.doesExist(reportWSName):
        reportWS = mtd[reportWSName]
    else:
        reportWS = CreateEmptyTableWorkspace(OutputWorkspace=reportWSName,
                                             EnableLogging=algorithmLogging)
    existingColumnNames = reportWS.getColumnNames()
    if 'WorkspaceIndex' not in existingColumnNames:
        reportWS.addColumn('int', 'WorkspaceIndex', _PLOT_TYPE_X)
    reportWS.setRowCount(numberHistograms)
    for i in range(numberHistograms):
        reportWS.setCell('WorkspaceIndex', i, i)
    return reportWS
    def test_parse_fit_table_correctly_formats_the_table(self):
        peaks = [(35.2, 0.4), (25.03, 0.1), (10.03, 0.05)]
        peaks += [(20.003, 0.004), (75.15, 0.2), (5.2, 0.05)]
        fit_table = self.simulate_fit_parameter_output(peaks, 100.034)
        data_table = CreateEmptyTableWorkspace()

        to_refit = self.alg_instance.parse_fit_table(fit_table,
                                                     data_table,
                                                     refit=False)

        self.assertEqual(to_refit, [])
        self.assertEqual(data_table.getColumnNames(), self.peak_table_header)
        np.testing.assert_almost_equal(data_table.column(0), [25.03, 75.15], 5)
        np.testing.assert_almost_equal(data_table.column(1), [0.1, 0.2], 5)
        np.testing.assert_almost_equal(data_table.column(2), [35.2, 20.003], 5)
        np.testing.assert_almost_equal(data_table.column(3), [0.4, 0.004], 5)
        np.testing.assert_almost_equal(data_table.column(4), [10.03, 5.2], 5)
        np.testing.assert_almost_equal(data_table.column(5), [0.05, 0.05], 5)
    def test_parse_fit_table_marks_peaks_for_refitting_if_error_larger_than_value(
            self):
        peaks = [(35.2, 0.4), (25.03, 0.1), (10.03, 0.05)]
        peaks += [(20.003, 40.22), (75.15, 0.2), (5.2, np.NaN)]
        fit_table = self.simulate_fit_parameter_output(peaks, 100.034)
        data_table = CreateEmptyTableWorkspace()

        to_refit = self.alg_instance.parse_fit_table(fit_table,
                                                     data_table,
                                                     refit=True)

        self.assertEqual(data_table.getColumnNames(), self.peak_table_header)
        np.testing.assert_almost_equal(data_table.column(0), [25.03], 5)
        np.testing.assert_almost_equal(data_table.column(1), [0.1], 5)
        np.testing.assert_almost_equal(data_table.column(2), [35.2], 5)
        np.testing.assert_almost_equal(data_table.column(3), [0.4], 5)
        np.testing.assert_almost_equal(data_table.column(4), [10.03], 5)
        np.testing.assert_almost_equal(data_table.column(5), [0.05], 5)
        np.testing.assert_almost_equal(to_refit, [(75.15, 20.003, 5.2)], 5)