コード例 #1
0
def _focus_mode_trans(output_file_paths, atten, instrument,
                      calibrated_spectra):
    summed_ws = mantid.CloneWorkspace(InputWorkspace=calibrated_spectra[0])
    for i in range(1, 9):  # Add workspaces 2-9 to workspace 1
        summed_ws = mantid.Plus(LHSWorkspace=summed_ws,
                                RHSWorkspace=calibrated_spectra[i])

    summed_ws = mantid.Scale(InputWorkspace=summed_ws,
                             Factor=0.111111111111111)

    if atten:
        # Clone a workspace which is not attenuated
        no_att = output_file_paths["output_name"] + "_noatten"
        mantid.CloneWorkspace(InputWorkspace=summed_ws, OutputWorkspace=no_att)

        summed_ws = mantid.ConvertUnits(InputWorkspace=summed_ws,
                                        Target="dSpacing")
        summed_ws = instrument._attenuate_workspace(summed_ws)
        summed_ws = mantid.ConvertUnits(InputWorkspace=summed_ws, Target="TOF")

    mantid.SaveGSS(InputWorkspace=summed_ws,
                   Filename=output_file_paths["gss_filename"],
                   Append=False,
                   Bank=1)
    mantid.SaveFocusedXYE(InputWorkspace=summed_ws,
                          Filename=output_file_paths["tof_xye_filename"],
                          Append=False,
                          IncludeHeader=False)

    summed_ws = mantid.ConvertUnits(InputWorkspace=summed_ws,
                                    Target="dSpacing")

    # Rename to user friendly name:
    summed_ws_name = output_file_paths["output_name"] + "_mods1-9"
    summed_ws = mantid.RenameWorkspace(InputWorkspace=summed_ws,
                                       OutputWorkspace=summed_ws_name)

    mantid.SaveFocusedXYE(InputWorkspace=summed_ws,
                          Filename=output_file_paths["dspacing_xye_filename"],
                          Append=False,
                          IncludeHeader=False)
    mantid.SaveNexus(InputWorkspace=summed_ws,
                     Filename=output_file_paths["nxs_filename"],
                     Append=False)

    output_list = [summed_ws]

    for i in range(0, 9):
        workspace_name = output_file_paths["output_name"] + "_mod" + str(i + 1)
        to_save = mantid.ConvertUnits(InputWorkspace=calibrated_spectra[i],
                                      Target="dSpacing",
                                      OutputWorkspace=workspace_name)
        output_list.append(to_save)
        mantid.SaveNexus(Filename=output_file_paths["nxs_filename"],
                         InputWorkspace=to_save,
                         Append=True)

    return output_list
コード例 #2
0
ファイル: pearl_output.py プロジェクト: yutiansut/mantid
def _focus_mode_trans(output_file_paths, attenuation_filepath,
                      calibrated_spectra):
    summed_ws = mantid.MergeRuns(InputWorkspaces=calibrated_spectra[:9])
    xList = summed_ws.readX(0)

    summed_ws = mantid.CropWorkspace(InputWorkspace=summed_ws,
                                     XMin=xList[1],
                                     Xmax=xList[-2])
    summed_ws = mantid.Scale(InputWorkspace=summed_ws,
                             Factor=0.111111111111111)

    if attenuation_filepath:
        summed_ws = _attenuate_workspace(
            output_file_paths=output_file_paths,
            attenuated_ws=summed_ws,
            attenuation_filepath=attenuation_filepath)

    summed_ws = mantid.ConvertUnits(InputWorkspace=summed_ws, Target="TOF")
    mantid.SaveGSS(InputWorkspace=summed_ws,
                   Filename=output_file_paths["gss_filename"],
                   Append=False,
                   Bank=1)

    mantid.SaveFocusedXYE(InputWorkspace=summed_ws,
                          Filename=output_file_paths["tof_xye_filename"],
                          Append=False,
                          IncludeHeader=False)

    summed_ws = mantid.ConvertUnits(InputWorkspace=summed_ws,
                                    Target="dSpacing")

    # Rename to user friendly name:
    summed_ws_name = output_file_paths["output_name"] + "_mods1-9"
    summed_ws = mantid.RenameWorkspace(InputWorkspace=summed_ws,
                                       OutputWorkspace=summed_ws_name)

    mantid.SaveFocusedXYE(InputWorkspace=summed_ws,
                          Filename=output_file_paths["dspacing_xye_filename"],
                          Append=False,
                          IncludeHeader=False)
    mantid.SaveNexus(InputWorkspace=summed_ws,
                     Filename=output_file_paths["nxs_filename"],
                     Append=False)

    output_list = [summed_ws]

    for i in range(0, 9):
        workspace_name = output_file_paths["output_name"] + "_mod" + str(i + 1)
        to_save = mantid.ConvertUnits(InputWorkspace=calibrated_spectra[i],
                                      Target="dSpacing",
                                      OutputWorkspace=workspace_name)
        output_list.append(to_save)
        mantid.SaveNexus(Filename=output_file_paths["nxs_filename"],
                         InputWorkspace=to_save,
                         Append=True)

    return output_list
コード例 #3
0
ファイル: pearl_output.py プロジェクト: yutiansut/mantid
def _focus_mode_mods(output_file_paths, calibrated_spectra):
    append = False
    output_list = []
    for index, ws in enumerate(calibrated_spectra):
        output_name = output_file_paths["output_name"] + "_mod" + str(index +
                                                                      1)
        tof_ws = mantid.ConvertUnits(InputWorkspace=ws,
                                     OutputWorkspace=output_name,
                                     Target=WORKSPACE_UNITS.tof)
        mantid.SaveFocusedXYE(InputWorkspace=tof_ws,
                              Filename=output_file_paths["tof_xye_filename"],
                              Append=False,
                              IncludeHeader=False)
        mantid.SaveGSS(InputWorkspace=tof_ws,
                       Filename=output_file_paths["gss_filename"],
                       Append=append,
                       Bank=index + 1)
        dspacing_ws = mantid.ConvertUnits(InputWorkspace=ws,
                                          OutputWorkspace=output_name,
                                          Target=WORKSPACE_UNITS.d_spacing)
        output_list.append(dspacing_ws)
        mantid.SaveNexus(Filename=output_file_paths["nxs_filename"],
                         InputWorkspace=dspacing_ws,
                         Append=append)

        append = True
    return output_list
コード例 #4
0
    def _build_gsas2_reader_with_data(self, gs2, gs2_focused_wks):
        """
        Build an "rd" GSAS-II data structure with reader, and importantly the rd.powderdata
        list with the histogram data.

        @param gs2_focused_wks :: a workspace with a histogram from focused data

        @return an "rd" object as used in GSAS-II, with histogram data in the 'powderdata'
        data member
        """

        # produce histo_file, to "import" it with the reader from GSAS-II which will initialize
        # the "rd" object.
        import tempfile
        with tempfile.NamedTemporaryFile(mode='w', suffix='.xye', delete=False) as histo_data_tmp:
            # SplitFiles=False is important to get the filename without suffix
            msapi.SaveFocusedXYE(InputWorkspace=gs2_focused_wks, Filename=histo_data_tmp.name,
                                 Format="XYE", SplitFiles=False)
            gs2_rd = self._get_histo_data_reader(gs2, histo_data_tmp.name)

        gs2_rd.powderdata = self._transform_to_centers_bins(gs2_rd.powderdata)

        if not isinstance(gs2_rd.powderdata, list):
            raise ValueError('rd.powderdata is not a list of array as expected')

        return gs2_rd
コード例 #5
0
ファイル: EnginX.py プロジェクト: gemmaguest/mantid
def _save_out(run_number, focus_directory, focus_general, output, enginx_file_name_format, bank_id):
    """
    save out the files required for the focus

    @param run_number :: the run number of the focused run
    @param focus_directory :: the user directory to save to
    @param focus_general :: the general folder to copy the saved out files to
    @param output :: the workspace to save
    @param enginx_file_name_format :: the naming scheme of the files
    @param bank_id :: the bank being saved

    """
    # work out where to save the files
    dat_name, genie_filename, gss_name, hdf5_name, nxs_name = _find_focus_file_location(bank_id, focus_directory,
                                                                                        enginx_file_name_format,
                                                                                        run_number)
    if not str(bank_id).isnumeric():
        bank_id = 0
    # save the files out to the user directory
    simple.SaveFocusedXYE(InputWorkspace=output, Filename=dat_name, SplitFiles=False,
                          StartAtBankNumber=bank_id)
    simple.SaveGSS(InputWorkspace=output, Filename=gss_name, SplitFiles=False, Bank=bank_id)
    simple.SaveOpenGenieAscii(InputWorkspace=output, Filename=genie_filename, OpenGenieFormat="ENGIN-X Format")
    simple.SaveNexus(InputWorkspace=output, Filename=nxs_name)
    simple.ExportSampleLogsToHDF5(InputWorkspace=output, Filename=hdf5_name, Blacklist="bankid")
    if not focus_general == focus_directory:
        if not os.path.exists(focus_general):
            os.makedirs(focus_general)
        # copy the files to the general directory
        copy2(dat_name, focus_general)
        copy2(gss_name, focus_general)
        copy2(genie_filename, focus_general)
        copy2(nxs_name, focus_general)
        copy2(hdf5_name, focus_general)
コード例 #6
0
    def save_combined_panel(self, run, panel):
        panel_combination = {5: 6, 4: 7, 3: 8, 2: 9, 1: 10}
        input_ws1 = "w{0}-{1}foc".format(run, panel)
        input_ws2 = "w{0}-{1}foc".format(run, panel_combination.get(panel))
        combined = "{0}{1}-{2}_{3}foc{4}".format("{0}", run, panel,
                                                 panel_combination.get(panel),
                                                 "{1}")
        combined_save = combined.format("", "{}")
        combined_ws = combined.format("w", "")

        simple.RebinToWorkspace(WorkspaceToRebin=input_ws2,
                                WorkspaceToMatch=input_ws1,
                                OutputWorkspace=input_ws2,
                                PreserveEvents='0')
        simple.Plus(LHSWorkspace=input_ws1,
                    RHSWorkspace=input_ws2,
                    OutputWorkspace=combined_ws)
        simple.ConvertUnits(InputWorkspace=combined_ws,
                            OutputWorkspace=combined_ws + "-d",
                            Target="dSpacing",
                            EMode="Elastic")

        simple.SaveGSS(combined_ws,
                       os.path.join(self.user_directory,
                                    combined_save.format("raw.gss")),
                       Append=False,
                       Bank=1)
        simple.SaveFocusedXYE(
            combined_ws,
            os.path.join(self.user_directory, combined_save.format("raw.dat")))
        simple.SaveNexusProcessed(
            combined_ws,
            os.path.join(self.user_directory, combined_save.format("raw.nxs")))
コード例 #7
0
    def savePDFile(self, exp, scan, filetype, sfilename):
        """ Save a reduced workspace to gsas/fullprof/topaz data file
        """
        # get workspace
        wsmanager = self.getWorkspace(exp, scan, raiseexception=True)
        if wsmanager.reducedws is None:
            raise NotImplementedError(
                "Unable to rebin the data for exp=%d, scan=%d because \
                    either data MD workspace and monitor MD workspace is not present."
                % (exp, scan))
        else:
            wksp = wsmanager.reducedws

        # save
        filetype = filetype.lower()
        if "gsas" in filetype:
            if sfilename.endswith('.dat') is True:
                sfilename.replace('.dat', '.gsa')

            api.SaveGSS(InputWorkspace=wksp,
                        Filename=sfilename,
                        SplitFiles=False,
                        Append=False,
                        MultiplyByBinWidth=False,
                        Bank=1,
                        Format="SLOG",
                        ExtendedHeader=True)
        # ENDIF

        if "fullprof" in filetype:
            if sfilename.endswith('.gsa') is True:
                sfilename.replace('.gsa', '.dat')

            api.SaveFocusedXYE(InputWorkspace=wksp,
                               StartAtBankNumber=1,
                               Filename=sfilename)
        # ENDIF

        if "topas" in filetype:
            sfilename = sfilename[:-4] + ".xye"
            api.SaveFocusedXYE(InputWorkspace=wksp,
                               StartAtBankNumber=info["bank"],
                               Filename=sfilename,
                               Format="TOPAS")
        # ENDIF

        return
コード例 #8
0
ファイル: gem_output.py プロジェクト: luzpaz/mantid
def save_maud(d_spacing_group, output_path):
    for i, ws in enumerate(d_spacing_group):
        mantid.SaveFocusedXYE(InputWorkspace=ws,
                              Filename=output_path,
                              SplitFiles=False,
                              StartAtBankNumber=i,
                              Append=i > 0,
                              IncludeHeader=True,
                              Format="MAUD")
コード例 #9
0
ファイル: EnggUtils.py プロジェクト: robertapplin/mantid
def _save_output_files(focus_dirs,
                       sample_ws_foc,
                       calibration,
                       van_run,
                       rb_num=None):
    # set bankid for use in fit tab
    foc_suffix = calibration.get_foc_ws_suffix()
    xunit = sample_ws_foc.getDimension(0).name
    xunit_suffix = XUNIT_SUFFIXES[xunit]
    sample_run_no = sample_ws_foc.run().get('run_number').value
    # save all spectra to single ASCII files
    ascii_fname = _generate_output_file_name(calibration.get_instrument(),
                                             sample_run_no,
                                             van_run,
                                             calibration.get_group_suffix(),
                                             xunit_suffix,
                                             ext='')

    for focus_dir in focus_dirs:
        if not path.exists(focus_dir):
            makedirs(focus_dir)
        mantid.SaveGSS(InputWorkspace=sample_ws_foc,
                       Filename=path.join(focus_dir, ascii_fname + '.gss'),
                       SplitFiles=False,
                       UseSpectrumNumberAsBankID=True)
        mantid.SaveFocusedXYE(InputWorkspace=sample_ws_foc,
                              Filename=path.join(focus_dir,
                                                 ascii_fname + ".abc"),
                              SplitFiles=False,
                              Format="TOPAS")
        # Save nxs per spectrum
        nxs_paths = []
        mantid.AddSampleLog(Workspace=sample_ws_foc,
                            LogName="Vanadium Run",
                            LogText=van_run)
        for ispec in range(sample_ws_foc.getNumberHistograms()):
            # add a bankid and vanadium to log that is read by fitting model
            bankid = foc_suffix if sample_ws_foc.getNumberHistograms(
            ) == 1 else f'{foc_suffix}_{ispec + 1}'
            mantid.AddSampleLog(Workspace=sample_ws_foc,
                                LogName="bankid",
                                LogText=bankid.replace('_', ' '))  # overwrites
            # save spectrum as nexus
            filename = _generate_output_file_name(calibration.get_instrument(),
                                                  sample_run_no,
                                                  van_run,
                                                  bankid,
                                                  xunit_suffix,
                                                  ext=".nxs")
            nxs_path = path.join(focus_dir, filename)
            mantid.SaveNexus(InputWorkspace=sample_ws_foc,
                             Filename=nxs_path,
                             WorkspaceIndexList=[ispec])
            nxs_paths.append(nxs_path)
    return nxs_paths  # from last focus_dir only
コード例 #10
0
    def saveMergedScan(self, sfilename, mergeindex):
        """ Save the current merged scan
        """
        if self._myMergedWSDict.has_key(mergeindex) is True:
            wksp = self._myMergedWSDict[mergeindex]
        else:
            raise NotImplementedError(
                'Unable to locate the merged scan workspace.')

        api.SaveFocusedXYE(InputWorkspace=wksp,
                           StartAtBankNumber=1,
                           Filename=sfilename)

        return
コード例 #11
0
 def _save_temporary_fxye(self, spectrum):
     """
     Create a temporary fxye file for GSAS to read the spectrum from. This is required as we cannot pass a workspace
     straight to GSASIIscriptable, but rather it must be read from a file
     :param spectrum: The spectrum to save
     :return: Fully qualified path to the new file
     """
     workspace_index = self.getPropertyValue(self.PROP_WORKSPACE_INDEX)
     temp_dir = tempfile.gettempdir()
     # Output file MUST end with "-n.fxye" where n is a number
     # If you see "Runtime error: Rvals" from GSASIIscriptable.py, it may be because this name is badly formatted
     file_path = os.path.join(temp_dir, "{}_focused_spectrum-{}.fxye".format(self.name(), workspace_index))
     mantid.SaveFocusedXYE(Filename=file_path, InputWorkspace=spectrum, SplitFiles=False, IncludeHeader=False)
     return file_path
コード例 #12
0
def _save_xye(ws_group, filename_template):
    """
    Saves XYE data into .dat files. This expects the .dat folder to be created and passed.
    It saves the specified group with the specified units into a file whose name contains that
    information.
    :param ws_group: The workspace group to save out to .dat files
    :param filename_template: A string containing a fullpath with a string format template {bankno} to
    denote where the bank number should be inserted
    """
    for bank_index, ws in enumerate(ws_group):
        bank_index += 1  # Ensure we start a 1 when saving out
        mantid.SaveFocusedXYE(
            InputWorkspace=ws,
            Filename=filename_template.format(bankno=bank_index),
            SplitFiles=False,
            IncludeHeader=False)
コード例 #13
0
    def saveProcessedVanadium(self, expno, scanno, savefilename):
        """ Save processed vanadium data
        """
        # Get workspace
        wsmanager = self.getWorkspace(expno, scanno, raiseexception=True)

        if wsmanager.isSmoothApplied() is True:
            wksp = wsmanager.getProcessedVanadiumWSTemp()
        else:
            wksp = wsmanager.getProcessedVanadiumWS()

        # Save
        api.SaveFocusedXYE(InputWorkspace=wksp,
                           StartAtBankNumber=1,
                           Filename=savefilename)

        return
コード例 #14
0
def _save_out(run_number, focus_directory, focus_general, output, join_string,
              bank_id):
    """
    save out the files required for the focus

    @param run_number :: the run number of the focused run
    @param focus_directory :: the user directory to save to
    @param focus_general :: the general folder to copy the saved out files to
    @param output :: the workspace to save
    @param join_string :: the nameing scheme of the files
    @param bank_id :: the bank being saved

    """
    # work out where to save the files
    filename = os.path.join(focus_directory,
                            join_string.format(run_number, bank_id))
    hdf5_name = os.path.join(focus_directory, run_number + ".hdf5")
    if not unicode(bank_id).isnumeric():
        bank_id = 0
    # save the files out to the user directory
    simple.SaveFocusedXYE(InputWorkspace=output,
                          Filename=filename + ".dat",
                          SplitFiles=False,
                          StartAtBankNumber=bank_id)
    simple.SaveGSS(InputWorkspace=output,
                   Filename=filename + ".gss",
                   SplitFiles=False,
                   Bank=bank_id)
    simple.SaveOpenGenieAscii(InputWorkspace=output,
                              Filename=filename + ".his",
                              OpenGenieFormat="ENGIN-X Format")
    simple.SaveNexus(InputWorkspace=output, Filename=filename + ".nxs")
    simple.ExportSampleLogsToHDF5(InputWorkspace=output,
                                  Filename=hdf5_name,
                                  Blacklist="bankid")
    if not focus_general == focus_directory:
        if not os.path.exists(focus_general):
            os.makedirs(focus_general)
        # copy the files to the general directory
        copy2(filename + ".dat", focus_general)
        copy2(filename + ".gss", focus_general)
        copy2(filename + ".his", focus_general)
        copy2(filename + ".nxs", focus_general)
        copy2(hdf5_name, focus_general)
コード例 #15
0
ファイル: common_output.py プロジェクト: yutiansut/mantid
def _save_xye(ws_group, ws_units, run_number, output_folder, inst_prefix, file_ext):
    """
    Saves XYE data into .dat files. This expects the .dat folder to be created and passed.
    It saves the specified group with the specified units into a file whose name contains that
    information.
    :param ws_group: The workspace group to save out to .dat files
    :param ws_units: The units of all workspaces in that group
    :param run_number: The run number string to use when generating the filename
    :param output_folder: The output folder to save these files to
    :param inst_prefix: The prefix of the instrument to generate the filename
    :return:
    """
    prefix_filename = str(inst_prefix) + str(run_number)
    for bank_index, ws in enumerate(ws_group):
        bank_index += 1  # Ensure we start a 1 when saving out
        outfile_name = file_ext + prefix_filename + "-b_" + str(bank_index) + "-" + ws_units + ".dat"
        full_file_path = os.path.join(output_folder, outfile_name)

        mantid.SaveFocusedXYE(InputWorkspace=ws, Filename=full_file_path, SplitFiles=False, IncludeHeader=False)
コード例 #16
0
    def process_run(self,
                    number,
                    panel,
                    extension,
                    cycle_vana="09_4",
                    absorb=False,
                    number_density=0.0,
                    scattering=0.0,
                    attenuation=0.0,
                    height=0.0,
                    radius=0.0):
        ws_to_focus = self.read(number, panel, extension)
        if absorb:
            absorption_corrections(attenuation, height, number_density, radius,
                                   scattering, ws_to_focus)
        focused_ws = self.focus(ws_to_focus, panel)

        panel_crop = {
            1: (0.8, 53.3),
            2: (0.5, 13.1),
            3: (0.5, 7.77),
            4: (0.4, 5.86),
            5: (0.35, 4.99),
            6: (0.35, 4.99),
            7: (0.4, 5.86),
            8: (0.5, 7.77),
            9: (0.5, 13.1),
            10: (0.8, 53.3)
        }
        d_min, d_max = panel_crop.get(panel)
        simple.CropWorkspace(InputWorkspace=focused_ws,
                             OutputWorkspace=focused_ws,
                             XMin=d_min,
                             XMax=d_max)
        save_location = os.path.join(self.user_directory, "{0}-{1}{2}.{3}")
        if panel == 0:
            for panel_i in range(Wish.NUM_PANELS):
                focused_ws = "w{0}-{1}foc".format(number, panel_i)
                simple.CropWorkspace(InputWorkspace=focused_ws,
                                     OutputWorkspace=focused_ws,
                                     XMin=d_min,
                                     XMax=d_max)
                logger.notice(
                    "will try to load a vanadium with the name: {}".format(
                        self.get_vanadium(panel_i, cycle_vana)))
                self.apply_vanadium_corrections(cycle_vana, panel_i,
                                                focused_ws)
                simple.SaveGSS(InputWorkspace=focused_ws,
                               Filename=save_location.format(
                                   number, panel_i, extension, "gss"),
                               Append=False,
                               Bank=1)
                simple.SaveFocusedXYE(
                    focused_ws,
                    save_location.format(number, panel_i, extension, "dat"))
                simple.SaveNexusProcessed(
                    focused_ws,
                    save_location.format(number, panel_i, extension, "nxs"))
        else:
            logger.notice(
                "will try to load a vanadium with the name: {}".format(
                    self.get_vanadium(panel, cycle_vana)))
            self.apply_vanadium_corrections(cycle_vana, panel, focused_ws)
            simple.SaveGSS(InputWorkspace=focused_ws,
                           Filename=save_location.format(
                               number, panel, extension, "gss"),
                           Append=False,
                           Bank=1)
            simple.SaveFocusedXYE(
                focused_ws,
                save_location.format(number, panel, extension, "dat"))
            simple.SaveNexusProcessed(
                focused_ws,
                save_location.format(number, panel, extension, "nxs"))
        return focused_ws
コード例 #17
0
ファイル: pearl_output.py プロジェクト: yutiansut/mantid
def _focus_mode_all(output_file_paths, processed_spectra,
                    attenuation_filepath):
    summed_spectra_name = output_file_paths["output_name"] + "_mods1-9"
    summed_spectra = mantid.MergeRuns(InputWorkspaces=processed_spectra[:9],
                                      OutputWorkspace=summed_spectra_name)
    xList = summed_spectra.readX(0)

    summed_spectra = mantid.CropWorkspace(InputWorkspace=summed_spectra,
                                          XMin=xList[1],
                                          Xmax=xList[-2])
    summed_spectra = mantid.Scale(InputWorkspace=summed_spectra,
                                  Factor=0.111111111111111,
                                  OutputWorkspace=summed_spectra_name)
    if attenuation_filepath:
        summed_spectra = _attenuate_workspace(
            output_file_paths=output_file_paths,
            attenuated_ws=summed_spectra,
            attenuation_filepath=attenuation_filepath)

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

    mantid.SaveGSS(InputWorkspace=summed_spectra,
                   Filename=output_file_paths["gss_filename"],
                   Append=False,
                   Bank=1)

    summed_spectra = mantid.ConvertUnits(InputWorkspace=summed_spectra,
                                         Target="dSpacing",
                                         OutputWorkspace=summed_spectra_name)
    mantid.SaveNexus(Filename=output_file_paths["nxs_filename"],
                     InputWorkspace=summed_spectra,
                     Append=False)
    mantid.SaveFocusedXYE(InputWorkspace=summed_spectra_name,
                          Filename=output_file_paths["tof_xye_filename"],
                          Append=False,
                          IncludeHeader=False)
    output_list = [summed_spectra]
    for i in range(0, 5):
        spectra_index = (i + 9)  # Compensate for 0 based index
        ws_to_save = processed_spectra[
            spectra_index]  # Save out workspaces 10/11/12
        output_name = output_file_paths["output_name"] + "_mod" + str(
            spectra_index + 1)

        ws_to_save = mantid.ConvertUnits(InputWorkspace=ws_to_save,
                                         OutputWorkspace=ws_to_save,
                                         Target="TOF")
        mantid.SaveGSS(InputWorkspace=ws_to_save,
                       Filename=output_file_paths["gss_filename"],
                       Append=True,
                       Bank=i + 2)
        splits = output_file_paths["tof_xye_filename"].split(".")
        tof_xye_name = splits[0] + "-" + str(i + 10) + "." + splits[1]
        mantid.SaveFocusedXYE(InputWorkspace=ws_to_save,
                              Filename=tof_xye_name,
                              Append=False,
                              IncludeHeader=False)
        ws_to_save = mantid.ConvertUnits(InputWorkspace=ws_to_save,
                                         OutputWorkspace=output_name,
                                         Target="dSpacing")
        mantid.SaveNexus(Filename=output_file_paths["nxs_filename"],
                         InputWorkspace=ws_to_save,
                         Append=True)

        output_list.append(ws_to_save)

    return output_list
コード例 #18
0
ファイル: pearl_output.py プロジェクト: yutiansut/mantid
def _focus_mode_groups(output_file_paths, calibrated_spectra):
    output_list = []
    to_save = _sum_groups_of_three_ws(calibrated_spectra=calibrated_spectra,
                                      output_file_names=output_file_paths)

    workspaces_4_to_9_name = output_file_paths["output_name"] + "_mods4-9"
    workspaces_4_to_9 = mantid.MergeRuns(
        InputWorkspaces=calibrated_spectra[3:9],
        OutputWorkspace=workspaces_4_to_9_name)
    xList = workspaces_4_to_9.readX(0)

    workspaces_4_to_9 = mantid.CropWorkspace(InputWorkspace=workspaces_4_to_9,
                                             XMin=xList[1],
                                             Xmax=xList[-2])
    workspaces_4_to_9 = mantid.Scale(InputWorkspace=workspaces_4_to_9,
                                     Factor=0.5,
                                     OutputWorkspace=workspaces_4_to_9_name)
    to_save.append(workspaces_4_to_9)
    append = False
    index = 1
    for ws in to_save:
        ws = mantid.ConvertUnits(InputWorkspace=ws,
                                 OutputWorkspace=ws,
                                 Target="TOF")
        mantid.SaveGSS(InputWorkspace=ws,
                       Filename=output_file_paths["gss_filename"],
                       Append=False,
                       Bank=index)
        mantid.SaveFocusedXYE(InputWorkspace=ws,
                              Filename=output_file_paths["tof_xye_filename"],
                              Append=False,
                              IncludeHeader=False)
        workspace_names = ws.name()
        ws = mantid.ConvertUnits(InputWorkspace=ws,
                                 OutputWorkspace=workspace_names,
                                 Target="dSpacing")
        output_list.append(ws)
        mantid.SaveNexus(Filename=output_file_paths["nxs_filename"],
                         InputWorkspace=ws,
                         Append=append)
        append = True
        index += 1

    save_range = 5
    for i in range(0, save_range):
        monitor_ws_name = output_file_paths["output_name"] + "_mod" + str(i +
                                                                          10)

        monitor_ws = calibrated_spectra[i + 9]
        to_save = mantid.CloneWorkspace(InputWorkspace=monitor_ws,
                                        OutputWorkspace=monitor_ws_name)

        to_save = mantid.ConvertUnits(InputWorkspace=to_save,
                                      OutputWorkspace=to_save,
                                      Target="TOF")
        splits = output_file_paths["tof_xye_filename"].split(".")
        tof_xye_name = splits[0] + "-" + str(i + 10) + "." + splits[1]
        mantid.SaveGSS(InputWorkspace=to_save,
                       Filename=output_file_paths["gss_filename"],
                       Append=True,
                       Bank=i + 5)
        mantid.SaveFocusedXYE(InputWorkspace=to_save,
                              Filename=tof_xye_name,
                              Append=False,
                              IncludeHeader=False)
        to_save = mantid.ConvertUnits(InputWorkspace=to_save,
                                      OutputWorkspace=monitor_ws_name,
                                      Target="dSpacing")
        mantid.SaveNexus(Filename=output_file_paths["nxs_filename"],
                         InputWorkspace=to_save,
                         Append=True)

        output_list.append(to_save)

    return output_list