Пример #1
0
def _read_ws(number, instrument):
    cycle_information = instrument._get_cycle_information(run_number=number)
    input_dir = instrument._generate_raw_data_cycle_dir(
        cycle_information["cycle"])
    read_in_ws = _load_raw_files(run_number=number,
                                 instrument=instrument,
                                 input_dir=input_dir)
    # TODO move this into instrument specific
    read_ws = mantid.ConvertUnits(InputWorkspace=read_in_ws,
                                  Target="Wavelength")
    remove_intermediate_workspace(read_in_ws)

    _read_pearl_monitor = instrument._get_monitor(run_number=number,
                                                  input_dir=input_dir,
                                                  spline_terms=20)

    read_ws = mantid.NormaliseToMonitor(InputWorkspace=read_ws,
                                        MonitorWorkspace=_read_pearl_monitor,
                                        IntegrationRangeMin=0.6,
                                        IntegrationRangeMax=5.0)
    output_name = "read_ws_output-" + str(g_ads_workaround["read_pearl_ws"])
    g_ads_workaround["read_pearl_ws"] += 1
    output_ws = mantid.ConvertUnits(InputWorkspace=read_ws,
                                    OutputWorkspace=output_name,
                                    Target="TOF")

    remove_intermediate_workspace(_read_pearl_monitor)
    remove_intermediate_workspace(read_ws)
    return output_ws
Пример #2
0
def normalise_ws_current(ws_to_correct, monitor_ws, spline_coeff, lambda_values, integration_range, ex_regions):
    processed_monitor_ws = mantid.ConvertUnits(InputWorkspace=monitor_ws, Target="Wavelength")
    processed_monitor_ws = mantid.CropWorkspace(InputWorkspace=processed_monitor_ws,
                                                XMin=lambda_values[0], XMax=lambda_values[-1])

    for reg in range(0, 4):
        processed_monitor_ws = mantid.MaskBins(InputWorkspace=processed_monitor_ws, XMin=ex_regions[0, reg],
                                               XMax=ex_regions[1, reg])

    splined_monitor_ws = mantid.SplineBackground(InputWorkspace=processed_monitor_ws,
                                                 WorkspaceIndex=0, NCoeff=spline_coeff)

    normalised_ws = mantid.ConvertUnits(InputWorkspace=ws_to_correct, Target="Wavelength",
                                        OutputWorkspace=ws_to_correct)
    normalised_ws = mantid.NormaliseToMonitor(InputWorkspace=normalised_ws, MonitorWorkspace=splined_monitor_ws,
                                              IntegrationRangeMin=integration_range[0],
                                              IntegrationRangeMax=integration_range[-1],
                                              OutputWorkspace=normalised_ws)

    normalised_ws = mantid.ConvertUnits(InputWorkspace=normalised_ws, Target="TOF", OutputWorkspace=normalised_ws)

    common.remove_intermediate_workspace(processed_monitor_ws)
    common.remove_intermediate_workspace(splined_monitor_ws)

    return normalised_ws
Пример #3
0
def normalise_ws_current(ws_to_correct, monitor_ws, spline_coeff,
                         lambda_values, integration_range):
    processed_monitor_ws = mantid.ConvertUnits(InputWorkspace=monitor_ws,
                                               Target="Wavelength")
    processed_monitor_ws = mantid.CropWorkspace(
        InputWorkspace=processed_monitor_ws,
        XMin=lambda_values[0],
        XMax=lambda_values[-1])
    # TODO move these masks to the adv. config file
    ex_regions = numpy.zeros((2, 4))
    ex_regions[:, 0] = [3.45, 3.7]
    ex_regions[:, 1] = [2.96, 3.2]
    ex_regions[:, 2] = [2.1, 2.26]
    ex_regions[:, 3] = [1.73, 1.98]

    for reg in range(0, 4):
        processed_monitor_ws = mantid.MaskBins(
            InputWorkspace=processed_monitor_ws,
            XMin=ex_regions[0, reg],
            XMax=ex_regions[1, reg])

    splined_monitor_ws = mantid.SplineBackground(
        InputWorkspace=processed_monitor_ws,
        WorkspaceIndex=0,
        NCoeff=spline_coeff)

    normalised_ws = mantid.ConvertUnits(InputWorkspace=ws_to_correct,
                                        Target="Wavelength",
                                        OutputWorkspace=ws_to_correct)
    normalised_ws = mantid.NormaliseToMonitor(
        InputWorkspace=normalised_ws,
        MonitorWorkspace=splined_monitor_ws,
        IntegrationRangeMin=integration_range[0],
        IntegrationRangeMax=integration_range[-1],
        OutputWorkspace=normalised_ws)

    normalised_ws = mantid.ConvertUnits(InputWorkspace=normalised_ws,
                                        Target="TOF",
                                        OutputWorkspace=normalised_ws)

    common.remove_intermediate_workspace(processed_monitor_ws)
    common.remove_intermediate_workspace(splined_monitor_ws)

    return normalised_ws
Пример #4
0
 def read(self, number, panel, extension):
     if type(number) is int:
         filename = self.datafile
         logger.notice("will be reading filename...{}".format(filename))
         spectra_min, spectra_max = self.return_panel_van.get(panel) if self.is_vanadium else \
             self.return_panel.get(panel)
         if panel != 0:
             output = "w{0}-{1}".format(number, panel)
         else:
             output = "w{}".format(number)
         shared_load_files(extension, filename, output, spectra_max,
                           spectra_min, False)
         if extension == "nxs_event":
             simple.LoadEventNexus(Filename=filename,
                                   OutputWorkspace=output,
                                   LoadMonitors='1')
             self.read_event_nexus(number, output, panel)
         if extension[:10] == "nxs_event_":
             label, tmin, tmax = split_string_event(extension)
             output = output + "_" + label
             if tmax == "end":
                 simple.LoadEventNexus(Filename=filename,
                                       OutputWorkspace=output,
                                       FilterByTimeStart=tmin,
                                       LoadMonitors='1',
                                       MonitorsAsEvents='1',
                                       FilterMonByTimeStart=tmin)
             else:
                 simple.LoadEventNexus(Filename=filename,
                                       OutputWorkspace=output,
                                       FilterByTimeStart=tmin,
                                       FilterByTimeStop=tmax,
                                       LoadMonitors='1',
                                       MonitorsAsEvents='1',
                                       FilterMonByTimeStart=tmin,
                                       FilterMonByTimeStop=tmax)
             self.read_event_nexus(number, output, panel)
     else:
         num_1, num_2 = split_run_string(number)
         output = "w{0}_{1}-{2}".format(num_1, num_2, panel)
         output1 = self.load_multi_run_part(extension, num_1, panel)
         output2 = self.load_multi_run_part(extension, num_2, panel)
         simple.MergeRuns(output1 + "," + output2, output)
         simple.DeleteWorkspace(output1)
         simple.DeleteWorkspace(output2)
     simple.ConvertUnits(InputWorkspace=output,
                         OutputWorkspace=output,
                         Target="Wavelength",
                         Emode="Elastic")
     lmin, lmax = Wish.LAMBDA_RANGE
     simple.CropWorkspace(InputWorkspace=output,
                          OutputWorkspace=output,
                          XMin=lmin,
                          XMax=lmax)
     monitor_run = "monitor{}".format(number)
     if monitor_run not in simple.mtd:
         monitor = self.process_incidentmon(number,
                                            extension,
                                            spline_terms=70)
     else:
         monitor = simple.mtd[monitor_run]
     simple.NormaliseToMonitor(InputWorkspace=output,
                               OutputWorkspace=output + "norm1",
                               MonitorWorkspace=monitor)
     simple.NormaliseToMonitor(InputWorkspace=output + "norm1",
                               OutputWorkspace=output + "norm2",
                               MonitorWorkspace=monitor,
                               IntegrationRangeMin=0.7,
                               IntegrationRangeMax=10.35)
     simple.DeleteWorkspace(output)
     simple.DeleteWorkspace(output + "norm1")
     simple.RenameWorkspace(InputWorkspace=output + "norm2",
                            OutputWorkspace=output)
     simple.ConvertUnits(InputWorkspace=output,
                         OutputWorkspace=output,
                         Target="TOF",
                         EMode="Elastic")
     simple.ReplaceSpecialValues(InputWorkspace=output,
                                 OutputWorkspace=output,
                                 NaNValue=0.0,
                                 NaNError=0.0,
                                 InfinityValue=0.0,
                                 InfinityError=0.0)
     return output