示例#1
0
    def _save(self, runnumber, basename, outputWksp):
        if not self.getProperty("SaveData").value:
            return

        # determine where to save the data
        saveDir = self.getPropertyValue("OutputDirectory").strip()
        if len(saveDir) <= 0:
            self.log().notice('Using default save location')
            saveDir = os.path.join(self.get_IPTS_Local(runnumber), 'shared', 'data')

        self.log().notice('Writing to \'' + saveDir + '\'')

        SaveNexusProcessed(InputWorkspace=outputWksp,
                           Filename=os.path.join(saveDir, 'nexus', basename + '.nxs'))
        SaveAscii(InputWorkspace=outputWksp,
                  Filename=os.path.join(saveDir, 'd_spacing', basename + '.dat'))
        ConvertUnits(InputWorkspace=outputWksp, OutputWorkspace='WS_tof',
                     Target="TOF", AlignBins=False)

        # GSAS and FullProf require data in time-of-flight
        SaveGSS(InputWorkspace='WS_tof',
                Filename=os.path.join(saveDir, 'gsas', basename + '.gsa'),
                Format='SLOG', SplitFiles=False, Append=False, ExtendedHeader=True)
        SaveFocusedXYE(InputWorkspace='WS_tof',
                       Filename=os.path.join(
                           saveDir, 'fullprof', basename + '.dat'),
                       SplitFiles=True, Append=False)
        DeleteWorkspace(Workspace='WS_tof')
示例#2
0
    def _save(self, saveDir, basename, outputWksp):
        if not self.getProperty("SaveData").value:
            return

        self.log().notice('Writing to \'' + saveDir + '\'')

        SaveNexusProcessed(InputWorkspace=outputWksp,
                           Filename=os.path.join(saveDir, 'nexus',
                                                 basename + '.nxs'))
        SaveAscii(InputWorkspace=outputWksp,
                  Filename=os.path.join(saveDir, 'd_spacing',
                                        basename + '.dat'))
        ConvertUnits(InputWorkspace=outputWksp,
                     OutputWorkspace='WS_tof',
                     Target="TOF",
                     AlignBins=False)

        # GSAS and FullProf require data in time-of-flight
        SaveGSS(InputWorkspace='WS_tof',
                Filename=os.path.join(saveDir, 'gsas', basename + '.gsa'),
                Format='SLOG',
                SplitFiles=False,
                Append=False,
                ExtendedHeader=True)
        SaveFocusedXYE(InputWorkspace='WS_tof',
                       Filename=os.path.join(saveDir, 'fullprof',
                                             basename + '.dat'),
                       SplitFiles=True,
                       Append=False)
        DeleteWorkspace(Workspace='WS_tof')
示例#3
0
    def _save(self, runnumber, basename, norm):
        if not self.getProperty("SaveData").value:
            return

        saveDir = self.getProperty("OutputDirectory").value.strip()
        if len(saveDir) <= 0:
            self.log().notice('Using default save location')
            saveDir = os.path.join(
                self.get_IPTS_Local(runnumber), 'shared', 'data')
        self.log().notice('Writing to \'' + saveDir + '\'')

        if norm == 'None':
            SaveNexusProcessed(InputWorkspace='WS_red',
                               Filename=os.path.join(saveDir, 'nexus', basename + '.nxs'))
            SaveAscii(InputWorkspace='WS_red',
                      Filename=os.path.join(saveDir, 'd_spacing', basename + '.dat'))
            ConvertUnits(InputWorkspace='WS_red', OutputWorkspace='WS_tof',
                         Target="TOF", AlignBins=False)
        else:
            SaveNexusProcessed(InputWorkspace='WS_nor',
                               Filename=os.path.join(saveDir, 'nexus', basename + '.nxs'))
            SaveAscii(InputWorkspace='WS_nor',
                      Filename=os.path.join(saveDir, 'd_spacing', basename + '.dat'))
            ConvertUnits(InputWorkspace='WS_nor', OutputWorkspace='WS_tof',
                         Target="TOF", AlignBins=False)

        SaveGSS(InputWorkspace='WS_tof',
                Filename=os.path.join(saveDir, 'gsas', basename + '.gsa'),
                Format='SLOG', SplitFiles=False, Append=False, ExtendedHeader=True)
        SaveFocusedXYE(InputWorkspace='WS_tof',
                       Filename=os.path.join(
                           saveDir, 'fullprof', basename + '.dat'),
                       SplitFiles=True, Append=False)
        DeleteWorkspace(Workspace='WS_tof')
示例#4
0
 def _save_focused_output_files_as_xye(self, instrument, sample_path, bank,
                                       sample_workspace, rb_num):
     xye_output_path = path.join(
         path_handling.get_output_path(), "Focus",
         self._generate_output_file_name(instrument, sample_path, bank,
                                         ".dat"))
     SaveFocusedXYE(InputWorkspace=sample_workspace,
                    Filename=xye_output_path,
                    SplitFiles=False)
     if rb_num:
         xye_output_path = path.join(
             path_handling.get_output_path(), "User", rb_num, "Focus",
             self._generate_output_file_name(instrument, sample_path, bank,
                                             ".dat"))
         SaveFocusedXYE(InputWorkspace=sample_workspace,
                        Filename=xye_output_path,
                        SplitFiles=False)
示例#5
0
 def _save_focused_output_files_as_topas_xye(self, instrument, sample_run,
                                             van_run, bank,
                                             sample_workspace, rb_num,
                                             unit):
     xye_output_path = path.join(
         output_settings.get_output_path(), "Focus",
         self._generate_output_file_name(instrument, sample_run, van_run,
                                         bank, unit, ".abc"))
     SaveFocusedXYE(InputWorkspace=sample_workspace,
                    Filename=xye_output_path,
                    SplitFiles=False,
                    Format="TOPAS")
     if rb_num:
         xye_output_path = path.join(
             output_settings.get_output_path(), "User", rb_num, "Focus",
             self._generate_output_file_name(instrument, sample_run,
                                             van_run, bank, unit, ".abc"))
         SaveFocusedXYE(InputWorkspace=sample_workspace,
                        Filename=xye_output_path,
                        SplitFiles=False,
                        Format="TOPAS")
示例#6
0
#!/usr/bin/env python2
import os
import sys

sys.path.insert(0, "/opt/mantidnightly/bin")
from mantid.simpleapi import HB2AReduce, SaveFocusedXYE

filename = sys.argv[1]
output_file = os.path.split(filename)[-1].replace('.dat', '.xye')
outdir = sys.argv[2]

ws = HB2AReduce(filename)
SaveFocusedXYE(ws,
               Filename=os.path.join(outdir, output_file),
               SplitFiles=False,
               IncludeHeader=False)
示例#7
0
d = (counts / monitor).ravel()
e = (np.sqrt(counts) / monitor).ravel()
data = CreateWorkspace(DataX=xarray.ravel()[index_array],
                       DataY=d[index_array],
                       DataE=np.sqrt(d[index_array]))

n = np.repeat(vcorr, len(xarray.T)).ravel() / normalization_monitor
norm = CreateWorkspace(DataX=xarray.ravel()[index_array],
                       DataY=n[index_array],
                       DataE=np.sqrt(n[index_array]))

data = Rebin(data, Params=binning)
norm = Rebin(norm, Params=binning)

ws = Divide(data, norm)

SaveFocusedXYE(ws, Filename='out.xye', SplitFiles=False, IncludeHeader=False)

c = CreateWorkspace(DataX=xarray.ravel()[index_array],
                    DataY=counts.ravel()[index_array],
                    DataE=np.sqrt(counts.ravel()[index_array]))

n = CreateWorkspace(DataX=xarray.ravel()[index_array],
                    DataY=n[index_array],
                    DataE=np.sqrt(n[index_array]))

#data = Rebin(data, Params=binning)
#norm = Rebin(norm, Params=binning)

d = Divide(c, n)
示例#8
0
        return ws

if powder:

    from mantid.simpleapi import LoadWAND, WANDPowderReduction, SavePlot1D, SaveFocusedXYE, Scale

    data = LoadWAND(filename, Grouping='4x4')
    runNumber = data.getRunNumber()
    cal = get_vanadium(runNumber)
    WANDPowderReduction(InputWorkspace=data,
                        CalibrationWorkspace=cal,
                        Target='Theta',
                        NumberBins=1200,
                        OutputWorkspace='reduced')
    Scale(InputWorkspace='reduced',OutputWorkspace='reduced',Factor=100)
    SaveFocusedXYE('reduced', Filename=os.path.join(outdir, output_file+'.xye'), SplitFiles=False, IncludeHeader=False)
    div = SavePlot1D('reduced', OutputType='plotly')
    request = publish_plot('HB2C', runNumber, files={'file': div})

else:  # Single Crystal

    with h5py.File(filename, 'r') as f:
        offset = decode(f['/entry/DASlogs/HB2C:Mot:s2.RBV/average_value'].value[0])
        title = decode(f['/entry/title'].value[0])
        mon = decode(f['/entry/monitor1/total_counts'].value[0])
        duration = decode(f['/entry/duration'].value[0])
        run_number = decode(f['/entry/run_number'].value[0])
        bc = np.zeros((512*480*8))
        for b in range(8):
            bc += np.bincount(f['/entry/bank'+str(b+1)+'_events/event_id'].value,
                              minlength=512*480*8)