Beispiel #1
0
 def _compute_slice_nonPSD(self, workspace, x_axis, y_axis, e_mode,
                           norm_to_one):
     axes = [x_axis, y_axis]
     if x_axis.units == 'DeltaE':
         e_axis = 0
     elif y_axis.units == 'DeltaE':
         e_axis = 1
     else:
         raise RuntimeError(
             'Cannot calculate slices without an energy axis')
     q_axis = (e_axis + 1) % 2
     ebin = '%f, %f, %f' % (axes[e_axis].start, axes[e_axis].step,
                            axes[e_axis].end)
     qbin = '%f, %f, %f' % (axes[q_axis].start, axes[q_axis].step,
                            axes[q_axis].end)
     if axes[q_axis].units == '|Q|':
         thisslice = SofQW3(InputWorkspace=workspace,
                            QAxisBinning=qbin,
                            EAxisBinning=ebin,
                            EMode=e_mode,
                            StoreInADS=False)
     elif axes[q_axis].units == '2Theta':
         thisslice = ConvertSpectrumAxis(InputWorkspace=workspace,
                                         Target='Theta',
                                         StoreInADS=False)
         thisslice = Rebin2D(InputWorkspace=thisslice,
                             Axis1Binning=ebin,
                             Axis2Binning=qbin,
                             StoreInADS=False)
     else:
         raise RuntimeError(
             "axis %s not recognised, must be '|Q|' or '2Theta'" %
             axes[q_axis].units)
     return thisslice
Beispiel #2
0
def _cut_nonPSD_momentum(q_binning, e_binning, emode, selected_workspace):
    ws_out = SofQW3(InputWorkspace=selected_workspace,
                    OutputWorkspace='out',
                    EMode=emode,
                    QAxisBinning=q_binning,
                    EAxisBinning=e_binning,
                    StoreInADS=False)
    return ws_out
 def createPhononWS(self, T, en, e_units):
     fn = 'name=Gaussian, PeakCentre='+str(en)+', Height=1, Sigma=0.5;'
     fn +='name=Gaussian, PeakCentre=-'+str(en)+', Height='+str(np.exp(-en*11.6/T))+', Sigma=0.5;'
     ws = CreateSampleWorkspace(binWidth = 0.1, XMin = -25, XMax = 25, XUnit = e_units, Function = 'User Defined', UserDefinedFunction=fn)
     LoadInstrument(ws, InstrumentName='MARI', RewriteSpectraMap = True)
     with self.assertRaises(RuntimeError):
         ws_DOS = ComputeIncoherentDOS(ws)
     ws = SofQW3(ws, [0, 0.05, 8], 'Direct', 25)
     qq = np.arange(0, 8, 0.05)+0.025
     for i in range(ws.getNumberHistograms()):
         ws.setY(i, ws.readY(i)*qq[i]**2)
         ws.setE(i, ws.readE(i)*qq[i]**2)
     return ws
Beispiel #4
0
 def _calcQEproj(self, input_workspace, emode, axis1, axis2):
     """ Carries out either the Q-E or E-Q projections """
     # For indirect geometry and large datafiles (likely to be using a 1-to-1 mapping use ConvertToMD('|Q|')
     numSpectra = input_workspace.getNumberHistograms()
     if emode == 'Indirect' or numSpectra > 1000:
         retval = ConvertToMD(InputWorkspace=input_workspace, QDimensions=MOD_Q_LABEL,
                              PreprocDetectorsWS='-', dEAnalysisMode=emode, StoreInADS=False)
         if axis1 == DELTA_E_LABEL and axis2 == MOD_Q_LABEL:
             retval = self._flip_axes(retval)
     # Otherwise first run SofQW3 to rebin it in |Q| properly before calling ConvertToMD with CopyToMD
     else:
         limits = self.getProperty('Limits').value
         limits = ','.join([str(limits[i]) for i in [0, 2, 1]])
         retval = SofQW3(InputWorkspace=input_workspace, QAxisBinning=limits, Emode=emode, StoreInADS=False)
         retval = ConvertToMD(InputWorkspace=retval, QDimensions='CopyToMD', PreprocDetectorsWS='-',
                              dEAnalysisMode=emode, StoreInADS=False)
         if axis1 == MOD_Q_LABEL:
             retval = self._flip_axes(retval)
     return retval