예제 #1
0
def create_difc_zero_workspace(difc, tzero, crop_on, name):
    """
    create a workspace that can be used to plot the expected peaks against the fitted ones

    @param difc :: the list of difc values to add to the table
    @param tzero :: the list of tzero values to add to the table
    @param crop_on :: where the cropping occured, either a bank, a spectra, or empty
    @param name :: the name of a cropped workspace to use, if it is a non default name

    """
    plot_spec_num = False
    # check what banks to use
    banks = [1]
    correction = 0
    if crop_on == "":
        banks = [1, 2]
    elif crop_on.lower() == "south":
        correction = 1
    elif not crop_on == "":
        plot_spec_num = True

    # loop through used banks
    for i in banks:
        actual_i = correction + i
        # retrieve required workspace
        if not plot_spec_num:
            bank_ws = simple.AnalysisDataService.retrieve("engg_calibration_bank_{}".format(actual_i))
        else:
            bank_ws = simple.AnalysisDataService.retrieve(name)

        # get the data to be used
        x_val = []
        y_val = []
        y2_val = []
        for irow in range(0, bank_ws.rowCount()):
            x_val.append(bank_ws.cell(irow, 0))
            y_val.append(bank_ws.cell(irow, 5))
            y2_val.append(x_val[irow] * difc[i - 1] + tzero[i - 1])

        # create workspaces to temporary hold the data
        simple.CreateWorkspace(OutputWorkspace="ws1", DataX=x_val, DataY=y_val,
                               UnitX="Expected Peaks Centre(dSpacing, A)",
                               YUnitLabel="Fitted Peaks Centre(TOF, us)")
        simple.CreateWorkspace(OutputWorkspace="ws2", DataX=x_val, DataY=y2_val)

        # get correct name for output
        if not plot_spec_num:
            name = actual_i
        output_name = "Engg difc Zero Peaks Bank {}".format(name)

        # use the two workspaces to creat the output
        output = simple.AppendSpectra(InputWorkspace1="ws1", InputWorkspace2="ws2",
                                      OutputWorkspace=output_name)
        plot_calibration(output, output_name)

    # remove the left-over workspaces
    simple.DeleteWorkspace("ws1")
    simple.DeleteWorkspace("ws2")
예제 #2
0
파일: EnginX.py 프로젝트: gemmaguest/mantid
def handle_van_curves(van_curves, van_path):
    if len(van_curves) == 2:
        curves_ws = simple.AppendSpectra(InputWorkspace1=van_curves[0], InputWorkspace2=van_curves[1])
        simple.DeleteWorkspace(van_curves[1])
    else:
        curves_ws = van_curves[0]
    simple.SaveNexus(curves_ws, van_path)
    simple.DeleteWorkspace(van_curves[0])
    simple.DeleteWorkspace(curves_ws)
예제 #3
0
def calculate_mantid_resolutions(ws_name, mass):
    max_Y = np.ceil(2.5*mass+27)
    rebin_parameters = str(-max_Y)+","+str(2.*max_Y/240)+","+str(max_Y) # twice the binning as for the data
    ws= sapi.mtd[ws_name]
    for index in range(ws.getNumberHistograms()):
        sapi.VesuvioResolution(Workspace=ws,WorkspaceIndex=index,Mass=mass,OutputWorkspaceYSpace="tmp")
        tmp=sapi.Rebin("tmp",rebin_parameters)
        if index == 0:
            sapi.RenameWorkspace(tmp,"resolution")
        else:
            sapi.AppendSpectra("resolution", tmp, OutputWorkspace= "resolution")
    sapi.SumSpectra(InputWorkspace="resolution",OutputWorkspace="resolution")
    normalise_workspace("resolution")
    safe_delete_ws(tmp)