def PyInit(self):
     """Initialize the input and output properties of the algorithm."""
     mandatoryInputWorkspaces = CompositeValidator()
     mandatoryInputWorkspaces.add(StringArrayMandatoryValidator())
     mandatoryInputWorkspaces.add(StringArrayLengthValidator(1, 4))
     self.declareProperty(StringArrayProperty(Prop.INPUT_WS,
                                              values=[],
                                              validator=mandatoryInputWorkspaces),
                          doc='A set of polarized workspaces, in wavelength.')
     self.declareProperty(WorkspaceGroupProperty(Prop.OUTPUT_WS,
                                                 defaultValue='',
                                                 direction=Direction.Output),
                          doc='A group of polarization efficiency corrected workspaces.')
     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(FileProperty(Prop.EFFICIENCY_FILE,
                                       defaultValue='',
                                       action=FileAction.Load),
                          doc='A file containing the polarization efficiency factors.')
 def PyInit(self):
     """Initialize the input and output properties of the algorithm."""
     mandatoryInputRuns = CompositeValidator()
     mandatoryInputRuns.add(StringArrayMandatoryValidator())
     lenValidator = StringArrayLengthValidator()
     lenValidator.setLengthMin(1)
     mandatoryInputRuns.add(lenValidator)
     self.declareProperty(StringArrayProperty(Prop.RUNS,
                                              values=[],
                                              validator=mandatoryInputRuns),
                          doc='A list of run numbers or workspace names for the input runs. '
                          'Multiple runs will be summed before reduction.')
     self.declareProperty(StringArrayProperty(Prop.FIRST_TRANS_RUNS,
                                              values=[]),
                          doc='A list of run numbers or workspace names for the first transmission run. '
                          'Multiple runs will be summed before reduction.')
     self.declareProperty(StringArrayProperty(Prop.SECOND_TRANS_RUNS,
                                              values=[]),
                          doc='A list of run numbers or workspace names for the second transmission run. '
                          'Multiple runs will be summed before reduction.')
     self._declareSliceAlgorithmProperties()
     self._declareReductionAlgorithmProperties()
     self.declareProperty(WorkspaceProperty(Prop.OUTPUT_WS, '',
                                            optional=PropertyMode.Optional,
                                            direction=Direction.Output),
                          doc='The output workspace, or workspace group if sliced.')
     self.declareProperty(WorkspaceProperty(Prop.OUTPUT_WS_BINNED, '',
                                            optional=PropertyMode.Optional,
                                            direction=Direction.Output),
                          doc='The binned output workspace, or workspace group if sliced.')
     self.declareProperty(WorkspaceProperty(Prop.OUTPUT_WS_LAM, '',
                                            optional=PropertyMode.Optional,
                                            direction=Direction.Output),
                          doc='The output workspace in wavelength, or workspace group if sliced.')
Exemplo n.º 3
0
 def _declareRunProperties(self):
     mandatoryInputRuns = CompositeValidator()
     mandatoryInputRuns.add(StringArrayMandatoryValidator())
     lenValidator = StringArrayLengthValidator()
     lenValidator.setLengthMin(1)
     mandatoryInputRuns.add(lenValidator)
     # Add property for the input runs
     self.declareProperty(
         StringArrayProperty(Prop.RUNS,
                             values=[],
                             validator=mandatoryInputRuns),
         doc='A list of run numbers or workspace names for the input runs. '
         'Multiple runs will be summed before reduction.')
     # Add properties from child algorithm
     properties = [
         'ThetaIn',
         'ThetaLogName',
     ]
     self.copyProperties('ReflectometryReductionOneAuto', properties)
     self._reduction_properties += properties
     # Add properties for settings to apply to input runs
     self.declareProperty(
         Prop.RELOAD,
         True,
         doc=
         'If true, reload input workspaces if they are of the incorrect type'
     )
     self.declareProperty(Prop.GROUP_TOF,
                          True,
                          doc='If true, group the TOF workspaces')
 def _get_input_runs_validator():
     mandatoryInputRuns = CompositeValidator()
     mandatoryInputRuns.add(StringArrayMandatoryValidator())
     lenValidator = StringArrayLengthValidator()
     lenValidator.setLengthMin(1)
     mandatoryInputRuns.add(lenValidator)
     return mandatoryInputRuns
 def PyInit(self):
     """Initialize the input and output properties of the algorithm."""
     mandatoryInputWorkspaces = CompositeValidator()
     mandatoryInputWorkspaces.add(StringArrayMandatoryValidator())
     mandatoryInputWorkspaces.add(StringArrayLengthValidator(1, 4))
     self.declareProperty(
         StringArrayProperty(Prop.INPUT_WS,
                             values=[],
                             validator=mandatoryInputWorkspaces),
         doc='A set of polarized workspaces, in wavelength.')
     self.declareProperty(
         WorkspaceGroupProperty(Prop.OUTPUT_WS,
                                defaultValue='',
                                direction=Direction.Output),
         doc='A group of polarization efficiency corrected workspaces.')
     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(
         FileProperty(Prop.EFFICIENCY_FILE,
                      defaultValue='',
                      action=FileAction.Load),
         doc='A file containing the polarization efficiency factors.')
    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.')
Exemplo n.º 7
0
 def test_creation_with_add_succeeds_correctly_in_algorithm(self):
     """
         Tests that a composite validator created with the add
         method validates correctly
     """
     validation = CompositeValidator()
     validation.add(FloatBoundedValidator(lower=5))
     validation.add(FloatBoundedValidator(upper=10))
     self._do_validation_test(validation)
Exemplo n.º 8
0
 def test_creation_with_add_succeeds_correctly_in_algorithm(self):
     """
         Tests that a composite validator created with the add
         method validates correctly
     """
     validation = CompositeValidator()
     validation.add(FloatBoundedValidator(lower=5))
     validation.add(FloatBoundedValidator(upper=10))
     self._do_validation_test(validation)
Exemplo n.º 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 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 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):
     """Initialize the input and output properties of the algorithm."""
     mandatoryInputRuns = CompositeValidator()
     mandatoryInputRuns.add(StringArrayMandatoryValidator())
     lenValidator = StringArrayLengthValidator()
     lenValidator.setLengthMin(1)
     mandatoryInputRuns.add(lenValidator)
     self.declareProperty(
         StringArrayProperty(Prop.RUNS,
                             values=[],
                             validator=mandatoryInputRuns),
         doc='A list of run numbers or workspace names for the input runs. '
         'Multiple runs will be summed before reduction.')
     self.declareProperty(
         StringArrayProperty(Prop.FIRST_TRANS_RUNS, values=[]),
         doc=
         'A list of run numbers or workspace names for the first transmission run. '
         'Multiple runs will be summed before reduction.')
     self.declareProperty(
         StringArrayProperty(Prop.SECOND_TRANS_RUNS, values=[]),
         doc=
         'A list of run numbers or workspace names for the second transmission run. '
         'Multiple runs will be summed before reduction.')
     self._declareSliceAlgorithmProperties()
     self._declareReductionAlgorithmProperties()
     self.declareProperty(Prop.GROUP_TOF,
                          True,
                          doc='If true, group the input TOF workspace')
     self.declareProperty(
         Prop.RELOAD,
         True,
         doc=
         'If true, reload input workspaces if they are of the incorrect type'
     )
     self.declareProperty(
         WorkspaceProperty(Prop.OUTPUT_WS,
                           '',
                           optional=PropertyMode.Optional,
                           direction=Direction.Output),
         doc='The output workspace, or workspace group if sliced.')
     self.declareProperty(
         WorkspaceProperty(Prop.OUTPUT_WS_BINNED,
                           '',
                           optional=PropertyMode.Optional,
                           direction=Direction.Output),
         doc='The binned output workspace, or workspace group if sliced.')
     self.declareProperty(
         WorkspaceProperty(Prop.OUTPUT_WS_LAM,
                           '',
                           optional=PropertyMode.Optional,
                           direction=Direction.Output),
         doc=
         'The output workspace in wavelength, or workspace group if sliced.'
     )
Exemplo n.º 13
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='A workspace to be integrated.')
        self.declareProperty(WorkspaceProperty(name=common.PROP_OUTPUT_WS,
                                               defaultValue='',
                                               direction=Direction.Output),
                             doc='The integrated 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.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='Vanadium temperature in Kelvin for Debye-Waller correction, ' +
                                 'overrides the default value from the sample logs.')
        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'))
        scalingFactor = FloatBoundedValidator(lower=0, upper=1)

        # 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=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='An empty container workspace for subtraction from the input workspace.')
        self.declareProperty(name=common.PROP_EC_SCALING,
                             defaultValue=1.0,
                             validator=scalingFactor,
                             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.')
Exemplo n.º 15
0
 def PyInit(self):
     validators = CompositeValidator()
     validators.add(HistogramValidator(True))
     validators.add(CommonBinsValidator())
     self.declareProperty(
         MatrixWorkspaceProperty(name='InputWorkspace',
                                 defaultValue='',
                                 direction=Direction.Input,
                                 validator=validators),
         doc=
         'Input MatrixWorkspace containing the reduced inelastic neutron spectrum in (Q,E) or (2theta,E) space.'
     )
     self.declareProperty(name='Temperature',
                          defaultValue=300.,
                          validator=FloatBoundedValidator(lower=0),
                          doc='Sample temperature in Kelvin.')
     self.declareProperty(
         name='MeanSquareDisplacement',
         defaultValue=0.,
         validator=FloatBoundedValidator(lower=0),
         doc='Average mean square displacement in Angstrom^2.')
     self.declareProperty(
         name='QSumRange',
         defaultValue='0,Qmax',
         doc='Range in Q (in Angstroms^-1) to sum data over.')
     self.declareProperty(
         name='EnergyBinning',
         defaultValue='0,Emax/50,Emax*0.9',
         doc=
         'Energy binning parameters [Emin, Emax] or [Emin, Estep, Emax] in meV.'
     )
     self.declareProperty(
         name='Wavenumbers',
         defaultValue=False,
         doc='Should the output be in Wavenumbers (cm^-1)?')
     self.declareProperty(
         name='StatesPerEnergy',
         defaultValue=False,
         doc=
         'Should the output be in states per unit energy rather than mb/sr/fu/energy?\n'
         +
         '(Only for pure elements, need to set the sample material information)'
     )
     self.declareProperty(MatrixWorkspaceProperty(
         name='OutputWorkspace',
         defaultValue='',
         direction=Direction.Output),
                          doc='Output workspace name.')
     self.declareProperty(
         name='TwoThetaSumRange',
         defaultValue='Twothetamin, Twothetamax',
         doc='Range in 2theta (in degrees) to sum data over.')
Exemplo n.º 16
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
Exemplo n.º 17
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")
Exemplo n.º 18
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):
        # 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.')
Exemplo n.º 20
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")
Exemplo n.º 21
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")
Exemplo n.º 22
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
Exemplo n.º 23
0
 def PyInit(self):
     validators = CompositeValidator()
     validators.add(HistogramValidator(True))
     validators.add(CommonBinsValidator())
     self.declareProperty(MatrixWorkspaceProperty(name='InputWorkspace', defaultValue='', direction=Direction.Input, validator=validators),
                          doc='Input MatrixWorkspace containing the reduced inelastic neutron spectrum in (Q,E) space.')
     self.declareProperty(name='Temperature', defaultValue=300., validator=FloatBoundedValidator(lower=0),
                          doc='Sample temperature in Kelvin.')
     self.declareProperty(name='MeanSquareDisplacement', defaultValue=0., validator=FloatBoundedValidator(lower=0),
                          doc='Average mean square displacement in Angstrom^2.')
     self.declareProperty(name='QSumRange', defaultValue='0,Qmax',
                          doc='Range in Q (in Angstroms^-1) to sum data over.')
     self.declareProperty(name='EnergyBinning', defaultValue='0,Emax/50,Emax*0.9',
                          doc='Energy binning parameters [Emin, Estep, Emax] in meV.')
     self.declareProperty(name='Wavenumbers', defaultValue=False,
                          doc='Should the output be in Wavenumbers (cm^-1)?')
     self.declareProperty(name='StatesPerEnergy', defaultValue=False,
                          doc='Should the output be in states per unit energy rather than mb/sr/fu/energy?\n'+
                          '(Only for pure elements, need to set the sample material information)')
     self.declareProperty(MatrixWorkspaceProperty(name='OutputWorkspace', defaultValue='', direction=Direction.Output),
                          doc='Output workspace name.')
Exemplo n.º 24
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 Sample workspace",
        )
        # Optional but required if tof_elastic must be taken from fitted Vanadium or sample data
        self.declareProperty(
            ITableWorkspaceProperty("EPPTable", "", direction=Direction.Input, optional=PropertyMode.Optional),
            "Input EPP table (optional). May be produced by FindEPP algorithm.",
        )
        self.declareProperty(
            WorkspaceProperty("OutputWorkspace", "", direction=Direction.Output),
            "Name of the workspace that will contain the result",
        )

        return
Exemplo n.º 25
0
    def PyInit(self):
        self.declareProperty(FileProperty('CalibrationRun', '', action=FileAction.Load, extensions=['nxs']),
                             doc='File path of calibration run. Must be a detector scan.')

        self.declareProperty(FileProperty('CalibrationFile', '', action=FileAction.OptionalLoad, extensions=['nxs']),
                             doc='Optional file containing previous calibration constants.')

        self.declareProperty(name='CalibrationMethod',
                             defaultValue='Median',
                             validator=StringListValidator(['Median', 'Mean', 'MostLikelyMean']),
                             doc='The method of how the calibration constant of a '
                                 'pixel relative to the neighbouring one is derived.')

        self.declareProperty(name='InterpolateOverlappingAngles', defaultValue=False,
                             doc='Wheter to interpolate 2theta values for overlapping regions between neighbouring cells.')

        self.declareProperty(name='NormaliseTo',
                             defaultValue='None',
                             validator=StringListValidator(['None', 'Monitor', 'ROI']),
                             doc='Normalise to time, monitor or ROI counts before deriving the calibration.')

        thetaRangeValidator = FloatArrayOrderedPairsValidator()

        self.declareProperty(FloatArrayProperty(name='ROI', values=[0,100.], validator=thetaRangeValidator),
                             doc='Regions of interest for normalisation [in scattering angle in degrees].')

        normaliseToROI = VisibleWhenProperty('NormaliseTo', PropertyCriterion.IsEqualTo, 'ROI')
        self.setPropertySettings('ROI', normaliseToROI)

        self.declareProperty(FloatArrayProperty(name='ExcludedRange', values=[], validator=thetaRangeValidator),
                             doc='2theta regions to exclude from the computation of relative calibration constants '
                                 '[in scattering angle in degrees]. ')

        pixelRangeValidator = CompositeValidator()
        greaterThanOne = IntArrayBoundedValidator()
        greaterThanOne.setLower(1)
        lengthTwo = IntArrayLengthValidator()
        lengthTwo.setLength(2)
        orderedPairsValidator = IntArrayOrderedPairsValidator()
        pixelRangeValidator.add(greaterThanOne)
        pixelRangeValidator.add(lengthTwo)
        pixelRangeValidator.add(orderedPairsValidator)

        self.declareProperty(IntArrayProperty(name='PixelRange', values=[1,3072], validator=pixelRangeValidator),
                             doc='Range of the pixel numbers to compute the calibration factors for. '
                                 'For the other pixels outside the range, the factor will be set to 1.')

        self.declareProperty(MatrixWorkspaceProperty('OutputResponseWorkspace', '',
                                                     optional=PropertyMode.Optional, direction=Direction.Output),
                             doc='Output workspace containing the summed diffraction patterns of all the pixels.')

        self.declareProperty(MatrixWorkspaceProperty('OutputWorkspace', '',
                                                     direction=Direction.Output),
                             doc='Output workspace containing the detector efficiencies for each pixel.')
Exemplo n.º 26
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')
Exemplo n.º 27
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 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=0.1,
                             validator=scalingFactor,
                             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=3.0,
                             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=3.3,
                             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=0.1,
                             validator=scalingFactor,
                             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=3.3,
                             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=3.3,
                             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)
Exemplo n.º 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'))

        # 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)
Exemplo n.º 29
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).')
Exemplo n.º 30
0
 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.')
Exemplo n.º 31
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)
Exemplo n.º 32
0
    def PyInit(self):

        mandatoryInputRuns = CompositeValidator()
        mandatoryInputRuns.add(StringArrayMandatoryValidator())
        self.declareProperty(StringArrayProperty('SampleRuns',
                                                 values=[],
                                                 validator=mandatoryInputRuns),
                             doc='Optional cycle number followed by comma separated range of\n'
                                 'sample runs as [cycle::] n1,n2,..\n'
                                 ' eg 123::7333-7341,7345')

        self.declareProperty(name='EmptyRuns',
                             defaultValue='',
                             doc='Optional cycle number followed by comma separated range of\n'
                                 'runs as [cycle::] n1,n2,..\n'
                                 '  eg 123::6300-6308')

        self.declareProperty(name='ScaleEmptyRuns',
                             defaultValue=1.0,
                             doc='Scale the empty runs prior to subtraction')

        self.declareProperty(name='CalibrationRuns',
                             defaultValue='',
                             doc='Optional cycle number followed by comma separated range of\n'
                                 'runs as [cycle::] n1,n2,..\n'
                                 '  eg 123::6350-6365')

        self.declareProperty(name='EmptyCalibrationRuns',
                             defaultValue='',
                             doc='Optional cycle number followed by comma separated range of\n'
                                 'runs as [cycle::] n1,n2,..\n'
                                 '  eg 123::6370-6375')

        self.declareProperty(name='EnergyTransfer',
                             defaultValue='0.0, 0.02, 3.0',
                             doc='Energy transfer range in meV expressed as min, step, max')

        self.declareProperty(name='MomentumTransfer',
                             defaultValue='0.0, 0.02, 2.6',
                             doc='Momentum transfer range in inverse Angstroms,\n'
                                 ' expressed as min, step, max')

        self.declareProperty(name='Processing', defaultValue='SOFQW1-Centre',
                             validator=StringListValidator(
                                 ['SOFQW1-Centre', 'SOFQW3-NormalisedPolygon', 'NXSPE']),
                             doc='Convert to SOFQW or save file as NXSPE,\n'
                                 'note SOFQW3 is more accurate but much slower than SOFQW1.')

        self.declareProperty(name='LambdaOnTwoMode', defaultValue=False,
                             doc='Set if instrument running in lambda on two mode.')

        self.declareProperty(WorkspaceProperty('OutputWorkspace', '',
                                               direction=Direction.Output),
                             doc='Name for the reduced workspace.')

        self.declareProperty(FileProperty('ScratchFolder', '',
                                          action=FileAction.OptionalDirectory,
                                          direction=Direction.Input),
                             doc='Path to save and restore merged workspaces.')

        self.declareProperty(name='KeepIntermediateWorkspaces', defaultValue=False,
                             doc='Whether to keep the intermediate sample and calibration\n'
                                 'workspaces for diagnostic checks.')

        self.declareProperty(FileProperty('ConfigurationFile', '',
                                          action=FileAction.OptionalLoad,
                                          extensions=['ini']),
                             doc='Optional: INI file to override default processing values.')
    def PyInit(self):
        # ---------------
        # INPUT
        # ---------------
        # State
        self.declareProperty(PropertyManagerProperty('SANSState'),
                             doc='A property manager which fulfills the SANSState contract.')

        # Input workspaces
        self.declareProperty(MatrixWorkspaceProperty('TransmissionWorkspace', '',
                                                     optional=PropertyMode.Optional, direction=Direction.Input),
                             doc='The transmission workspace.')
        self.declareProperty(MatrixWorkspaceProperty('DirectWorkspace', '',
                                                     optional=PropertyMode.Optional, direction=Direction.Input),
                             doc='The direct workspace.')
        self.declareProperty(MatrixWorkspaceProperty('MonitorWorkspace', '',
                                                     optional=PropertyMode.Optional, direction=Direction.Input),
                             doc='The scatter monitor workspace. This workspace only contains monitors.')

        workspace_validator = CompositeValidator()
        workspace_validator.add(WorkspaceUnitValidator("Wavelength"))
        self.declareProperty(MatrixWorkspaceProperty('SampleData', '',
                                                     optional=PropertyMode.Optional, direction=Direction.Input,
                                                     validator=workspace_validator),
                             doc='A workspace cropped to the detector to be reduced (the SAME as the input to Q1D). '
                                 'This used to verify the solid angle. The workspace is not modified, just inspected.')

        # The component
        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.")

        # The data type
        allowed_data = StringListValidator([DataType.to_string(DataType.Sample),
                                            DataType.to_string(DataType.Can)])
        self.declareProperty("DataType", DataType.to_string(DataType.Sample),
                             validator=allowed_data, direction=Direction.Input,
                             doc="The component of the instrument which is to be reduced.")

        # Slice factor for monitor
        self.declareProperty('SliceEventFactor', 1.0, direction=Direction.Input, doc='The slice factor for the monitor '
                                                                                     'normalization. This factor is the'
                                                                                     ' one obtained from event '
                                                                                     'slicing.')

        # ---------------
        # Output
        # ---------------
        self.declareProperty(MatrixWorkspaceProperty('OutputWorkspaceWavelengthAdjustment', '',
                                                     direction=Direction.Output),
                             doc='The workspace for wavelength-based adjustments.')

        self.declareProperty(MatrixWorkspaceProperty('OutputWorkspacePixelAdjustment', '',
                                                     direction=Direction.Output),
                             doc='The workspace for wavelength-based adjustments.')

        self.declareProperty(MatrixWorkspaceProperty('OutputWorkspaceWavelengthAndPixelAdjustment', '',
                                                     direction=Direction.Output),
                             doc='The workspace for, both, wavelength- and pixel-based adjustments.')

        self.declareProperty(MatrixWorkspaceProperty('CalculatedTransmissionWorkspace', ''
                                                     ,optional=PropertyMode.Optional, direction=Direction.Output),
                             doc='The calculated transmission workspace')

        self.declareProperty(MatrixWorkspaceProperty('UnfittedTransmissionWorkspace', ''
                                                     ,optional=PropertyMode.Optional, direction=Direction.Output),
                             doc='The unfitted transmission workspace')
Exemplo n.º 34
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.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. Overrides '
                                 + 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_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=3.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):
     """Initialize the input and output properties of the algorithm."""
     nonnegativeInt = IntBoundedValidator(lower=0)
     nonnegativeIntArray = IntArrayBoundedValidator()
     nonnegativeIntArray.setLower(0)
     nonnegativeFloatArray = FloatArrayBoundedValidator()
     nonnegativeFloatArray.setLower(0.)
     twoNonnegativeFloats = CompositeValidator()
     twoNonnegativeFloats.add(FloatArrayLengthValidator(length=2))
     twoNonnegativeFloats.add(nonnegativeFloatArray)
     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(
         ITableWorkspaceProperty(Prop.BEAM_POS_WS,
                                 defaultValue='',
                                 direction=Direction.Input,
                                 optional=PropertyMode.Optional),
         doc='A beam position table corresponding to InputWorkspace.')
     self.declareProperty(Prop.BEAM_ANGLE,
                          defaultValue=Property.EMPTY_DBL,
                          doc='A user-defined beam angle (unit degrees).')
     self.declareProperty(
         name=Prop.BEAM_CENTRE,
         defaultValue=Property.EMPTY_DBL,
         doc='A workspace index corresponding to the beam centre.')
     self.declareProperty(
         MatrixWorkspaceProperty(Prop.OUTPUT_WS,
                                 defaultValue='',
                                 direction=Direction.Output),
         doc=
         'The preprocessed output workspace (unit wavelength), single histogram.'
     )
     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(
         ITableWorkspaceProperty(Prop.DIRECT_BEAM_POS_WS,
                                 defaultValue='',
                                 direction=Direction.Input,
                                 optional=PropertyMode.Optional),
         doc='A beam position table from a direct beam measurement.')
     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(ITableWorkspaceProperty(
         Prop.OUTPUT_BEAM_POS_WS,
         defaultValue='',
         direction=Direction.Output,
         optional=PropertyMode.Optional),
                          doc='Output the beam position table.')
 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,
                                               extensions=['nxs']),
                          doc='A list of input run numbers/files.')
     self.declareProperty(MatrixWorkspaceProperty(Prop.OUTPUT_WS,
                                                  defaultValue='',
                                                  direction=Direction.Output),
                          doc='The preprocessed output workspace (unit wavelength), single histogram.')
     self.declareProperty('Measurement', 'DirectBeam',
                          StringListValidator(['DirectBeam', 'ReflectedBeam']),
                          'Whether to process as direct or reflected beam.')
     self.declareProperty('AngleOption', 'SampleAngle',
                          StringListValidator(['SampleAngle', 'DetectorAngle', 'UserAngle']))
     self.setPropertySettings('AngleOption',
                              EnabledWhenProperty('Measurement', PropertyCriterion.IsEqualTo, 'ReflectedBeam'))
     self.declareProperty(Prop.THETA,
                          defaultValue=-1.,
                          doc='The bragg angle for reflected beam [Degree], used if angle option is UserAngle.')
     self.setPropertySettings(Prop.THETA,
                              EnabledWhenProperty('AngleOption', PropertyCriterion.IsEqualTo, 'UserAngle'))
     self.declareProperty('DirectBeamDetectorAngle', -1.,
                          'The detector angle value [Degree] for the corresponding direct beam, '
                          'used if angle option is DetectorAngle')
     self.declareProperty('DirectBeamForegroundCentre', -1.,
                          'Fractional pixel index for the direct beam, used if angle option is DetectorAngle.')
     self.setPropertySettings('DirectBeamDetectorAngle',
                              EnabledWhenProperty('AngleOption', PropertyCriterion.IsEqualTo, 'DetectorAngle'))
     self.setPropertySettings('DirectBeamForegroundCentre',
                              EnabledWhenProperty('AngleOption', PropertyCriterion.IsEqualTo, 'DetectorAngle'))
     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.AUTO,
                          validator=StringListValidator([SlitNorm.AUTO, 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.AVERAGE,
                          validator=StringListValidator([BkgMethod.AVERAGE, 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=-1.,
                          doc='Minimum wavelength [Angstrom] used for peak fitting.')
     self.declareProperty(Prop.XMAX,
                          defaultValue=-1.,
                          doc='Maximum wavelength [Angstrom] used for peak fitting.')
Exemplo n.º 37
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)
Exemplo n.º 38
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)
Exemplo n.º 39
0
    def PyInit(self):

        mandatoryInputRuns = CompositeValidator()
        mandatoryInputRuns.add(StringArrayMandatoryValidator())
        self.declareProperty(StringArrayProperty('SampleRuns',
                                                 values=[],
                                                 validator=mandatoryInputRuns),
                             doc='Comma separated range of sample runs,\n'
                             ' eg [cycle::] 7333-7341,7345')

        self.declareProperty(
            name='EmptyRuns',
            defaultValue='',
            doc='Optional path followed by comma separated range of runs,\n'
            'looking for runs in the sample folder if path not included,\n'
            '  eg [cycle::] 6300-6308')

        self.declareProperty(name='ScaleEmptyRuns',
                             defaultValue=1.0,
                             doc='Scale the empty runs prior to subtraction')

        self.declareProperty(
            name='CalibrationRuns',
            defaultValue='',
            doc='Optional path followed by comma separated range of runs,\n'
            'looking for runs in the sample folder if path not included,\n'
            '  eg [cycle::] 6350-6365')

        self.declareProperty(
            name='EmptyCalibrationRuns',
            defaultValue='',
            doc='Optional path followed by comma separated range of runs,\n'
            'looking for runs in the sample folder if path not included,\n'
            '  eg [cycle::] 6370-6375')

        self.declareProperty(
            name='EnergyTransfer',
            defaultValue='0.0, 0.02, 3.0',
            doc='Energy transfer range in meV expressed as min, step, max')

        self.declareProperty(
            name='MomentumTransfer',
            defaultValue='',
            doc='Momentum transfer range in inverse Angstroms,\n'
            'expressed as min, step, max. Default estimates\n'
            'the max range based on energy transfer.')

        self.declareProperty(
            name='LambdaOnTwoMode',
            defaultValue=False,
            doc='Set if instrument running in lambda on two mode.')

        self.declareProperty(
            name='FrameOverlap',
            defaultValue=False,
            doc='Set if the energy transfer extends over a frame.')

        self.declareProperty(name='FixedDetector',
                             defaultValue=True,
                             doc='Fix detector positions to the first run')

        self.declareProperty(FileProperty('ScratchFolder',
                                          '',
                                          action=FileAction.OptionalDirectory,
                                          direction=Direction.Input),
                             doc='Path to save and restore merged workspaces.')

        mandatoryOutputFolder = CompositeValidator()
        mandatoryOutputFolder.add(StringArrayMandatoryValidator())
        self.declareProperty(FileProperty('OutputFolder',
                                          '',
                                          action=FileAction.Directory,
                                          direction=Direction.Input),
                             doc='Path to save the output nxspe files.')

        self.declareProperty(
            FileProperty('ConfigurationFile',
                         '',
                         action=FileAction.OptionalLoad,
                         extensions=['ini']),
            doc='Optional: INI file to override default processing values.')

        self.declareProperty(name='KeepReducedWorkspace',
                             defaultValue=False,
                             doc='Keep the last reduced workspace.')
    def PyInit(self):
        self.declareProperty(MultipleFileProperty('CalibrationRun', action=FileAction.Load, extensions=['nxs']),
                             doc='File path of calibration runs (numors). Must be detector scans.')

        self.declareProperty(FileProperty('CalibrationFile', '', action=FileAction.OptionalLoad, extensions=['nxs']),
                             doc='Optional file containing previous calibration constants.')

        self.declareProperty(name='CalibrationMethod',
                             defaultValue='Median',
                             validator=StringListValidator(['Median', 'Mean', 'MostLikelyMean']),
                             doc='The method of how the calibration constant of a pixel '
                                 'is derived from the distribution of ratios.')

        self.declareProperty(name='DerivationMethod', defaultValue='SequentialSummedReference1D',
                             validator=StringListValidator(['SequentialSummedReference1D', 'GlobalSummedReference2D']),
                             doc='Choose sequential for D20 (1D detector), global for D2B (2D detector).')

        self.declareProperty(name='InterpolateOverlappingAngles', defaultValue=False,
                             doc='Whether to interpolate scattering angle values in overlapping regions (D20 only).')

        self.declareProperty(name='NormaliseTo',
                             defaultValue='None',
                             validator=StringListValidator(['None', 'Monitor', 'ROI']),
                             doc='Normalise to monitor or ROI counts before deriving the calibration.')

        thetaRangeValidator = FloatArrayOrderedPairsValidator()

        self.declareProperty(FloatArrayProperty(name='ROI', values=[0,100.], validator=thetaRangeValidator),
                             doc='Scattering angle regions of interest for normalisation [degrees].')

        normaliseToROI = VisibleWhenProperty('NormaliseTo', PropertyCriterion.IsEqualTo, 'ROI')
        self.setPropertySettings('ROI', normaliseToROI)

        self.declareProperty(FloatArrayProperty(name='ExcludedRange', values=[], validator=thetaRangeValidator),
                             doc='Scattering angle regions to exclude from the computation of '
                                 'relative calibration constants; for example, the beam stop [degrees]. ')

        pixelRangeValidator = CompositeValidator()
        greaterThanOne = IntArrayBoundedValidator()
        greaterThanOne.setLower(1)
        lengthTwo = IntArrayLengthValidator()
        lengthTwo.setLength(2)
        orderedPairsValidator = IntArrayOrderedPairsValidator()
        pixelRangeValidator.add(greaterThanOne)
        pixelRangeValidator.add(lengthTwo)
        pixelRangeValidator.add(orderedPairsValidator)

        self.declareProperty(IntArrayProperty(name='PixelRange', values=[1,3072], validator=pixelRangeValidator),
                             doc='Range of the pixel numbers to compute the calibration factors for (D20 only); '
                                 'for the other pixels outside the range, the factor will be set to 1.')

        self.declareProperty(MatrixWorkspaceProperty('OutputResponseWorkspace', '',
                                                     optional=PropertyMode.Optional, direction=Direction.Output),
                             doc='Output workspace containing the summed diffraction patterns of all the overlapping pixels.')

        self.declareProperty(MatrixWorkspaceProperty('OutputWorkspace', '',
                                                     direction=Direction.Output),
                             doc='Output workspace containing the calibration constants (inverse of efficiency) for each pixel.')

        self.declareProperty(name='NumberOfIterations',
                             defaultValue=1,
                             validator=IntBoundedValidator(lower=0, upper=10),
                             doc='Number of iterations to perform (D2B only): 0 means auto; that is, the '
                                 'iterations will terminate after reaching some Chi2/NdoF.')

        maskCriterionValidator = CompositeValidator()
        arrayLengthTwo = FloatArrayLengthValidator()
        arrayLengthTwo.setLengthMax(2)
        orderedPairs = FloatArrayOrderedPairsValidator()
        maskCriterionValidator.add(arrayLengthTwo)
        maskCriterionValidator.add(orderedPairs)

        self.declareProperty(FloatArrayProperty(name='MaskCriterion', values=[], validator=maskCriterionValidator),
                             doc='Efficiency constants outside this range will be set to zero.')

        self.declareProperty(name='UseCalibratedData',
                             defaultValue=False,
                             doc='Whether or not to use the calibrated data in the NeXus files (D2B only).')
Exemplo n.º 41
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).'
        )
    def PyInit(self):
        # ---------------
        # INPUT
        # ---------------
        # State
        self.declareProperty('SANSState', '',
                             doc='A JSON string which fulfills the SANSState contract.')
        self.declareProperty('WavelengthMin', '', doc='Minimum Wavelength of associated workspace')
        self.declareProperty('WavelengthMax', '', doc='Maximum Wavelength of associated workspace')

        # Input workspaces
        self.declareProperty(MatrixWorkspaceProperty('TransmissionWorkspace', '',
                                                     optional=PropertyMode.Optional, direction=Direction.Input),
                             doc='The transmission workspace.')
        self.declareProperty(MatrixWorkspaceProperty('DirectWorkspace', '',
                                                     optional=PropertyMode.Optional, direction=Direction.Input),
                             doc='The direct workspace.')
        self.declareProperty(MatrixWorkspaceProperty('MonitorWorkspace', '',
                                                     optional=PropertyMode.Optional, direction=Direction.Input),
                             doc='The scatter monitor workspace. This workspace only contains monitors.')

        workspace_validator = CompositeValidator()
        workspace_validator.add(WorkspaceUnitValidator("Wavelength"))
        self.declareProperty(MatrixWorkspaceProperty('SampleData', '',
                                                     optional=PropertyMode.Optional, direction=Direction.Input,
                                                     validator=workspace_validator),
                             doc='A workspace cropped to the detector to be reduced (the SAME as the input to Q1D). '
                                 'This used to verify the solid angle. The workspace is not modified, just inspected.')

        # The component
        allowed_detector_types = StringListValidator([DetectorType.HAB.value,
                                                      DetectorType.LAB.value])
        self.declareProperty("Component", DetectorType.LAB.value,
                             validator=allowed_detector_types, direction=Direction.Input,
                             doc="The component of the instrument which is currently being investigated.")

        # The data type
        allowed_data = StringListValidator([DataType.SAMPLE.value,
                                            DataType.CAN.value])
        self.declareProperty("DataType", DataType.SAMPLE.value,
                             validator=allowed_data, direction=Direction.Input,
                             doc="The component of the instrument which is to be reduced.")

        # Slice factor for monitor
        self.declareProperty('SliceEventFactor', 1.0, direction=Direction.Input, doc='The slice factor for the monitor '
                                                                                     'normalization. This factor is the'
                                                                                     ' one obtained from event '
                                                                                     'slicing.')

        # ---------------
        # Output
        # ---------------
        self.declareProperty(MatrixWorkspaceProperty('OutputWorkspaceWavelengthAdjustment', '',
                                                     direction=Direction.Output),
                             doc='The workspace for wavelength-based adjustments.')

        self.declareProperty(MatrixWorkspaceProperty('OutputWorkspacePixelAdjustment', '',
                                                     direction=Direction.Output),
                             doc='The workspace for wavelength-based adjustments.')

        self.declareProperty(MatrixWorkspaceProperty('OutputWorkspaceWavelengthAndPixelAdjustment', '',
                                                     direction=Direction.Output),
                             doc='The workspace for, both, wavelength- and pixel-based adjustments.')

        self.declareProperty(MatrixWorkspaceProperty('CalculatedTransmissionWorkspace', ''
                                                     , optional=PropertyMode.Optional, direction=Direction.Output),
                             doc='The calculated transmission workspace')

        self.declareProperty(MatrixWorkspaceProperty('UnfittedTransmissionWorkspace', ''
                                                     , optional=PropertyMode.Optional, direction=Direction.Output),
                             doc='The unfitted transmission workspace')
 def PyInit(self):
     """Initialize the input and output properties of the algorithm."""
     nonnegativeInt = IntBoundedValidator(lower=0)
     nonnegativeIntArray = IntArrayBoundedValidator()
     nonnegativeIntArray.setLower(0)
     nonnegativeFloatArray = FloatArrayBoundedValidator()
     nonnegativeFloatArray.setLower(0.)
     twoNonnegativeFloats = CompositeValidator()
     twoNonnegativeFloats.add(FloatArrayLengthValidator(length=2))
     twoNonnegativeFloats.add(nonnegativeFloatArray)
     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(ITableWorkspaceProperty(Prop.BEAM_POS_WS,
                                                  defaultValue='',
                                                  direction=Direction.Input,
                                                  optional=PropertyMode.Optional),
                          doc='A beam position table corresponding to InputWorkspace.')
     self.declareProperty(Prop.BEAM_ANGLE,
                          defaultValue=Property.EMPTY_DBL,
                          doc='A user-defined beam angle (unit degrees).')
     self.declareProperty(name=Prop.BEAM_CENTRE,
                          defaultValue=Property.EMPTY_DBL,
                          doc='A workspace index corresponding to the beam centre.')
     self.declareProperty(MatrixWorkspaceProperty(Prop.OUTPUT_WS,
                                                  defaultValue='',
                                                  direction=Direction.Output),
                          doc='The preprocessed output workspace (unit wavelength), single histogram.')
     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(ITableWorkspaceProperty(Prop.DIRECT_BEAM_POS_WS,
                                                  defaultValue='',
                                                  direction=Direction.Input,
                                                  optional=PropertyMode.Optional),
                          doc='A beam position table from a direct beam measurement.')
     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(ITableWorkspaceProperty(Prop.OUTPUT_BEAM_POS_WS,
                                                  defaultValue='',
                                                  direction=Direction.Output,
                                                  optional=PropertyMode.Optional),
                          doc='Output the beam position table.')
Exemplo n.º 44
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):
     """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.')
Exemplo n.º 46
0
    def PyInit(self):
        self.declareProperty(
            MultipleFileProperty('CalibrationRun',
                                 action=FileAction.Load,
                                 extensions=['nxs']),
            doc=
            'File path of calibration runs (numors). Must be detector scans.')

        self.declareProperty(
            FileProperty('CalibrationFile',
                         '',
                         action=FileAction.OptionalLoad,
                         extensions=['nxs']),
            doc='Optional file containing previous calibration constants.')

        self.declareProperty(
            name='CalibrationMethod',
            defaultValue='Median',
            validator=StringListValidator(['Median', 'Mean',
                                           'MostLikelyMean']),
            doc='The method of how the calibration constant of a pixel '
            'is derived from the distribution of ratios.')

        self.declareProperty(
            name='DerivationMethod',
            defaultValue='SequentialSummedReference1D',
            validator=StringListValidator(
                ['SequentialSummedReference1D', 'GlobalSummedReference2D']),
            doc=
            'Choose sequential for D20 (1D detector), global for D2B (2D detector).'
        )

        self.declareProperty(
            name='InterpolateOverlappingAngles',
            defaultValue=False,
            doc=
            'Whether to interpolate scattering angle values in overlapping regions (D20 only).'
        )

        self.declareProperty(
            name='NormaliseTo',
            defaultValue='None',
            validator=StringListValidator(['None', 'Monitor', 'ROI']),
            doc=
            'Normalise to monitor or ROI counts before deriving the calibration.'
        )

        thetaRangeValidator = FloatArrayOrderedPairsValidator()

        self.declareProperty(
            FloatArrayProperty(name='ROI',
                               values=[0, 100.],
                               validator=thetaRangeValidator),
            doc=
            'Scattering angle regions of interest for normalisation [degrees].'
        )

        normaliseToROI = VisibleWhenProperty('NormaliseTo',
                                             PropertyCriterion.IsEqualTo,
                                             'ROI')
        self.setPropertySettings('ROI', normaliseToROI)

        self.declareProperty(
            FloatArrayProperty(name='ExcludedRange',
                               values=[],
                               validator=thetaRangeValidator),
            doc='Scattering angle regions to exclude from the computation of '
            'relative calibration constants; for example, the beam stop [degrees]. '
        )

        pixelRangeValidator = CompositeValidator()
        greaterThanOne = IntArrayBoundedValidator(lower=1)
        lengthTwo = IntArrayLengthValidator()
        lengthTwo.setLength(2)
        orderedPairsValidator = IntArrayOrderedPairsValidator()
        pixelRangeValidator.add(greaterThanOne)
        pixelRangeValidator.add(lengthTwo)
        pixelRangeValidator.add(orderedPairsValidator)

        self.declareProperty(
            IntArrayProperty(name='PixelRange',
                             values=[1, 3072],
                             validator=pixelRangeValidator),
            doc=
            'Range of the pixel numbers to compute the calibration factors for (D20 only); '
            'for the other pixels outside the range, the factor will be set to 1.'
        )

        self.declareProperty(
            MatrixWorkspaceProperty('OutputResponseWorkspace',
                                    '',
                                    optional=PropertyMode.Optional,
                                    direction=Direction.Output),
            doc=
            'Output workspace containing the summed diffraction patterns of all the overlapping pixels.'
        )

        self.declareProperty(
            MatrixWorkspaceProperty('OutputWorkspace',
                                    '',
                                    direction=Direction.Output),
            doc=
            'Output workspace containing the calibration constants (inverse of efficiency) for each pixel.'
        )

        self.declareProperty(
            name='NumberOfIterations',
            defaultValue=1,
            validator=IntBoundedValidator(lower=0, upper=10),
            doc=
            'Number of iterations to perform (D2B only): 0 means auto; that is, the '
            'iterations will terminate after reaching some Chi2/NdoF.')

        maskCriterionValidator = CompositeValidator()
        arrayLengthTwo = FloatArrayLengthValidator()
        arrayLengthTwo.setLengthMax(2)
        orderedPairs = FloatArrayOrderedPairsValidator()
        maskCriterionValidator.add(arrayLengthTwo)
        maskCriterionValidator.add(orderedPairs)

        self.declareProperty(
            FloatArrayProperty(name='MaskCriterion',
                               values=[],
                               validator=maskCriterionValidator),
            doc='Efficiency constants outside this range will be set to zero.')

        self.declareProperty(
            name='UseCalibratedData',
            defaultValue=False,
            doc=
            'Whether or not to use the calibrated data in the NeXus files (D2B only).'
        )
Exemplo n.º 47
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)
Exemplo n.º 48
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)
Exemplo n.º 49
0
    def PyInit(self):
        self.declareProperty(MatrixWorkspaceProperty(
            'InputWorkspace', '', direction=Direction.Input),
                             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', 'DirectBeam', '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).'
        )
    def PyInit(self):
        """Initialize the input and output properties of the algorithm."""
        nonnegativeInts = IntArrayBoundedValidator()
        nonnegativeInts.setLower(0)
        maxTwoNonnegativeInts = CompositeValidator()
        maxTwoNonnegativeInts.add(IntArrayLengthValidator(lenmin=0, lenmax=2))
        maxTwoNonnegativeInts.add(nonnegativeInts)
        nonnegativeFloatArray = FloatArrayBoundedValidator()
        nonnegativeFloatArray.setLower(0.)
        stringArrayValidator = StringArrayLengthValidator()
        stringArrayValidator.setLengthMin(1)

        #======================== Main Properties ========================
        self.declareProperty(
            PropertyNames.POLARIZATION_OPTION, 'NonPolarized',
            StringListValidator(['NonPolarized', 'Polarized']),
            'Indicate whether measurements are polarized')

        is_polarized = EnabledWhenProperty(PropertyNames.POLARIZATION_OPTION,
                                           PropertyCriterion.IsEqualTo,
                                           'Polarized')
        is_not_polarized = EnabledWhenProperty(
            PropertyNames.POLARIZATION_OPTION, PropertyCriterion.IsEqualTo,
            'NonPolarized')
        polarized = 'Inputs for polarized measurements'

        self.declareProperty(MultipleFileProperty(
            PropertyNames.RB,
            action=FileAction.OptionalLoad,
            extensions=['nxs']),
                             doc='A list of reflected run numbers/files.')
        self.setPropertySettings(PropertyNames.RB, is_not_polarized)

        self.declareProperty(
            MultipleFileProperty(PropertyNames.RB00,
                                 action=FileAction.OptionalLoad,
                                 extensions=['nxs']),
            doc='A list of reflected run numbers/files for 00.')
        self.setPropertySettings(PropertyNames.RB00, is_polarized)
        self.setPropertyGroup(PropertyNames.RB00, polarized)

        self.declareProperty(
            MultipleFileProperty(PropertyNames.RB01,
                                 action=FileAction.OptionalLoad,
                                 extensions=['nxs']),
            doc='A list of reflected run numbers/files for 01.')
        self.setPropertySettings(PropertyNames.RB01, is_polarized)
        self.setPropertyGroup(PropertyNames.RB01, polarized)

        self.declareProperty(
            MultipleFileProperty(PropertyNames.RB10,
                                 action=FileAction.OptionalLoad,
                                 extensions=['nxs']),
            doc='A list of reflected run numbers/files for 10.')
        self.setPropertySettings(PropertyNames.RB10, is_polarized)
        self.setPropertyGroup(PropertyNames.RB10, polarized)

        self.declareProperty(
            MultipleFileProperty(PropertyNames.RB11,
                                 action=FileAction.OptionalLoad,
                                 extensions=['nxs']),
            doc='A list of reflected run numbers/files for 11.')
        self.setPropertySettings(PropertyNames.RB11, is_polarized)
        self.setPropertyGroup(PropertyNames.RB11, polarized)

        self.declareProperty(
            FileProperty(PropertyNames.EFFICIENCY_FILE,
                         defaultValue='',
                         action=FileAction.OptionalLoad),
            doc='A file containing the polarization efficiency factors.')
        self.setPropertySettings(PropertyNames.EFFICIENCY_FILE, is_polarized)
        self.setPropertyGroup(PropertyNames.EFFICIENCY_FILE, polarized)

        self.declareProperty(MultipleFileProperty(PropertyNames.DB,
                                                  action=FileAction.Load,
                                                  extensions=['nxs']),
                             doc='A list of direct run numbers/files.')
        self.declareProperty(WorkspaceGroupProperty(
            Prop.OUTPUT_WS, defaultValue='', direction=Direction.Output),
                             doc='The output workspace group.')
        self.declareProperty(
            PropertyNames.BKG_METHOD_DIRECT,
            defaultValue=BkgMethod.CONSTANT,
            validator=StringListValidator(
                [BkgMethod.CONSTANT, BkgMethod.LINEAR, BkgMethod.OFF]),
            doc='Flat background calculation method for background subtraction.'
        )
        self.declareProperty(
            PropertyNames.BKG_METHOD,
            defaultValue=BkgMethod.CONSTANT,
            validator=StringListValidator(
                [BkgMethod.CONSTANT, BkgMethod.LINEAR, BkgMethod.OFF]),
            doc='Flat background calculation method for background subtraction.'
        )
        self.copyProperties('ReflectometryILLPreprocess', [
            Prop.SUBALG_LOGGING, Prop.CLEANUP, Prop.WATER_REFERENCE,
            Prop.SLIT_NORM, Prop.FLUX_NORM_METHOD
        ])
        self.declareProperty(PropertyNames.SCALE_FACTOR,
                             defaultValue=1.0,
                             doc='Scale factor.')

        self.declareProperty(
            PropertyNames.USE_MANUAL_SCALE_FACTORS,
            defaultValue=False,
            doc='Choose to apply manual scale factors for stitching.')

        self.declareProperty(
            FloatArrayProperty(PropertyNames.MANUAL_SCALE_FACTORS, values=[]),
            doc=
            'A list of manual scale factors for stitching (number of anlge configurations minus 1)'
        )

        self.setPropertySettings(
            PropertyNames.MANUAL_SCALE_FACTORS,
            EnabledWhenProperty(PropertyNames.USE_MANUAL_SCALE_FACTORS,
                                PropertyCriterion.IsNotDefault))

        self.declareProperty(
            PropertyNames.CACHE_DIRECT_BEAM,
            defaultValue=False,
            doc=
            'Cache the processed direct beam in ADS for ready use with further reflected beams;'
            'saves important execution time, however assumes that the direct beam processing '
            'configuration must be invariant for different reflected beams.')

        # ======================== Common Properties ========================
        commonProp = 'Preprocessing common properties: provide a list or a single value'

        self.declareProperty(StringArrayProperty(
            PropertyNames.ANGLE_OPTION,
            values=[PropertyNames.DAN],
            validator=stringArrayValidator,
            direction=Direction.Input,
        ),
                             doc='Angle option used for detector positioning')
        self.declareProperty(FloatArrayProperty(PropertyNames.THETA,
                                                values=[-1.]),
                             doc='A user-defined angle theta in degree')
        self.declareProperty(StringArrayProperty(
            PropertyNames.SUM_TYPE,
            values=[PropertyNames.INCOHERENT],
            validator=stringArrayValidator,
            direction=Direction.Input,
        ),
                             doc='Type of summation to perform')
        self.declareProperty(FloatArrayProperty(
            PropertyNames.WAVELENGTH_LOWER,
            values=[0.],
            validator=nonnegativeFloatArray),
                             doc='The lower wavelength bound (Angstrom)')
        self.declareProperty(FloatArrayProperty(
            PropertyNames.WAVELENGTH_UPPER,
            values=[35.],
            validator=nonnegativeFloatArray),
                             doc='The upper wavelength bound (Angstrom)')
        self.declareProperty(
            FloatArrayProperty(
                PropertyNames.GROUPING_FRACTION,
                values=[0.5],
                validator=nonnegativeFloatArray,
            ),
            doc=
            'If set, group the output by steps of this fraction multiplied by Q resolution'
        )
        self.setPropertyGroup(PropertyNames.ANGLE_OPTION, commonProp)
        self.setPropertyGroup(PropertyNames.THETA, commonProp)
        self.setPropertyGroup(PropertyNames.SUM_TYPE, commonProp)
        self.setPropertyGroup(PropertyNames.WAVELENGTH_LOWER, commonProp)
        self.setPropertyGroup(PropertyNames.WAVELENGTH_UPPER, commonProp)
        self.setPropertyGroup(PropertyNames.GROUPING_FRACTION, commonProp)

        # ======================== Direct Run Properties ========================
        preProcessDirect = 'Preprocessing for direct runs: provide a list or a single value'

        self.declareProperty(
            IntArrayProperty(PropertyNames.LOW_FRG_HALF_WIDTH_DIRECT,
                             values=[0],
                             validator=nonnegativeInts),
            doc=
            'Number of foreground pixels at lower angles from the centre pixel.'
        )
        self.setPropertyGroup(PropertyNames.LOW_FRG_HALF_WIDTH_DIRECT,
                              preProcessDirect)
        self.declareProperty(
            IntArrayProperty(
                PropertyNames.LOW_BKG_OFFSET_DIRECT,
                values=[7],
                validator=nonnegativeInts,
            ),
            doc=
            'Distance of flat background region towards smaller detector angles from the '
            + 'foreground centre, in pixels')
        self.setPropertyGroup(PropertyNames.LOW_BKG_OFFSET_DIRECT,
                              preProcessDirect)
        self.declareProperty(
            IntArrayProperty(
                PropertyNames.LOW_BKG_WIDTH_DIRECT,
                values=[5],
                validator=nonnegativeInts,
            ),
            doc=
            'Width of flat background region towards smaller detector angles from the '
            + 'foreground centre, in pixels')
        self.setPropertyGroup(PropertyNames.LOW_BKG_WIDTH_DIRECT,
                              preProcessDirect)
        self.declareProperty(
            IntArrayProperty(PropertyNames.HIGH_FRG_HALF_WIDTH_DIRECT,
                             values=[0],
                             validator=nonnegativeInts),
            doc=
            'Number of foreground pixels at higher angles from the centre pixel.'
        )
        self.setPropertyGroup(PropertyNames.HIGH_FRG_HALF_WIDTH_DIRECT,
                              preProcessDirect)
        self.declareProperty(
            IntArrayProperty(
                PropertyNames.HIGH_BKG_OFFSET_DIRECT,
                values=[7],
                validator=nonnegativeInts,
            ),
            doc=
            'Distance of flat background region towards larger detector angles from the '
            + 'foreground centre, in pixels')
        self.setPropertyGroup(PropertyNames.HIGH_BKG_OFFSET_DIRECT,
                              preProcessDirect)
        self.declareProperty(
            IntArrayProperty(
                PropertyNames.HIGH_BKG_WIDTH_DIRECT,
                values=[5],
                validator=nonnegativeInts,
            ),
            doc=
            'Width of flat background region towards larger detector angles from the '
            + 'foreground centre, in pixels')
        self.setPropertyGroup(PropertyNames.HIGH_BKG_WIDTH_DIRECT,
                              preProcessDirect)
        self.declareProperty(IntArrayProperty(
            PropertyNames.START_WS_INDEX_DIRECT,
            values=[0],
            validator=nonnegativeInts,
        ),
                             doc='Start histogram index used for peak fitting')
        self.setPropertyGroup(PropertyNames.START_WS_INDEX_DIRECT,
                              preProcessDirect)
        self.declareProperty(IntArrayProperty(
            PropertyNames.END_WS_INDEX_DIRECT,
            values=[255],
            validator=nonnegativeInts,
        ),
                             doc='Last histogram index used for peak fitting')
        self.setPropertyGroup(PropertyNames.END_WS_INDEX_DIRECT,
                              preProcessDirect)
        self.declareProperty(
            PropertyNames.XMIN_DIRECT,
            defaultValue=-1.,
            doc='Minimum x value (unit wavelength) used for peak fitting.')
        self.setPropertyGroup(PropertyNames.XMIN_DIRECT, preProcessDirect)
        self.declareProperty(
            PropertyNames.XMAX_DIRECT,
            defaultValue=-1.,
            doc='Maximum x value (unit wavelength) used for peak fitting.')
        self.setPropertyGroup(PropertyNames.XMAX_DIRECT, preProcessDirect)

        # ======================== Preprocessing For Reflected Runs ========================
        preProcessReflected = 'Preprocessing for reflected runs: provide a list or a single value'

        self.declareProperty(
            IntArrayProperty(
                PropertyNames.LOW_FRG_HALF_WIDTH,
                values=[0],
                validator=nonnegativeInts,
            ),
            doc=
            'Number of foreground pixels at lower angles from the centre pixel.'
        )
        self.setPropertyGroup(PropertyNames.LOW_FRG_HALF_WIDTH,
                              preProcessReflected)
        self.declareProperty(
            IntArrayProperty(
                PropertyNames.LOW_BKG_OFFSET,
                values=[7],
                validator=nonnegativeInts,
            ),
            doc=
            'Distance of flat background region towards smaller detector angles from the '
            + 'foreground centre, in pixels.')
        self.setPropertyGroup(PropertyNames.LOW_BKG_OFFSET,
                              preProcessReflected)
        self.declareProperty(
            IntArrayProperty(
                PropertyNames.LOW_BKG_WIDTH,
                values=[5],
                validator=nonnegativeInts,
            ),
            doc=
            'Width of flat background region towards smaller detector angles from the '
            + 'foreground centre, in pixels')
        self.setPropertyGroup(PropertyNames.LOW_BKG_WIDTH, preProcessReflected)
        self.declareProperty(
            IntArrayProperty(
                PropertyNames.HIGH_FRG_HALF_WIDTH,
                values=[0],
                validator=nonnegativeInts,
            ),
            doc=
            'Number of foreground pixels at higher angles from the centre pixel.'
        )
        self.setPropertyGroup(PropertyNames.HIGH_FRG_HALF_WIDTH,
                              preProcessReflected)
        self.declareProperty(
            IntArrayProperty(
                PropertyNames.HIGH_BKG_OFFSET,
                values=[7],
                validator=nonnegativeInts,
            ),
            doc=
            'Distance of flat background region towards larger detector angles from the '
            + 'foreground centre, in pixels')
        self.setPropertyGroup(PropertyNames.HIGH_BKG_OFFSET,
                              preProcessReflected)
        self.declareProperty(
            IntArrayProperty(
                PropertyNames.HIGH_BKG_WIDTH,
                values=[5],
                validator=nonnegativeInts,
            ),
            doc=
            'Width of flat background region towards larger detector angles from the '
            + 'foreground centre, in pixels.')
        self.setPropertyGroup(PropertyNames.HIGH_BKG_WIDTH,
                              preProcessReflected)
        self.declareProperty(IntArrayProperty(
            PropertyNames.START_WS_INDEX,
            values=[0],
            validator=nonnegativeInts,
        ),
                             doc='Start histogram index used for peak fitting')
        self.setPropertyGroup(PropertyNames.START_WS_INDEX,
                              preProcessReflected)
        self.declareProperty(IntArrayProperty(
            PropertyNames.END_WS_INDEX,
            values=[255],
            validator=nonnegativeInts,
        ),
                             doc='Last histogram index used for peak fitting')
        self.setPropertyGroup(PropertyNames.END_WS_INDEX, preProcessReflected)
        self.declareProperty(
            FloatArrayProperty(PropertyNames.XMIN, values=[-1.]),
            doc='Minimum x value (unit wavelength) used for peak fitting')
        self.setPropertyGroup(PropertyNames.XMIN, preProcessReflected)
        self.declareProperty(
            FloatArrayProperty(PropertyNames.XMAX, values=[-1.]),
            doc='Maximum x value (unit wavelength) used for peak fitting')
        self.setPropertyGroup(PropertyNames.XMAX, preProcessReflected)