Example #1
0
def is_sliceable(workspace):
    ws = get_workspace_handle(workspace)
    if isinstance(ws, PixelWorkspace):
        return True
    else:
        validator = WorkspaceUnitValidator('DeltaE')
        return isinstance(ws, Workspace) and validator.isValid(ws.raw_ws) == ''
Example #2
0
 def PyInit(self):
     """
     Declare properties
     """
     allowed_units = CompositeValidator([
         WorkspaceUnitValidator("DeltaE"),
         WorkspaceUnitValidator("Momentum")
     ],
                                        relation=CompositeRelation.OR)
     self.declareProperty(
         IEventWorkspaceProperty("InputWorkspace",
                                 "",
                                 direction=Direction.Input,
                                 validator=allowed_units),
         doc="Input workspace. It has to be an event workspace" +
         " with units of energy transfer or momentum")
     self.declareProperty(name="XMin",
                          defaultValue=Property.EMPTY_DBL,
                          direction=Direction.Input,
                          validator=FloatMandatoryValidator(),
                          doc="Minimum energy transfer or momentum")
     self.declareProperty(name="XMax",
                          defaultValue=Property.EMPTY_DBL,
                          direction=Direction.Input,
                          validator=FloatMandatoryValidator(),
                          doc="Maximum energy transfer or momentum")
     self.declareProperty(WorkspaceProperty('OutputWorkspace',
                                            '',
                                            direction=Direction.Output),
                          doc='Output workspace')
Example #3
0
    def PyInit(self):

        self.declareProperty(MatrixWorkspaceProperty(
            'InputWorkspace',
            '',
            direction=Direction.Input,
            validator=WorkspaceUnitValidator("Wavelength")),
                             doc='Flood weighting measurement')
        self.declareProperty(MatrixWorkspaceProperty(
            'TransmissionWorkspace',
            '',
            direction=Direction.Input,
            optional=PropertyMode.Optional,
            validator=WorkspaceUnitValidator("Wavelength")),
                             doc='Flood weighting measurement')

        validator = FloatArrayBoundedValidator(lower=0.)
        self.declareProperty(
            FloatArrayProperty('Bands', [],
                               direction=Direction.Input,
                               validator=validator),
            doc='Wavelength bands to use. Single pair min to max.')

        self.declareProperty(MatrixWorkspaceProperty(
            'OutputWorkspace', '', direction=Direction.Output),
                             doc='Normalized flood weighting measurement')

        self.declareProperty("SolidAngleCorrection",
                             True,
                             direction=Direction.Input,
                             doc="Perform final solid angle correction")
Example #4
0
def is_sliceable(workspace):
    ws = get_workspace_handle(workspace)
    if isinstance(ws, PixelWorkspace):
        return True
    else:
        validator = WorkspaceUnitValidator('DeltaE')
        return isinstance(ws, Workspace) and validator.isValid(ws.raw_ws) == ''
    def PyInit(self):
        """Initialize the input and output properties of the algorithm."""
        threeNonnegativeInts = CompositeValidator()
        threeNonnegativeInts.add(IntArrayLengthValidator(3))
        nonnegativeInts = IntArrayBoundedValidator()
        nonnegativeInts.setLower(0)
        threeNonnegativeInts.add(nonnegativeInts)

        self.declareProperty(
            MatrixWorkspaceProperty(
                Prop.INPUT_WS,
                defaultValue='',
                direction=Direction.Input,
                validator=WorkspaceUnitValidator('Wavelength')),
            doc='An input workspace (units wavelength) to be integrated.')
        self.declareProperty(
            MatrixWorkspaceProperty(Prop.OUTPUT_WS,
                                    defaultValue='',
                                    direction=Direction.Output),
            doc='The integrated foreground divided by the summed direct beam.')
        self.declareProperty(Prop.SUBALG_LOGGING,
                             defaultValue=SubalgLogging.OFF,
                             validator=StringListValidator(
                                 [SubalgLogging.OFF, SubalgLogging.ON]),
                             doc='Enable or disable child algorithm logging.')
        self.declareProperty(
            Prop.CLEANUP,
            defaultValue=common.WSCleanup.ON,
            validator=StringListValidator(
                [common.WSCleanup.ON, common.WSCleanup.OFF]),
            doc='Enable or disable intermediate workspace cleanup.')
        self.declareProperty(Prop.SUM_TYPE,
                             defaultValue=SumType.IN_LAMBDA,
                             validator=StringListValidator(
                                 [SumType.IN_LAMBDA, SumType.IN_Q]),
                             doc='Type of summation to perform.')
        self.declareProperty(
            MatrixWorkspaceProperty(
                Prop.DIRECT_FOREGROUND_WS,
                defaultValue='',
                direction=Direction.Input,
                optional=PropertyMode.Optional,
                validator=WorkspaceUnitValidator('Wavelength')),
            doc=
            'Summed direct beam workspace if output in reflectivity is required.'
        )
        self.declareProperty(
            IntArrayProperty(Prop.FOREGROUND_INDICES,
                             values=[
                                 Property.EMPTY_INT, Property.EMPTY_INT,
                                 Property.EMPTY_INT
                             ],
                             validator=threeNonnegativeInts),
            doc=
            'A three element array of foreground start, centre and end workspace indices.'
        )
 def PyInit(self):
     """Initialize the input and output properties of the algorithm."""
     positiveFloat = FloatBoundedValidator(lower=0., exclusive=True)
     self.declareProperty(
         MatrixWorkspaceProperty(
             Prop.INPUT_WS,
             defaultValue='',
             direction=Direction.Input,
             validator=WorkspaceUnitValidator('Wavelength')),
         doc='A reflectivity workspace in wavelength to be converted to Q.')
     self.declareProperty(MatrixWorkspaceProperty(
         Prop.OUTPUT_WS, defaultValue='', direction=Direction.Output),
                          doc='The input workspace in momentum transfer.')
     self.declareProperty(Prop.SUBALG_LOGGING,
                          defaultValue=SubalgLogging.OFF,
                          validator=StringListValidator(
                              [SubalgLogging.OFF, SubalgLogging.ON]),
                          doc='Enable or disable child algorithm logging.')
     self.declareProperty(
         Prop.CLEANUP,
         defaultValue=common.WSCleanup.ON,
         validator=StringListValidator(
             [common.WSCleanup.ON, common.WSCleanup.OFF]),
         doc='Enable or disable intermediate workspace cleanup.')
     self.declareProperty(
         MatrixWorkspaceProperty(
             Prop.REFLECTED_WS,
             defaultValue='',
             direction=Direction.Input,
             validator=WorkspaceUnitValidator('Wavelength')),
         doc=
         'A non-summed reflected beam workspace, needed for Q resolution calculation.'
     )
     self.declareProperty(
         MatrixWorkspaceProperty(
             Prop.DIRECT_WS,
             defaultValue='',
             direction=Direction.Input,
             validator=WorkspaceUnitValidator('Wavelength')),
         doc=
         'A non-summed direct beam workspace, needed for Q resolution calculation.'
     )
     self.declareProperty(
         Prop.POLARIZED,
         defaultValue=False,
         doc=
         'True if input workspace has been corrected for polarization efficiencies.'
     )
     self.declareProperty(
         Prop.GROUPING_FRACTION,
         defaultValue=Property.EMPTY_DBL,
         validator=positiveFloat,
         doc=
         'If set, group the output by steps of this fraction multiplied by Q resolution'
     )
Example #7
0
def is_cuttable(workspace):
    workspace = get_workspace_handle(workspace)
    try:
        is2D = workspace.raw_ws.getNumDims() == 2
    except AttributeError:
        is2D = False
    if not is2D:
        return False
    if isinstance(workspace, PixelWorkspace):
        return True
    else:
        validator = WorkspaceUnitValidator('DeltaE')
        return isinstance(workspace, Workspace2D) and validator.isValid(workspace.raw_ws) == ''
Example #8
0
def is_cuttable(workspace):
    workspace = get_workspace_handle(workspace)
    try:
        is2D = workspace.raw_ws.getNumDims() == 2
    except AttributeError:
        is2D = False
    if not is2D:
        return False
    if isinstance(workspace, PixelWorkspace):
        return True
    else:
        validator = WorkspaceUnitValidator('DeltaE')
        return isinstance(workspace, Workspace2D) and validator.isValid(
            workspace.raw_ws) == ''
Example #9
0
    def PyInit(self):
        inputWorkspaceValidator = CompositeValidator()
        inputWorkspaceValidator.add(InstrumentValidator())
        inputWorkspaceValidator.add(WorkspaceUnitValidator('TOF'))
        positiveFloat = FloatBoundedValidator(lower=0)

        self.declareProperty(MatrixWorkspaceProperty(
            name=common.PROP_INPUT_WS,
            defaultValue='',
            validator=inputWorkspaceValidator,
            optional=PropertyMode.Mandatory,
            direction=Direction.Input),
                             doc='Input workspace.')
        self.declareProperty(WorkspaceProperty(name=common.PROP_OUTPUT_WS,
                                               defaultValue='',
                                               direction=Direction.Output),
                             doc='The output of the algorithm.')
        self.declareProperty(name=common.PROP_CLEANUP_MODE,
                             defaultValue=common.CLEANUP_ON,
                             validator=StringListValidator(
                                 [common.CLEANUP_ON, common.CLEANUP_OFF]),
                             direction=Direction.Input,
                             doc='What to do with intermediate workspaces.')
        self.declareProperty(
            name=common.PROP_SUBALG_LOGGING,
            defaultValue=common.SUBALG_LOGGING_OFF,
            validator=StringListValidator(
                [common.SUBALG_LOGGING_OFF, common.SUBALG_LOGGING_ON]),
            direction=Direction.Input,
            doc='Enable or disable subalgorithms to ' + 'print in the logs.')
        self.declareProperty(
            ITableWorkspaceProperty(name=common.PROP_EPP_WS,
                                    defaultValue='',
                                    direction=Direction.Input,
                                    optional=PropertyMode.Mandatory),
            doc='Table workspace containing results from the FindEPP algorithm.'
        )
        self.declareProperty(
            name=common.PROP_DWF_CORRECTION,
            defaultValue=common.DWF_ON,
            validator=StringListValidator([common.DWF_ON, common.DWF_OFF]),
            direction=Direction.Input,
            doc=
            'Enable or disable the correction for the Debye-Waller factor for '
            + common.PROP_OUTPUT_WS + '.')
        self.declareProperty(
            name=common.PROP_TEMPERATURE,
            defaultValue=Property.EMPTY_DBL,
            validator=positiveFloat,
            direction=Direction.Input,
            doc='Experimental temperature (Vanadium ' +
            'reduction type only) for the Debye-Waller correction, in Kelvins.'
        )
        self.setPropertySettings(
            common.PROP_TEMPERATURE,
            EnabledWhenProperty(common.PROP_DWF_CORRECTION,
                                PropertyCriterion.IsDefault))
    def PyInit(self):
        """Initialize the algorithm's input and output properties."""
        inputWorkspaceValidator = CompositeValidator()
        inputWorkspaceValidator.add(InstrumentValidator())
        inputWorkspaceValidator.add(WorkspaceUnitValidator('TOF'))
        mustBePositive = FloatBoundedValidator(lower=0)

        # Properties.
        self.declareProperty(
            MatrixWorkspaceProperty(name=common.PROP_INPUT_WS,
                                    defaultValue='',
                                    validator=inputWorkspaceValidator,
                                    direction=Direction.Input),
            doc='A workspace to which to apply the corrections.')
        self.declareProperty(WorkspaceProperty(name=common.PROP_OUTPUT_WS,
                                               defaultValue='',
                                               direction=Direction.Output),
                             doc='The corrected workspace.')
        self.declareProperty(name=common.PROP_CLEANUP_MODE,
                             defaultValue=utils.Cleanup.ON,
                             validator=StringListValidator(
                                 [utils.Cleanup.ON, utils.Cleanup.OFF]),
                             direction=Direction.Input,
                             doc='What to do with intermediate workspaces.')
        self.declareProperty(
            name=common.PROP_SUBALG_LOGGING,
            defaultValue=common.SUBALG_LOGGING_OFF,
            validator=StringListValidator(
                [common.SUBALG_LOGGING_OFF, common.SUBALG_LOGGING_ON]),
            direction=Direction.Input,
            doc='Enable or disable subalgorithms to print in the logs.')
        self.declareProperty(
            MatrixWorkspaceProperty(name=common.PROP_EC_WS,
                                    defaultValue='',
                                    validator=inputWorkspaceValidator,
                                    direction=Direction.Input,
                                    optional=PropertyMode.Optional),
            doc=
            'An empty container workspace for subtraction from the input workspace.'
        )
        self.declareProperty(
            name=common.PROP_EC_SCALING,
            defaultValue=1.0,
            validator=mustBePositive,
            direction=Direction.Input,
            doc=
            'A multiplier (transmission, if no self shielding is applied) for the empty container.'
        )
        self.declareProperty(
            MatrixWorkspaceProperty(
                name=common.PROP_SELF_SHIELDING_CORRECTION_WS,
                defaultValue='',
                direction=Direction.Input,
                optional=PropertyMode.Optional),
            doc='A workspace containing the self shielding correction factors.'
        )
    def PyInit(self):
        ws_validator = CompositeValidator([WorkspaceUnitValidator('Wavelength'), InstrumentValidator()])

        self.declareProperty(MatrixWorkspaceProperty('SampleWorkspace', '',
                                                     direction=Direction.Input,
                                                     validator=ws_validator),
                             doc='Name for the input sample workspace')

        self.declareProperty(name='SampleChemicalFormula', defaultValue='',
                             validator=StringMandatoryValidator(),
                             doc='Sample chemical formula')
        self.declareProperty(name='SampleNumberDensity', defaultValue=0.1,
                             validator=FloatBoundedValidator(0.0),
                             doc='Sample number density in atoms/Angstrom3')
        self.declareProperty(name='SampleThickness', defaultValue=0.0,
                             validator=FloatBoundedValidator(0.0),
                             doc='Sample thickness in cm')
        self.declareProperty(name='SampleAngle', defaultValue=0.0,
                             doc='Sample angle in degrees')

        self.declareProperty(MatrixWorkspaceProperty('CanWorkspace', '',
                                                     direction=Direction.Input,
                                                     optional=PropertyMode.Optional,
                                                     validator=ws_validator),
                             doc="Name for the input container workspace")

        self.declareProperty(name='CanChemicalFormula', defaultValue='',
                             doc='Container chemical formula')
        self.declareProperty(name='CanNumberDensity', defaultValue=0.1,
                             validator=FloatBoundedValidator(0.0),
                             doc='Container number density in atoms/Angstrom3')

        self.declareProperty(name='CanFrontThickness', defaultValue=0.0,
                             validator=FloatBoundedValidator(0.0),
                             doc='Container front thickness in cm')
        self.declareProperty(name='CanBackThickness', defaultValue=0.0,
                             validator=FloatBoundedValidator(0.0),
                             doc='Container back thickness in cm')

        self.declareProperty(name='NumberWavelengths', defaultValue=10,
                             validator=IntBoundedValidator(1),
                             doc='Number of wavelengths for calculation')
        self.declareProperty(name='Interpolate', defaultValue=True,
                             doc='Interpolate the correction workspaces to match the sample workspace')

        self.declareProperty(name='Emode', defaultValue='Elastic',
                             validator=StringListValidator(['Elastic', 'Indirect']),
                             doc='Emode: Elastic or Indirect')
        self.declareProperty(name='Efixed', defaultValue=1.0,
                             doc='Analyser energy')

        self.declareProperty(WorkspaceGroupProperty('OutputWorkspace', '',
                                                    direction=Direction.Output),
                             doc='The output corrections workspace group')
    def PyInit(self):
        ws_validator = CompositeValidator([WorkspaceUnitValidator('Wavelength'), InstrumentValidator()])

        self.declareProperty(MatrixWorkspaceProperty('SampleWorkspace', '',
                                                     direction=Direction.Input,
                                                     validator=ws_validator),
                             doc='Name for the input sample workspace')

        self.declareProperty(name='SampleChemicalFormula', defaultValue='',
                             validator=StringMandatoryValidator(),
                             doc='Sample chemical formula')
        self.declareProperty(name='SampleNumberDensity', defaultValue=0.1,
                             validator=FloatBoundedValidator(0.0),
                             doc='Sample number density in atoms/Angstrom3')
        self.declareProperty(name='SampleInnerRadius', defaultValue=0.05,
                             doc='Sample inner radius')
        self.declareProperty(name='SampleOuterRadius', defaultValue=0.1,
                             doc='Sample outer radius')

        self.declareProperty(MatrixWorkspaceProperty('CanWorkspace', '',
                                                     direction=Direction.Input,
                                                     optional=PropertyMode.Optional,
                                                     validator=ws_validator),
                             doc="Name for the input container workspace")

        self.declareProperty(name='CanChemicalFormula', defaultValue='',
                             doc='Container chemical formula')
        self.declareProperty(name='CanNumberDensity', defaultValue=0.1,
                             validator=FloatBoundedValidator(0.0),
                             doc='Container number density in atoms/Angstrom3')
        self.declareProperty(name='CanOuterRadius', defaultValue=0.15,
                             doc='Can outer radius')

        self.declareProperty(name='BeamHeight', defaultValue=3.0,
                             doc='Height of the beam at the sample.')
        self.declareProperty(name='BeamWidth', defaultValue=2.0,
                             doc='Width of the beam at the sample.')

        self.declareProperty(name='StepSize', defaultValue=0.002,
                             doc='Step size for calculation')
        self.declareProperty(name='Interpolate', defaultValue=True,
                             doc='Interpolate the correction workspaces to match the sample workspace')

        self.declareProperty(name='Emode', defaultValue='Elastic',
                             validator=StringListValidator(['Elastic', 'Indirect']),
                             doc='Emode: Elastic or Indirect')
        self.declareProperty(name='Efixed', defaultValue=1.0,
                             doc='Analyser energy')

        self.declareProperty(WorkspaceGroupProperty('OutputWorkspace', '',
                                                    direction=Direction.Output),
                             doc='The output corrections workspace group')
Example #13
0
    def PyInit(self):
        """Declare properties
        """
        wsValidators = CompositeValidator()
        # X axis must be a NumericAxis in energy transfer units.
        wsValidators.add(WorkspaceUnitValidator("DeltaE"))
        # Workspace must have an Instrument
        wsValidators.add(InstrumentValidator())

        self.declareProperty(MatrixWorkspaceProperty(name="InputWorkspace", defaultValue="", direction=Direction.Input,
                             validator=wsValidators), doc="Workspace name for input")
        self.declareProperty(FileProperty(name="Filename", defaultValue="", action=FileAction.Save, extensions=""),
                             doc="The name to use when writing the file")
Example #14
0
    def PyInit(self):
        # input
        self.declareProperty(MatrixWorkspaceProperty(
            "InputWorkspace",
            "",
            direction=Direction.Input,
            validator=WorkspaceUnitValidator("TOF")),
                             doc="Input Sample or Vanadium workspace")

        # output
        self.declareProperty(
            ITableWorkspaceProperty("OutputWorkspace", "", Direction.Output),
            doc="The name of the table workspace that will be created.")
Example #15
0
    def PyInit(self):
        """Initialize the algorithm's input and output properties."""
        inputWorkspaceValidator = CompositeValidator()
        inputWorkspaceValidator.add(InstrumentValidator())
        inputWorkspaceValidator.add(WorkspaceUnitValidator('TOF'))
        scalingFactor = FloatBoundedValidator(lower=0, upper=1)

        # Properties.
        self.declareProperty(MatrixWorkspaceProperty(
            name=common.PROP_INPUT_WS,
            defaultValue='',
            validator=inputWorkspaceValidator,
            direction=Direction.Input),
                             doc='Input workspace.')
        self.declareProperty(WorkspaceProperty(name=common.PROP_OUTPUT_WS,
                                               defaultValue='',
                                               direction=Direction.Output),
                             doc='The output of the algorithm.')
        self.declareProperty(name=common.PROP_CLEANUP_MODE,
                             defaultValue=common.CLEANUP_ON,
                             validator=StringListValidator(
                                 [common.CLEANUP_ON, common.CLEANUP_OFF]),
                             direction=Direction.Input,
                             doc='What to do with intermediate workspaces.')
        self.declareProperty(
            name=common.PROP_SUBALG_LOGGING,
            defaultValue=common.SUBALG_LOGGING_OFF,
            validator=StringListValidator(
                [common.SUBALG_LOGGING_OFF, common.SUBALG_LOGGING_ON]),
            direction=Direction.Input,
            doc='Enable or disable subalgorithms to ' + 'print in the logs.')
        self.declareProperty(MatrixWorkspaceProperty(
            name=common.PROP_EC_WS,
            defaultValue='',
            validator=inputWorkspaceValidator,
            direction=Direction.Input,
            optional=PropertyMode.Optional),
                             doc='Reduced empty container workspace.')
        self.declareProperty(name=common.PROP_EC_SCALING,
                             defaultValue=1.0,
                             validator=scalingFactor,
                             direction=Direction.Input,
                             doc='Scaling factor (transmission, if no self ' +
                             'shielding is applied) for empty container.')
        self.declareProperty(
            MatrixWorkspaceProperty(
                name=common.PROP_SELF_SHIELDING_CORRECTION_WS,
                defaultValue='',
                direction=Direction.Input,
                optional=PropertyMode.Optional),
            doc='A workspace containing self shielding correction factors.')
 def PyInit(self):
     """Initialize the input and output properties of the algorithm."""
     positiveFloat = FloatBoundedValidator(lower=0., exclusive=True)
     self.declareProperty(
         MatrixWorkspaceProperty(
             Prop.INPUT_WS,
             defaultValue='',
             direction=Direction.Input,
             validator=WorkspaceUnitValidator('Wavelength')),
         doc='A reflectivity workspace in wavelength to be converted to Q.')
     self.declareProperty(
         MatrixWorkspaceProperty(
             Prop.OUTPUT_WS,
             defaultValue='',
             direction=Direction.Output),
         doc='The input workspace in momentum transfer.')
     self.declareProperty(
         Prop.SUBALG_LOGGING,
         defaultValue=SubalgLogging.OFF,
         validator=StringListValidator([SubalgLogging.OFF, SubalgLogging.ON]),
         doc='Enable or disable child algorithm logging.')
     self.declareProperty(
         Prop.CLEANUP,
         defaultValue=utils.Cleanup.ON,
         validator=StringListValidator([utils.Cleanup.ON, utils.Cleanup.OFF]),
         doc='Enable or disable intermediate workspace cleanup.')
     self.declareProperty(
         MatrixWorkspaceProperty(
             Prop.DIRECT_FOREGROUND_WS,
             defaultValue='',
             direction=Direction.Input,
             validator=WorkspaceUnitValidator('Wavelength')),
         doc='Summed direct beam workspace.')
     self.declareProperty(
         Prop.GROUPING_FRACTION,
         defaultValue=Property.EMPTY_DBL,
         validator=positiveFloat,
         doc='If set, group the output by steps of this fraction multiplied by Q resolution')
Example #17
0
    def PyInit(self):
        validator = CompositeValidator()
        validator.add(WorkspaceUnitValidator('Wavelength'))
        validator.add(HistogramValidator())
        validator.add(InstrumentValidator())

        self.declareProperty(MatrixWorkspaceProperty('InputWorkspace', defaultValue='',
                                                     validator = validator,
                                                     direction = Direction.Input),
                             doc='The input workspace in wavelength')

        self.declareProperty('BeamRadius', 0.1, FloatBoundedValidator(lower=0.), 'The radius of the beam [m]')

        self.declareProperty(MatrixWorkspaceProperty('OutputWorkspace',
                                                     defaultValue='',
                                                     direction = Direction.Output),
                             doc='The output workspace')
    def PyInit(self):
        # State
        self.declareProperty(
            PropertyManagerProperty('SANSState'),
            doc='A property manager which fulfills the SANSState contract.')
        # Input workspaces
        workspace_validator = CompositeValidator()
        workspace_validator.add(WorkspaceUnitValidator("Wavelength"))

        self.declareProperty(
            MatrixWorkspaceProperty("TransmissionWorkspace",
                                    '',
                                    optional=PropertyMode.Optional,
                                    direction=Direction.Input,
                                    validator=workspace_validator),
            doc='The calculated transmission workspace in wavelength units.')
        self.declareProperty(
            MatrixWorkspaceProperty("NormalizeToMonitorWorkspace",
                                    '',
                                    optional=PropertyMode.Mandatory,
                                    direction=Direction.Input,
                                    validator=workspace_validator),
            doc='The monitor normalization workspace in wavelength units.')
        allowed_detector_types = StringListValidator([
            DetectorType.to_string(DetectorType.HAB),
            DetectorType.to_string(DetectorType.LAB)
        ])
        self.declareProperty(
            "Component",
            DetectorType.to_string(DetectorType.LAB),
            validator=allowed_detector_types,
            direction=Direction.Input,
            doc=
            "The component of the instrument which is currently being investigated."
        )

        # Output workspace
        self.declareProperty(MatrixWorkspaceProperty(
            "OutputWorkspaceWavelengthAdjustment",
            '',
            direction=Direction.Output),
                             doc='A wavelength adjustment output workspace.')
        self.declareProperty(MatrixWorkspaceProperty(
            "OutputWorkspacePixelAdjustment", '', direction=Direction.Output),
                             doc='A pixel adjustment output workspace.')
Example #19
0
    def PyInit(self):
        # ----------
        # INPUT
        # ----------
        # State
        self.declareProperty(PropertyManagerProperty('SANSState'),
                             doc='A property manager which fulfills the SANSState contract.')

        # Main workspace
        workspace_validator = CompositeValidator()
        workspace_validator.add(WorkspaceUnitValidator("Wavelength"))
        self.declareProperty(MatrixWorkspaceProperty("InputWorkspace", '',
                                                     optional=PropertyMode.Mandatory, direction=Direction.Input,
                                                     validator=workspace_validator),
                             doc='The main input workspace.')

        # Adjustment workspaces
        self.declareProperty(MatrixWorkspaceProperty("InputWorkspaceWavelengthAdjustment", '',
                                                     optional=PropertyMode.Optional, direction=Direction.Input,
                                                     validator=workspace_validator),
                             doc='The workspace which contains only wavelength-specific adjustments, ie which affects '
                                 'all spectra equally.')
        self.declareProperty(MatrixWorkspaceProperty("InputWorkspacePixelAdjustment", '',
                                                     optional=PropertyMode.Optional, direction=Direction.Input),
                             doc='The workspace which contains only pixel-specific adjustments, ie which affects '
                                 'all bins within a spectrum equally.')
        self.declareProperty(MatrixWorkspaceProperty("InputWorkspaceWavelengthAndPixelAdjustment", '',
                                                     optional=PropertyMode.Optional, direction=Direction.Input,
                                                     validator=workspace_validator),
                             doc='The workspace which contains wavelength- and pixel-specific adjustments.')

        self.declareProperty('OutputParts', defaultValue=False,
                             direction=Direction.Input,
                             doc='Set to true to output two additional workspaces which will have the names '
                                 'OutputWorkspace_sumOfCounts OutputWorkspace_sumOfNormFactors. The division '
                                 'of _sumOfCounts and _sumOfNormFactors equals the workspace returned by the '
                                 'property OutputWorkspace (default is false).')

        # ----------
        # Output
        # ----------
        self.declareProperty(MatrixWorkspaceProperty("OutputWorkspace", '',
                                                     optional=PropertyMode.Mandatory, direction=Direction.Output),
                             doc="The reduced workspace")
Example #20
0
 def PyInit(self):
     """
     Declare properties
     """
     allowed_units = WorkspaceUnitValidator("MomentumTransfer")
     self.declareProperty(
         MatrixWorkspaceProperty("InputWorkspace",
                                 "",
                                 direction=Direction.Input,
                                 validator=allowed_units),
         doc="Input workspace with units of momentum transfer")
     functions = [SQ, FQ, FKQ, DCS]
     self.declareProperty("From", SQ, StringListValidator(functions),
                          "Function type in the input workspace")
     self.declareProperty("To", SQ, StringListValidator(functions),
                          "Function type in the output workspace")
     self.declareProperty(WorkspaceProperty('OutputWorkspace',
                                            '',
                                            direction=Direction.Output),
                          doc='Output workspace')
Example #21
0
 def PyInit(self):
     """ Declare properties
     """
     validator = CompositeValidator()
     validator.add(WorkspaceUnitValidator("TOF"))
     validator.add(InstrumentValidator())
     self.declareProperty(MatrixWorkspaceProperty("InputWorkspace",
                                                  "",
                                                  direction=Direction.Input,
                                                  validator=validator),
                          doc="Input workspace.")
     self.declareProperty(
         ITableWorkspaceProperty("EPPTable", "", direction=Direction.Input),
         doc="Input EPP table. May be produced by FindEPP algorithm.")
     self.declareProperty(
         MatrixWorkspaceProperty("OutputWorkspace",
                                 "",
                                 direction=Direction.Output),
         doc="Name of the workspace that will contain the results")
     return
 def PyInit(self):
     """Initialize the input and output properties of the algorithm."""
     nonnegativeInt = IntBoundedValidator(lower=0)
     wsIndexRange = IntBoundedValidator(lower=0, upper=255)
     nonnegativeIntArray = IntArrayBoundedValidator(lower=0)
     maxTwoNonnegativeInts = CompositeValidator()
     maxTwoNonnegativeInts.add(IntArrayLengthValidator(lenmin=0, lenmax=2))
     maxTwoNonnegativeInts.add(nonnegativeIntArray)
     self.declareProperty(MultipleFileProperty(
         Prop.RUN, action=FileAction.OptionalLoad, extensions=['nxs']),
                          doc='A list of input run numbers/files.')
     self.declareProperty(
         MatrixWorkspaceProperty(Prop.INPUT_WS,
                                 defaultValue='',
                                 direction=Direction.Input,
                                 validator=WorkspaceUnitValidator('TOF'),
                                 optional=PropertyMode.Optional),
         doc='An input workspace (units TOF) if no Run is specified.')
     self.declareProperty(
         MatrixWorkspaceProperty(Prop.OUTPUT_WS,
                                 defaultValue='',
                                 direction=Direction.Output),
         doc=
         'The preprocessed output workspace (unit wavelength), single histogram.'
     )
     self.declareProperty(
         Prop.TWO_THETA,
         defaultValue=Property.EMPTY_DBL,
         doc='A user-defined scattering angle 2 theta (unit degrees).')
     self.declareProperty(
         name=Prop.LINE_POSITION,
         defaultValue=Property.EMPTY_DBL,
         doc=
         'A workspace index corresponding to the beam centre between 0.0 and 255.0.'
     )
     self.declareProperty(MatrixWorkspaceProperty(
         Prop.DIRECT_LINE_WORKSPACE,
         defaultValue='',
         direction=Direction.Input,
         optional=PropertyMode.Optional),
                          doc='A pre-processed direct beam workspace.')
     self.declareProperty(Prop.SUBALG_LOGGING,
                          defaultValue=SubalgLogging.OFF,
                          validator=StringListValidator(
                              [SubalgLogging.OFF, SubalgLogging.ON]),
                          doc='Enable or disable child algorithm logging.')
     self.declareProperty(
         Prop.CLEANUP,
         defaultValue=utils.Cleanup.ON,
         validator=StringListValidator(
             [utils.Cleanup.ON, utils.Cleanup.OFF]),
         doc='Enable or disable intermediate workspace cleanup.')
     self.declareProperty(MatrixWorkspaceProperty(
         Prop.WATER_REFERENCE,
         defaultValue='',
         direction=Direction.Input,
         validator=WorkspaceUnitValidator("TOF"),
         optional=PropertyMode.Optional),
                          doc='A (water) calibration workspace (unit TOF).')
     self.declareProperty(Prop.SLIT_NORM,
                          defaultValue=SlitNorm.OFF,
                          validator=StringListValidator(
                              [SlitNorm.OFF, SlitNorm.ON]),
                          doc='Enable or disable slit normalisation.')
     self.declareProperty(Prop.FLUX_NORM_METHOD,
                          defaultValue=FluxNormMethod.TIME,
                          validator=StringListValidator([
                              FluxNormMethod.TIME, FluxNormMethod.MONITOR,
                              FluxNormMethod.OFF
                          ]),
                          doc='Neutron flux normalisation method.')
     self.declareProperty(
         IntArrayProperty(Prop.FOREGROUND_HALF_WIDTH,
                          validator=maxTwoNonnegativeInts),
         doc=
         'Number of foreground pixels at lower and higher angles from the centre pixel.'
     )
     self.declareProperty(
         Prop.BKG_METHOD,
         defaultValue=BkgMethod.CONSTANT,
         validator=StringListValidator(
             [BkgMethod.CONSTANT, BkgMethod.LINEAR, BkgMethod.OFF]),
         doc='Flat background calculation method for background subtraction.'
     )
     self.declareProperty(
         Prop.LOW_BKG_OFFSET,
         defaultValue=7,
         validator=nonnegativeInt,
         doc=
         'Distance of flat background region towards smaller detector angles from the '
         + 'foreground centre, in pixels.')
     self.declareProperty(
         Prop.LOW_BKG_WIDTH,
         defaultValue=5,
         validator=nonnegativeInt,
         doc=
         'Width of flat background region towards smaller detector angles from the '
         + 'foreground centre, in pixels.')
     self.declareProperty(
         Prop.HIGH_BKG_OFFSET,
         defaultValue=7,
         validator=nonnegativeInt,
         doc=
         'Distance of flat background region towards larger detector angles from the '
         + 'foreground centre, in pixels.')
     self.declareProperty(
         Prop.HIGH_BKG_WIDTH,
         defaultValue=5,
         validator=nonnegativeInt,
         doc=
         'Width of flat background region towards larger detector angles from the '
         + 'foreground centre, in pixels.')
     self.declareProperty(
         Prop.START_WS_INDEX,
         validator=wsIndexRange,
         defaultValue=0,
         doc='Start workspace index used for peak fitting.')
     self.declareProperty(Prop.END_WS_INDEX,
                          validator=wsIndexRange,
                          defaultValue=255,
                          doc='Last workspace index used for peak fitting.')
     self.declareProperty(
         Prop.XMIN,
         defaultValue=Property.EMPTY_DBL,
         doc='Minimum x value (unit Angstrom) used for peak fitting.')
     self.declareProperty(
         Prop.XMAX,
         defaultValue=Property.EMPTY_DBL,
         doc='Maximum x value (unit Angstrom) used for peak fitting.')
Example #23
0
    def PyInit(self):
        """Initialize the algorithm's input and output properties."""
        PROPGROUP_BEAM_STOP_DIAGNOSTICS = 'Beam Stop Diagnostics'
        PROPGROUP_BKG_DIAGNOSTICS = 'Background Diagnostics'
        PROPGROUP_PEAK_DIAGNOSTICS = 'Elastic Peak Diagnostics'
        PROPGROUP_USER_MASK = 'Additional Masking'
        greaterThanUnityFloat = FloatBoundedValidator(lower=1)
        inputWorkspaceValidator = CompositeValidator()
        inputWorkspaceValidator.add(InstrumentValidator())
        inputWorkspaceValidator.add(WorkspaceUnitValidator('TOF'))
        positiveFloat = FloatBoundedValidator(lower=0)
        positiveIntArray = IntArrayBoundedValidator()
        positiveIntArray.setLower(0)
        scalingFactor = FloatBoundedValidator(lower=0, upper=1)

        # Properties.
        self.declareProperty(
            MatrixWorkspaceProperty(name=common.PROP_INPUT_WS,
                                    defaultValue='',
                                    validator=inputWorkspaceValidator,
                                    direction=Direction.Input),
            doc=
            "A 'raw' workspace from DirectILLCollectData to calculate the diagnostics from."
        )
        self.declareProperty(WorkspaceProperty(name=common.PROP_OUTPUT_WS,
                                               defaultValue='',
                                               direction=Direction.Output),
                             doc='A diagnostics mask workspace.')
        self.declareProperty(name=common.PROP_CLEANUP_MODE,
                             defaultValue=common.CLEANUP_ON,
                             validator=StringListValidator(
                                 [common.CLEANUP_ON, common.CLEANUP_OFF]),
                             direction=Direction.Input,
                             doc='What to do with intermediate workspaces.')
        self.declareProperty(
            name=common.PROP_SUBALG_LOGGING,
            defaultValue=common.SUBALG_LOGGING_OFF,
            validator=StringListValidator(
                [common.SUBALG_LOGGING_OFF, common.SUBALG_LOGGING_ON]),
            direction=Direction.Input,
            doc='Enable or disable subalgorithms to ' + 'print in the logs.')
        self.declareProperty(
            ITableWorkspaceProperty(name=common.PROP_EPP_WS,
                                    defaultValue='',
                                    direction=Direction.Input,
                                    optional=PropertyMode.Optional),
            doc='Table workspace containing results from the FindEPP algorithm.'
        )
        self.declareProperty(name=common.PROP_ELASTIC_PEAK_DIAGNOSTICS,
                             defaultValue=common.ELASTIC_PEAK_DIAGNOSTICS_AUTO,
                             validator=StringListValidator([
                                 common.ELASTIC_PEAK_DIAGNOSTICS_AUTO,
                                 common.ELASTIC_PEAK_DIAGNOSTICS_ON,
                                 common.ELASTIC_PEAK_DIAGNOSTICS_OFF
                             ]),
                             direction=Direction.Input,
                             doc='Enable or disable elastic peak diagnostics.')
        self.setPropertyGroup(common.PROP_ELASTIC_PEAK_DIAGNOSTICS,
                              PROPGROUP_PEAK_DIAGNOSTICS)
        self.declareProperty(
            name=common.PROP_ELASTIC_PEAK_SIGMA_MULTIPLIER,
            defaultValue=3.0,
            validator=positiveFloat,
            direction=Direction.Input,
            doc="Integration half width of the elastic peak in multiples " +
            " of 'Sigma' in the EPP table.")
        self.setPropertyGroup(common.PROP_ELASTIC_PEAK_SIGMA_MULTIPLIER,
                              PROPGROUP_PEAK_DIAGNOSTICS)
        self.declareProperty(name=common.PROP_PEAK_DIAGNOSTICS_LOW_THRESHOLD,
                             defaultValue=Property.EMPTY_DBL,
                             validator=positiveFloat,
                             direction=Direction.Input,
                             doc='Multiplier for lower acceptance limit ' +
                             'used in elastic peak diagnostics.')
        self.setPropertyGroup(common.PROP_PEAK_DIAGNOSTICS_LOW_THRESHOLD,
                              PROPGROUP_PEAK_DIAGNOSTICS)
        self.declareProperty(name=common.PROP_PEAK_DIAGNOSTICS_HIGH_THRESHOLD,
                             defaultValue=Property.EMPTY_DBL,
                             validator=greaterThanUnityFloat,
                             direction=Direction.Input,
                             doc='Multiplier for higher acceptance limit ' +
                             'used in elastic peak diagnostics.')
        self.setPropertyGroup(common.PROP_PEAK_DIAGNOSTICS_HIGH_THRESHOLD,
                              PROPGROUP_PEAK_DIAGNOSTICS)
        self.declareProperty(
            name=common.PROP_PEAK_DIAGNOSTICS_SIGNIFICANCE_TEST,
            defaultValue=Property.EMPTY_DBL,
            validator=positiveFloat,
            direction=Direction.Input,
            doc=
            'To fail the elastic peak diagnostics, the intensity must also exceed '
            +
            'this number of error bars with respect to the median intensity.')
        self.setPropertyGroup(common.PROP_PEAK_DIAGNOSTICS_SIGNIFICANCE_TEST,
                              PROPGROUP_PEAK_DIAGNOSTICS)
        self.declareProperty(name=common.PROP_BKG_DIAGNOSTICS,
                             defaultValue=common.BKG_DIAGNOSTICS_AUTO,
                             validator=StringListValidator([
                                 common.BKG_DIAGNOSTICS_AUTO,
                                 common.BKG_DIAGNOSTICS_ON,
                                 common.BKG_DIAGNOSTICS_OFF
                             ]),
                             direction=Direction.Input,
                             doc='Control the background diagnostics.')
        self.setPropertyGroup(common.PROP_BKG_DIAGNOSTICS,
                              PROPGROUP_BKG_DIAGNOSTICS)
        self.declareProperty(
            name=common.PROP_BKG_SIGMA_MULTIPLIER,
            defaultValue=10.0,
            validator=positiveFloat,
            direction=Direction.Input,
            doc=
            "Width of the range excluded from background integration around " +
            "the elastic peaks in multiplies of 'Sigma' in the EPP table")
        self.setPropertyGroup(common.PROP_BKG_SIGMA_MULTIPLIER,
                              PROPGROUP_BKG_DIAGNOSTICS)
        self.declareProperty(name=common.PROP_BKG_DIAGNOSTICS_LOW_THRESHOLD,
                             defaultValue=Property.EMPTY_DBL,
                             validator=positiveFloat,
                             direction=Direction.Input,
                             doc='Multiplier for lower acceptance limit ' +
                             'used in noisy background diagnostics.')
        self.setPropertyGroup(common.PROP_BKG_DIAGNOSTICS_LOW_THRESHOLD,
                              PROPGROUP_BKG_DIAGNOSTICS)
        self.declareProperty(name=common.PROP_BKG_DIAGNOSTICS_HIGH_THRESHOLD,
                             defaultValue=Property.EMPTY_DBL,
                             validator=greaterThanUnityFloat,
                             direction=Direction.Input,
                             doc='Multiplier for higher acceptance limit ' +
                             'used in noisy background diagnostics.')
        self.setPropertyGroup(common.PROP_BKG_DIAGNOSTICS_HIGH_THRESHOLD,
                              PROPGROUP_BKG_DIAGNOSTICS)
        self.declareProperty(
            name=common.PROP_BKG_DIAGNOSTICS_SIGNIFICANCE_TEST,
            defaultValue=Property.EMPTY_DBL,
            validator=positiveFloat,
            direction=Direction.Input,
            doc=
            'To fail the background diagnostics, the background level must also exceed '
            + 'this number of error bars with respect to the median level.')
        self.setPropertyGroup(common.PROP_BKG_DIAGNOSTICS_SIGNIFICANCE_TEST,
                              PROPGROUP_BKG_DIAGNOSTICS)
        self.declareProperty(name=common.PROP_BEAM_STOP_DIAGNOSTICS,
                             defaultValue=common.BEAM_STOP_DIAGNOSTICS_AUTO,
                             validator=StringListValidator([
                                 common.BEAM_STOP_DIAGNOSTICS_AUTO,
                                 common.BEAM_STOP_DIAGNOSTICS_ON,
                                 common.BEAM_STOP_DIAGNOSTICS_OFF
                             ]),
                             direction=Direction.Input,
                             doc='Control the beam stop diagnostics.')
        self.setPropertyGroup(common.PROP_BEAM_STOP_DIAGNOSTICS,
                              PROPGROUP_BEAM_STOP_DIAGNOSTICS)
        self.declareProperty(
            name=common.PROP_BEAM_STOP_THRESHOLD,
            defaultValue=0.67,
            validator=scalingFactor,
            direction=Direction.Input,
            doc=
            'Multiplier for the lower acceptance limit for beam stop diagnostics.'
        )
        self.setPropertyGroup(common.PROP_BEAM_STOP_THRESHOLD,
                              PROPGROUP_BEAM_STOP_DIAGNOSTICS)
        self.declareProperty(
            name=common.PROP_DEFAULT_MASK,
            defaultValue=common.DEFAULT_MASK_ON,
            validator=StringListValidator(
                [common.DEFAULT_MASK_ON, common.DEFAULT_MASK_OFF]),
            direction=Direction.Input,
            doc='Enable or disable instrument specific default mask.')
        self.declareProperty(IntArrayProperty(name=common.PROP_USER_MASK,
                                              values='',
                                              validator=positiveIntArray,
                                              direction=Direction.Input),
                             doc='List of spectra to mask.')
        self.setPropertyGroup(common.PROP_USER_MASK, PROPGROUP_USER_MASK)
        self.declareProperty(StringArrayProperty(
            name=common.PROP_USER_MASK_COMPONENTS,
            values='',
            direction=Direction.Input),
                             doc='List of instrument components to mask.')
        self.setPropertyGroup(common.PROP_USER_MASK_COMPONENTS,
                              PROPGROUP_USER_MASK)
        # Rest of the output properties
        self.declareProperty(
            ITableWorkspaceProperty(
                name=common.PROP_OUTPUT_DIAGNOSTICS_REPORT_WS,
                defaultValue='',
                direction=Direction.Output,
                optional=PropertyMode.Optional),
            doc='Output table workspace for detector diagnostics reporting.')
        self.setPropertyGroup(common.PROP_OUTPUT_DIAGNOSTICS_REPORT_WS,
                              common.PROPGROUP_OPTIONAL_OUTPUT)
        self.declareProperty(name=common.PROP_OUTPUT_DIAGNOSTICS_REPORT,
                             defaultValue='',
                             direction=Direction.Output,
                             doc='Diagnostics report as a string.')
        self.setPropertyGroup(common.PROP_OUTPUT_DIAGNOSTICS_REPORT,
                              common.PROPGROUP_OPTIONAL_OUTPUT)
Example #24
0
    def PyInit(self):
        """Initialize the algorithm's input and output properties."""
        PROPGROUP_SIMULATION_INSTRUMENT = 'Simulation Instrument Settings'
        greaterThanOneInt = IntBoundedValidator(lower=2)
        greaterThanTwoInt = IntBoundedValidator(lower=3)
        inputWorkspaceValidator = CompositeValidator()
        inputWorkspaceValidator.add(InstrumentValidator())
        inputWorkspaceValidator.add(WorkspaceUnitValidator('TOF'))

        # Properties.
        self.declareProperty(
            MatrixWorkspaceProperty(name=common.PROP_INPUT_WS,
                                    defaultValue='',
                                    validator=inputWorkspaceValidator,
                                    optional=PropertyMode.Optional,
                                    direction=Direction.Input),
            doc='A workspace for which to simulate the self shielding.')
        self.declareProperty(
            MatrixWorkspaceProperty(name=common.PROP_OUTPUT_WS,
                                    defaultValue='',
                                    direction=Direction.Output),
            doc='A workspace containing the self shielding correction factors.'
        )
        self.declareProperty(name=common.PROP_CLEANUP_MODE,
                             defaultValue=common.CLEANUP_ON,
                             validator=StringListValidator(
                                 [common.CLEANUP_ON, common.CLEANUP_OFF]),
                             direction=Direction.Input,
                             doc='What to do with intermediate workspaces.')
        self.declareProperty(
            name=common.PROP_SUBALG_LOGGING,
            defaultValue=common.SUBALG_LOGGING_OFF,
            validator=StringListValidator(
                [common.SUBALG_LOGGING_OFF, common.SUBALG_LOGGING_ON]),
            direction=Direction.Input,
            doc='Enable or disable subalgorithms to ' + 'print in the logs.')
        self.declareProperty(
            name=common.PROP_SIMULATION_INSTRUMENT,
            defaultValue=common.SIMULATION_INSTRUMEN_SPARSE,
            validator=StringListValidator([
                common.SIMULATION_INSTRUMEN_SPARSE,
                common.SIMULATION_INSTRUMENT_FULL
            ]),
            direction=Direction.Input,
            doc=
            'Select if the simulation should be performed on full or approximated instrument.'
        )
        self.setPropertyGroup(common.PROP_SIMULATION_INSTRUMENT,
                              PROPGROUP_SIMULATION_INSTRUMENT)
        self.declareProperty(
            name=common.PROP_SPARSE_INSTRUMENT_ROWS,
            defaultValue=5,
            validator=greaterThanTwoInt,
            direction=Direction.Input,
            doc='Number of detector rows in sparse simulation instrument.')
        self.setPropertyGroup(common.PROP_SPARSE_INSTRUMENT_ROWS,
                              PROPGROUP_SIMULATION_INSTRUMENT)
        self.setPropertySettings(
            common.PROP_SPARSE_INSTRUMENT_ROWS,
            EnabledWhenProperty(common.PROP_SIMULATION_INSTRUMENT,
                                PropertyCriterion.IsEqualTo,
                                common.SIMULATION_INSTRUMEN_SPARSE))
        self.declareProperty(
            name=common.PROP_SPARSE_INSTRUMENT_COLUMNS,
            defaultValue=20,
            validator=greaterThanOneInt,
            direction=Direction.Input,
            doc='Number of detector columns in sparse simulation instrument.')
        self.setPropertyGroup(common.PROP_SPARSE_INSTRUMENT_COLUMNS,
                              PROPGROUP_SIMULATION_INSTRUMENT)
        self.setPropertySettings(
            common.PROP_SPARSE_INSTRUMENT_COLUMNS,
            EnabledWhenProperty(common.PROP_SIMULATION_INSTRUMENT,
                                PropertyCriterion.IsEqualTo,
                                common.SIMULATION_INSTRUMEN_SPARSE))
        self.declareProperty(
            name=common.PROP_NUMBER_OF_SIMULATION_WAVELENGTHS,
            defaultValue=Property.EMPTY_INT,
            validator=greaterThanTwoInt,
            direction=Direction.Input,
            doc=
            'Number of wavelength points where the simulation is performed (default: all).'
        )
Example #25
0
    def PyInit(self):
        """Initialize the algorithm's input and output properties."""
        PROPGROUP_FLAT_BKG = 'Flat Time-Independent Background'
        PROPGROUP_INCIDENT_ENERGY_CALIBRATION = 'Indicent Energy Calibration'
        PROPGROUP_MON_NORMALISATION = 'Neutron Flux Normalisation'
        # Validators.
        mandatoryPositiveInt = CompositeValidator()
        mandatoryPositiveInt.add(IntMandatoryValidator())
        mandatoryPositiveInt.add(IntBoundedValidator(lower=0))
        positiveFloat = FloatBoundedValidator(lower=0)
        positiveInt = IntBoundedValidator(lower=0)
        inputWorkspaceValidator = CompositeValidator()
        inputWorkspaceValidator.add(InstrumentValidator())
        inputWorkspaceValidator.add(WorkspaceUnitValidator('TOF'))

        # Properties.
        self.declareProperty(MultipleFileProperty(name=common.PROP_INPUT_FILE,
                                                  action=FileAction.OptionalLoad,
                                                  extensions=['nxs']),
                             doc='An input run number (or a list thereof) or a filename.')
        self.getProperty(common.PROP_INPUT_FILE).setAutoTrim(False)
        self.declareProperty(MatrixWorkspaceProperty(
            name=common.PROP_INPUT_WS,
            defaultValue='',
            validator=inputWorkspaceValidator,
            optional=PropertyMode.Optional,
            direction=Direction.Input),
            doc='Input workspace if no run is given.')
        self.declareProperty(WorkspaceProperty(name=common.PROP_OUTPUT_WS,
                                               defaultValue='',
                                               direction=Direction.Output),
                             doc='A flux normalized and background subtracted workspace.')
        self.declareProperty(name=common.PROP_CLEANUP_MODE,
                             defaultValue=utils.Cleanup.ON,
                             validator=StringListValidator([
                                 utils.Cleanup.ON,
                                 utils.Cleanup.OFF]),
                             direction=Direction.Input,
                             doc='What to do with intermediate workspaces.')
        self.declareProperty(name=common.PROP_SUBALG_LOGGING,
                             defaultValue=common.SUBALG_LOGGING_OFF,
                             validator=StringListValidator([
                                 common.SUBALG_LOGGING_OFF,
                                 common.SUBALG_LOGGING_ON]),
                             direction=Direction.Input,
                             doc='Enable or disable subalgorithms to ' + 'print in the logs.')
        self.declareProperty(name=common.PROP_EPP_METHOD,
                             defaultValue=common.EPP_METHOD_AUTO,
                             validator=StringListValidator([
                                 common.EPP_METHOD_AUTO,
                                 common.EPP_METHOD_FIT,
                                 common.EPP_METHOD_CALCULATE]),
                             direction=Direction.Input,
                             doc='Method to create the EPP table for detectors (monitor is awlays fitted).')
        self.declareProperty(name=common.PROP_EPP_SIGMA,
                             defaultValue=Property.EMPTY_DBL,
                             validator=positiveFloat,
                             direction=Direction.Input,
                             doc='Nominal sigma for the EPP table when ' + common.PROP_EPP_METHOD
                                 + ' is set to ' + common.EPP_METHOD_CALCULATE
                                 + ' (default: 10 times the first bin width).')
        self.declareProperty(name=common.PROP_ELASTIC_CHANNEL_MODE,
                             defaultValue=common.ELASTIC_CHANNEL_AUTO,
                             validator=StringListValidator([
                                 common.ELASTIC_CHANNEL_AUTO,
                                 common.ELASTIC_CHANNEL_SAMPLE_LOG,
                                 common.ELASTIC_CHANNEL_FIT]),
                             direction=Direction.Input,
                             doc='How to acquire the nominal elastic channel.')
        self.declareProperty(MatrixWorkspaceProperty(
                             name=common.PROP_ELASTIC_CHANNEL_WS,
                             defaultValue='',
                             direction=Direction.Input,
                             optional=PropertyMode.Optional),
                             doc='A single value workspace containing the nominal elastic channel index'
                                 '(can be floating point). Overrides {}.'.format(common.PROP_ELASTIC_CHANNEL_MODE))
        self.declareProperty(name=common.PROP_MON_INDEX,
                             defaultValue=Property.EMPTY_INT,
                             validator=positiveInt,
                             direction=Direction.Input,
                             doc='Index of the incident monitor, if not specified in instrument parameters.')
        self.declareProperty(name=common.PROP_INCIDENT_ENERGY_CALIBRATION,
                             defaultValue=common.INCIDENT_ENERGY_CALIBRATION_AUTO,
                             validator=StringListValidator([
                                 common.INCIDENT_ENERGY_CALIBRATION_AUTO,
                                 common.INCIDENT_ENERGY_CALIBRATION_ON,
                                 common.INCIDENT_ENERGY_CALIBRATION_OFF]),
                             direction=Direction.Input,
                             doc='Control the incident energy calibration.')
        self.setPropertyGroup(common.PROP_INCIDENT_ENERGY_CALIBRATION, PROPGROUP_INCIDENT_ENERGY_CALIBRATION)
        self.declareProperty(MatrixWorkspaceProperty(
            name=common.PROP_INCIDENT_ENERGY_WS,
            defaultValue='',
            direction=Direction.Input,
            optional=PropertyMode.Optional),
            doc='A single-valued workspace holding a previously determined ' + 'incident energy.')
        self.setPropertyGroup(common.PROP_INCIDENT_ENERGY_WS, PROPGROUP_INCIDENT_ENERGY_CALIBRATION)
        self.declareProperty(name=common.PROP_FLAT_BKG,
                             defaultValue=common.BKG_AUTO,
                             validator=StringListValidator([
                                 common.BKG_AUTO,
                                 common.BKG_ON,
                                 common.BKG_OFF]),
                             direction=Direction.Input,
                             doc='Control flat background subtraction.')
        self.setPropertyGroup(common.PROP_FLAT_BKG, PROPGROUP_FLAT_BKG)
        self.declareProperty(name=common.PROP_FLAT_BKG_SCALING,
                             defaultValue=1.0,
                             validator=positiveFloat,
                             direction=Direction.Input,
                             doc='Flat background multiplication factor.')
        self.setPropertyGroup(common.PROP_FLAT_BKG_SCALING, PROPGROUP_FLAT_BKG)
        self.declareProperty(name=common.PROP_FLAT_BKG_WINDOW,
                             defaultValue=30,
                             validator=mandatoryPositiveInt,
                             direction=Direction.Input,
                             doc='Running average window width (in bins) for flat background.')
        self.setPropertyGroup(common.PROP_FLAT_BKG_WINDOW, PROPGROUP_FLAT_BKG)
        self.declareProperty(MatrixWorkspaceProperty(
            name=common.PROP_FLAT_BKG_WS,
            defaultValue='',
            direction=Direction.Input,
            optional=PropertyMode.Optional),
            doc='Workspace with previously determined flat background data.')
        self.setPropertyGroup(common.PROP_FLAT_BKG_WS, PROPGROUP_FLAT_BKG)
        self.declareProperty(name=common.PROP_DET_HOR_GROUPING,
                             defaultValue=1,
                             doc='Step to use when grouping detectors horizontally (between tubes) to increase'
                                 ' the statistics for flat background calculation.')
        self.setPropertyGroup(common.PROP_DET_HOR_GROUPING, PROPGROUP_FLAT_BKG)
        self.declareProperty(name=common.PROP_DET_VER_GROUPING,
                             defaultValue=1,
                             doc='Step to use when grouping detectors vertically (inside the same tube)'
                                 ' to increase the statistics for flat background calculation.')
        self.setPropertyGroup(common.PROP_DET_VER_GROUPING, PROPGROUP_FLAT_BKG)
        self.declareProperty(name=common.PROP_NORMALISATION,
                             defaultValue=common.NORM_METHOD_MON,
                             validator=StringListValidator([
                                 common.NORM_METHOD_MON,
                                 common.NORM_METHOD_TIME,
                                 common.NORM_METHOD_OFF]),
                             direction=Direction.Input,
                             doc='Normalisation method.')
        self.setPropertyGroup(common.PROP_NORMALISATION, PROPGROUP_MON_NORMALISATION)
        self.declareProperty(name=common.PROP_MON_PEAK_SIGMA_MULTIPLIER,
                             defaultValue=7.0,
                             validator=positiveFloat,
                             direction=Direction.Input,
                             doc="Width of the monitor peak in multiples " + " of 'Sigma' in monitor's EPP table.")
        self.setPropertyGroup(common.PROP_MON_PEAK_SIGMA_MULTIPLIER, PROPGROUP_MON_NORMALISATION)
        # Rest of the output properties.
        self.declareProperty(WorkspaceProperty(
            name=common.PROP_OUTPUT_RAW_WS,
            defaultValue='',
            direction=Direction.Output,
            optional=PropertyMode.Optional),
            doc='Non-normalized and non-background subtracted output workspace for DirectILLDiagnostics.')
        self.setPropertyGroup(common.PROP_OUTPUT_RAW_WS,
                              common.PROPGROUP_OPTIONAL_OUTPUT)
        self.declareProperty(WorkspaceProperty(
            name=common.PROP_OUTPUT_ELASTIC_CHANNEL_WS,
            defaultValue='',
            direction=Direction.Output,
            optional=PropertyMode.Optional),
            doc='Output workspace for elastic channel index.')
        self.setPropertyGroup(common.PROP_OUTPUT_ELASTIC_CHANNEL_WS,
                              common.PROPGROUP_OPTIONAL_OUTPUT)
        self.declareProperty(ITableWorkspaceProperty(
            name=common.PROP_OUTPUT_DET_EPP_WS,
            defaultValue='',
            direction=Direction.Output,
            optional=PropertyMode.Optional),
            doc='Output workspace for elastic peak positions.')
        self.setPropertyGroup(common.PROP_OUTPUT_DET_EPP_WS,
                              common.PROPGROUP_OPTIONAL_OUTPUT)
        self.declareProperty(WorkspaceProperty(
            name=common.PROP_OUTPUT_INCIDENT_ENERGY_WS,
            defaultValue='',
            direction=Direction.Output,
            optional=PropertyMode.Optional),
            doc='Output workspace for calibrated incident energy.')
        self.setPropertyGroup(common.PROP_OUTPUT_INCIDENT_ENERGY_WS,
                              common.PROPGROUP_OPTIONAL_OUTPUT)
        self.declareProperty(WorkspaceProperty(
            name=common.PROP_OUTPUT_FLAT_BKG_WS,
            defaultValue='',
            direction=Direction.Output,
            optional=PropertyMode.Optional),
            doc='Output workspace for flat background.')
        self.setPropertyGroup(common.PROP_OUTPUT_FLAT_BKG_WS,
                              common.PROPGROUP_OPTIONAL_OUTPUT)
    def PyInit(self):
        self.declareProperty(
            WorkspaceProperty('InputWorkspace',
                              '',
                              direction=Direction.Input,
                              validator=WorkspaceUnitValidator('TOF')),
            doc=
            'Powder event data, ideally from a highly symmetric space group',
        )
        self.declareProperty(name='OutputWorkspacesPrefix',
                             defaultValue='pdcal_',
                             direction=Direction.Input,
                             doc="Prefix to be added to output workspaces")

        # PDCalibration properties exposed, grouped
        property_names = ['TofBinning', 'PeakFunction', 'PeakPositions']
        self.copyProperties('PDCalibration', property_names)
        [
            self.setPropertyGroup(name, 'PDCalibration')
            for name in property_names
        ]

        # "Source Position" properties
        self.declareProperty(name='FixSource',
                             defaultValue=True,
                             doc="Fix source's distance from the sample")
        self.declareProperty(
            name='SourceToSampleDistance',
            defaultValue=20.004,
            doc=
            'Set this value for a fixed distance from source to sample, in meters'
        )
        self.setPropertySettings(
            'SourceToSampleDistance',
            EnabledWhenProperty("FixSource", PropertyCriterion.IsDefault))
        self.declareProperty(name='AdjustSource',
                             defaultValue=False,
                             doc='Adjust Z-coordinate of the source')
        self.declareProperty(
            name='SourceMaxTranslation',
            defaultValue=0.1,
            doc=
            'Maximum adjustment of source position along the beam (Z) axis (m)'
        )
        self.setPropertySettings(
            "SourceMaxTranslation",
            EnabledWhenProperty("AdjustSource",
                                PropertyCriterion.IsNotDefault))
        property_names = [
            'FixSource', 'SourceToSampleDistance', 'AdjustSource',
            'SourceMaxTranslation'
        ]
        [
            self.setPropertyGroup(name, 'Source Calibration')
            for name in property_names
        ]

        # AlignComponents properties
        self.declareProperty(name='FixY',
                             defaultValue=True,
                             doc="Vertical bank position is left unchanged")
        self.declareProperty(StringArrayProperty('ComponentList',
                                                 values=self._banks,
                                                 direction=Direction.Input),
                             doc='Comma separated list on banks to refine')
        self.declareProperty(
            name='ComponentMaxTranslation',
            defaultValue=0.02,
            doc=
            'Maximum translation of each component along either of the X, Y, Z axes (m)'
        )
        self.declareProperty(
            name='FixYaw',
            defaultValue=True,
            doc="Prevent rotations around the axis normal to the bank")
        self.declareProperty(
            name='ComponentMaxRotation',
            defaultValue=3.0,
            doc=
            'Maximum rotation of each component along either of the X, Y, Z axes (deg)'
        )
        property_names = [
            'FixY', 'ComponentList', 'ComponentMaxTranslation', 'FixYaw',
            'ComponentMaxRotation'
        ]
        [
            self.setPropertyGroup(name, 'Banks Calibration')
            for name in property_names
        ]

        #
        # Minimization Properties
        self.declareProperty(
            name='Minimizer',
            defaultValue='L-BFGS-B',
            direction=Direction.Input,
            validator=StringListValidator(
                ['L-BFGS-B', 'differential_evolution']),
            doc=
            'Minimizer to use, differential_evolution is more accurate and slower.'
        )
        self.declareProperty(
            name='MaxIterations',
            defaultValue=20,
            direction=Direction.Input,
            doc=
            'Maximum number of iterations for minimizer differential_evolution'
        )

        properties = ['Minimizer', 'MaxIterations']
        [self.setPropertyGroup(name, "Minimization") for name in properties]
Example #27
0
    def PyInit(self):
        self.declareProperty(MatrixWorkspaceProperty(
            'InputWorkspace',
            '',
            direction=Direction.Input,
            validator=WorkspaceUnitValidator('Wavelength')),
                             doc='The input workspace.')

        self.declareProperty(MatrixWorkspaceProperty(
            'OutputWorkspace', '', direction=Direction.Output),
                             doc='The output workspace.')

        self.declareProperty(name='OutputType',
                             defaultValue='I(Q)',
                             validator=StringListValidator(
                                 ['I(Q)', 'I(Qx,Qy)', 'I(Phi,Q)']),
                             doc='Choose the output type.')

        self.declareProperty(name='CalculateResolution',
                             defaultValue='None',
                             validator=StringListValidator(
                                 ['MildnerCarpenter', 'None']),
                             doc='Choose to calculate the Q resolution.')

        output_iq = EnabledWhenProperty('OutputType',
                                        PropertyCriterion.IsEqualTo, 'I(Q)')
        output_iphiq = EnabledWhenProperty('OutputType',
                                           PropertyCriterion.IsEqualTo,
                                           'I(Phi,Q)')
        output_iqxy = EnabledWhenProperty('OutputType',
                                          PropertyCriterion.IsEqualTo,
                                          'I(Qx,Qy)')

        self.declareProperty(
            name='DefaultQBinning',
            defaultValue='PixelSizeBased',
            validator=StringListValidator(
                ['PixelSizeBased', 'ResolutionBased']),
            doc='Choose how to calculate the default Q binning.')
        self.setPropertySettings(
            'DefaultQBinning',
            EnabledWhenProperty(output_iq, output_iphiq, LogicOperator.Or))

        self.declareProperty(
            name='BinningFactor',
            defaultValue=1.,
            validator=FloatBoundedValidator(lower=0.),
            doc=
            'Specify a multiplicative factor for default Q binning (pixel or resolution based).'
        )
        self.setPropertySettings(
            'BinningFactor',
            EnabledWhenProperty(output_iq, output_iphiq, LogicOperator.Or))

        self.declareProperty(FloatArrayProperty('OutputBinning'),
                             doc='The manual Q binning of the output')
        self.setPropertySettings(
            'OutputBinning',
            EnabledWhenProperty(output_iq, output_iphiq, LogicOperator.Or))

        self.declareProperty('NPixelDivision', 1, IntBoundedValidator(lower=1),
                             'Number of subpixels to split the pixel (NxN)')
        self.setPropertySettings(
            'NPixelDivision',
            EnabledWhenProperty(output_iq, output_iphiq, LogicOperator.Or))

        iq_without_shapes = EnabledWhenProperty(
            EnabledWhenProperty("ShapeTable", PropertyCriterion.IsDefault),
            EnabledWhenProperty(output_iq, output_iphiq, LogicOperator.Or),
            LogicOperator.And)

        self.declareProperty(name='NumberOfWedges',
                             defaultValue=0,
                             validator=IntBoundedValidator(lower=0),
                             doc='Number of wedges to integrate separately.')
        self.setPropertySettings('NumberOfWedges', iq_without_shapes)

        iq_with_wedges = EnabledWhenProperty(
            output_iq,
            EnabledWhenProperty('NumberOfWedges',
                                PropertyCriterion.IsNotDefault),
            LogicOperator.And)
        iq_with_wedges_or_shapes = EnabledWhenProperty(
            iq_with_wedges,
            EnabledWhenProperty("ShapeTable", PropertyCriterion.IsNotDefault),
            LogicOperator.Or)
        iq_with_wedges_but_no_shapes = EnabledWhenProperty(
            iq_with_wedges,
            EnabledWhenProperty("ShapeTable", PropertyCriterion.IsDefault),
            LogicOperator.And)

        self.declareProperty(
            WorkspaceGroupProperty('WedgeWorkspace',
                                   '',
                                   direction=Direction.Output,
                                   optional=PropertyMode.Optional),
            doc='WorkspaceGroup containing I(Q) for each azimuthal wedge.')
        self.setPropertySettings('WedgeWorkspace', iq_with_wedges_or_shapes)

        self.declareProperty(name='WedgeAngle',
                             defaultValue=30.,
                             validator=FloatBoundedValidator(lower=0.),
                             doc='Wedge opening angle [degrees].')
        self.setPropertySettings('WedgeAngle', iq_with_wedges_but_no_shapes)

        self.declareProperty(name='WedgeOffset',
                             defaultValue=0.,
                             validator=FloatBoundedValidator(lower=0.),
                             doc='Wedge offset angle from x+ axis.')
        self.setPropertySettings('WedgeOffset', iq_with_wedges_but_no_shapes)

        self.declareProperty(name='AsymmetricWedges',
                             defaultValue=False,
                             doc='Whether to have asymmetric wedges.')
        self.setPropertySettings('AsymmetricWedges', iq_with_wedges_or_shapes)

        self.setPropertyGroup('DefaultQBinning', 'I(Q) Options')
        self.setPropertyGroup('BinningFactor', 'I(Q) Options')
        self.setPropertyGroup('OutputBinning', 'I(Q) Options')
        self.setPropertyGroup('NPixelDivision', 'I(Q) Options')
        self.setPropertyGroup('NumberOfWedges', 'I(Q) Options')
        self.setPropertyGroup('WedgeWorkspace', 'I(Q) Options')
        self.setPropertyGroup('WedgeAngle', 'I(Q) Options')
        self.setPropertyGroup('WedgeOffset', 'I(Q) Options')
        self.setPropertyGroup('AsymmetricWedges', 'I(Q) Options')

        self.declareProperty(name='MaxQxy',
                             defaultValue=-1.0,
                             validator=FloatBoundedValidator(lower=-1.0),
                             doc='Maximum of absolute Qx and Qy.')
        self.setPropertySettings('MaxQxy', output_iqxy)

        self.declareProperty(name='DeltaQ',
                             defaultValue=-1.0,
                             validator=FloatBoundedValidator(lower=-1.0),
                             doc='The dimension of a Qx-Qy cell.')
        self.setPropertySettings('DeltaQ', output_iqxy)

        self.declareProperty(
            name='IQxQyLogBinning',
            defaultValue=False,
            doc='I(Qx, Qy) log binning when binning is not specified.')
        self.setPropertySettings('IQxQyLogBinning', output_iqxy)

        self.setPropertyGroup('MaxQxy', 'I(Qx,Qy) Options')
        self.setPropertyGroup('DeltaQ', 'I(Qx,Qy) Options')
        self.setPropertyGroup('IQxQyLogBinning', 'I(Qx,Qy) Options')
        self.declareProperty(
            WorkspaceGroupProperty('PanelOutputWorkspaces',
                                   '',
                                   direction=Direction.Output,
                                   optional=PropertyMode.Optional),
            doc='The name of the output workspace group for detector panels.')
        self.declareProperty(
            ITableWorkspaceProperty('ShapeTable',
                                    '',
                                    direction=Direction.Input,
                                    optional=PropertyMode.Optional),
            doc=
            'The name of the table workspace containing drawn shapes on which to integrate. '
            'If provided, NumberOfWedges, WedgeOffset and WedgeAngle arguments are ignored. '
        )

        self.setPropertyGroup('PanelOutputWorkspaces', 'I(Q) Options')
        self.setPropertyGroup('ShapeTable', 'I(Q) Options')

        lambda_range_validator = CompositeValidator()
        lambda_range_validator.add(FloatArrayOrderedPairsValidator())
        lambda_range_validator.add(FloatArrayLengthValidator(2))
        self.declareProperty(
            FloatArrayProperty('WavelengthRange', [1., 10.],
                               validator=lambda_range_validator),
            doc=
            'Wavelength range [Angstrom] to be used in integration (TOF only).'
        )
Example #28
0
    def PyInit(self):
        """Initialize the algorithm's input and output properties."""
        PROPGROUP_REBINNING = 'Rebinning for SofQW'
        inputWorkspaceValidator = CompositeValidator()
        inputWorkspaceValidator.add(InstrumentValidator())
        inputWorkspaceValidator.add(WorkspaceUnitValidator('TOF'))
        positiveFloat = FloatBoundedValidator(0., exclusive=True)
        validRebinParams = RebinParamsValidator(AllowEmpty=True)

        # Properties.
        self.declareProperty(MatrixWorkspaceProperty(
            name=common.PROP_INPUT_WS,
            defaultValue='',
            validator=inputWorkspaceValidator,
            direction=Direction.Input),
                             doc='A workspace to reduce.')
        self.declareProperty(WorkspaceProperty(name=common.PROP_OUTPUT_WS,
                                               defaultValue='',
                                               direction=Direction.Output),
                             doc='The reduced S(Q, DeltaE) workspace.')
        self.declareProperty(name=common.PROP_CLEANUP_MODE,
                             defaultValue=utils.Cleanup.ON,
                             validator=StringListValidator(
                                 [utils.Cleanup.ON, utils.Cleanup.OFF]),
                             direction=Direction.Input,
                             doc='What to do with intermediate workspaces.')
        self.declareProperty(
            name=common.PROP_SUBALG_LOGGING,
            defaultValue=common.SUBALG_LOGGING_OFF,
            validator=StringListValidator(
                [common.SUBALG_LOGGING_OFF, common.SUBALG_LOGGING_ON]),
            direction=Direction.Input,
            doc='Enable or disable subalgorithms to ' + 'print in the logs.')
        self.declareProperty(MatrixWorkspaceProperty(
            name=common.PROP_VANA_WS,
            defaultValue='',
            validator=inputWorkspaceValidator,
            direction=Direction.Input,
            optional=PropertyMode.Optional),
                             doc='An integrated vanadium workspace.')
        self.declareProperty(
            name=common.PROP_ABSOLUTE_UNITS,
            defaultValue=common.ABSOLUTE_UNITS_OFF,
            validator=StringListValidator(
                [common.ABSOLUTE_UNITS_OFF, common.ABSOLUTE_UNITS_ON]),
            direction=Direction.Input,
            doc='Enable or disable normalisation to absolute units.')
        self.declareProperty(MatrixWorkspaceProperty(
            name=common.PROP_DIAGNOSTICS_WS,
            defaultValue='',
            direction=Direction.Input,
            optional=PropertyMode.Optional),
                             doc='Detector diagnostics workspace for masking.')
        self.declareProperty(
            name=common.PROP_GROUPING_ANGLE_STEP,
            defaultValue=Property.EMPTY_DBL,
            validator=positiveFloat,
            doc=
            'A scattering angle step to which to group detectors, in degrees.')
        self.declareProperty(FloatArrayProperty(
            name=common.PROP_REBINNING_PARAMS_W, validator=validRebinParams),
                             doc='Manual energy rebinning parameters.')
        self.setPropertyGroup(common.PROP_REBINNING_PARAMS_W,
                              PROPGROUP_REBINNING)
        self.declareProperty(
            name=common.PROP_REBINNING_W,
            defaultValue='',
            doc=
            'Energy rebinning when mixing manual and automatic binning parameters.'
        )
        self.declareProperty(FloatArrayProperty(
            name=common.PROP_BINNING_PARAMS_Q, validator=validRebinParams),
                             doc='Manual q rebinning parameters.')
        self.setPropertyGroup(common.PROP_BINNING_PARAMS_Q,
                              PROPGROUP_REBINNING)
        self.declareProperty(
            name=common.PROP_TRANSPOSE_SAMPLE_OUTPUT,
            defaultValue=common.TRANSPOSING_ON,
            validator=StringListValidator(
                [common.TRANSPOSING_ON, common.TRANSPOSING_OFF]),
            direction=Direction.Input,
            doc='Enable or disable ' + common.PROP_OUTPUT_WS + ' transposing.')
        self.declareProperty(
            WorkspaceProperty(name=common.PROP_OUTPUT_THETA_W_WS,
                              defaultValue='',
                              direction=Direction.Output,
                              optional=PropertyMode.Optional),
            doc='Output workspace for reduced S(theta, DeltaE).')
        self.setPropertyGroup(common.PROP_OUTPUT_THETA_W_WS,
                              common.PROPGROUP_OPTIONAL_OUTPUT)
    def PyInit(self):
        # input
        self.declareProperty(MatrixWorkspaceProperty(
            'InputWorkspace',
            '',
            direction=Direction.Input,
            optional=PropertyMode.Mandatory),
                             doc='Particle counts as a function of wavelength')

        self.declareProperty(MatrixWorkspaceProperty(
            'InputMaskingWorkspace',
            '',
            direction=Direction.Input,
            optional=PropertyMode.Optional),
                             doc='Mask for the scattering data')

        # blocked beam, beam shape and detector corrections
        self.declareProperty(MatrixWorkspaceProperty(
            'BlockedBeamWorkspace',
            '',
            direction=Direction.Input,
            optional=PropertyMode.Optional),
                             doc='Blocked beam scattering')

        self.declareProperty(
            MatrixWorkspaceProperty(
                'EmptyBeamSpectrumShapeWorkspace',
                '',
                direction=Direction.Input,
                optional=PropertyMode.Mandatory,
                validator=WorkspaceUnitValidator("Wavelength")),
            doc=
            'Empty beam transmission, where only a given wavelength slice is considered'
        )

        self.declareProperty(MatrixWorkspaceProperty(
            'SensitivityCorrectionMatrix',
            '',
            direction=Direction.Input,
            optional=PropertyMode.Optional),
                             doc='Detector sensitivity calibration data set')

        self.declareProperty(MatrixWorkspaceProperty(
            'TransmissionWorkspace',
            '',
            direction=Direction.Input,
            optional=PropertyMode.Mandatory),
                             doc='Sample transmission workspace')

        self.declareProperty(MatrixWorkspaceProperty(
            'TransmissionEmptyBeamWorkspace',
            '',
            direction=Direction.Input,
            optional=PropertyMode.Mandatory),
                             doc='Empty beam transmission workspace')

        self.declareProperty(MatrixWorkspaceProperty(
            'TransmissionMaskingWorkspace',
            '',
            direction=Direction.Input,
            optional=PropertyMode.Mandatory),
                             doc='Mask for the transmission data')

        self.declareProperty(
            name='FitMethod',
            defaultValue='log',
            doc='Function to use to fit transmission; can be Linear,'
            ' Log, Polynomial (first letter shall be capital)')

        self.declareProperty(
            name='PolynomialOrder',
            defaultValue='3',
            doc=
            'Used only for Polynomial function, but needed as an input parameter anyway'
        )

        self.declareProperty(name='ScalingFactor',
                             defaultValue=1.0,
                             validator=FloatBoundedValidator(lower=0.0),
                             doc='Attenuating factor')

        self.declareProperty(name='SampleThickness',
                             defaultValue=1.0,
                             validator=FloatBoundedValidator(lower=0.0),
                             doc='Thickness of sample')

        self.declareProperty(
            FloatArrayProperty('BinningWavelength',
                               direction=Direction.Input,
                               validator=FloatArrayMandatoryValidator()),
            doc=
            'Wavelength boundaries for reduction: a comma separated list of first bin boundary,'
            ' width, last bin boundary')

        self.declareProperty(
            FloatArrayProperty('BinningWavelengthTransm',
                               direction=Direction.Input,
                               validator=FloatArrayMandatoryValidator()),
            doc=
            'Wavelengths boundaries for transmission binning: a comma separated list of first bin'
            ' boundary, width, last bin')

        self.declareProperty(
            FloatArrayProperty('BinningQ',
                               direction=Direction.Input,
                               validator=FloatArrayMandatoryValidator()),
            doc=
            'Output Q-boundaries: a comma separated list of first bin boundary,'
            ' width, last bin boundary')

        self.declareProperty(
            name='Timemode',
            defaultValue=True,
            doc='If data collected in ToF or monochromatic mode')

        self.declareProperty(
            name='AccountForGravity',
            defaultValue=True,
            doc='Whether to correct for the effects of gravity')

        self.declareProperty(
            name='SolidAngleWeighting',
            defaultValue=True,
            doc='If True, pixels will be weighted by their solid angle')

        self.declareProperty(
            name='RadiusCut',
            defaultValue=1.0,
            validator=FloatBoundedValidator(lower=0.0),
            doc=
            'To increase resolution some wavelengths are excluded within this distance from the'
            ' beam center (mm). Note that RadiusCut and WaveCut both need to be larger than 0 to'
            ' affect the effective cutoff. See the algorithm description for a detailed'
            ' explanation of the cutoff.')

        self.declareProperty(
            name='WaveCut',
            defaultValue=1.0,
            validator=FloatBoundedValidator(lower=0.0),
            doc=
            'To increase resolution by starting to remove some wavelengths below this threshold'
            ' (angstrom). Note that WaveCut and RadiusCut both need to be larger than 0 to affect'
            ' on the effective cutoff. See the algorithm description for a detailed explanation'
            ' of the cutoff.')

        self.declareProperty(
            name='WideAngleCorrection',
            defaultValue=True,
            doc=
            'If true, the wide angle correction for transmissions will be applied'
        )

        self.declareProperty(
            name='Reduce2D',
            defaultValue=False,
            doc='If true, 2D data reduction will be performed')

        self.declareProperty(
            MatrixWorkspaceProperty('OutputWorkspace',
                                    '',
                                    direction=Direction.Output),
            doc=
            'Name of the workspace that contains the result of the calculation. '
            'Created automatically.')

        self.declareProperty(
            MatrixWorkspaceProperty('OutputWorkspaceTransmissionFit',
                                    '',
                                    direction=Direction.Output),
            # This works only when transmission is True. Problems starts when it is not...
            doc='Counts vs wavelength, fit for the sample transmission')
Example #30
0
 def PyInit(self):
     """Initialize the input and output properties of the algorithm."""
     threeNonnegativeInts = CompositeValidator()
     threeNonnegativeInts.add(IntArrayLengthValidator(3))
     nonnegativeInts = IntArrayBoundedValidator(lower=0)
     threeNonnegativeInts.add(nonnegativeInts)
     nonnegativeFloatArray = FloatArrayBoundedValidator(lower=0.)
     inWavelength = WorkspaceUnitValidator('Wavelength')
     self.declareProperty(
         MatrixWorkspaceProperty(
             Prop.INPUT_WS,
             defaultValue='',
             direction=Direction.Input,
             validator=inWavelength),
         doc='A reflected beam workspace (units wavelength).')
     self.declareProperty(
         MatrixWorkspaceProperty(
             Prop.OUTPUT_WS,
             defaultValue='',
             direction=Direction.Output),
         doc='The summed foreground workspace.')
     self.declareProperty(
         Prop.SUBALG_LOGGING,
         defaultValue=SubalgLogging.OFF,
         validator=StringListValidator([SubalgLogging.OFF, SubalgLogging.ON]),
         doc='Enable or disable child algorithm logging.')
     self.declareProperty(
         Prop.CLEANUP,
         defaultValue=utils.Cleanup.ON,
         validator=StringListValidator([utils.Cleanup.ON, utils.Cleanup.OFF]),
         doc='Enable or disable intermediate workspace cleanup.')
     self.declareProperty(
         Prop.SUM_TYPE,
         defaultValue=SumType.IN_LAMBDA,
         validator=StringListValidator([SumType.IN_LAMBDA, SumType.IN_Q]),
         doc='Type of summation to perform.')
     self.declareProperty(
         MatrixWorkspaceProperty(
             Prop.DIRECT_FOREGROUND_WS,
             defaultValue='',
             direction=Direction.Input,
             optional=PropertyMode.Optional,
             validator=inWavelength),
         doc='Summed direct beam workspace (units wavelength).')
     self.declareProperty(
         IntArrayProperty(
             Prop.FOREGROUND_INDICES,
             values=[Property.EMPTY_INT, Property.EMPTY_INT, Property.EMPTY_INT],
             validator=threeNonnegativeInts),
         doc='A three element array of foreground start, centre and end workspace indices.')
     self.declareProperty(
         MatrixWorkspaceProperty(
             Prop.DIRECT_WS,
             defaultValue='',
             direction=Direction.Input,
             optional=PropertyMode.Optional,
             validator=inWavelength),
         doc='The (not summed) direct beam workspace (units wavelength).')
     self.declareProperty(
         FloatArrayProperty(
             Prop.WAVELENGTH_RANGE,
             values=[0.],
             validator=nonnegativeFloatArray),
         doc='The wavelength bounds.')
    def PyInit(self):
        self.declareProperty(MatrixWorkspaceProperty('InputWorkspace', '', direction=Direction.Input,
                             validator=WorkspaceUnitValidator('Wavelength')),
                             doc='The input workspace.')

        self.declareProperty(MatrixWorkspaceProperty('OutputWorkspace', '', direction=Direction.Output),
                             doc='The output workspace.')

        self.declareProperty(name='OutputType', defaultValue='I(Q)',
                             validator=StringListValidator(['I(Q)', 'I(Qx,Qy)', 'I(Phi,Q)']),
                             doc='Choose the output type.')

        self.declareProperty(name='CalculateResolution',
                             defaultValue='MildnerCarpenter',
                             validator=StringListValidator(['MildnerCarpenter', 'None']),
                             doc='Choose to calculate the Q resolution.')

        output_iq = EnabledWhenProperty('OutputType', PropertyCriterion.IsEqualTo, 'I(Q)')
        output_iphiq = EnabledWhenProperty('OutputType', PropertyCriterion.IsEqualTo, 'I(Phi,Q)')
        output_iqxy = EnabledWhenProperty('OutputType', PropertyCriterion.IsEqualTo, 'I(Qx,Qy)')

        self.declareProperty(name='DefaultQBinning', defaultValue='PixelSizeBased',
                             validator=StringListValidator(['PixelSizeBased', 'ResolutionBased']),
                             doc='Choose how to calculate the default Q binning.')
        self.setPropertySettings('DefaultQBinning', EnabledWhenProperty(output_iq, output_iphiq, LogicOperator.Or))

        self.declareProperty(name='BinningFactor', defaultValue=1.,
                             validator=FloatBoundedValidator(lower=0.),
                             doc='Specify a multiplicative factor for default Q binning (pixel or resolution based).')
        self.setPropertySettings('BinningFactor', EnabledWhenProperty(output_iq, output_iphiq, LogicOperator.Or))

        self.declareProperty(FloatArrayProperty('OutputBinning'), doc='The manual Q binning of the output')
        self.setPropertySettings('OutputBinning', EnabledWhenProperty(output_iq, output_iphiq, LogicOperator.Or))

        self.declareProperty('NPixelDivision', 1, IntBoundedValidator(lower=1), 'Number of subpixels to split the pixel (NxN)')
        self.setPropertySettings('NPixelDivision', EnabledWhenProperty(output_iq, output_iphiq, LogicOperator.Or))

        self.declareProperty(name='NumberOfWedges', defaultValue=0, validator=IntBoundedValidator(lower=0),
                             doc='Number of wedges to integrate separately.')
        self.setPropertySettings('NumberOfWedges', EnabledWhenProperty(output_iq, output_iphiq, LogicOperator.Or))

        iq_with_wedges = EnabledWhenProperty(output_iq,
                                             EnabledWhenProperty('NumberOfWedges',
                                                                 PropertyCriterion.IsNotDefault), LogicOperator.And)

        self.declareProperty(WorkspaceGroupProperty('WedgeWorkspace', '', direction=Direction.Output, optional=PropertyMode.Optional),
                             doc='WorkspaceGroup containing I(Q) for each azimuthal wedge.')
        self.setPropertySettings('WedgeWorkspace', iq_with_wedges)

        self.declareProperty(name='WedgeAngle', defaultValue=30., validator=FloatBoundedValidator(lower=0.),
                             doc='Wedge opening angle [degrees].')
        self.setPropertySettings('WedgeAngle', iq_with_wedges)

        self.declareProperty(name='WedgeOffset', defaultValue=0., validator=FloatBoundedValidator(lower=0.),
                             doc='Wedge offset angle from x+ axis.')
        self.setPropertySettings('WedgeOffset', iq_with_wedges)

        self.declareProperty(name='AsymmetricWedges', defaultValue=False, doc='Whether to have asymmetric wedges.')
        self.setPropertySettings('AsymmetricWedges', iq_with_wedges)

        self.setPropertyGroup('DefaultQBinning', 'I(Q) Options')
        self.setPropertyGroup('BinningFactor', 'I(Q) Options')
        self.setPropertyGroup('OutputBinning', 'I(Q) Options')
        self.setPropertyGroup('NPixelDivision', 'I(Q) Options')
        self.setPropertyGroup('NumberOfWedges', 'I(Q) Options')
        self.setPropertyGroup('WedgeWorkspace', 'I(Q) Options')
        self.setPropertyGroup('WedgeAngle', 'I(Q) Options')
        self.setPropertyGroup('WedgeOffset', 'I(Q) Options')
        self.setPropertyGroup('AsymmetricWedges', 'I(Q) Options')

        self.declareProperty(name='MaxQxy', defaultValue=0., validator=FloatBoundedValidator(lower=0.),
                             doc='Maximum of absolute Qx and Qy.')
        self.setPropertySettings('MaxQxy', output_iqxy)

        self.declareProperty(name='DeltaQ', defaultValue=0., validator=FloatBoundedValidator(lower=0),
                             doc='The dimension of a Qx-Qy cell.')
        self.setPropertySettings('DeltaQ', output_iqxy)

        self.declareProperty(name='IQxQyLogBinning', defaultValue=False,
                             doc='I(Qx, Qy) log binning when binning is not specified.')
        self.setPropertySettings('IQxQyLogBinning', output_iqxy)

        self.setPropertyGroup('MaxQxy', 'I(Qx,Qy) Options')
        self.setPropertyGroup('DeltaQ', 'I(Qx,Qy) Options')
        self.setPropertyGroup('IQxQyLogBinning', 'I(Qx,Qy) Options')

        self.declareProperty(name='BinMaskingCriteria', defaultValue='',
                             doc='Criteria to mask bins, used for TOF mode,'
                                 ' for example to discard high and low lambda ranges;'
                                 'see MaskBinsIf algorithm for details.')
Example #32
0
    def PyInit(self):
        """Initialize the algorithm's input and output properties."""
        PROPGROUP_REBINNING = 'Rebinning for SofQW'
        inputWorkspaceValidator = CompositeValidator()
        inputWorkspaceValidator.add(InstrumentValidator())
        inputWorkspaceValidator.add(WorkspaceUnitValidator('TOF'))

        # Properties.
        self.declareProperty(MatrixWorkspaceProperty(
            name=common.PROP_INPUT_WS,
            defaultValue='',
            validator=inputWorkspaceValidator,
            direction=Direction.Input),
            doc='A workspace to reduce.')
        self.declareProperty(WorkspaceProperty(name=common.PROP_OUTPUT_WS,
                                               defaultValue='',
                                               direction=Direction.Output),
                             doc='The reduced S(Q, DeltaE) workspace.')
        self.declareProperty(name=common.PROP_CLEANUP_MODE,
                             defaultValue=common.CLEANUP_ON,
                             validator=StringListValidator([
                                 common.CLEANUP_ON,
                                 common.CLEANUP_OFF]),
                             direction=Direction.Input,
                             doc='What to do with intermediate workspaces.')
        self.declareProperty(name=common.PROP_SUBALG_LOGGING,
                             defaultValue=common.SUBALG_LOGGING_OFF,
                             validator=StringListValidator([
                                 common.SUBALG_LOGGING_OFF,
                                 common.SUBALG_LOGGING_ON]),
                             direction=Direction.Input,
                             doc='Enable or disable subalgorithms to ' +
                                 'print in the logs.')
        self.declareProperty(MatrixWorkspaceProperty(
            name=common.PROP_VANA_WS,
            defaultValue='',
            validator=inputWorkspaceValidator,
            direction=Direction.Input,
            optional=PropertyMode.Optional),
            doc='An integrated vanadium workspace.')
        self.declareProperty(name=common.PROP_ABSOLUTE_UNITS,
                             defaultValue=common.ABSOLUTE_UNITS_OFF,
                             validator=StringListValidator([
                                 common.ABSOLUTE_UNITS_OFF,
                                 common.ABSOLUTE_UNITS_ON]),
                             direction=Direction.Input,
                             doc='Enable or disable normalisation to absolute units.')
        self.declareProperty(MatrixWorkspaceProperty(
            name=common.PROP_DIAGNOSTICS_WS,
            defaultValue='',
            direction=Direction.Input,
            optional=PropertyMode.Optional),
            doc='Detector diagnostics workspace for masking.')
        self.declareProperty(FloatArrayProperty(name=common.PROP_REBINNING_PARAMS_W),
                             doc='Manual energy rebinning parameters.')
        self.setPropertyGroup(common.PROP_REBINNING_PARAMS_W, PROPGROUP_REBINNING)
        self.declareProperty(FloatArrayProperty(name=common.PROP_BINNING_PARAMS_Q),
                             doc='Manual q rebinning parameters.')
        self.setPropertyGroup(common.PROP_BINNING_PARAMS_Q, PROPGROUP_REBINNING)
        self.declareProperty(name=common.PROP_TRANSPOSE_SAMPLE_OUTPUT,
                             defaultValue=common.TRANSPOSING_ON,
                             validator=StringListValidator([
                                 common.TRANSPOSING_ON,
                                 common.TRANSPOSING_OFF]),
                             direction=Direction.Input,
                             doc='Enable or disable ' + common.PROP_OUTPUT_WS + ' transposing.')
        self.declareProperty(WorkspaceProperty(
            name=common.PROP_OUTPUT_THETA_W_WS,
            defaultValue='',
            direction=Direction.Output,
            optional=PropertyMode.Optional),
            doc='Output workspace for reduced S(theta, DeltaE).')
        self.setPropertyGroup(common.PROP_OUTPUT_THETA_W_WS,
                              common.PROPGROUP_OPTIONAL_OUTPUT)