parameters: (self, mainWS)
return_statement: return correctedWS
docstring: Adjust the TOF axis to get the elastic channel correct.
docstring_summary: Adjust the TOF axis to get the elastic channel correct.
docstring_tokens: Adjust the TOF axis to get the elastic channel correct .
function: def _correctTOFAxis(self, mainWS):
          """Adjust the TOF axis to get the elastic channel correct."""
          try:
              l2 = float(mainWS.getInstrument().getStringParameter('l2')[0])
          except IndexError:
              self.log().warning("No 'l2' instrument parameter defined. TOF axis will not be adjusted")
              return mainWS
          if not self.getProperty(common.PROP_ELASTIC_CHANNEL_WS).isDefault:
              indexWS = self.getProperty(common.PROP_ELASTIC_CHANNEL_WS).value
              index = int(indexWS.readY(0)[0])
          else:
              mode = self._chooseElasticChannelMode(mainWS)
              if mode == common.ELASTIC_CHANNEL_SAMPLE_LOG:
                  if not mainWS.run().hasProperty('Detector.elasticpeak'):
                      self.log().warning('No ' + common.PROP_ELASTIC_CHANNEL_WS + ' given. TOF axis will not be adjusted.')
                      return mainWS
                  index = mainWS.run().getLogData('Detector.elasticpeak').value
              else:
                  ys = _sumDetectorsAtDistance(mainWS, l2, 1e-5)
                  index = _fitElasticChannel(ys, self._names, self._cleanup, self._subalgLogging)
          correctedWSName = self._names.withSuffix('tof_axis_corrected')
          correctedWS = CorrectTOFAxis(InputWorkspace=mainWS,
                                       OutputWorkspace=correctedWSName,
                                       IndexType='Workspace Index',
                                       ElasticBinIndex=index,
                                       L2=l2,
                                       EnableLogging=self._subalgLogging)
          self._report.notice('Elastic channel index {0} was used for TOF axis adjustment.'.format(index))
          if not self.getProperty(common.PROP_OUTPUT_ELASTIC_CHANNEL_WS).isDefault:
              indexOutputWSName = self._names.withSuffix('elastic_channel_output')
              indexOutputWS = CreateSingleValuedWorkspace(OutputWorkspace=indexOutputWSName,
                                                          DataValue=index,
                                                          EnableLogging=self._subalgLogging)
              self.setProperty(common.PROP_OUTPUT_ELASTIC_CHANNEL_WS, indexOutputWS)
              self._cleanup.cleanup(indexOutputWS)
          self._cleanup.cleanup(mainWS)
          return correctedWS
function_tokens: def _correctTOFAxis ( self , mainWS ) : try : l2 = float ( mainWS . getInstrument ( ) . getStringParameter ( 'l2' ) [ 0 ] ) except IndexError : self . log ( ) . warning ( "No 'l2' instrument parameter defined. TOF axis will not be adjusted" ) return mainWS if not self . getProperty ( common . PROP_ELASTIC_CHANNEL_WS ) . isDefault : indexWS = self . getProperty ( common . PROP_ELASTIC_CHANNEL_WS ) . value index = int ( indexWS . readY ( 0 ) [ 0 ] ) else : mode = self . _chooseElasticChannelMode ( mainWS ) if mode == common . ELASTIC_CHANNEL_SAMPLE_LOG : if not mainWS . run ( ) . hasProperty ( 'Detector.elasticpeak' ) : self . log ( ) . warning ( 'No ' + common . PROP_ELASTIC_CHANNEL_WS + ' given. TOF axis will not be adjusted.' ) return mainWS index = mainWS . run ( ) . getLogData ( 'Detector.elasticpeak' ) . value else : ys = _sumDetectorsAtDistance ( mainWS , l2 , 1e-5 ) index = _fitElasticChannel ( ys , self . _names , self . _cleanup , self . _subalgLogging ) correctedWSName = self . _names . withSuffix ( 'tof_axis_corrected' ) correctedWS = CorrectTOFAxis ( InputWorkspace = mainWS , OutputWorkspace = correctedWSName , IndexType = 'Workspace Index' , ElasticBinIndex = index , L2 = l2 , EnableLogging = self . _subalgLogging ) self . _report . notice ( 'Elastic channel index {0} was used for TOF axis adjustment.' . format ( index ) ) if not self . getProperty ( common . PROP_OUTPUT_ELASTIC_CHANNEL_WS ) . isDefault : indexOutputWSName = self . _names . withSuffix ( 'elastic_channel_output' ) indexOutputWS = CreateSingleValuedWorkspace ( OutputWorkspace = indexOutputWSName , DataValue = index , EnableLogging = self . _subalgLogging ) self . setProperty ( common . PROP_OUTPUT_ELASTIC_CHANNEL_WS , indexOutputWS ) self . _cleanup . cleanup ( indexOutputWS ) self . _cleanup . cleanup ( mainWS ) return correctedWS