コード例 #1
0
ファイル: presenter.py プロジェクト: ethoeng/mantid
    def action_copy_bin_to_table(self, table):
        selected_cols = [i.column() for i in table.selectionModel().selectedColumns()]
        if not selected_cols:
            self.notify_no_selection_to_copy()
            return
        ws = table.model().ws
        table_ws = CreateEmptyTableWorkspace(OutputWorkspace=ws.name() + "_bins")
        num_rows = ws.getNumberHistograms()
        table_ws.setRowCount(num_rows)
        table_ws.addColumn("double", "X")
        for i, col in enumerate(selected_cols):
            table_ws.addColumn("double", "YB" + str(col))
            table_ws.addColumn("double", "YE" + str(col))

            col_y = 2 * i + 1
            col_e = 2 * i + 2

            for j in range(num_rows):
                data_y = ws.readY(j)
                data_e = ws.readE(j)

                if i == 0:
                    if ws.axes() > 1:
                        table_ws.setCell(j, 0, ws.getAxis(1).getValue(j))
                    else:
                        table_ws.setCell(j, 0, j)
                table_ws.setCell(j, col_y, data_y[col])
                table_ws.setCell(j, col_e, data_e[col])
コード例 #2
0
ファイル: presenter.py プロジェクト: ethoeng/mantid
    def action_copy_spectrum_to_table(self, table):
        selected_rows = [i.row() for i in table.selectionModel().selectedRows()]
        if not selected_rows:
            self.notify_no_selection_to_copy()
            return
        ws = table.model().ws
        table_ws = CreateEmptyTableWorkspace(OutputWorkspace=ws.name() + "_spectra")
        num_rows = ws.blocksize()
        table_ws.setRowCount(num_rows)
        for i, row in enumerate(selected_rows):
            table_ws.addColumn("double", "XS" + str(row))
            table_ws.addColumn("double", "YS" + str(row))
            table_ws.addColumn("double", "ES" + str(row))

            col_x = 3 * i
            col_y = 3 * i + 1
            col_e = 3 * i + 2

            data_y = ws.readY(row)
            data_x = ws.readX(row)
            data_e = ws.readE(row)

            for j in range(num_rows):
                table_ws.setCell(j, col_x, data_x[j])
                table_ws.setCell(j, col_y, data_y[j])
                table_ws.setCell(j, col_e, data_e[j])
コード例 #3
0
def _create_empty_table_workspace(name: str, num_rows: int) -> ITableWorkspace:
    """Create and empty table with the given number of rows

    :param name: The name of the workspace in the ADS
    :param num_rows: Number of rows for the new table
    :return: A new tableworkspace
    """
    # keep import here to avoid framework initialization in tests
    from mantid.simpleapi import CreateEmptyTableWorkspace
    table = CreateEmptyTableWorkspace(OutputWorkspace=name)
    table.setRowCount(num_rows)
    return table
コード例 #4
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
コード例 #5
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