Ejemplo n.º 1
0
 def _waterCalibration(self, ws):
     """Divide ws by a (water) reference workspace."""
     if self.getProperty(Prop.WATER_REFERENCE).isDefault:
         return ws
     waterWS = self.getProperty(Prop.WATER_REFERENCE).value
     detWSName = self._names.withSuffix('water_detectors')
     waterWS = ExtractMonitors(InputWorkspace=waterWS,
                               DetectorWorkspace=detWSName,
                               EnableLogging=self._subalgLogging)
     if mtd.doesExist(detWSName) is None:
         raise RuntimeError('No detectors in the water reference data.')
     if waterWS.getNumberHistograms() != ws.getNumberHistograms():
         self.log().error(
             'Water workspace and run do not have the same number of histograms.'
         )
     rebinnedWaterWSName = self._names.withSuffix('water_rebinned')
     rebinnedWaterWS = RebinToWorkspace(WorkspaceToRebin=waterWS,
                                        WorkspaceToMatch=ws,
                                        OutputWorkspace=rebinnedWaterWSName,
                                        EnableLogging=self._subalgLogging)
     calibratedWSName = self._names.withSuffix('water_calibrated')
     calibratedWS = Divide(LHSWorkspace=ws,
                           RHSWorkspace=rebinnedWaterWS,
                           OutputWorkspace=calibratedWSName,
                           EnableLogging=self._subalgLogging)
     self._cleanup.cleanup(waterWS)
     self._cleanup.cleanup(rebinnedWaterWS)
     self._cleanup.cleanup(ws)
     return calibratedWS
 def _waterCalibration(self, ws):
     """Divide ws by a (water) reference workspace."""
     if self.getProperty(Prop.WATER_REFERENCE).isDefault:
         return ws
     waterWS = self.getProperty(Prop.WATER_REFERENCE).value
     detWSName = self._names.withSuffix('water_detectors')
     waterWS = ExtractMonitors(
         InputWorkspace=waterWS,
         DetectorWorkspace=detWSName,
         EnableLogging=self._subalgLogging
     )
     if mtd.doesExist(detWSName) is None:
         raise RuntimeError('No detectors in the water reference data.')
     if waterWS.getNumberHistograms() != ws.getNumberHistograms():
         self.log().error('Water workspace and run do not have the same number of histograms.')
     rebinnedWaterWSName = self._names.withSuffix('water_rebinned')
     rebinnedWaterWS = RebinToWorkspace(
         WorkspaceToRebin=waterWS,
         WorkspaceToMatch=ws,
         OutputWorkspace=rebinnedWaterWSName,
         EnableLogging=self._subalgLogging
     )
     calibratedWSName = self._names.withSuffix('water_calibrated')
     calibratedWS = Divide(
         LHSWorkspace=ws,
         RHSWorkspace=rebinnedWaterWS,
         OutputWorkspace=calibratedWSName,
         EnableLogging=self._subalgLogging
     )
     self._cleanup.cleanup(waterWS)
     self._cleanup.cleanup(rebinnedWaterWS)
     self._cleanup.cleanup(ws)
     return calibratedWS
Ejemplo n.º 3
0
def _get_instrument_structure(ws):
    """Returns the number of detectors and the number of detectors per tube in the currently processed
    instrument."""
    instrument = ws.getInstrument().getName()
    if instrument in ['IN4', 'IN6']:
        self.log.warning(
            "Grouping pattern cannot be provided for IN4 and IN6.")
        return ""
    tmp_inst = '{}_tmp'.format(instrument)
    LoadEmptyInstrument(InstrumentName=instrument, OutputWorkspace=tmp_inst)
    tmp_mon_inst = 'mon_{}'.format(tmp_inst)
    ExtractMonitors(InputWorkspace=tmp_inst,
                    DetectorWorkspace=tmp_inst,
                    MonitorWorkspace=tmp_mon_inst)
    n_monitors = mtd[tmp_mon_inst].getNumberHistograms()
    n_tubes = 0
    for comp in mtd[tmp_inst].componentInfo():
        if len(comp.detectorsInSubtree) > 1 and comp.hasParent:
            n_tubes += 1
    n_tubes -= n_monitors
    if instrument == 'IN5':  # there is an extra bank that contains all of the tubes
        n_tubes -= 1
    n_pixels = mtd[tmp_inst].getNumberHistograms()
    n_pixels_per_tube = int(n_pixels / n_tubes)
    DeleteWorkspace(Workspace=tmp_inst)
    DeleteWorkspace(Workspace=tmp_mon_inst)
    return n_pixels, n_pixels_per_tube
Ejemplo n.º 4
0
 def _separateMons(self, mainWS):
     """Extract monitors to a separate workspace."""
     detWSName = self._names.withSuffix('extracted_detectors')
     monWSName = self._names.withSuffix('extracted_monitors')
     detWS, monWS = ExtractMonitors(InputWorkspace=mainWS,
                                    DetectorWorkspace=detWSName,
                                    MonitorWorkspace=monWSName,
                                    EnableLogging=self._subalgLogging)
     self._cleanup.cleanup(mainWS)
     return detWS, monWS
Ejemplo n.º 5
0
 def _extractMonitors(self, ws):
     """Extract monitor spectra from ws to another workspace."""
     detWSName = self._names.withSuffix('detectors')
     monWSName = self._names.withSuffix('monitors')
     ExtractMonitors(InputWorkspace=ws,
                     DetectorWorkspace=detWSName,
                     MonitorWorkspace=monWSName,
                     EnableLogging=self._subalgLogging)
     if mtd.doesExist(detWSName) is None:
         raise RuntimeError('No detectors in the input data.')
     detWS = mtd[detWSName]
     monWS = mtd[monWSName] if mtd.doesExist(monWSName) else None
     self._cleanup.cleanup(ws)
     return detWS, monWS