Example #1
0
    def PyInit(self):
        # input
        self.declareProperty(MatrixWorkspaceProperty("Workspace", "",
                                                     Direction.Input),
                             doc="input workspace")
        self.declareProperty(name="Index",
                             defaultValue=0,
                             validator=IntBoundedValidator(lower=0),
                             doc="workspace index - which spectrum to fit")

        # output
        self.declareProperty(name="PeakCentre",
                             defaultValue=0.,
                             direction=Direction.Output,
                             doc="the centre of the fitted peak")
        self.declareProperty(
            name="Sigma",
            defaultValue=0.,
            direction=Direction.Output,
            doc="the sigma of the fitted peak; 0. if fitting was not successful"
        )
Example #2
0
    def PyInit(self):
        """ Declare properties
        """
        self.declareProperty(
            FileProperty("Filename", "", FileAction.Load,
                         ['.hkl', '.prf', '.dat']),
            "Name of [http://www.ill.eu/sites/fullprof/ Fullprof] .hkl or .prf file."
        )

        #self.declareProperty("Bank", 1, "Bank ID for output if there are more than one bank in .irf file.")

        self.declareProperty(
            ITableWorkspaceProperty("PeakParameterWorkspace", "",
                                    Direction.Output),
            "Name of table workspace containing peak parameters from .hkl file."
        )

        self.declareProperty(
            MatrixWorkspaceProperty("OutputWorkspace", "", Direction.Output),
            "Name of data workspace containing the diffraction pattern in .prf file. "
        )

        return
Example #3
0
    def PyInit(self):
        # ----------
        # INPUT
        # ----------
        self.declareProperty(
            'SANSState',
            "",
            doc='A JSON String which fulfills the SANSState contract.')

        self.declareProperty(
            "PublishToCache",
            True,
            direction=Direction.Input,
            doc=
            "Publish the calibration workspace to a cache, in order to avoid reloading "
            "for subsequent runs.")

        self.declareProperty(
            "UseCached",
            True,
            direction=Direction.Input,
            doc=
            "Checks if there are loaded files available. If they are, those files are used."
        )

        # Beam coordinates if an initial move of the workspace is requested
        self.declareProperty(
            FloatArrayProperty(name='BeamCoordinates', values=[]),
            doc=
            'The coordinates which is used to position the instrument component(s). '
            'If the workspaces should be loaded with an initial move, then this '
            'needs to be specified.')
        # Components which are to be moved
        self.declareProperty(
            'Component',
            '',
            direction=Direction.Input,
            doc='Component that should be moved. '
            'If the workspaces should be loaded with an initial move, then this '
            'needs to be specified.')

        # ------------
        #  OUTPUT
        # ------------
        default_number_of_workspaces = 0

        # Sample Scatter Workspaces
        self.declareProperty(
            WorkspaceProperty('SampleScatterWorkspace',
                              '',
                              optional=PropertyMode.Optional,
                              direction=Direction.Output),
            doc=
            'The sample scatter workspace. This workspace does not contain monitors.'
        )
        self.declareProperty(
            WorkspaceProperty('SampleScatterMonitorWorkspace',
                              '',
                              optional=PropertyMode.Optional,
                              direction=Direction.Output),
            doc=
            'The sample scatter monitor workspace. This workspace only contains monitors.'
        )
        self.declareProperty(MatrixWorkspaceProperty(
            'SampleTransmissionWorkspace',
            '',
            optional=PropertyMode.Optional,
            direction=Direction.Output),
                             doc='The sample transmission workspace.')
        self.declareProperty(MatrixWorkspaceProperty(
            'SampleDirectWorkspace',
            '',
            optional=PropertyMode.Optional,
            direction=Direction.Output),
                             doc='The sample scatter direct workspace.')

        self.setPropertyGroup("SampleScatterWorkspace", 'Sample')
        self.setPropertyGroup("SampleScatterMonitorWorkspace", 'Sample')
        self.setPropertyGroup("SampleTransmissionWorkspace", 'Sample')
        self.setPropertyGroup("SampleDirectWorkspace", 'Sample')

        # Number of sample workspaces
        self.declareProperty('NumberOfSampleScatterWorkspaces',
                             defaultValue=default_number_of_workspaces,
                             direction=Direction.Output,
                             doc='The number of workspace for sample scatter.')
        self.declareProperty(
            'NumberOfSampleTransmissionWorkspaces',
            defaultValue=default_number_of_workspaces,
            direction=Direction.Output,
            doc='The number of workspace for sample transmission.')
        self.declareProperty('NumberOfSampleDirectWorkspaces',
                             defaultValue=default_number_of_workspaces,
                             direction=Direction.Output,
                             doc='The number of workspace for sample direct.')

        self.declareProperty(
            MatrixWorkspaceProperty('CanScatterWorkspace',
                                    '',
                                    optional=PropertyMode.Optional,
                                    direction=Direction.Output),
            doc=
            'The can scatter workspace. This workspace does not contain monitors.'
        )
        self.declareProperty(
            MatrixWorkspaceProperty('CanScatterMonitorWorkspace',
                                    '',
                                    optional=PropertyMode.Optional,
                                    direction=Direction.Output),
            doc=
            'The can scatter monitor workspace. This workspace only contains monitors.'
        )
        self.declareProperty(MatrixWorkspaceProperty(
            'CanTransmissionWorkspace',
            '',
            optional=PropertyMode.Optional,
            direction=Direction.Output),
                             doc='The can transmission workspace.')
        self.declareProperty(MatrixWorkspaceProperty(
            'CanDirectWorkspace',
            '',
            optional=PropertyMode.Optional,
            direction=Direction.Output),
                             doc='The sample scatter direct workspace.')
        self.setPropertyGroup("CanScatterWorkspace", 'Can')
        self.setPropertyGroup("CanScatterMonitorWorkspace", 'Can')
        self.setPropertyGroup("CanTransmissionWorkspace", 'Can')
        self.setPropertyGroup("CanDirectWorkspace", 'Can')

        self.declareProperty('NumberOfCanScatterWorkspaces',
                             defaultValue=default_number_of_workspaces,
                             direction=Direction.Output,
                             doc='The number of workspace for can scatter.')
        self.declareProperty(
            'NumberOfCanTransmissionWorkspaces',
            defaultValue=default_number_of_workspaces,
            direction=Direction.Output,
            doc='The number of workspace for can transmission.')
        self.declareProperty('NumberOfCanDirectWorkspaces',
                             defaultValue=default_number_of_workspaces,
                             direction=Direction.Output,
                             doc='The number of workspace for can direct.')
    def PyInit(self):
        # input
        self.declareProperty(MatrixWorkspaceProperty(
            'InputWorkspace',
            '',
            direction=Direction.Input,
            optional=PropertyMode.Mandatory),
                             doc='Particle counts as a function of wavelength')

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        self.declareProperty(
            MatrixWorkspaceProperty('OutputWorkspaceTransmissionFit',
                                    '',
                                    direction=Direction.Output),
            # This works only when transmission is True. Problems starts when it is not...
            doc='Counts vs wavelength, fit for the sample transmission')
Example #5
0
 def PyInit(self):
     self.declareProperty(MatrixWorkspaceProperty("RequiredWorkspace", "", Direction.Output))
     self.declareProperty(MatrixWorkspaceProperty("OptionalWorkspace", "", Direction.Output, PropertyMode.Optional))
Example #6
0
    def PyInit(self):
        # ----------
        # INPUT
        # ----------
        self.declareProperty(
            PropertyManagerProperty('SANSState'),
            doc='A property manager which fulfills the SANSState contract.')

        self.declareProperty(
            "UseOptimizations",
            True,
            direction=Direction.Input,
            doc=
            "When enabled the ADS is being searched for already loaded and reduced workspaces. "
            "Depending on your concrete reduction, this could provide a significant"
            " performance boost")

        # Sample Scatter Workspaces
        self.declareProperty(
            MatrixWorkspaceProperty('SampleScatterWorkspace',
                                    '',
                                    optional=PropertyMode.Mandatory,
                                    direction=Direction.Input),
            doc=
            'The sample scatter workspace. This workspace does not contain monitors.'
        )
        self.declareProperty(
            MatrixWorkspaceProperty('SampleScatterMonitorWorkspace',
                                    '',
                                    optional=PropertyMode.Mandatory,
                                    direction=Direction.Input),
            doc=
            'The sample scatter monitor workspace. This workspace only contains monitors.'
        )

        # Sample Transmission Workspace
        self.declareProperty(MatrixWorkspaceProperty(
            'SampleTransmissionWorkspace',
            '',
            optional=PropertyMode.Optional,
            direction=Direction.Input),
                             doc='The sample transmission workspace.')

        # Sample Direct Workspace
        self.declareProperty(MatrixWorkspaceProperty(
            'SampleDirectWorkspace',
            '',
            optional=PropertyMode.Optional,
            direction=Direction.Input),
                             doc='The sample scatter direct workspace.')

        self.setPropertyGroup("SampleScatterWorkspace", 'Sample')
        self.setPropertyGroup("SampleScatterMonitorWorkspace", 'Sample')
        self.setPropertyGroup("SampleTransmissionWorkspace", 'Sample')
        self.setPropertyGroup("SampleDirectWorkspace", 'Sample')

        # Can Scatter Workspaces
        self.declareProperty(
            MatrixWorkspaceProperty('CanScatterWorkspace',
                                    '',
                                    optional=PropertyMode.Optional,
                                    direction=Direction.Input),
            doc=
            'The can scatter workspace. This workspace does not contain monitors.'
        )
        self.declareProperty(
            MatrixWorkspaceProperty('CanScatterMonitorWorkspace',
                                    '',
                                    optional=PropertyMode.Optional,
                                    direction=Direction.Input),
            doc=
            'The can scatter monitor workspace. This workspace only contains monitors.'
        )

        # Sample Transmission Workspace
        self.declareProperty(MatrixWorkspaceProperty(
            'CanTransmissionWorkspace',
            '',
            optional=PropertyMode.Optional,
            direction=Direction.Input),
                             doc='The can transmission workspace.')

        # Sample Direct Workspace
        self.declareProperty(MatrixWorkspaceProperty(
            'CanDirectWorkspace',
            '',
            optional=PropertyMode.Optional,
            direction=Direction.Input),
                             doc='The sample scatter direct workspace.')

        self.setPropertyGroup("CanScatterWorkspace", 'Can')
        self.setPropertyGroup("CanScatterMonitorWorkspace", 'Can')
        self.setPropertyGroup("CanTransmissionWorkspace", 'Can')
        self.setPropertyGroup("CanDirectWorkspace", 'Can')

        # ----------
        # OUTPUT
        # ----------
        self.declareProperty('OutScaleFactor',
                             defaultValue=Property.EMPTY_DBL,
                             direction=Direction.Output,
                             doc='Applied scale factor.')

        self.declareProperty('OutShiftFactor',
                             defaultValue=Property.EMPTY_DBL,
                             direction=Direction.Output,
                             doc='Applied shift factor.')

        # This breaks our flexibility with the reduction mode. We need to check if we can populate this based on
        # the available reduction modes for the state input. TODO: check if this is possible
        self.declareProperty(
            MatrixWorkspaceProperty('OutputWorkspaceLAB',
                                    '',
                                    optional=PropertyMode.Optional,
                                    direction=Direction.Output),
            doc='The output workspace for the low-angle bank.')
        self.declareProperty(
            MatrixWorkspaceProperty('OutputWorkspaceHAB',
                                    '',
                                    optional=PropertyMode.Optional,
                                    direction=Direction.Output),
            doc='The output workspace for the high-angle bank.')
        self.declareProperty(
            MatrixWorkspaceProperty('OutputWorkspaceMerged',
                                    '',
                                    optional=PropertyMode.Optional,
                                    direction=Direction.Output),
            doc='The output workspace for the merged reduction.')
        self.setPropertyGroup("OutScaleFactor", 'Output')
        self.setPropertyGroup("OutShiftFactor", 'Output')
        self.setPropertyGroup("OutputWorkspaceLAB", 'Output')
        self.setPropertyGroup("OutputWorkspaceHAB", 'Output')
        self.setPropertyGroup("OutputWorkspaceMerged", 'Output')

        # CAN output
        # We want to output the can workspaces since they can be persited in the case of optimizations
        self.declareProperty(
            MatrixWorkspaceProperty('OutputWorkspaceLABCan',
                                    '',
                                    optional=PropertyMode.Optional,
                                    direction=Direction.Output),
            doc=
            'The can output workspace for the low-angle bank, provided there is one.'
        )
        self.declareProperty(
            MatrixWorkspaceProperty('OutputWorkspaceLABCanCount',
                                    '',
                                    optional=PropertyMode.Optional,
                                    direction=Direction.Output),
            doc=
            'The can count output workspace for the low-angle bank, provided there is one.'
        )
        self.declareProperty(
            MatrixWorkspaceProperty('OutputWorkspaceLABCanNorm',
                                    '',
                                    optional=PropertyMode.Optional,
                                    direction=Direction.Output),
            doc=
            'The can norm output workspace for the low-angle bank, provided there is one.'
        )

        self.declareProperty(
            MatrixWorkspaceProperty('OutputWorkspaceHABCan',
                                    '',
                                    optional=PropertyMode.Optional,
                                    direction=Direction.Output),
            doc=
            'The can output workspace for the high-angle bank, provided there is one.'
        )
        self.declareProperty(
            MatrixWorkspaceProperty('OutputWorkspaceHABCanCount',
                                    '',
                                    optional=PropertyMode.Optional,
                                    direction=Direction.Output),
            doc=
            'The can count output workspace for the high-angle bank, provided there is one.'
        )
        self.declareProperty(
            MatrixWorkspaceProperty('OutputWorkspaceHABCanNorm',
                                    '',
                                    optional=PropertyMode.Optional,
                                    direction=Direction.Output),
            doc=
            'The can norm output workspace for the high-angle bank, provided there is one.'
        )
        self.setPropertyGroup("OutputWorkspaceLABCan", 'Can Output')
        self.setPropertyGroup("OutputWorkspaceLABCanCount", 'Can Output')
        self.setPropertyGroup("OutputWorkspaceLABCanNorm", 'Can Output')
        self.setPropertyGroup("OutputWorkspaceHABCan", 'Can Output')
        self.setPropertyGroup("OutputWorkspaceHABCanCount", 'Can Output')
        self.setPropertyGroup("OutputWorkspaceHABCanNorm", 'Can Output')
Example #7
0
    def PyInit(self):
        """Initialize the algorithm's input and output properties."""
        PROPGROUP_REBINNING = 'Rebinning for SofQW'
        inputWorkspaceValidator = CompositeValidator()
        inputWorkspaceValidator.add(InstrumentValidator())
        inputWorkspaceValidator.add(WorkspaceUnitValidator('TOF'))
        positiveFloat = FloatBoundedValidator(0., exclusive=True)
        validRebinParams = RebinParamsValidator(AllowEmpty=True)

        # Properties.
        self.declareProperty(MatrixWorkspaceProperty(
            name=common.PROP_INPUT_WS,
            defaultValue='',
            validator=inputWorkspaceValidator,
            direction=Direction.Input),
                             doc='A workspace to reduce.')
        self.declareProperty(WorkspaceProperty(name=common.PROP_OUTPUT_WS,
                                               defaultValue='',
                                               direction=Direction.Output),
                             doc='The reduced S(Q, DeltaE) workspace.')
        self.declareProperty(name=common.PROP_CLEANUP_MODE,
                             defaultValue=utils.Cleanup.ON,
                             validator=StringListValidator(
                                 [utils.Cleanup.ON, utils.Cleanup.OFF]),
                             direction=Direction.Input,
                             doc='What to do with intermediate workspaces.')
        self.declareProperty(
            name=common.PROP_SUBALG_LOGGING,
            defaultValue=common.SUBALG_LOGGING_OFF,
            validator=StringListValidator(
                [common.SUBALG_LOGGING_OFF, common.SUBALG_LOGGING_ON]),
            direction=Direction.Input,
            doc='Enable or disable subalgorithms to ' + 'print in the logs.')
        self.declareProperty(MatrixWorkspaceProperty(
            name=common.PROP_VANA_WS,
            defaultValue='',
            validator=inputWorkspaceValidator,
            direction=Direction.Input,
            optional=PropertyMode.Optional),
                             doc='An integrated vanadium workspace.')
        self.declareProperty(
            name=common.PROP_ABSOLUTE_UNITS,
            defaultValue=common.ABSOLUTE_UNITS_OFF,
            validator=StringListValidator(
                [common.ABSOLUTE_UNITS_OFF, common.ABSOLUTE_UNITS_ON]),
            direction=Direction.Input,
            doc='Enable or disable normalisation to absolute units.')
        self.declareProperty(MatrixWorkspaceProperty(
            name=common.PROP_DIAGNOSTICS_WS,
            defaultValue='',
            direction=Direction.Input,
            optional=PropertyMode.Optional),
                             doc='Detector diagnostics workspace for masking.')
        self.declareProperty(
            name=common.PROP_GROUPING_ANGLE_STEP,
            defaultValue=Property.EMPTY_DBL,
            validator=positiveFloat,
            doc=
            'A scattering angle step to which to group detectors, in degrees.')
        self.declareProperty(FloatArrayProperty(
            name=common.PROP_REBINNING_PARAMS_W, validator=validRebinParams),
                             doc='Manual energy rebinning parameters.')
        self.setPropertyGroup(common.PROP_REBINNING_PARAMS_W,
                              PROPGROUP_REBINNING)
        self.declareProperty(
            name=common.PROP_REBINNING_W,
            defaultValue='',
            doc=
            'Energy rebinning when mixing manual and automatic binning parameters.'
        )
        self.declareProperty(FloatArrayProperty(
            name=common.PROP_BINNING_PARAMS_Q, validator=validRebinParams),
                             doc='Manual q rebinning parameters.')
        self.setPropertyGroup(common.PROP_BINNING_PARAMS_Q,
                              PROPGROUP_REBINNING)
        self.declareProperty(
            name=common.PROP_TRANSPOSE_SAMPLE_OUTPUT,
            defaultValue=common.TRANSPOSING_ON,
            validator=StringListValidator(
                [common.TRANSPOSING_ON, common.TRANSPOSING_OFF]),
            direction=Direction.Input,
            doc='Enable or disable ' + common.PROP_OUTPUT_WS + ' transposing.')
        self.declareProperty(
            WorkspaceProperty(name=common.PROP_OUTPUT_THETA_W_WS,
                              defaultValue='',
                              direction=Direction.Output,
                              optional=PropertyMode.Optional),
            doc='Output workspace for reduced S(theta, DeltaE).')
        self.setPropertyGroup(common.PROP_OUTPUT_THETA_W_WS,
                              common.PROPGROUP_OPTIONAL_OUTPUT)
    def PyInit(self):
        # Sample options
        self.declareProperty(MatrixWorkspaceProperty(
            'SampleWorkspace', '', direction=Direction.Input),
                             doc='Sample workspace.')
        self.declareProperty(name='SampleChemicalFormula',
                             defaultValue='',
                             validator=StringMandatoryValidator(),
                             doc='Sample chemical formula')
        self.declareProperty(name='SampleDensityType',
                             defaultValue='Mass Density',
                             validator=StringListValidator(
                                 ['Mass Density', 'Number Density']),
                             doc='Use of Mass Density or Number density')
        self.declareProperty(
            name='SampleDensity',
            defaultValue=0.1,
            doc='Mass Density (g/cm^3) or Number density (atoms/Angstrom^3)')
        self.declareProperty(name='SampleRadius',
                             defaultValue=0.1,
                             validator=FloatBoundedValidator(0.0),
                             doc='Sample radius')
        self.declareProperty(name='SampleHeight',
                             defaultValue=1.0,
                             validator=FloatBoundedValidator(0.0),
                             doc='Sample height')

        # Container options
        self.declareProperty(MatrixWorkspaceProperty(
            'CanWorkspace',
            '',
            optional=PropertyMode.Optional,
            direction=Direction.Input),
                             doc='Container workspace.')
        self.declareProperty(name='UseCanCorrections',
                             defaultValue=False,
                             doc='Use can corrections in subtraction')
        self.declareProperty(name='CanChemicalFormula',
                             defaultValue='',
                             doc='Can chemical formula')
        self.declareProperty(name='CanDensityType',
                             defaultValue='Mass Density',
                             validator=StringListValidator(
                                 ['Mass Density', 'Number Density']),
                             doc='Use of Mass Density or Number density')
        self.declareProperty(
            name='CanDensity',
            defaultValue=0.1,
            doc='Mass Density (g/cm^3) or Number density (atoms/Angstrom^3)')
        self.declareProperty(name='CanRadius',
                             defaultValue=0.2,
                             validator=FloatBoundedValidator(0.0),
                             doc='Can radius')
        self.declareProperty(name='CanScaleFactor',
                             defaultValue=1.0,
                             validator=FloatBoundedValidator(0.0),
                             doc='Scale factor to multiply can data')

        # Beam size
        self.declareProperty(name='BeamHeight',
                             defaultValue=1.0,
                             validator=FloatBoundedValidator(0.0),
                             doc='Height of the beam (cm)')
        self.declareProperty(name='BeamWidth',
                             defaultValue=1.0,
                             validator=FloatBoundedValidator(0.0),
                             doc='Width of the beam (cm)')

        # General options
        self.declareProperty(name='NumberWavelengths',
                             defaultValue=10,
                             validator=IntBoundedValidator(1),
                             doc='Number of wavelengths for calculation')

        self.declareProperty(name='Events',
                             defaultValue=5000,
                             validator=IntBoundedValidator(0),
                             doc='Number of neutron events')

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

        self.declareProperty(
            WorkspaceGroupProperty('CorrectionsWorkspace',
                                   '',
                                   direction=Direction.Output,
                                   optional=PropertyMode.Optional),
            doc=
            'The corrections workspace for scattering and absorptions in sample.'
        )
    def PyInit(self):

        self.declareProperty(MultipleFileProperty('Run', extensions=['nxs']),
                             doc='File path of run(s).')

        self.declareProperty(FileProperty('CalibrationFile',
                                          '',
                                          action=FileAction.OptionalLoad,
                                          extensions=['nxs']),
                             doc='File containing the detector efficiencies.')

        self.declareProperty(
            FileProperty('ROCCorrectionFile',
                         '',
                         action=FileAction.OptionalLoad,
                         extensions=['nxs']),
            doc=
            'File containing the radial oscillating collimator (ROC) corrections.'
        )

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

        thetaRangeValidator = FloatArrayOrderedPairsValidator()

        self.declareProperty(
            FloatArrayProperty(name='ROI',
                               values=[0, 153.6],
                               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(name='Observable',
                             defaultValue='sample.temperature',
                             doc='Scanning observable, a Sample Log entry.')

        self.declareProperty(
            name='SortObservableAxis',
            defaultValue=False,
            doc='Whether or not to sort the scanning observable axis.')

        self.declareProperty(
            name='ScanAxisBinWidth',
            defaultValue=0.,
            validator=FloatBoundedValidator(lower=0.),
            doc=
            'Rebin the observable axis to this width. Default is to not rebin.'
        )

        self.declareProperty(
            name='CropNegative2Theta',
            defaultValue=True,
            doc=
            'Whether or not to crop out the bins corresponding to negative scattering angle.'
        )

        self.declareProperty(
            name='ZeroCountingCells',
            defaultValue='Interpolate',
            validator=StringListValidator(['Crop', 'Interpolate', 'Leave']),
            doc=
            'Crop out the zero counting cells or interpolate the counts from the neighbours.'
        )

        self.declareProperty(name='Unit',
                             defaultValue='ScatteringAngle',
                             validator=StringListValidator([
                                 'ScatteringAngle', 'MomentumTransfer',
                                 'dSpacing'
                             ]),
                             doc='The unit of the reduced diffractogram.')

        self.declareProperty(
            MatrixWorkspaceProperty('OutputWorkspace',
                                    '',
                                    direction=Direction.Output),
            doc='Output workspace containing the reduced data.')
    def PyInit(self):
        # basic sample options

        self.declareProperty(MatrixWorkspaceProperty(
            'InputWorkspace', '', direction=Direction.Input),
                             doc='Input workspace')

        self.declareProperty(
            name='MaterialAlreadyDefined',
            defaultValue=False,
            doc='Select this option if the material has already been defined')

        material_defined_prop = EnabledWhenProperty(
            'MaterialAlreadyDefined', PropertyCriterion.IsDefault)

        self.declareProperty(name='ChemicalFormula',
                             defaultValue='',
                             doc='Chemical formula of sample')
        self.setPropertySettings('ChemicalFormula', material_defined_prop)

        self.declareProperty(name='DensityType',
                             defaultValue='Mass Density',
                             validator=StringListValidator(
                                 ['Mass Density', 'Number Density']),
                             doc='Use of Mass density or Number density')
        self.setPropertySettings('DensityType', material_defined_prop)

        self.declareProperty(
            name='Density',
            defaultValue=0.1,
            doc='Mass density (g/cm^3) or Number density (atoms/Angstrom^3)')
        self.setPropertySettings('Density', material_defined_prop)

        # -------------------------------------------------------------------------------------------

        # Monte Carlo options
        self.declareProperty(name='NumberOfWavelengthPoints',
                             defaultValue=10,
                             validator=IntBoundedValidator(1),
                             doc='Number of wavelengths for calculation')

        self.declareProperty(name='EventsPerPoint',
                             defaultValue=1000,
                             validator=IntBoundedValidator(0),
                             doc='Number of neutron events')

        self.declareProperty(name='Interpolation',
                             defaultValue='Linear',
                             validator=StringListValidator(
                                 ['Linear', 'CSpline']),
                             doc='Type of interpolation')

        # -------------------------------------------------------------------------------------------

        # Beam size
        self.declareProperty(name='BeamHeight',
                             defaultValue=1.0,
                             validator=FloatBoundedValidator(0.0),
                             doc='Height of the beam (cm)')

        self.declareProperty(name='BeamWidth',
                             defaultValue=1.0,
                             validator=FloatBoundedValidator(0.0),
                             doc='Width of the beam (cm)')

        # -------------------------------------------------------------------------------------------

        # set up shape options

        self.declareProperty(
            name='Shape',
            defaultValue='FlatPlate',
            validator=StringListValidator(['FlatPlate', 'Cylinder',
                                           'Annulus']),
            doc=
            'Geometry of sample environment. Options are: FlatPlate, Cylinder, Annulus'
        )

        flat_plate_condition = VisibleWhenProperty('Shape',
                                                   PropertyCriterion.IsEqualTo,
                                                   'FlatPlate')
        cylinder_condition = VisibleWhenProperty('Shape',
                                                 PropertyCriterion.IsEqualTo,
                                                 'Cylinder')
        annulus_condition = VisibleWhenProperty('Shape',
                                                PropertyCriterion.IsEqualTo,
                                                'Annulus')

        # height is common to all options

        self.declareProperty(name='Height',
                             defaultValue=0.0,
                             validator=FloatBoundedValidator(0.0),
                             doc='Height of the sample environment (cm)')

        # flat plate options

        self.declareProperty(
            name='Width',
            defaultValue=0.0,
            validator=FloatBoundedValidator(0.0),
            doc='Width of the FlatPlate sample environment (cm)')
        self.setPropertySettings('Width', flat_plate_condition)

        self.declareProperty(
            name='Thickness',
            defaultValue=0.0,
            validator=FloatBoundedValidator(),
            doc='Thickness of the FlatPlate sample environment (cm)')
        self.setPropertySettings('Thickness', flat_plate_condition)

        self.declareProperty(name='Center',
                             defaultValue=0.0,
                             doc='Center of the FlatPlate sample environment')
        self.setPropertySettings('Center', flat_plate_condition)

        self.declareProperty(
            name='Angle',
            defaultValue=0.0,
            validator=FloatBoundedValidator(0.0),
            doc=
            'Angle of the FlatPlate sample environment with respect to the beam (degrees)'
        )
        self.setPropertySettings('Angle', flat_plate_condition)

        # cylinder options

        self.declareProperty(
            name='Radius',
            defaultValue=0.0,
            validator=FloatBoundedValidator(0.0),
            doc='Radius of the Cylinder sample environment (cm)')
        self.setPropertySettings('Radius', cylinder_condition)

        # annulus options

        self.declareProperty(
            name='OuterRadius',
            defaultValue=0.0,
            validator=FloatBoundedValidator(0.0),
            doc='Outer radius of the Annulus sample environment (cm)')
        self.setPropertySettings('OuterRadius', annulus_condition)

        self.declareProperty(
            name='InnerRadius',
            defaultValue=0.0,
            validator=FloatBoundedValidator(0.0),
            doc='Inner radius of the Annulus sample environment (cm)')
        self.setPropertySettings('InnerRadius', annulus_condition)

        # -------------------------------------------------------------------------------------------

        # Output options
        self.declareProperty(MatrixWorkspaceProperty(
            'OutputWorkspace', '', direction=Direction.Output),
                             doc='The output corrected workspace.')
Example #11
0
    def PyInit(self):

        refine_methods = ["Pawley refinement", "Rietveld refinement", "Peak fitting"]
        self.declareProperty(self.PROP_METHOD, defaultValue = refine_methods[0],
                             validator = StringListValidator(refine_methods),
                             doc = 'Rietveld corresponds to the Calculate/Refine option of the '
                             'GSAS-II GUI. Peak fitting is single peak (does not use phase '
                             'information  and corresponds to the option '
                             'Peaks List/Peak Fitting/PeakFitType of the GSAS-II GUI. The '
                             'third alternative requires a list of peaks which can be bassed in '
                             'the properties ' + self.PROP_EXPECTED_PEAKS + ' and ' +
                             self.PROP_EXPECTED_PEAKS_FROM_FILE + '.')

        self.declareProperty(MatrixWorkspaceProperty(self.PROP_INPUT_WORKSPACE, '',
                                                     optional = PropertyMode.Mandatory,
                                                     direction = Direction.Input),
                             doc = 'Workspace with spectra to fit peaks. ToF is expected X unit.')

        self.declareProperty(self.PROP_WORKSPACE_INDEX, 0,
                             doc = 'Index of the workspace for the spectrum to fit. By default '
                             'the first spectrum will be processed (that is, the only spectrum '
                             'for focussed data workspaces.', direction = Direction.Input)

        self.declareProperty(FileProperty(name = self.PROP_INSTR_FILE, defaultValue = '',
                                          action = FileAction.Load,
                                          extensions = [".par", ".prm", ".ipar", ".iparm"]),
                             doc = 'File with instrument parameters (in GSAS format).')

        self.declareProperty(FileProperty(name = self.PROP_PHASE_INFO_FILE, defaultValue = '',
                                          action = FileAction.OptionalLoad, extensions = [".cif"]),
                             doc = 'File with phase information for the material.')

        self.declareProperty(FileProperty(name = self.PROP_PATH_TO_GSASII, defaultValue = '',
                                          action = FileAction.OptionalDirectory),
                             doc = 'Optional path to GSAS-II software installation. '
                             'This will be used to import several Python modules from GSAS-II.')

        GRP_RESULTS = "Results"

        self.declareProperty('GoF', 0.0, direction = Direction.Output,
                             doc = 'Goodness of fit value (Chi squared).')

        self.declareProperty('Rwp', 0.0, direction = Direction.Output,
                             doc = 'Weighted profile R-factor (Rwp) discrepancy index for the '
                             'goodness of fit.')

        self.declareProperty(ITableWorkspaceProperty(self.PROP_OUT_LATTICE_PARAMS, "", Direction.Output),
                             doc = 'Table to output the the lattice parameters (refined).')

        self.declareProperty(self.PROP_OUT_FITTED_PARAMS, "", direction=Direction.Input,
                             doc = "Name for an (output) table of fitted parameters. This is used "
                             "with the peak fitting method. The table will have one row per peak "
                             "found.")

        # This is mandatory. We could also make it FileAction.OptionalSave, and use a temporary
        # project file when the option is not given by the user.
        self.declareProperty(FileProperty(name = self.PROP_OUT_PROJECT_FILE, defaultValue = '',
                                          direction = Direction.Input,
                                          action = FileAction.Save, extensions = [".gpx"]),
                             doc = 'GSAS-II project file (that can be openened in the GSAS-II GUI).')

        self.setPropertyGroup(self.PROP_OUT_GOF, GRP_RESULTS)
        self.setPropertyGroup(self.PROP_OUT_RWP, GRP_RESULTS)
        self.setPropertyGroup(self.PROP_OUT_LATTICE_PARAMS, GRP_RESULTS)
        self.setPropertyGroup(self.PROP_OUT_FITTED_PARAMS, GRP_RESULTS)
        self.setPropertyGroup(self.PROP_OUT_PROJECT_FILE, GRP_RESULTS)

        GRP_FITTING_OPTS = "Fitting options"
        background_types = ["Chebyshev", "None"]
        self.declareProperty(self.PROP_BACKGROUND_TYPE, defaultValue = background_types[0],
                             validator = StringListValidator(background_types),
                             doc = 'Type of background for the peak fitting. Currently only the '
                             'default option of GSAS-II (chebyshev) is supported.')

        self.declareProperty(self.PROP_MINX, Property.EMPTY_DBL,
                             direction = Direction.Input,
                             doc = "Minimum x value for the fitting, in the same units as the input "
                             "workspace (TOF). Defines the range or domain of fitting together "
                             "with the property {0}. Leave empty to use the whole range".
                             format(self.PROP_MAXX))

        self.declareProperty(self.PROP_MAXX, Property.EMPTY_DBL,
                             direction = Direction.Input,
                             doc = "Maximum x value for the fitting, in the same units as the input "
                             "workspace (TOF). Defines the range or domain of fitting together "
                             "with the property {0}. Leave empty to use the whole range".
                             format(self.PROP_MINX))

        self.setPropertyGroup(self.PROP_BACKGROUND_TYPE, GRP_FITTING_OPTS)
        self.setPropertyGroup(self.PROP_MINX, GRP_FITTING_OPTS)
        self.setPropertyGroup(self.PROP_MAXX, GRP_FITTING_OPTS)

        GRP_PAWLEY_OPTIONS = "Pawley refinement options"

        self.declareProperty(self.PROP_PAWLEY_DMIN, 1.0, direction = Direction.Input,
                             doc = "For Pawley refiment: as defined in GSAS-II, the minimum d-spacing "
                             "to be used in a Pawley refinement. Please refer to the GSAS-II "
                             "documentation for full details.")

        self.declareProperty(self.PROP_PAWLEY_NEG_WEIGHT, 0.0, direction = Direction.Input,
                             doc = "For Pawley refinement: as defined in GSAS-II, the weight for a "
                             "penalty function applied during a Pawley refinement on resulting negative "
                             "intensities. Please refer to the GSAS-II documentation for full details.")

        self.setPropertyGroup(self.PROP_PAWLEY_DMIN, GRP_PAWLEY_OPTIONS)
        self.setPropertyGroup(self.PROP_PAWLEY_NEG_WEIGHT, GRP_PAWLEY_OPTIONS)

        GRP_PEAKS = "Expected peaks (phase information takes precedence)"

        self.declareProperty(FloatArrayProperty(self.PROP_EXPECTED_PEAKS, [],
                                                direction = Direction.Input),
                             "A list of dSpacing values for the peak centers. These will be "
                             "converted into TOF to find expected peaks.")

        self.declareProperty(FileProperty(name = self.PROP_EXPECTED_PEAKS_FROM_FILE, defaultValue = "",
                                          action = FileAction.OptionalLoad, extensions = [".csv"],
                                          direction = Direction.Input),
                             doc = "Load from this file a list of dSpacing values to be converted "
                             "into TOF . This takes precedence over '" + self.PROP_EXPECTED_PEAKS + "' "
                             "when both options are given.")

        self.setPropertyGroup(self.PROP_EXPECTED_PEAKS, GRP_PEAKS)
        self.setPropertyGroup(self.PROP_EXPECTED_PEAKS_FROM_FILE, GRP_PEAKS)

        GRP_PARAMS = "Refinement of peak parameters"

        self.declareProperty(name = self.PROP_REFINE_CENTER, defaultValue = False,
                             doc = 'Whether to refine the peak centers.')

        self.declareProperty(name = self.PROP_REFINE_INTENSITY, defaultValue = False,
                             doc = 'Whether to refine the peak function intensity parameters '
                             '(assuming a shape of type back-to-back exponential convoluted '
                             'with pseudo-voigt (BackToBackExponentialPV).')

        self.declareProperty(name = self.PROP_REFINE_ALPHA, defaultValue = False,
                             doc = 'Whether to refine the peak function beta parameters '
                             '(assuming a BackToBackExponentialPV peak shape.')

        self.declareProperty(name = self.PROP_REFINE_BETA, defaultValue = False,
                             doc = 'Whether to refine the peak function beta parameters '
                             '(assuming a BackToBackExponentialPV peak shape.')

        self.declareProperty(name = self.PROP_REFINE_SIGMA, defaultValue = True,
                             doc = 'Whether to refine the peak function sigma parameters '
                             '(assuming a BackToBackExponentialPV peak shape.')

        self.declareProperty(name = self.PROP_REFINE_GAMMA, defaultValue = True,
                             doc = 'Whether to refine the peak function gamma parameters '
                             '(assuming a BackToBackExponentialPV peak shape.')

        self.setPropertyGroup(self.PROP_REFINE_CENTER, GRP_PARAMS)
        self.setPropertyGroup(self.PROP_REFINE_INTENSITY, GRP_PARAMS)
        self.setPropertyGroup(self.PROP_REFINE_ALPHA, GRP_PARAMS)
        self.setPropertyGroup(self.PROP_REFINE_BETA, GRP_PARAMS)
        self.setPropertyGroup(self.PROP_REFINE_SIGMA, GRP_PARAMS)
        self.setPropertyGroup(self.PROP_REFINE_GAMMA, GRP_PARAMS)
Example #12
0
    def PyInit(self):
        self.declareProperty(ITableWorkspaceProperty(
            "CalibrationTable",
            "",
            optional=PropertyMode.Mandatory,
            direction=Direction.Input),
                             doc="Calibration table, currently only uses difc")

        self.declareProperty(MatrixWorkspaceProperty(
            "MaskWorkspace",
            "",
            optional=PropertyMode.Optional,
            direction=Direction.Input),
                             doc="Mask workspace")

        self.declareProperty(FileProperty(name="InstrumentFilename",
                                          defaultValue="",
                                          action=FileAction.OptionalLoad,
                                          extensions=[".xml"]),
                             doc="Instrument filename")

        self.declareProperty(
            WorkspaceProperty("Workspace",
                              "",
                              validator=InstrumentValidator(),
                              optional=PropertyMode.Optional,
                              direction=Direction.Input),
            doc="Workspace containing the instrument to be calibrated.")

        # Source
        self.declareProperty(
            name="FitSourcePosition",
            defaultValue=False,
            doc=
            "Fit the source position, changes L1 (source to sample) distance."
            "Uses entire instrument. Occurs before Components are Aligned.")

        # Sample
        self.declareProperty(
            name="FitSamplePosition",
            defaultValue=False,
            doc=
            "Fit the sample position, changes L1 (source to sample) and L2 (sample to detector) distance."
            "Uses entire instrument. Occurs before Components are Aligned.")

        # List of components
        self.declareProperty(
            StringArrayProperty("ComponentList", direction=Direction.Input),
            doc="Comma separated list on instrument components to refine.")

        # X position
        self.declareProperty(name="Xposition",
                             defaultValue=False,
                             doc="Refine Xposition")
        condition = EnabledWhenProperty("Xposition",
                                        PropertyCriterion.IsNotDefault)
        self.declareProperty(name="MinXposition",
                             defaultValue=-0.1,
                             validator=FloatBoundedValidator(-10.0, 10.0),
                             doc="Minimum relative X bound (m)")
        self.setPropertySettings("MinXposition", condition)
        self.declareProperty(name="MaxXposition",
                             defaultValue=0.1,
                             validator=FloatBoundedValidator(-10.0, 10.0),
                             doc="Maximum relative X bound (m)")
        self.setPropertySettings("MaxXposition", condition)

        # Y position
        self.declareProperty(name="Yposition",
                             defaultValue=False,
                             doc="Refine Yposition")
        condition = EnabledWhenProperty("Yposition",
                                        PropertyCriterion.IsNotDefault)
        self.declareProperty(name="MinYposition",
                             defaultValue=-0.1,
                             validator=FloatBoundedValidator(-10.0, 10.0),
                             doc="Minimum relative Y bound (m)")
        self.setPropertySettings("MinYposition", condition)
        self.declareProperty(name="MaxYposition",
                             defaultValue=0.1,
                             validator=FloatBoundedValidator(-10.0, 10.0),
                             doc="Maximum relative Y bound (m)")
        self.setPropertySettings("MaxYposition", condition)

        # Z position
        self.declareProperty(name="Zposition",
                             defaultValue=False,
                             doc="Refine Zposition")
        condition = EnabledWhenProperty("Zposition",
                                        PropertyCriterion.IsNotDefault)
        self.declareProperty(name="MinZposition",
                             defaultValue=-0.1,
                             validator=FloatBoundedValidator(-10.0, 10.0),
                             doc="Minimum relative Z bound (m)")
        self.setPropertySettings("MinZposition", condition)
        self.declareProperty(name="MaxZposition",
                             defaultValue=0.1,
                             validator=FloatBoundedValidator(-10.0, 10.0),
                             doc="Maximum relative Z bound (m)")
        self.setPropertySettings("MaxZposition", condition)

        # euler angles convention
        eulerConventions = [
            "ZXZ", "XYX", "YZY", "ZYZ", "XZX", "YXY", "XYZ", "YZX", "ZXY",
            "XZY", "ZYX", "YXZ"
        ]
        self.declareProperty(
            name="EulerConvention",
            defaultValue="YZX",
            validator=StringListValidator(eulerConventions),
            doc=
            "Euler angles convention used when calculating and displaying angles,"
            "eg XYZ corresponding to alpha beta gamma.")

        # alpha rotation
        self.declareProperty(name="AlphaRotation",
                             defaultValue=False,
                             doc="Refine rotation around first axis, alpha")
        condition = EnabledWhenProperty("AlphaRotation",
                                        PropertyCriterion.IsNotDefault)
        self.declareProperty(name="MinAlphaRotation",
                             defaultValue=-10.0,
                             validator=FloatBoundedValidator(-90, 90),
                             doc="Minimum relative alpha rotation (deg)")
        self.setPropertySettings("MinAlphaRotation", condition)
        self.declareProperty(name="MaxAlphaRotation",
                             defaultValue=10.0,
                             validator=FloatBoundedValidator(-90, 90),
                             doc="Maximum relative alpha rotation (deg)")
        self.setPropertySettings("MaxAlphaRotation", condition)

        # beta rotation
        self.declareProperty(name="BetaRotation",
                             defaultValue=False,
                             doc="Refine rotation around seconds axis, beta")
        condition = EnabledWhenProperty("BetaRotation",
                                        PropertyCriterion.IsNotDefault)
        self.declareProperty(name="MinBetaRotation",
                             defaultValue=-10.0,
                             validator=FloatBoundedValidator(-90, 90),
                             doc="Minimum relative beta rotation (deg)")
        self.setPropertySettings("MinBetaRotation", condition)
        self.declareProperty(name="MaxBetaRotation",
                             defaultValue=10.0,
                             validator=FloatBoundedValidator(-90, 90),
                             doc="Maximum relative beta rotation (deg)")
        self.setPropertySettings("MaxBetaRotation", condition)

        # gamma rotation
        self.declareProperty(name="GammaRotation",
                             defaultValue=False,
                             doc="Refine rotation around third axis, gamma")
        condition = EnabledWhenProperty("GammaRotation",
                                        PropertyCriterion.IsNotDefault)
        self.declareProperty(name="MinGammaRotation",
                             defaultValue=-10.0,
                             validator=FloatBoundedValidator(-90, 90),
                             doc="Minimum relative gamma rotation (deg)")
        self.setPropertySettings("MinGammaRotation", condition)
        self.declareProperty(name="MaxGammaRotation",
                             defaultValue=10.0,
                             validator=FloatBoundedValidator(-90, 90),
                             doc="Maximum relative gamma rotation (deg)")
        self.setPropertySettings("MaxGammaRotation", condition)

        # Translation
        self.setPropertyGroup("Xposition", "Translation")
        self.setPropertyGroup("MinXposition", "Translation")
        self.setPropertyGroup("MaxXposition", "Translation")
        self.setPropertyGroup("Yposition", "Translation")
        self.setPropertyGroup("MinYposition", "Translation")
        self.setPropertyGroup("MaxYposition", "Translation")
        self.setPropertyGroup("Zposition", "Translation")
        self.setPropertyGroup("MinZposition", "Translation")
        self.setPropertyGroup("MaxZposition", "Translation")

        # Rotation
        self.setPropertyGroup("EulerConvention", "Rotation")
        self.setPropertyGroup("AlphaRotation", "Rotation")
        self.setPropertyGroup("MinAlphaRotation", "Rotation")
        self.setPropertyGroup("MaxAlphaRotation", "Rotation")
        self.setPropertyGroup("BetaRotation", "Rotation")
        self.setPropertyGroup("MinBetaRotation", "Rotation")
        self.setPropertyGroup("MaxBetaRotation", "Rotation")
        self.setPropertyGroup("GammaRotation", "Rotation")
        self.setPropertyGroup("MinGammaRotation", "Rotation")
        self.setPropertyGroup("MaxGammaRotation", "Rotation")
Example #13
0
    def PyInit(self):
        self.declareProperty(
            name='Program',
            defaultValue='QL',
            validator=StringListValidator(['QL', 'QSe']),
            doc='The type of program to run (either QL or QSe)')

        self.declareProperty(MatrixWorkspaceProperty(
            'SampleWorkspace', '', direction=Direction.Input),
                             doc='Name of the Sample input Workspace')

        self.declareProperty(MatrixWorkspaceProperty(
            'ResolutionWorkspace', '', direction=Direction.Input),
                             doc='Name of the resolution input Workspace')

        self.declareProperty(WorkspaceGroupProperty(
            'ResNormWorkspace',
            '',
            optional=PropertyMode.Optional,
            direction=Direction.Input),
                             doc='Name of the ResNorm input Workspace')

        self.declareProperty(name='MinRange',
                             defaultValue=-0.2,
                             doc='The start of the fit range. Default=-0.2')

        self.declareProperty(name='MaxRange',
                             defaultValue=0.2,
                             doc='The end of the fit range. Default=0.2')

        self.declareProperty(name='SampleBins',
                             defaultValue=1,
                             doc='The number of sample bins')

        self.declareProperty(name='ResolutionBins',
                             defaultValue=1,
                             doc='The number of resolution bins')

        self.declareProperty(name='Elastic',
                             defaultValue=True,
                             doc='Fit option for using the elastic peak')

        self.declareProperty(name='Background',
                             defaultValue='Flat',
                             validator=StringListValidator(
                                 ['Sloping', 'Flat', 'Zero']),
                             doc='Fit option for the type of background')

        self.declareProperty(name='FixedWidth',
                             defaultValue=True,
                             doc='Fit option for using FixedWidth')

        self.declareProperty(name='UseResNorm',
                             defaultValue=False,
                             doc='fit option for using ResNorm')

        self.declareProperty(name='WidthFile',
                             defaultValue='',
                             doc='The name of the fixedWidth file')

        self.declareProperty(name='Loop',
                             defaultValue=True,
                             doc='Switch Sequential fit On/Off')

        self.declareProperty(name='Plot', defaultValue='', doc='Plot options')

        self.declareProperty(name='Save',
                             defaultValue=False,
                             doc='Switch Save result to nxs file Off/On')

        self.declareProperty(WorkspaceGroupProperty(
            'OutputWorkspaceFit', '', direction=Direction.Output),
                             doc='The name of the fit output workspaces')

        self.declareProperty(MatrixWorkspaceProperty(
            'OutputWorkspaceResult', '', direction=Direction.Output),
                             doc='The name of the result output workspaces')

        self.declareProperty(
            MatrixWorkspaceProperty('OutputWorkspaceProb',
                                    '',
                                    optional=PropertyMode.Optional,
                                    direction=Direction.Output),
            doc='The name of the probability output workspaces')
Example #14
0
    def _declare_output_properties(self):
        self.declareProperty(
            MatrixWorkspaceProperty('OutShiftAndScaleFactor',
                                    '',
                                    optional=PropertyMode.Optional,
                                    direction=Direction.Output),
            doc=
            'A workspace containing the applied shift factor as X data and applied scale factor '
            'as Y data.')

        # This breaks our flexibility with the reduction mode. We need to check if we can populate this based on
        # the available reduction modes for the state input. TODO: check if this is possible
        self.declareProperty(
            WorkspaceGroupProperty('OutputWorkspaceLAB',
                                   '',
                                   optional=PropertyMode.Optional,
                                   direction=Direction.Output),
            doc='The output workspace for the low-angle bank.')
        self.declareProperty(
            WorkspaceGroupProperty('OutputWorkspaceHAB',
                                   '',
                                   optional=PropertyMode.Optional,
                                   direction=Direction.Output),
            doc='The output workspace for the high-angle bank.')
        self.declareProperty(
            WorkspaceGroupProperty('OutputWorkspaceMerged',
                                   '',
                                   optional=PropertyMode.Optional,
                                   direction=Direction.Output),
            doc='The output workspace for the merged reduction.')
        self.setPropertyGroup("OutShiftAndScaleFactor", 'Output')
        self.setPropertyGroup("OutputWorkspaceLAB", 'Output')
        self.setPropertyGroup("OutputWorkspaceHAB", 'Output')
        self.setPropertyGroup("OutputWorkspaceMerged", 'Output')

        # CAN output
        self.declareProperty(
            WorkspaceGroupProperty('OutputWorkspaceLABCan',
                                   '',
                                   optional=PropertyMode.Optional,
                                   direction=Direction.Output),
            doc=
            'The can output workspace group for the low-angle bank, provided there is one. '
            'Each workspace in the group is one event slice.')
        self.declareProperty(
            WorkspaceGroupProperty('OutputWorkspaceHABCan',
                                   '',
                                   optional=PropertyMode.Optional,
                                   direction=Direction.Output),
            doc=
            'The can output workspace group for the high-angle bank, provided there is one. '
            'Each workspace in the group is one event slice.')
        self.declareProperty(
            WorkspaceGroupProperty('OutputWorkspaceLABSample',
                                   '',
                                   optional=PropertyMode.Optional,
                                   direction=Direction.Output),
            doc=
            'The sample output workspace group for the low-angle bank, provided there is one. '
            'Each workspace in the group is one event slice.')
        self.declareProperty(
            WorkspaceGroupProperty('OutputWorkspaceHABSample',
                                   '',
                                   optional=PropertyMode.Optional,
                                   direction=Direction.Output),
            doc=
            'The sample output workspace group for the high-angle bank, provided there is one. '
            'Each workspace in the group is one event slice.')
        self.declareProperty(MatrixWorkspaceProperty(
            'OutputWorkspaceCalculatedTransmission',
            '',
            optional=PropertyMode.Optional,
            direction=Direction.Output),
                             doc='The calculated transmission workspace.')
        self.declareProperty(MatrixWorkspaceProperty(
            'OutputWorkspaceUnfittedTransmission',
            '',
            optional=PropertyMode.Optional,
            direction=Direction.Output),
                             doc='The unfitted transmission workspace.')
        self.declareProperty(
            MatrixWorkspaceProperty('OutputWorkspaceCalculatedTransmissionCan',
                                    '',
                                    optional=PropertyMode.Optional,
                                    direction=Direction.Output),
            doc='The calculated transmission workspace for the can.')
        self.declareProperty(
            MatrixWorkspaceProperty('OutputWorkspaceUnfittedTransmissionCan',
                                    '',
                                    optional=PropertyMode.Optional,
                                    direction=Direction.Output),
            doc='The unfitted transmission workspace for the can.')
        self.setPropertyGroup("OutputWorkspaceLABCan", 'Can Output')
        self.setPropertyGroup("OutputWorkspaceHABCan", 'Can Output')
        self.setPropertyGroup("OutputWorkspaceLABSample", 'Can Output')
        self.setPropertyGroup("OutputWorkspaceHABSample", 'Can Output')

        # Output CAN Count and Norm for optimizations
        self.declareProperty(
            WorkspaceGroupProperty('OutputWorkspaceLABCanNorm',
                                   '',
                                   optional=PropertyMode.Optional,
                                   direction=Direction.Output),
            doc=
            'The can norm output workspace group for the low-angle bank, provided there is one. '
            'Each workspace in the group is one event slice.')
        self.declareProperty(
            WorkspaceGroupProperty('OutputWorkspaceLABCanCount',
                                   '',
                                   optional=PropertyMode.Optional,
                                   direction=Direction.Output),
            doc=
            'The can count output workspace group for the low-angle bank, provided there is one. '
            'Each workspace in the group is one event slice.')
        self.declareProperty(
            WorkspaceGroupProperty('OutputWorkspaceHABCanCount',
                                   '',
                                   optional=PropertyMode.Optional,
                                   direction=Direction.Output),
            doc=
            'The can count output workspace group for the high-angle bank, provided there is one. '
            'Each workspace in the group is one event slice.')
        self.declareProperty(
            WorkspaceGroupProperty('OutputWorkspaceHABCanNorm',
                                   '',
                                   optional=PropertyMode.Optional,
                                   direction=Direction.Output),
            doc=
            'The can norm output workspace group for the high-angle bank, provided there is one. '
            'Each workspace in the group is one event slice.')

        self.setPropertyGroup("OutputWorkspaceLABCanCount", 'Opt Output')
        self.setPropertyGroup("OutputWorkspaceLABCanNorm", 'Opt Output')
        self.setPropertyGroup("OutputWorkspaceHABCanCount", 'Opt Output')
        self.setPropertyGroup("OutputWorkspaceHABCanNorm", 'Opt Output')
Example #15
0
    def PyInit(self):
        ws_validator = InstrumentValidator()

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

        self.declareProperty(name='SampleChemicalFormula', defaultValue='',
                             doc='Sample chemical formula')

        self.declareProperty(name='SampleCoherentXSection', defaultValue=0.0,
                             validator=FloatBoundedValidator(0.0),
                             doc='The coherent cross-section for the sample material in barns. To be used instead of '
                                 'Chemical Formula.')

        self.declareProperty(name='SampleIncoherentXSection', defaultValue=0.0,
                             validator=FloatBoundedValidator(0.0),
                             doc='The incoherent cross-section for the sample material in barns. To be used instead of '
                                 'Chemical Formula.')

        self.declareProperty(name='SampleAttenuationXSection', defaultValue=0.0,
                             validator=FloatBoundedValidator(0.0),
                             doc='The absorption cross-section for the sample material in barns. To be used instead of '
                                 'Chemical Formula.')

        self.declareProperty(name='SampleDensityType', defaultValue='Mass Density',
                             validator=StringListValidator(['Mass Density', 'Number Density']),
                             doc='Use of Mass density or Number density for the sample.')

        self.declareProperty(name='SampleNumberDensityUnit', defaultValue='Atoms',
                             validator=StringListValidator(['Atoms', 'Formula Units']),
                             doc='Choose which units SampleDensity refers to. Allowed values: '
                                 '[Atoms, Formula Units]')

        self.declareProperty(name='SampleDensity', defaultValue=0.1,
                             doc='The value for the sample Mass density (g/cm^3) or Number density (1/Angstrom^3).')

        self.declareProperty(name='SampleThickness', defaultValue=0.0,
                             validator=FloatBoundedValidator(0.0),
                             doc='Sample thickness in cm')

        self.declareProperty(name='SampleAngle', defaultValue=0.0,
                             doc='Angle between incident beam and normal to flat plate surface')

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

        self.declareProperty(name='CanChemicalFormula', defaultValue='',
                             doc='Container chemical formula')

        self.declareProperty(name='CanCoherentXSection', defaultValue=0.0,
                             validator=FloatBoundedValidator(0.0),
                             doc='The coherent cross-section for the can material in barns. To be used instead of '
                                 'Chemical Formula.')

        self.declareProperty(name='CanIncoherentXSection', defaultValue=0.0,
                             validator=FloatBoundedValidator(0.0),
                             doc='The incoherent cross-section for the can material in barns. To be used instead of '
                                 'Chemical Formula.')

        self.declareProperty(name='CanAttenuationXSection', defaultValue=0.0,
                             validator=FloatBoundedValidator(0.0),
                             doc='The absorption cross-section for the can material in barns. To be used instead of '
                                 'Chemical Formula.')

        self.declareProperty(name='CanDensityType', defaultValue='Mass Density',
                             validator=StringListValidator(['Mass Density', 'Number Density']),
                             doc='Use of Mass density or Number density for the can.')

        self.declareProperty(name='CanNumberDensityUnit', defaultValue='Atoms',
                             validator=StringListValidator(['Atoms', 'Formula Units']),
                             doc='Choose which units CanDensity refers to. Allowed values: [Atoms, Formula Units]')

        self.declareProperty(name='CanDensity', defaultValue=0.1,
                             doc='The value for the can Mass density (g/cm^3) or Number density (1/Angstrom^3).')

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

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

        self.declareProperty(name='NumberWavelengths', defaultValue=10,
                             validator=IntBoundedValidator(1),
                             doc='Number of wavelengths for calculation')

        self.declareProperty(name='Interpolate', defaultValue=True,
                             doc='Interpolate the correction workspaces to match the sample workspace')

        self.declareProperty(name='Emode', defaultValue='Elastic',
                             validator=StringListValidator(['Elastic', 'Indirect', 'Direct', 'Efixed']),
                             doc='Energy transfer mode.')

        self.declareProperty(name='Efixed', defaultValue=0.,
                             doc='Analyser energy (mev). By default will be read from the instrument parameters. '
                                 'Specify manually to override. This is used only in Efixed energy transfer mode.')

        self.declareProperty(WorkspaceGroupProperty('OutputWorkspace', '',
                                                    direction=Direction.Output),
                             doc='The output corrections workspace group')
Example #16
0
    def PyInit(self):
        self.declareProperty(
            MatrixWorkspaceProperty("InputWorkspace",
                                    '',
                                    optional=PropertyMode.Mandatory,
                                    direction=Direction.Input),
            doc='The workspace which is to be saved.'
            ' This workspace needs to be the result of a SANS reduction,'
            ' i.e. it can only be 1D or 2D if the second axis is numeric.')

        self.declareProperty(
            FileProperty("Filename", '', action=FileAction.Save,
                         extensions=[]),
            doc="The name of the file which needs to be stored. Note that "
            "the actual file type is selected below.")

        self.declareProperty(
            MatrixWorkspaceProperty("Transmission",
                                    defaultValue='',
                                    optional=PropertyMode.Optional,
                                    direction=Direction.Input),
            doc='The sample transmission workspace. Optional.')
        self.declareProperty(MatrixWorkspaceProperty(
            "TransmissionCan",
            defaultValue='',
            optional=PropertyMode.Optional,
            direction=Direction.Input),
                             doc='The can transmission workspace. Optional.')

        self.declareProperty(
            "Nexus",
            False,
            direction=Direction.Input,
            doc="Save as nexus format. "
            "Note that if file formats of the same type, e.g. .xml are chosen, then the "
            "file format is appended to the file name.")
        self.declareProperty(
            "CanSAS",
            False,
            direction=Direction.Input,
            doc="Save as CanSAS xml format."
            "Note that if file formats of the same type, e.g. .xml are chosen, then the "
            "file format is appended to the file name.")
        self.declareProperty(
            "NXcanSAS",
            False,
            direction=Direction.Input,
            doc="Save as NXcanSAS format."
            "Note that if file formats of the same type, e.g. .xml are chosen, then the "
            "file format is appended to the file name.")
        self.declareProperty(
            "NistQxy",
            False,
            direction=Direction.Input,
            doc="Save as Nist Qxy format."
            "Note that if file formats of the same type, e.g. .xml are chosen, then the "
            "file format is appended to the file name.")
        self.declareProperty(
            "RKH",
            False,
            direction=Direction.Input,
            doc="Save as RKH format."
            "Note that if file formats of the same type, e.g. .xml are chosen, then the "
            "file format is appended to the file name.")
        self.declareProperty(
            "CSV",
            False,
            direction=Direction.Input,
            doc="Save as CSV format."
            "Note that if file formats of the same type, e.g. .xml are chosen, then the "
            "file format is appended to the file name.")

        self.setPropertyGroup("Nexus", 'FileFormats')
        self.setPropertyGroup("CanSAS", 'FileFormats')
        self.setPropertyGroup("NXCanSAS", 'FileFormats')
        self.setPropertyGroup("NistQxy", 'FileFormats')
        self.setPropertyGroup("RKH", 'FileFormats')
        self.setPropertyGroup("CSV", 'FileFormats')

        self.declareProperty(
            "UseZeroErrorFree",
            True,
            direction=Direction.Input,
            doc=
            "This allows the user to artificially inflate zero error values.")

        self.declareProperty(
            "SampleTransmissionRunNumber",
            "",
            direction=Direction.Input,
            doc="The run number for the Sample Transmission workspace used in "
            "the reduction. Can be blank.")
        self.declareProperty(
            "SampleDirectRunNumber",
            "",
            direction=Direction.Input,
            doc="The run number for the Sample Direct workspace used in "
            "the reduction. Can be blank.")
        self.declareProperty(
            "CanScatterRunNumber",
            "",
            direction=Direction.Input,
            doc=
            "The run number for the Can Scatter workspace used in the reduction. Can be blank."
        )
        self.declareProperty(
            "CanDirectRunNumber",
            "",
            direction=Direction.Input,
            doc=
            "The run number for the Can Direct workspace used in the reduction. Can be blank."
        )
Example #17
0
    def PyInit(self):

        self.declareProperty(
            WorkspaceGroupProperty('OutputWorkspace',
                                   '',
                                   direction=Direction.Output),
            doc='The output workspace group containing reduced data.')

        self.declareProperty(MultipleFileProperty(
            'SampleRuns',
            action=FileAction.OptionalLoad,
            extensions=['nxs'],
            allow_empty=True),
                             doc='Sample run(s).')

        self.declareProperty(
            MultipleFileProperty('AbsorberRuns',
                                 action=FileAction.OptionalLoad,
                                 extensions=['nxs']),
            doc='Absorber (Cd/B4C) run(s).')

        self.declareProperty(MultipleFileProperty(
            'BeamRuns', action=FileAction.OptionalLoad, extensions=['nxs']),
                             doc='Empty beam run(s).')

        self.declareProperty(
            MultipleFileProperty('FluxRuns',
                                 action=FileAction.OptionalLoad,
                                 extensions=['nxs']),
            doc='Empty beam run(s) for flux calculation only; '
            'if left blank flux will be calculated from BeamRuns.')

        self.declareProperty(MultipleFileProperty(
            'ContainerRuns',
            action=FileAction.OptionalLoad,
            extensions=['nxs']),
                             doc='Empty container run(s).')

        self.setPropertyGroup('SampleRuns', 'Numors')
        self.setPropertyGroup('AbsorberRuns', 'Numors')
        self.setPropertyGroup('BeamRuns', 'Numors')
        self.setPropertyGroup('FluxRuns', 'Numors')
        self.setPropertyGroup('ContainerRuns', 'Numors')

        self.declareProperty(MultipleFileProperty(
            'SampleTransmissionRuns',
            action=FileAction.OptionalLoad,
            extensions=['nxs']),
                             doc='Sample transmission run(s).')

        self.declareProperty(MultipleFileProperty(
            'ContainerTransmissionRuns',
            action=FileAction.OptionalLoad,
            extensions=['nxs']),
                             doc='Container transmission run(s).')

        self.declareProperty(MultipleFileProperty(
            'TransmissionBeamRuns',
            action=FileAction.OptionalLoad,
            extensions=['nxs']),
                             doc='Empty beam run(s) for transmission.')

        self.declareProperty(MultipleFileProperty(
            'TransmissionAbsorberRuns',
            action=FileAction.OptionalLoad,
            extensions=['nxs']),
                             doc='Absorber (Cd/B4C) run(s) for transmission.')

        self.setPropertyGroup('SampleTransmissionRuns', 'Transmissions')
        self.setPropertyGroup('ContainerTransmissionRuns', 'Transmissions')
        self.setPropertyGroup('TransmissionBeamRuns', 'Transmissions')
        self.setPropertyGroup('TransmissionAbsorberRuns', 'Transmissions')
        self.copyProperties('SANSILLReduction', ['ThetaDependent'])
        self.setPropertyGroup('ThetaDependent', 'Transmissions')

        self.declareProperty(
            'SensitivityMaps',
            '',
            doc=
            'File(s) or workspaces containing the maps of relative detector efficiencies.'
        )

        self.declareProperty(
            'DefaultMaskFile',
            '',
            doc=
            'File or workspace containing the default mask (typically the detector edges and dead pixels/tubes)'
            ' to be applied to all the detector configurations.')

        self.declareProperty(
            'MaskFiles',
            '',
            doc=
            'File(s) or workspaces containing the detector mask (typically beam stop).'
        )

        self.declareProperty(
            'ReferenceFiles',
            '',
            doc=
            'File(s) or workspaces containing the corrected water data (in 2D) for absolute normalisation.'
        )

        self.declareProperty(
            'SolventFiles',
            '',
            doc=
            'File(s) or workspaces containing the corrected solvent data (in 2D) for solvent subtraction.'
        )

        self.declareProperty(MatrixWorkspaceProperty(
            'SensitivityOutputWorkspace',
            '',
            direction=Direction.Output,
            optional=PropertyMode.Optional),
                             doc='The output sensitivity map workspace.')

        self.copyProperties('SANSILLReduction', ['NormaliseBy'])

        self.declareProperty('SampleThickness',
                             0.1,
                             validator=FloatBoundedValidator(lower=-1),
                             doc='Sample thickness [cm]')

        self.declareProperty('TransmissionBeamRadius',
                             0.1,
                             validator=FloatBoundedValidator(lower=0.),
                             doc='Beam radius [m]; used for transmission '
                             'calculations.')

        self.declareProperty(FloatArrayProperty('BeamRadius', values=[0.1]),
                             doc='Beam radius [m]; used for beam center '
                             'finding and flux calculations.')

        self.declareProperty(
            'WaterCrossSection',
            1.,
            doc='Provide water cross-section; '
            'used only if the absolute scale is done by dividing to water.')

        self.setPropertyGroup('SensitivityMaps', 'Options')
        self.setPropertyGroup('DefaultMaskFile', 'Options')
        self.setPropertyGroup('MaskFiles', 'Options')
        self.setPropertyGroup('ReferenceFiles', 'Options')
        self.setPropertyGroup('SolventFiles', 'Options')
        self.setPropertyGroup('SensitivityOutputWorkspace', 'Options')
        self.setPropertyGroup('NormaliseBy', 'Options')
        self.setPropertyGroup('SampleThickness', 'Options')
        self.setPropertyGroup('BeamRadius', 'Options')
        self.setPropertyGroup('TransmissionBeamRadius', 'Options')
        self.setPropertyGroup('WaterCrossSection', 'Options')

        self.declareProperty(FloatArrayProperty('MaxQxy', values=[-1]),
                             doc='Maximum of absolute Qx and Qy.')
        self.declareProperty(FloatArrayProperty('DeltaQ', values=[-1]),
                             doc='The dimension of a Qx-Qy cell.')

        self.declareProperty('OutputPanels',
                             False,
                             doc='Whether or not process the individual '
                             'detector panels.')

        self.copyProperties('SANSILLIntegration', [
            'OutputType', 'CalculateResolution', 'DefaultQBinning',
            'BinningFactor', 'NPixelDivision', 'NumberOfWedges', 'WedgeAngle',
            'WedgeOffset', 'AsymmetricWedges', 'IQxQyLogBinning',
            'WavelengthRange'
        ])

        self.declareProperty(
            'OutputBinning',
            '',
            doc=
            'Output binning for each distance. : separated list of binning params.'
        )
        self.setPropertyGroup('OutputBinning', 'Integration Options')
        self.setPropertyGroup('OutputType', 'Integration Options')
        self.setPropertyGroup('CalculateResolution', 'Integration Options')
        self.declareProperty(
            'ClearCorrected2DWorkspace', True,
            'Whether to clear the fully corrected 2D workspace.')

        self.declareProperty(
            'SensitivityWithOffsets', False,
            'Whether the sensitivity data has been measured with different horizontal offsets.'
        )

        self.declareProperty(
            'StitchReferenceIndex',
            defaultValue=1,
            validator=IntBoundedValidator(lower=0),
            doc='Index of reference workspace during stitching.')

        self.copyProperties('SANSILLIntegration', ['ShapeTable'])

        self.copyProperties('SANSILLReduction', 'Wavelength')
Example #18
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)
Example #19
0
    def PyInit(self):

        self.declareProperty(MultipleFileProperty('Run', action=FileAction.OptionalLoad,
                                                  extensions=['nxs'], allow_empty=True),
                             doc='File path of run(s).')

        options = ['Absorber', 'Beam', 'Transmission', 'Container', 'Sample']

        self.declareProperty(name='ProcessAs',
                             defaultValue='Sample',
                             validator=StringListValidator(options),
                             doc='Choose the process type.')

        self.declareProperty(MatrixWorkspaceProperty('OutputWorkspace', '',
                                                     direction=Direction.Output),
                             doc='The output workspace based on the value of ProcessAs.')

        not_absorber = EnabledWhenProperty('ProcessAs', PropertyCriterion.IsNotEqualTo, 'Absorber')

        sample = EnabledWhenProperty('ProcessAs', PropertyCriterion.IsEqualTo, 'Sample')

        beam = EnabledWhenProperty('ProcessAs', PropertyCriterion.IsEqualTo, 'Beam')

        transmission = EnabledWhenProperty('ProcessAs', PropertyCriterion.IsEqualTo, 'Transmission')

        not_beam = EnabledWhenProperty('ProcessAs', PropertyCriterion.IsNotEqualTo, 'Beam')

        container = EnabledWhenProperty('ProcessAs', PropertyCriterion.IsEqualTo, 'Container')

        self.declareProperty(name='NormaliseBy',
                             defaultValue='Timer',
                             validator=StringListValidator(['None', 'Timer', 'Monitor']),
                             doc='Choose the normalisation type.')

        self.declareProperty('BeamRadius', 0.05, validator=FloatBoundedValidator(lower=0.),
                             doc='Beam radius [m]; used for beam center finding, transmission and flux calculations.')

        self.setPropertySettings('BeamRadius',
                                 EnabledWhenProperty(beam, transmission, LogicOperator.Or))

        self.declareProperty('BeamFinderMethod', 'DirectBeam', StringListValidator(['DirectBeam', 'ScatteredBeam']),
                             doc='Choose between direct beam or scattered beam method for beam center finding.')

        self.setPropertySettings('BeamFinderMethod', beam)

        self.declareProperty('SampleThickness', 0.1, validator=FloatBoundedValidator(lower=0.), doc='Sample thickness [cm]')

        self.setPropertySettings('SampleThickness', sample)

        self.declareProperty(MatrixWorkspaceProperty('AbsorberInputWorkspace', '',
                                                     direction=Direction.Input,
                                                     optional=PropertyMode.Optional),
                             doc='The name of the absorber workspace.')

        self.setPropertySettings('AbsorberInputWorkspace', not_absorber)

        self.declareProperty(MatrixWorkspaceProperty('BeamInputWorkspace', '',
                                                     direction=Direction.Input,
                                                     optional=PropertyMode.Optional),
                             doc='The name of the empty beam input workspace.')

        self.setPropertySettings('BeamInputWorkspace',
                                 EnabledWhenProperty(not_absorber, not_beam, LogicOperator.And))

        self.declareProperty(MatrixWorkspaceProperty('TransmissionInputWorkspace', '',
                                                     direction=Direction.Input,
                                                     optional=PropertyMode.Optional),
                             doc='The name of the transmission input workspace.')

        self.setPropertySettings('TransmissionInputWorkspace',
                                 EnabledWhenProperty(container, sample, LogicOperator.Or))

        self.declareProperty(MatrixWorkspaceProperty('ContainerInputWorkspace', '',
                                                     direction=Direction.Input,
                                                     optional=PropertyMode.Optional),
                             doc='The name of the container workspace.')

        self.setPropertySettings('ContainerInputWorkspace', sample)

        self.declareProperty(MatrixWorkspaceProperty('ReferenceInputWorkspace', '',
                                                     direction=Direction.Input,
                                                     optional=PropertyMode.Optional),
                             doc='The name of the reference workspace.')

        self.setPropertySettings('ReferenceInputWorkspace', sample)

        self.declareProperty(MatrixWorkspaceProperty('SensitivityInputWorkspace', '',
                                                     direction=Direction.Input,
                                                     optional=PropertyMode.Optional),
                             doc='The name of the input sensitivity workspace.')

        self.setPropertySettings('SensitivityInputWorkspace',
                                 EnabledWhenProperty(sample,
                                                     EnabledWhenProperty('ReferenceInputWorkspace',
                                                                         PropertyCriterion.IsEqualTo, ''),
                                                     LogicOperator.And))

        self.declareProperty(MatrixWorkspaceProperty('SensitivityOutputWorkspace', '',
                                                     direction=Direction.Output,
                                                     optional=PropertyMode.Optional),
                             doc='The name of the output sensitivity workspace.')

        self.setPropertySettings('SensitivityOutputWorkspace', sample)

        self.declareProperty(MatrixWorkspaceProperty('MaskedInputWorkspace', '',
                                                     direction=Direction.Input,
                                                     optional=PropertyMode.Optional),
                             doc='Workspace to copy the mask from; for example, the beam stop')

        self.setPropertySettings('MaskedInputWorkspace', sample)

        self.declareProperty(MatrixWorkspaceProperty('FluxInputWorkspace', '',
                                                     direction=Direction.Output,
                                                     optional=PropertyMode.Optional),
                             doc='The name of the input direct beam flux workspace.')

        self.setPropertySettings('FluxInputWorkspace', sample)

        self.declareProperty(MatrixWorkspaceProperty('FluxOutputWorkspace', '',
                                                     direction=Direction.Output,
                                                     optional=PropertyMode.Optional),
                             doc='The name of the output direct beam flux workspace.')

        self.setPropertySettings('FluxOutputWorkspace', beam)

        self.declareProperty('CacheSolidAngle', False, doc='Whether or not to cache the solid angle workspace.')

        self.declareProperty('WaterCrossSection', 1., doc='Provide water cross-section; '
                                                          'used only if the absolute scale is done by dividing to water.')

        self.declareProperty(MatrixWorkspaceProperty('DefaultMaskedInputWorkspace', '',
                                                     direction=Direction.Input,
                                                     optional=PropertyMode.Optional),
                             doc='Workspace to copy the mask from; for example, the bad detector edges.')

        self.setPropertySettings('DefaultMaskedInputWorkspace', sample)

        self.declareProperty('ThetaDependent', True,
                             doc='Whether or not to use 2theta dependent transmission correction')

        self.declareProperty(MatrixWorkspaceProperty('InputWorkspace', '', direction=Direction.Input,
                                                     optional=PropertyMode.Optional),
                             doc='Input workspace containing already loaded raw data, used for parameter scans.')
Example #20
0
    def PyInit(self):
        """Initialize the algorithm's input and output properties."""
        PROPGROUP_SIMULATION_INSTRUMENT = 'Simulation Instrument Settings'
        greaterThanOneInt = IntBoundedValidator(lower=2)
        greaterThanTwoInt = IntBoundedValidator(lower=3)
        inputWorkspaceValidator = CompositeValidator()
        inputWorkspaceValidator.add(InstrumentValidator())
        inputWorkspaceValidator.add(WorkspaceUnitValidator('TOF'))

        # Properties.
        self.declareProperty(
            MatrixWorkspaceProperty(name=common.PROP_INPUT_WS,
                                    defaultValue='',
                                    validator=inputWorkspaceValidator,
                                    optional=PropertyMode.Optional,
                                    direction=Direction.Input),
            doc='A workspace for which to simulate the self shielding.')
        self.declareProperty(
            MatrixWorkspaceProperty(name=common.PROP_OUTPUT_WS,
                                    defaultValue='',
                                    direction=Direction.Output),
            doc='A workspace containing the self shielding correction factors.'
        )
        self.declareProperty(name=common.PROP_CLEANUP_MODE,
                             defaultValue=common.CLEANUP_ON,
                             validator=StringListValidator(
                                 [common.CLEANUP_ON, common.CLEANUP_OFF]),
                             direction=Direction.Input,
                             doc='What to do with intermediate workspaces.')
        self.declareProperty(
            name=common.PROP_SUBALG_LOGGING,
            defaultValue=common.SUBALG_LOGGING_OFF,
            validator=StringListValidator(
                [common.SUBALG_LOGGING_OFF, common.SUBALG_LOGGING_ON]),
            direction=Direction.Input,
            doc='Enable or disable subalgorithms to ' + 'print in the logs.')
        self.declareProperty(
            name=common.PROP_SIMULATION_INSTRUMENT,
            defaultValue=common.SIMULATION_INSTRUMEN_SPARSE,
            validator=StringListValidator([
                common.SIMULATION_INSTRUMEN_SPARSE,
                common.SIMULATION_INSTRUMENT_FULL
            ]),
            direction=Direction.Input,
            doc=
            'Select if the simulation should be performed on full or approximated instrument.'
        )
        self.setPropertyGroup(common.PROP_SIMULATION_INSTRUMENT,
                              PROPGROUP_SIMULATION_INSTRUMENT)
        self.declareProperty(
            name=common.PROP_SPARSE_INSTRUMENT_ROWS,
            defaultValue=5,
            validator=greaterThanTwoInt,
            direction=Direction.Input,
            doc='Number of detector rows in sparse simulation instrument.')
        self.setPropertyGroup(common.PROP_SPARSE_INSTRUMENT_ROWS,
                              PROPGROUP_SIMULATION_INSTRUMENT)
        self.setPropertySettings(
            common.PROP_SPARSE_INSTRUMENT_ROWS,
            EnabledWhenProperty(common.PROP_SIMULATION_INSTRUMENT,
                                PropertyCriterion.IsEqualTo,
                                common.SIMULATION_INSTRUMEN_SPARSE))
        self.declareProperty(
            name=common.PROP_SPARSE_INSTRUMENT_COLUMNS,
            defaultValue=20,
            validator=greaterThanOneInt,
            direction=Direction.Input,
            doc='Number of detector columns in sparse simulation instrument.')
        self.setPropertyGroup(common.PROP_SPARSE_INSTRUMENT_COLUMNS,
                              PROPGROUP_SIMULATION_INSTRUMENT)
        self.setPropertySettings(
            common.PROP_SPARSE_INSTRUMENT_COLUMNS,
            EnabledWhenProperty(common.PROP_SIMULATION_INSTRUMENT,
                                PropertyCriterion.IsEqualTo,
                                common.SIMULATION_INSTRUMEN_SPARSE))
        self.declareProperty(
            name=common.PROP_NUMBER_OF_SIMULATION_WAVELENGTHS,
            defaultValue=Property.EMPTY_INT,
            validator=greaterThanTwoInt,
            direction=Direction.Input,
            doc=
            'Number of wavelength points where the simulation is performed (default: all).'
        )
Example #21
0
    def _pyinit(self):
        # ----------
        # INPUT
        # ----------
        self.declareProperty(
            'SANSState',
            '',
            doc='A JSON string which fulfills the SANSState contract.')

        self.declareProperty(
            "UseOptimizations",
            True,
            direction=Direction.Input,
            doc=
            "When enabled the ADS is being searched for already loaded and reduced workspaces. "
            "Depending on your concrete reduction, this could provide a significant"
            " performance boost")

        self.declareProperty(
            "SaveCan",
            False,
            direction=Direction.Input,
            doc=
            "When enabled, the unsubtracted can and sam workspaces are added to the ADS."
        )

        # Sample Scatter Workspaces
        self.declareProperty(
            MatrixWorkspaceProperty('SampleScatterWorkspace',
                                    '',
                                    optional=PropertyMode.Mandatory,
                                    direction=Direction.Input),
            doc=
            'The sample scatter workspace. This workspace does not contain monitors.'
        )
        self.declareProperty(
            MatrixWorkspaceProperty('SampleScatterMonitorWorkspace',
                                    '',
                                    optional=PropertyMode.Mandatory,
                                    direction=Direction.Input),
            doc=
            'The sample scatter monitor workspace. This workspace only contains monitors.'
        )

        # Sample Transmission Workspace
        self.declareProperty(MatrixWorkspaceProperty(
            'SampleTransmissionWorkspace',
            '',
            optional=PropertyMode.Optional,
            direction=Direction.Input),
                             doc='The sample transmission workspace.')

        # Sample Direct Workspace
        self.declareProperty(MatrixWorkspaceProperty(
            'SampleDirectWorkspace',
            '',
            optional=PropertyMode.Optional,
            direction=Direction.Input),
                             doc='The sample scatter direct workspace.')

        self.setPropertyGroup("SampleScatterWorkspace", 'Sample')
        self.setPropertyGroup("SampleScatterMonitorWorkspace", 'Sample')
        self.setPropertyGroup("SampleTransmissionWorkspace", 'Sample')
        self.setPropertyGroup("SampleDirectWorkspace", 'Sample')

        # Can Scatter Workspaces
        self.declareProperty(
            MatrixWorkspaceProperty('CanScatterWorkspace',
                                    '',
                                    optional=PropertyMode.Optional,
                                    direction=Direction.Input),
            doc=
            'The can scatter workspace. This workspace does not contain monitors.'
        )
        self.declareProperty(
            MatrixWorkspaceProperty('CanScatterMonitorWorkspace',
                                    '',
                                    optional=PropertyMode.Optional,
                                    direction=Direction.Input),
            doc=
            'The can scatter monitor workspace. This workspace only contains monitors.'
        )

        # Sample Transmission Workspace
        self.declareProperty(MatrixWorkspaceProperty(
            'CanTransmissionWorkspace',
            '',
            optional=PropertyMode.Optional,
            direction=Direction.Input),
                             doc='The can transmission workspace.')

        # Sample Direct Workspace
        self.declareProperty(MatrixWorkspaceProperty(
            'CanDirectWorkspace',
            '',
            optional=PropertyMode.Optional,
            direction=Direction.Input),
                             doc='The sample scatter direct workspace.')

        self.setPropertyGroup("CanScatterWorkspace", 'Can')
        self.setPropertyGroup("CanScatterMonitorWorkspace", 'Can')
        self.setPropertyGroup("CanTransmissionWorkspace", 'Can')
        self.setPropertyGroup("CanDirectWorkspace", 'Can')

        # ----------
        # OUTPUT
        # ----------
        self._declare_output_properties()
 def PyInit(self):
     self.declareProperty(MatrixWorkspaceProperty('Workspace', '', Direction.InOut),
                          doc="Name to give the input workspace.")
 def PyInit(self):
     """Initialize the input and output properties of the algorithm."""
     nonnegativeInt = IntBoundedValidator(lower=0)
     wsIndexRange = IntBoundedValidator(lower=0, upper=255)
     nonnegativeIntArray = IntArrayBoundedValidator(lower=0)
     maxTwoNonnegativeInts = CompositeValidator()
     maxTwoNonnegativeInts.add(IntArrayLengthValidator(lenmin=0, lenmax=2))
     maxTwoNonnegativeInts.add(nonnegativeIntArray)
     self.declareProperty(MultipleFileProperty(
         Prop.RUN, action=FileAction.OptionalLoad, extensions=['nxs']),
                          doc='A list of input run numbers/files.')
     self.declareProperty(
         MatrixWorkspaceProperty(Prop.INPUT_WS,
                                 defaultValue='',
                                 direction=Direction.Input,
                                 validator=WorkspaceUnitValidator('TOF'),
                                 optional=PropertyMode.Optional),
         doc='An input workspace (units TOF) if no Run is specified.')
     self.declareProperty(
         MatrixWorkspaceProperty(Prop.OUTPUT_WS,
                                 defaultValue='',
                                 direction=Direction.Output),
         doc=
         'The preprocessed output workspace (unit wavelength), single histogram.'
     )
     self.declareProperty(
         Prop.TWO_THETA,
         defaultValue=Property.EMPTY_DBL,
         doc='A user-defined scattering angle 2 theta (unit degrees).')
     self.declareProperty(
         name=Prop.LINE_POSITION,
         defaultValue=Property.EMPTY_DBL,
         doc=
         'A workspace index corresponding to the beam centre between 0.0 and 255.0.'
     )
     self.declareProperty(MatrixWorkspaceProperty(
         Prop.DIRECT_LINE_WORKSPACE,
         defaultValue='',
         direction=Direction.Input,
         optional=PropertyMode.Optional),
                          doc='A pre-processed direct beam workspace.')
     self.declareProperty(Prop.SUBALG_LOGGING,
                          defaultValue=SubalgLogging.OFF,
                          validator=StringListValidator(
                              [SubalgLogging.OFF, SubalgLogging.ON]),
                          doc='Enable or disable child algorithm logging.')
     self.declareProperty(
         Prop.CLEANUP,
         defaultValue=utils.Cleanup.ON,
         validator=StringListValidator(
             [utils.Cleanup.ON, utils.Cleanup.OFF]),
         doc='Enable or disable intermediate workspace cleanup.')
     self.declareProperty(MatrixWorkspaceProperty(
         Prop.WATER_REFERENCE,
         defaultValue='',
         direction=Direction.Input,
         validator=WorkspaceUnitValidator("TOF"),
         optional=PropertyMode.Optional),
                          doc='A (water) calibration workspace (unit TOF).')
     self.declareProperty(Prop.SLIT_NORM,
                          defaultValue=SlitNorm.OFF,
                          validator=StringListValidator(
                              [SlitNorm.OFF, SlitNorm.ON]),
                          doc='Enable or disable slit normalisation.')
     self.declareProperty(Prop.FLUX_NORM_METHOD,
                          defaultValue=FluxNormMethod.TIME,
                          validator=StringListValidator([
                              FluxNormMethod.TIME, FluxNormMethod.MONITOR,
                              FluxNormMethod.OFF
                          ]),
                          doc='Neutron flux normalisation method.')
     self.declareProperty(
         IntArrayProperty(Prop.FOREGROUND_HALF_WIDTH,
                          validator=maxTwoNonnegativeInts),
         doc=
         'Number of foreground pixels at lower and higher angles from the centre pixel.'
     )
     self.declareProperty(
         Prop.BKG_METHOD,
         defaultValue=BkgMethod.CONSTANT,
         validator=StringListValidator(
             [BkgMethod.CONSTANT, BkgMethod.LINEAR, BkgMethod.OFF]),
         doc='Flat background calculation method for background subtraction.'
     )
     self.declareProperty(
         Prop.LOW_BKG_OFFSET,
         defaultValue=7,
         validator=nonnegativeInt,
         doc=
         'Distance of flat background region towards smaller detector angles from the '
         + 'foreground centre, in pixels.')
     self.declareProperty(
         Prop.LOW_BKG_WIDTH,
         defaultValue=5,
         validator=nonnegativeInt,
         doc=
         'Width of flat background region towards smaller detector angles from the '
         + 'foreground centre, in pixels.')
     self.declareProperty(
         Prop.HIGH_BKG_OFFSET,
         defaultValue=7,
         validator=nonnegativeInt,
         doc=
         'Distance of flat background region towards larger detector angles from the '
         + 'foreground centre, in pixels.')
     self.declareProperty(
         Prop.HIGH_BKG_WIDTH,
         defaultValue=5,
         validator=nonnegativeInt,
         doc=
         'Width of flat background region towards larger detector angles from the '
         + 'foreground centre, in pixels.')
     self.declareProperty(
         Prop.START_WS_INDEX,
         validator=wsIndexRange,
         defaultValue=0,
         doc='Start workspace index used for peak fitting.')
     self.declareProperty(Prop.END_WS_INDEX,
                          validator=wsIndexRange,
                          defaultValue=255,
                          doc='Last workspace index used for peak fitting.')
     self.declareProperty(
         Prop.XMIN,
         defaultValue=Property.EMPTY_DBL,
         doc='Minimum x value (unit Angstrom) used for peak fitting.')
     self.declareProperty(
         Prop.XMAX,
         defaultValue=Property.EMPTY_DBL,
         doc='Maximum x value (unit Angstrom) used for peak fitting.')
Example #24
0
    def PyInit(self):
        self.declareProperty(MatrixWorkspaceProperty(
            'SampleWorkspace',
            '',
            optional=PropertyMode.Mandatory,
            direction=Direction.Input),
                             doc="Name for the sample workspace.")

        self.declareProperty(MatrixWorkspaceProperty(
            'ResolutionWorkspace',
            '',
            optional=PropertyMode.Mandatory,
            direction=Direction.Input),
                             doc="Name for the resolution workspace.")

        self.declareProperty(name='EnergyMin',
                             defaultValue=-0.5,
                             doc='Minimum energy for fit. Default=-0.5')
        self.declareProperty(name='EnergyMax',
                             defaultValue=0.5,
                             doc='Maximum energy for fit. Default=0.5')
        self.declareProperty(
            name='BinReductionFactor',
            defaultValue=10.0,
            doc=
            'Decrease total number of spectrum points by this ratio through merging of '
            'intensities from neighbouring bins. Default=1')

        self.declareProperty(
            'NumberOfIterations',
            DEFAULT_ITERATIONS,
            IntBoundedValidator(lower=1),
            doc=
            "Number of randomised simulations for monte-carlo error calculation."
        )

        self.declareProperty(
            'SeedValue',
            DEFAULT_SEED,
            IntBoundedValidator(lower=1),
            doc=
            "Seed for pseudo-random number generator in monte-carlo error calculation."
        )

        self.declareProperty(
            ITableWorkspaceProperty('ParameterWorkspace',
                                    '',
                                    direction=Direction.Output,
                                    optional=PropertyMode.Optional),
            doc='Table workspace for saving TransformToIqt properties')

        self.declareProperty(MatrixWorkspaceProperty(
            'OutputWorkspace',
            '',
            direction=Direction.Output,
            optional=PropertyMode.Optional),
                             doc='Output workspace')

        self.declareProperty(name='DryRun',
                             defaultValue=False,
                             doc='Only calculate and output the parameters')
Example #25
0
    def PyInit(self):
        """Initialize the algorithm's input and output properties."""
        PROPGROUP_BEAM_STOP_DIAGNOSTICS = 'Beam Stop Diagnostics'
        PROPGROUP_BKG_DIAGNOSTICS = 'Background Diagnostics'
        PROPGROUP_PEAK_DIAGNOSTICS = 'Elastic Peak Diagnostics'
        PROPGROUP_USER_MASK = 'Additional Masking'
        greaterThanUnityFloat = FloatBoundedValidator(lower=1)
        inputWorkspaceValidator = CompositeValidator()
        inputWorkspaceValidator.add(InstrumentValidator())
        inputWorkspaceValidator.add(WorkspaceUnitValidator('TOF'))
        positiveFloat = FloatBoundedValidator(lower=0)
        positiveIntArray = IntArrayBoundedValidator()
        positiveIntArray.setLower(0)
        scalingFactor = FloatBoundedValidator(lower=0, upper=1)

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

        self.declareProperty(name='Function',
                             defaultValue='',
                             doc='The function to use in fitting')

        self.declareProperty(name='FitType',
                             defaultValue='',
                             doc='The type of fit being carried out')

        self.declareProperty(name='StartX',
                             defaultValue=0.0,
                             validator=FloatBoundedValidator(0.0),
                             doc="The first value for X")

        self.declareProperty(name='EndX',
                             defaultValue=0.2,
                             validator=FloatBoundedValidator(0.0),
                             doc="The last value for X")

        self.declareProperty(name='SpecMin',
                             defaultValue=0,
                             validator=IntBoundedValidator(0),
                             doc='Minimum spectra in the worksapce to fit')

        self.declareProperty(name='SpecMax',
                             defaultValue=1,
                             validator=IntBoundedValidator(0),
                             doc='Maximum spectra in the worksapce to fit')

        self.declareProperty(name='Minimizer',
                             defaultValue='Levenberg-Marquardt',
                             doc='The minimizer to use in fitting')

        self.declareProperty(
            name="MaxIterations",
            defaultValue=500,
            validator=IntBoundedValidator(0),
            doc="The Maximum number of iterations for the fit")

        self.declareProperty(
            name='ConstrainIntensities',
            defaultValue=False,
            doc="If the Intensities should be constrained during the fit")

        self.declareProperty(
            MatrixWorkspaceProperty('OutputResultWorkspace',
                                    '',
                                    direction=Direction.Output),
            doc='The outputworkspace containing the results of the fit data')

        self.declareProperty(
            ITableWorkspaceProperty('OutputParameterWorkspace',
                                    '',
                                    direction=Direction.Output),
            doc='The outputworkspace containing the parameters for each fit')

        self.declareProperty(
            WorkspaceGroupProperty('OutputWorkspaceGroup',
                                   '',
                                   direction=Direction.Output),
            doc=
            'The OutputWorkspace group Data, Calc and Diff, values for the fit of each spectra'
        )
Example #27
0
 def PyInit(self):
     self.declareProperty(
         MatrixWorkspaceProperty("OutputWorkspace", "",
                                 Direction.Output))
    def PyInit(self):
        ws_validator = CompositeValidator(
            [WorkspaceUnitValidator('Wavelength'),
             InstrumentValidator()])

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

        self.declareProperty(name='SampleChemicalFormula',
                             defaultValue='',
                             validator=StringMandatoryValidator(),
                             doc='Sample chemical formula')

        self.declareProperty(name='SampleDensityType',
                             defaultValue='Mass Density',
                             validator=StringListValidator(
                                 ['Mass Density', 'Number Density']),
                             doc='Use of Mass density or Number density')

        self.declareProperty(
            name='SampleDensity',
            defaultValue=0.1,
            doc='Mass density (g/cm^3) or Number density (atoms/Angstrom^3)')

        self.declareProperty(name='SampleThickness',
                             defaultValue=0.0,
                             validator=FloatBoundedValidator(0.0),
                             doc='Sample thickness in cm')

        self.declareProperty(name='SampleAngle',
                             defaultValue=0.0,
                             doc='Sample angle in degrees')

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

        self.declareProperty(name='CanChemicalFormula',
                             defaultValue='',
                             doc='Container chemical formula')

        self.declareProperty(name='CanDensityType',
                             defaultValue='Mass Density',
                             validator=StringListValidator(
                                 ['Mass Density', 'Number Density']),
                             doc='Use of Mass density or Number density')

        self.declareProperty(
            name='CanDensity',
            defaultValue=0.1,
            doc='Mass density (g/cm^3) or Number density (atoms/Angstrom^3)')

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

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

        self.declareProperty(name='NumberWavelengths',
                             defaultValue=10,
                             validator=IntBoundedValidator(1),
                             doc='Number of wavelengths for calculation')

        self.declareProperty(
            name='Interpolate',
            defaultValue=True,
            doc=
            'Interpolate the correction workspaces to match the sample workspace'
        )

        self.declareProperty(name='Emode',
                             defaultValue='Elastic',
                             validator=StringListValidator(
                                 ['Elastic', 'Indirect', 'Direct']),
                             doc='Energy transfer mode')

        self.declareProperty(name='Efixed',
                             defaultValue=1.0,
                             doc='Analyser energy')

        self.declareProperty(WorkspaceGroupProperty(
            'OutputWorkspace', '', direction=Direction.Output),
                             doc='The output corrections workspace group')
Example #29
0
    def PyInit(self):
        self.declareProperty(
            MatrixWorkspaceProperty('HABCountsSample', '', optional=PropertyMode.Mandatory, direction=Direction.Input),
            doc='High angle bank sample workspace in Q')

        self.declareProperty(
            MatrixWorkspaceProperty('HABNormSample', '', optional=PropertyMode.Mandatory, direction=Direction.Input),
            doc='High angle bank normalization workspace in Q')

        self.declareProperty(
            MatrixWorkspaceProperty('LABCountsSample', '', optional=PropertyMode.Mandatory, direction=Direction.Input),
            doc='Low angle bank sample workspace in Q')

        self.declareProperty(
            MatrixWorkspaceProperty('LABNormSample', '', optional=PropertyMode.Mandatory, direction=Direction.Input),
            doc='Low angle bank normalization workspace in Q')

        self.declareProperty('ProcessCan', defaultValue=False, direction=Direction.Input, doc='Process the can')

        self.declareProperty(
            MatrixWorkspaceProperty('HABCountsCan', '', optional=PropertyMode.Optional, direction=Direction.Input),
            doc='High angle bank sample workspace in Q')

        self.declareProperty(
            MatrixWorkspaceProperty('HABNormCan', '', optional=PropertyMode.Optional, direction=Direction.Input),
            doc='High angle bank normalization workspace in Q')

        self.declareProperty(
            MatrixWorkspaceProperty('LABCountsCan', '', optional=PropertyMode.Optional, direction=Direction.Input),
            doc='Low angle bank sample workspace in Q')

        self.declareProperty(
            MatrixWorkspaceProperty('LABNormCan', '', optional=PropertyMode.Optional, direction=Direction.Input),
            doc='Low angle bank normalization workspace in Q')

        allowedModes = StringListValidator(list(self._make_mode_map().keys()))

        self.declareProperty('Mode', 'None', validator=allowedModes, direction=Direction.Input,
                             doc='What to fit. Free parameter(s).')

        self.declareProperty('ScaleFactor', defaultValue=Property.EMPTY_DBL, direction=Direction.Input,
                             doc='Optional scaling factor')

        self.declareProperty('ShiftFactor', defaultValue=Property.EMPTY_DBL, direction=Direction.Input,
                             doc='Optional shift factor')

        self.declareProperty(MatrixWorkspaceProperty('OutputWorkspace', '', direction=Direction.Output),
                             doc='Stitched high and low Q 1-D data')

        self.declareProperty('OutScaleFactor', defaultValue=Property.EMPTY_DBL, direction=Direction.Output,
                             doc='Applied scale factor')
        self.declareProperty('OutShiftFactor', defaultValue=Property.EMPTY_DBL, direction=Direction.Output,
                             doc='Applied shift factor')

        self.setPropertyGroup("Mode", 'Fitting')
        self.setPropertyGroup("ScaleFactor", 'Fitting')
        self.setPropertyGroup("ShiftFactor", 'Fitting')

        self.setPropertyGroup("HABCountsSample", 'Sample')
        self.setPropertyGroup("HABNormSample", 'Sample')
        self.setPropertyGroup("LABCountsSample", 'Sample')
        self.setPropertyGroup("LABNormSample", 'Sample')

        self.setPropertyGroup("OutputWorkspace", 'Output')
        self.setPropertyGroup("OutScaleFactor", 'Output')
        self.setPropertyGroup("OutShiftFactor", 'Output')

        can_settings = EnabledWhenProperty('ProcessCan', PropertyCriterion.IsNotDefault)

        self.setPropertyGroup("HABCountsCan", 'Can')
        self.setPropertyGroup("HABNormCan", 'Can')
        self.setPropertyGroup("LABCountsCan", 'Can')
        self.setPropertyGroup("LABNormCan", 'Can')
        self.setPropertySettings("HABCountsCan", can_settings)
        self.setPropertySettings("HABNormCan", can_settings)
        self.setPropertySettings("LABCountsCan", can_settings)
        self.setPropertySettings("LABNormCan", can_settings)
Example #30
0
    def PyInit(self):
        # ----------
        # INPUT
        # ----------
        # Workspace which is to be cropped
        self.declareProperty(
            'SANSState',
            '',
            doc='A JSON string which fulfills the SANSState contract.')

        self.declareProperty(MatrixWorkspaceProperty(
            "SampleScatterWorkspace",
            '',
            optional=PropertyMode.Mandatory,
            direction=Direction.Input),
                             doc='The sample scatter data')

        self.declareProperty(MatrixWorkspaceProperty(
            "SampleScatterMonitorWorkspace",
            '',
            optional=PropertyMode.Mandatory,
            direction=Direction.Input),
                             doc='The sample scatter monitor data')

        self.declareProperty(MatrixWorkspaceProperty(
            "SampleTransmissionWorkspace",
            '',
            optional=PropertyMode.Optional,
            direction=Direction.Input),
                             doc='The sample transmission data')

        self.declareProperty(MatrixWorkspaceProperty(
            "SampleDirectWorkspace",
            '',
            optional=PropertyMode.Optional,
            direction=Direction.Input),
                             doc='The sample direct data')

        self.declareProperty(MatrixWorkspaceProperty(
            "CanScatterWorkspace",
            '',
            optional=PropertyMode.Optional,
            direction=Direction.Input),
                             doc='The can scatter data')

        self.declareProperty(MatrixWorkspaceProperty(
            "CanScatterMonitorWorkspace",
            '',
            optional=PropertyMode.Optional,
            direction=Direction.Input),
                             doc='The can scatter monitor data')

        self.declareProperty(MatrixWorkspaceProperty(
            "CanTransmissionWorkspace",
            '',
            optional=PropertyMode.Optional,
            direction=Direction.Input),
                             doc='The can transmission data')

        self.declareProperty(MatrixWorkspaceProperty(
            "CanDirectWorkspace",
            '',
            optional=PropertyMode.Optional,
            direction=Direction.Input),
                             doc='The can direct data')

        # The component, i.e. HAB or LAB
        allowed_detectors = StringListValidator(
            [DetectorType.LAB.value, DetectorType.HAB.value])
        self.declareProperty(
            "Component",
            DetectorType.LAB.value,
            validator=allowed_detectors,
            direction=Direction.Input,
            doc="The component of the instrument which is to be reduced.")

        self.declareProperty("Iterations",
                             10,
                             direction=Direction.Input,
                             doc="The maximum number of iterations.")

        self.declareProperty("RMin",
                             0.6,
                             direction=Direction.Input,
                             doc="The inner radius of the quartile mask")

        self.declareProperty('RMax',
                             0.28,
                             direction=Direction.Input,
                             doc="The outer radius of the quartile mask")

        self.declareProperty('Position1Start',
                             0.0,
                             direction=Direction.Input,
                             doc="The search start position1")

        self.declareProperty('Position2Start',
                             0.0,
                             direction=Direction.Input,
                             doc="The search start position2")

        self.declareProperty('Tolerance',
                             0.0001251,
                             direction=Direction.Input,
                             doc="The search tolerance")

        self.declareProperty(
            'Direction',
            FindDirectionEnum.ALL.value,
            direction=Direction.Input,
            doc=
            "The search direction is an enumerable which can be either All, LeftRight or UpDown"
        )

        self.declareProperty(
            'Verbose',
            False,
            direction=Direction.Input,
            doc="Whether to keep workspaces from each iteration in ADS.")

        # ----------
        # Output
        # ----------
        # Workspace which is to be cropped

        self.declareProperty(
            'Centre1',
            0.0,
            direction=Direction.Output,
            doc="The centre position found in the first dimension")
        self.declareProperty(
            'Centre2',
            0.0,
            direction=Direction.Output,
            doc="The centre position found in the second dimension")