def test_multiple_condition_construction(self):
     # We cannot manipulate properties easily from the Python side compared to the C++
     # side. So we will check we can construct the object from Python correctly and rely
     # on the C++ unit tests to check all operators
     a = VisibleWhenProperty("PropA", PropertyCriterion.IsDefault)
     b = VisibleWhenProperty("PropB", PropertyCriterion.IsDefault)
     result = VisibleWhenProperty(a, b, LogicOperator.And)
     self.assertIsNotNone(result)
    def PyInit(self):
        self.declareProperty(IPeaksWorkspaceProperty(
            'Workspace', '', direction=Direction.InOut),
                             doc='Peaks Workspace to be modified')
        self.declareProperty(
            "Wavelength",
            Property.EMPTY_DBL,
            validator=FloatBoundedValidator(0.0),
            doc=
            "Wavelength to set the workspace, will be the value set on workspace if not provided."
        )
        self.declareProperty(
            "OverrideProperty", False,
            "If False then the value for InnerGoniometer and FlipX will be determiend from the workspace, "
            "it True then the properties will be used")
        condition = VisibleWhenProperty("OverrideProperty",
                                        PropertyCriterion.IsNotDefault)

        self.declareProperty(
            "InnerGoniometer", False,
            "Whether the goniometer to be calculated is the most inner (phi) or most outer (omega)"
        )
        self.setPropertySettings("InnerGoniometer", condition)
        self.declareProperty(
            "FlipX", False,
            "Used when calculating goniometer angle if the q_lab x value should be negative, "
            "hence the detector of the other side (right) of the beam")
        self.setPropertySettings("FlipX", condition)
 def test_default_construction_raises_error(self):
     try:
         VisibleWhenProperty()
         self.fail("Expected default constructor to raise an error")
     except Exception as e:
         # boost.python.ArgumentError are not catchable
         if "Python argument types in" not in str(e):
             raise RuntimeError("Unexpected exception type raised")
    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.')
Esempio n. 5
0
    def PyInit(self):
        self.declareProperty(
            MultipleFileProperty('CalibrationRun',
                                 action=FileAction.Load,
                                 extensions=['nxs']),
            doc=
            'File path of calibration runs (numors). Must be detector scans.')

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

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

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

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

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

        thetaRangeValidator = FloatArrayOrderedPairsValidator()

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

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

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

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

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

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

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

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

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

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

        self.declareProperty(
            name='UseCalibratedData',
            defaultValue=False,
            doc=
            'Whether or not to use the calibrated data in the NeXus files (D2B only).'
        )
 def test_construction_with_name_criterion_value_succeeds(self):
     p = VisibleWhenProperty("OtherProperty", PropertyCriterion.IsEqualTo,
                             "value")
     self.assertIsNotNone(p)
    def PyInit(self):
        # Sample Input
        self.declareProperty(
            WorkspaceProperty('InputWorkspace', '', direction=Direction.Input),
            doc='Workspace with the measurement of the sample [in a container].'
        )

        # Monte Carlo Options
        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')
        self.declareProperty(
            name='MaxScatterPtAttempts',
            defaultValue=5000,
            validator=IntBoundedValidator(0),
            doc='Maximum number of tries made to generate a scattering point')
        self.declareProperty(
            name='SparseInstrument',
            defaultValue=False,
            doc=
            'Whether to spatially approximate the instrument for faster calculation.'
        )
        self.declareProperty(
            name='NumberOfDetectorRows',
            defaultValue=3,
            validator=IntBoundedValidator(lower=3),
            doc=
            'Number of detector rows in the detector grid of the sparse instrument.'
        )
        self.declareProperty(
            name='NumberOfDetectorColumns',
            defaultValue=2,
            validator=IntBoundedValidator(lower=2),
            doc=
            'Number of detector columns in the detector grid of the sparse instrument.'
        )

        sparse_condition = EnabledWhenProperty('SparseInstrument',
                                               PropertyCriterion.IsNotDefault)
        self.setPropertySettings('NumberOfDetectorRows', sparse_condition)
        self.setPropertySettings('NumberOfDetectorColumns', sparse_condition)

        self.setPropertyGroup('SparseInstrument', 'Monte Carlo Options')
        self.setPropertyGroup('NumberOfDetectorRows', 'Monte Carlo Options')
        self.setPropertyGroup('NumberOfDetectorColumns', 'Monte Carlo Options')
        self.setPropertyGroup('EventsPerPoint', 'Monte Carlo Options')
        self.setPropertyGroup('Interpolation', 'Monte Carlo Options')
        self.setPropertyGroup('MaxScatterPtAttempts', 'Monte Carlo Options')

        # Beam Options
        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)')

        self.setPropertyGroup('BeamHeight', 'Beam Options')
        self.setPropertyGroup('BeamWidth', 'Beam Options')

        # Shape Options
        self.declareProperty(name='Shape',
                             defaultValue='Preset',
                             validator=StringListValidator([
                                 'Preset', 'FlatPlate', 'Cylinder', 'Annulus'
                             ]),
                             doc='Geometric shape of the sample environment')

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

        # show flat plate as visible but disabled if preset shape chosen, to avoid empty group on alg dialogue
        preset_condition = VisibleWhenProperty('Shape',
                                               PropertyCriterion.IsEqualTo,
                                               'Preset')
        flat_plate_visible = VisibleWhenProperty(preset_condition,
                                                 flat_plate_condition,
                                                 LogicOperator.Or)

        # height is common to all shapes, and should be the same for sample and container
        self.declareProperty('Height',
                             defaultValue=0.0,
                             validator=FloatBoundedValidator(0.0),
                             doc='Height of the sample environment (cm)')
        self.setPropertySettings('Height', not_preset_condition)

        self.setPropertyGroup('Shape', 'Shape Options')
        self.setPropertyGroup('Height', 'Shape Options')

        # Sample Shape
        # Flat Plate
        self.declareProperty(name='SampleWidth',
                             defaultValue=0.0,
                             validator=FloatBoundedValidator(0.0),
                             doc='Width of the sample environment (cm)')
        self.declareProperty(name='SampleThickness',
                             defaultValue=0.0,
                             validator=FloatBoundedValidator(0.0),
                             doc='Thickness of the sample environment (cm)')
        self.declareProperty(name='SampleCenter',
                             defaultValue=0.0,
                             doc='Center of the sample environment')
        self.declareProperty(
            name='SampleAngle',
            defaultValue=0.0,
            validator=FloatBoundedValidator(0.0),
            doc=
            'Angle of the sample environment with respect to the beam (degrees)'
        )

        self.setPropertySettings('SampleWidth', flat_plate_visible)
        self.setPropertySettings('SampleThickness', flat_plate_visible)
        self.setPropertySettings('SampleCenter', flat_plate_visible)
        self.setPropertySettings('SampleAngle', flat_plate_visible)
        self.setPropertySettings('SampleWidth', not_preset_condition)
        self.setPropertySettings('SampleThickness', not_preset_condition)
        self.setPropertySettings('SampleCenter', not_preset_condition)
        self.setPropertySettings('SampleAngle', not_preset_condition)

        self.setPropertyGroup('SampleWidth', 'Sample Shape')
        self.setPropertyGroup('SampleThickness', 'Sample Shape')
        self.setPropertyGroup('SampleCenter', 'Sample Shape')
        self.setPropertyGroup('SampleAngle', 'Sample Shape')

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

        self.setPropertySettings('SampleRadius', cylinder_condition)
        self.setPropertyGroup('SampleRadius', 'Sample Shape')

        # Annulus
        self.declareProperty(name='SampleInnerRadius',
                             defaultValue=0.0,
                             validator=FloatBoundedValidator(0.0),
                             doc='Inner radius of the sample environment (cm)')
        self.declareProperty(name='SampleOuterRadius',
                             defaultValue=0.0,
                             validator=FloatBoundedValidator(0.0),
                             doc='Outer radius of the sample environment (cm)')

        self.setPropertySettings('SampleInnerRadius', annulus_condition)
        self.setPropertySettings('SampleOuterRadius', annulus_condition)

        self.setPropertyGroup('SampleInnerRadius', 'Sample Shape')
        self.setPropertyGroup('SampleOuterRadius', 'Sample Shape')

        # Sample Material
        self.declareProperty(name='SampleChemicalFormula',
                             defaultValue='',
                             doc='Chemical formula for the sample material')
        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.0,
            validator=FloatBoundedValidator(0.0),
            doc=
            'The value for the sample Mass density (g/cm^3) or Number density (1/Angstrom^3).'
        )

        self.setPropertyGroup('SampleChemicalFormula', 'Sample Material')
        self.setPropertyGroup('SampleCoherentXSection', 'Sample Material')
        self.setPropertyGroup('SampleIncoherentXSection', 'Sample Material')
        self.setPropertyGroup('SampleAttenuationXSection', 'Sample Material')
        self.setPropertyGroup('SampleDensityType', 'Sample Material')
        self.setPropertyGroup('SampleNumberDensityUnit', 'Sample Material')
        self.setPropertyGroup('SampleDensity', 'Sample Material')

        # Flat Plate
        self.declareProperty(
            name='ContainerFrontThickness',
            defaultValue=0.0,
            validator=FloatBoundedValidator(0.0),
            doc='Front thickness of the container environment (cm)')
        self.declareProperty(
            name='ContainerBackThickness',
            defaultValue=0.0,
            validator=FloatBoundedValidator(0.0),
            doc='Back thickness of the container environment (cm)')

        self.setPropertySettings('ContainerFrontThickness',
                                 flat_plate_condition)
        self.setPropertySettings('ContainerBackThickness',
                                 flat_plate_condition)
        self.setPropertySettings('ContainerFrontThickness',
                                 not_preset_condition)
        self.setPropertySettings('ContainerBackThickness',
                                 not_preset_condition)
        self.setPropertyGroup('ContainerFrontThickness', 'Container Shape')
        self.setPropertyGroup('ContainerBackThickness', 'Container Shape')

        # Cylinder
        self.declareProperty(name='ContainerRadius',
                             defaultValue=0.0,
                             validator=FloatBoundedValidator(0.0),
                             doc='Outer radius of the sample environment (cm)')

        self.setPropertySettings('ContainerRadius', cylinder_condition)
        self.setPropertyGroup('ContainerRadius', 'Container Shape')

        # Annulus
        self.declareProperty(
            name='ContainerInnerRadius',
            defaultValue=0.0,
            validator=FloatBoundedValidator(0.0),
            doc='Inner radius of the container environment (cm)')
        self.declareProperty(
            name='ContainerOuterRadius',
            defaultValue=0.0,
            validator=FloatBoundedValidator(0.0),
            doc='Outer radius of the container environment (cm)')

        self.setPropertySettings('ContainerInnerRadius', annulus_condition)
        self.setPropertySettings('ContainerOuterRadius', annulus_condition)

        self.setPropertyGroup('ContainerInnerRadius', 'Container Shape')
        self.setPropertyGroup('ContainerOuterRadius', 'Container Shape')

        # Container Material
        self.declareProperty(name='ContainerChemicalFormula',
                             defaultValue='',
                             doc='Chemical formula for the container material')
        self.declareProperty(
            name='ContainerCoherentXSection',
            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='ContainerIncoherentXSection',
            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='ContainerAttenuationXSection',
            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='ContainerDensityType',
            defaultValue='Mass Density',
            validator=StringListValidator(['Mass Density', 'Number Density']),
            doc='Use of Mass density or Number density for the container.')
        self.declareProperty(
            name='ContainerNumberDensityUnit',
            defaultValue='Atoms',
            validator=StringListValidator(['Atoms', 'Formula Units']),
            doc=
            'Choose which units ContainerDensity refers to. Allowed values: [Atoms, Formula Units]'
        )
        self.declareProperty(
            name='ContainerDensity',
            defaultValue=0.0,
            validator=FloatBoundedValidator(0.0),
            doc=
            'The value for the container Mass density (g/cm^3) or Number density (1/Angstrom^3).'
        )

        self.setPropertyGroup('ContainerChemicalFormula', 'Container Material')
        self.setPropertyGroup('ContainerCoherentXSection',
                              'Container Material')
        self.setPropertyGroup('ContainerIncoherentXSection',
                              'Container Material')
        self.setPropertyGroup('ContainerAttenuationXSection',
                              'Container Material')
        self.setPropertyGroup('ContainerDensityType', 'Container Material')
        self.setPropertyGroup('ContainerNumberDensityUnit',
                              'Container Material')
        self.setPropertyGroup('ContainerDensity', 'Container Material')
        self.setPropertySettings('ContainerChemicalFormula',
                                 not_preset_condition)
        self.setPropertySettings('ContainerCoherentXSection',
                                 not_preset_condition)
        self.setPropertySettings('ContainerIncoherentXSection',
                                 not_preset_condition)
        self.setPropertySettings('ContainerAttenuationXSection',
                                 not_preset_condition)
        self.setPropertySettings('ContainerDensityType', not_preset_condition)
        self.setPropertySettings('ContainerNumberDensityUnit',
                                 not_preset_condition)
        self.setPropertySettings('ContainerDensity', not_preset_condition)

        # Output Workspace Group
        self.declareProperty(
            WorkspaceGroupProperty(name='CorrectionsWorkspace',
                                   defaultValue='corrections',
                                   direction=Direction.Output,
                                   optional=PropertyMode.Optional),
            doc='Name of the workspace group to save correction factors')
    def PyInit(self):
        # Sample options
        self.declareProperty(WorkspaceProperty('SampleWorkspace',
                                               '',
                                               direction=Direction.Input),
                             doc='Sample Workspace')
        self.declareProperty(name='SampleChemicalFormula',
                             defaultValue='',
                             doc='Chemical formula for the sample material')
        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.0,
            validator=FloatBoundedValidator(0.0),
            doc=
            'The value for the sample Mass density (g/cm^3) or Number density (1/Angstrom^3).'
        )

        self.setPropertyGroup('SampleWorkspace', 'Sample Options')
        self.setPropertyGroup('SampleChemicalFormula', 'Sample Options')
        self.setPropertyGroup('SampleCoherentXSection', 'Sample Options')
        self.setPropertyGroup('SampleIncoherentXSection', 'Sample Options')
        self.setPropertyGroup('SampleAttenuationXSection', 'Sample Options')
        self.setPropertyGroup('SampleDensityType', 'Sample Options')
        self.setPropertyGroup('SampleDensity', 'Sample Options')

        # Beam Options
        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)')

        self.setPropertyGroup('BeamHeight', 'Beam Options')
        self.setPropertyGroup('BeamWidth', 'Beam Options')

        # 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')
        self.declareProperty(
            name='MaxScatterPtAttempts',
            defaultValue=5000,
            validator=IntBoundedValidator(0),
            doc='Maximum number of tries made to generate a scattering point')

        self.setPropertyGroup('NumberOfWavelengthPoints',
                              'Monte Carlo Options')
        self.setPropertyGroup('EventsPerPoint', 'Monte Carlo Options')
        self.setPropertyGroup('Interpolation', 'Monte Carlo Options')
        self.setPropertyGroup('MaxScatterPtAttempts', 'Monte Carlo Options')

        # Container options
        self.declareProperty(WorkspaceProperty('ContainerWorkspace',
                                               '',
                                               direction=Direction.Input,
                                               optional=PropertyMode.Optional),
                             doc='Container Workspace')

        container_condition = VisibleWhenProperty(
            'ContainerWorkspace', PropertyCriterion.IsNotDefault)

        self.declareProperty(name='ContainerChemicalFormula',
                             defaultValue='',
                             doc='Chemical formula for the container material')
        self.declareProperty(
            name='ContainerCoherentXSection',
            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='ContainerIncoherentXSection',
            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='ContainerAttenuationXSection',
            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='ContainerDensityType',
            defaultValue='Mass Density',
            validator=StringListValidator(['Mass Density', 'Number Density']),
            doc='Use of Mass density or Number density for the container.')
        self.declareProperty(
            name='ContainerNumberDensityUnit',
            defaultValue='Atoms',
            validator=StringListValidator(['Atoms', 'Formula Units']),
            doc=
            'Choose which units ContainerDensity refers to. Allowed values: [Atoms, Formula Units]'
        )
        self.declareProperty(
            name='ContainerDensity',
            defaultValue=0.0,
            validator=FloatBoundedValidator(0.0),
            doc=
            'The value for the container Mass density (g/cm^3) or Number density (1/Angstrom^3).'
        )

        self.setPropertyGroup('ContainerWorkspace', 'Container Options')
        self.setPropertyGroup('ContainerChemicalFormula', 'Container Options')
        self.setPropertyGroup('ContainerCoherentXSection', 'Container Options')
        self.setPropertyGroup('ContainerIncoherentXSection',
                              'Container Options')
        self.setPropertyGroup('ContainerAttenuationXSection',
                              'Container Options')
        self.setPropertyGroup('ContainerDensityType', 'Container Options')
        self.setPropertyGroup('ContainerDensity', 'Container Options')

        self.setPropertySettings('ContainerChemicalFormula',
                                 container_condition)
        self.setPropertySettings('ContainerDensityType', container_condition)
        self.setPropertySettings('ContainerDensity', container_condition)

        # Shape options
        self.declareProperty(name='Shape',
                             defaultValue='FlatPlate',
                             validator=StringListValidator(
                                 ['FlatPlate', 'Cylinder', 'Annulus']),
                             doc='Geometric shape of the sample environment')

        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, and should be the same for sample and container
        self.declareProperty('Height',
                             defaultValue=0.0,
                             validator=FloatBoundedValidator(0.0),
                             doc='Height of the sample environment (cm)')

        self.setPropertyGroup('Shape', 'Shape Options')
        self.setPropertyGroup('Height', 'Shape Options')

        # ---------------------------Sample---------------------------
        # Flat Plate
        self.declareProperty(name='SampleWidth',
                             defaultValue=0.0,
                             validator=FloatBoundedValidator(0.0),
                             doc='Width of the sample environment (cm)')
        self.declareProperty(name='SampleThickness',
                             defaultValue=0.0,
                             validator=FloatBoundedValidator(0.0),
                             doc='Thickness of the sample environment (cm)')
        self.declareProperty(name='SampleCenter',
                             defaultValue=0.0,
                             doc='Center of the sample environment')
        self.declareProperty(
            name='SampleAngle',
            defaultValue=0.0,
            validator=FloatBoundedValidator(0.0),
            doc=
            'Angle of the sample environment with respect to the beam (degrees)'
        )

        self.setPropertySettings('SampleWidth', flat_plate_condition)
        self.setPropertySettings('SampleThickness', flat_plate_condition)
        self.setPropertySettings('SampleCenter', flat_plate_condition)
        self.setPropertySettings('SampleAngle', flat_plate_condition)

        self.setPropertyGroup('SampleWidth', 'Sample Shape Options')
        self.setPropertyGroup('SampleThickness', 'Sample Shape Options')
        self.setPropertyGroup('SampleCenter', 'Sample Shape Options')
        self.setPropertyGroup('SampleAngle', 'Sample Shape Options')

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

        self.setPropertySettings('SampleRadius', cylinder_condition)
        self.setPropertyGroup('SampleRadius', 'Sample Shape Options')

        # Annulus
        self.declareProperty(name='SampleInnerRadius',
                             defaultValue=0.0,
                             validator=FloatBoundedValidator(0.0),
                             doc='Inner radius of the sample environment (cm)')
        self.declareProperty(name='SampleOuterRadius',
                             defaultValue=0.0,
                             validator=FloatBoundedValidator(0.0),
                             doc='Outer radius of the sample environment (cm)')

        self.setPropertySettings('SampleInnerRadius', annulus_condition)
        self.setPropertySettings('SampleOuterRadius', annulus_condition)

        self.setPropertyGroup('SampleInnerRadius', 'Sample Shape Options')
        self.setPropertyGroup('SampleOuterRadius', 'Sample Shape Options')

        # ---------------------------Container---------------------------
        # Flat Plate
        self.declareProperty(
            name='ContainerFrontThickness',
            defaultValue=0.0,
            validator=FloatBoundedValidator(0.0),
            doc='Front thickness of the container environment (cm)')
        self.declareProperty(
            name='ContainerBackThickness',
            defaultValue=0.0,
            validator=FloatBoundedValidator(0.0),
            doc='Back thickness of the container environment (cm)')

        container_flat_plate_condition = VisibleWhenProperty(
            container_condition, flat_plate_condition, LogicOperator.And)

        self.setPropertySettings('ContainerFrontThickness',
                                 container_flat_plate_condition)
        self.setPropertySettings('ContainerBackThickness',
                                 container_flat_plate_condition)

        self.setPropertyGroup('ContainerFrontThickness',
                              'Container Shape Options')
        self.setPropertyGroup('ContainerBackThickness',
                              'Container Shape Options')

        # Both cylinder and annulus have an annulus container

        not_flat_plate_condition = VisibleWhenProperty(
            'Shape', PropertyCriterion.IsNotEqualTo, 'FlatPlate')

        container_n_f_p_condition = VisibleWhenProperty(
            container_condition, not_flat_plate_condition, LogicOperator.And)

        self.declareProperty(
            name='ContainerInnerRadius',
            defaultValue=0.0,
            validator=FloatBoundedValidator(0.0),
            doc='Inner radius of the container environment (cm)')
        self.declareProperty(
            name='ContainerOuterRadius',
            defaultValue=0.0,
            validator=FloatBoundedValidator(0.0),
            doc='Outer radius of the container environment (cm)')

        self.setPropertySettings('ContainerInnerRadius',
                                 container_n_f_p_condition)
        self.setPropertySettings('ContainerOuterRadius',
                                 container_n_f_p_condition)

        self.setPropertyGroup('ContainerInnerRadius',
                              'Container Shape Options')
        self.setPropertyGroup('ContainerOuterRadius',
                              'Container Shape Options')

        # output
        self.declareProperty(
            WorkspaceGroupProperty(name='CorrectionsWorkspace',
                                   defaultValue='corrections',
                                   direction=Direction.Output,
                                   optional=PropertyMode.Optional),
            doc='Name of the workspace group to save correction factors')
        self.setPropertyGroup('CorrectionsWorkspace', 'Output Options')
 def test_construction_with_name_criterion_only_succeeds(self):
     p = VisibleWhenProperty("OtherProperty", PropertyCriterion.IsDefault)
     self.assertIsNotNone(p)
Esempio n. 10
0
    def PyInit(self):
        # files to reduce
        self.declareProperty(
            MultipleFileProperty(name="Filename",
                                 extensions=["_event.nxs", ".nxs.h5", ".nxs"]),
            "Files to combine in reduction")

        # background
        self.declareProperty(
            FileProperty(name="Background",
                         defaultValue="",
                         action=FileAction.OptionalLoad,
                         extensions=["_event.nxs", ".nxs.h5", ".nxs"]),
            "Background run")
        self.declareProperty(
            "BackgroundScale",
            1.0,
            doc=
            "The background will be scaled by this number before being subtracted."
        )

        # Filter by TOF
        self.copyProperties('LoadEventNexus',
                            ['FilterByTofMin', 'FilterByTofMax'])

        # Cropping
        self.declareProperty('MomentumMin',
                             Property.EMPTY_DBL,
                             doc="Minimum value in momentum.",
                             validator=FloatMandatoryValidator())
        self.declareProperty('MomentumMax',
                             Property.EMPTY_DBL,
                             doc="Maximum value in momentum.",
                             validator=FloatMandatoryValidator())

        # Grouping
        self.declareProperty(
            FileProperty(name="GroupingFile",
                         defaultValue="",
                         action=FileAction.OptionalLoad,
                         extensions=[".xml", ".map"]),
            "A file that consists of lists of spectra numbers to group. See :ref:`GroupDetectors <algm-GroupDetectors>`"
        )

        # Corrections
        self.declareProperty(
            'NormaliseByCurrent', True,
            "Normalise the Solid Angle workspace by the proton charge.")
        self.declareProperty(
            FileProperty(name="LoadInstrument",
                         defaultValue="",
                         action=FileAction.OptionalLoad,
                         extensions=[".xml"]),
            "Load a different instrument IDF onto the data from a file. See :ref:`LoadInstrument <algm-LoadInstrument>`"
        )
        self.declareProperty(
            FileProperty(name="DetCal",
                         defaultValue="",
                         action=FileAction.OptionalLoad,
                         extensions=[".detcal"]),
            "Load an ISAW DetCal calibration onto the data from a file. See :ref:`LoadIsawDetCal <algm-LoadIsawDetCal>`"
        )
        self.declareProperty(
            FileProperty(name="MaskFile",
                         defaultValue="",
                         action=FileAction.OptionalLoad,
                         extensions=[".xml", ".msk"]),
            "Masking file for masking. Supported file format is XML and ISIS ASCII. See :ref:`LoadMask <algm-LoadMask>`"
        )
        # Anvred
        self.declareProperty(
            'SphericalAbsorptionCorrection', False,
            "Apply Spherical Absorption correction using :ref:`AnvredCorrection <algm-AnvredCorrection>`"
        )
        condition = VisibleWhenProperty("SphericalAbsorptionCorrection",
                                        PropertyCriterion.IsNotDefault)
        self.copyProperties(
            'AnvredCorrection',
            ['LinearScatteringCoef', 'LinearAbsorptionCoef', 'Radius'])
        self.setPropertySettings("LinearScatteringCoef", condition)
        self.setPropertySettings("LinearAbsorptionCoef", condition)
        self.setPropertySettings("Radius", condition)

        # Output
        self.declareProperty(
            WorkspaceProperty("SolidAngleOutputWorkspace",
                              "",
                              optional=PropertyMode.Mandatory,
                              direction=Direction.Output),
            "Output Workspace for Solid Angle")

        self.declareProperty(
            WorkspaceProperty("FluxOutputWorkspace",
                              "",
                              optional=PropertyMode.Mandatory,
                              direction=Direction.Output),
            "Output Workspace for Flux")

        # Background
        self.setPropertyGroup("Background", "Background")
        self.setPropertyGroup("BackgroundScale", "Background")

        # Corrections
        self.setPropertyGroup("NormaliseByCurrent", "Corrections")
        self.setPropertyGroup("LoadInstrument", "Corrections")
        self.setPropertyGroup("DetCal", "Corrections")
        self.setPropertyGroup("MaskFile", "Corrections")
        self.setPropertyGroup("SphericalAbsorptionCorrection", "Corrections")
        self.setPropertyGroup("LinearScatteringCoef", "Corrections")
        self.setPropertyGroup("LinearAbsorptionCoef", "Corrections")
        self.setPropertyGroup("Radius", "Corrections")
    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.')
Esempio n. 12
0
    def PyInit(self):
        # files to reduce
        self.declareProperty(
            MultipleFileProperty(name="Filename",
                                 extensions=["_event.nxs", ".nxs.h5", ".nxs"]),
            "Files to combine in reduction")

        # Filter by time
        self.copyProperties(
            'LoadEventNexus',
            ['FilterByTofMin', 'FilterByTofMax', 'FilterByTimeStop'])

        # Filter momentum
        self.declareProperty(
            'MomentumMin',
            Property.EMPTY_DBL,
            doc=
            "Minimum value in momentum. This should match the Flux momentum if "
            "the output is to be used with :ref:`MDNorm <algm-MDNorm>`")
        self.declareProperty(
            'MomentumMax',
            Property.EMPTY_DBL,
            doc=
            "Maximum value in momentum. This should match the Fluxmomentum if "
            "the output is to be used with :ref:`MDNorm <algm-MDNorm>`")
        # UBMatrix
        self.declareProperty(
            FileProperty(name="UBMatrix",
                         defaultValue="",
                         action=FileAction.OptionalLoad,
                         extensions=[".mat", ".ub", ".txt"]),
            doc=
            "Path to an ISAW-style UB matrix text file. See :ref:`LoadIsawUB <algm-LoadIsawUB>`"
        )
        # Goniometer
        self.declareProperty(
            'SetGoniometer', False,
            "Set which Goniometer to use. See :ref:`SetGoniometer <algm-SetGoniometer>`"
        )
        condition = VisibleWhenProperty("SetGoniometer",
                                        PropertyCriterion.IsNotDefault)
        self.copyProperties('SetGoniometer',
                            ['Goniometers', 'Axis0', 'Axis1', 'Axis2'])
        self.setPropertySettings("Goniometers", condition)
        self.setPropertySettings('Axis0', condition)
        self.setPropertySettings('Axis1', condition)
        self.setPropertySettings('Axis2', condition)

        # Corrections
        self.declareProperty(
            FileProperty(name="LoadInstrument",
                         defaultValue="",
                         action=FileAction.OptionalLoad,
                         extensions=[".xml"]),
            "Load a different instrument IDF onto the data from a file. See :ref:`LoadInstrument <algm-LoadInstrument>`"
        )
        self.declareProperty(
            ITableWorkspaceProperty("ApplyCalibration",
                                    '',
                                    optional=PropertyMode.Optional,
                                    direction=Direction.Input),
            doc='Calibration will be applied using this TableWorkspace using '
            ':ref:`ApplyCalibration <algm-ApplyCalibration>`.')
        self.declareProperty(
            FileProperty(name="DetCal",
                         defaultValue="",
                         action=FileAction.OptionalLoad,
                         extensions=[".detcal"]),
            "Load an ISAW DetCal calibration onto the data from a file. See :ref:`LoadIsawDetCal <algm-LoadIsawDetCal>`"
        )
        self.declareProperty(
            MatrixWorkspaceProperty("CopyInstrumentParameters",
                                    '',
                                    optional=PropertyMode.Optional,
                                    direction=Direction.Input),
            doc=
            'The input workpsace from which :ref:`CopyInstrumentParameters <algm-CopyInstrumentParameters>` '
            'will copy parameters to data')
        self.declareProperty(
            FileProperty(name="MaskFile",
                         defaultValue="",
                         action=FileAction.OptionalLoad,
                         extensions=[".xml", ".msk"]),
            "Masking file for masking. Supported file format is XML and ISIS ASCII. See :ref:`LoadMask <algm-LoadMask>`"
        )

        self.declareProperty(
            WorkspaceProperty("OutputWorkspace",
                              "",
                              optional=PropertyMode.Mandatory,
                              direction=Direction.Output), "Output Workspace")

        # Convert Settings
        self.declareProperty(
            'QFrame',
            'Q_sample',
            validator=StringListValidator(['Q_sample', 'HKL']),
            doc=
            "Selects Q-dimensions of the output workspace. Q (sample frame): "
            "Wave-vector converted into the frame of the sample (taking out the "
            "goniometer rotation). HKL: Use the sample's UB matrix to convert "
            "Wave-vector to crystal's HKL indices.")

        self.copyProperties('ConvertToMD', [
            'Uproj', 'Vproj', 'Wproj', 'MinValues', 'MaxValues', 'SplitInto',
            'SplitThreshold', 'MaxRecursionDepth', 'OverwriteExisting'
        ])

        self.setPropertyGroup('FilterByTofMin', 'Loading')
        self.setPropertyGroup('FilterByTofMax', 'Loading')
        self.setPropertyGroup('FilterByTimeStop', 'Loading')
        self.setPropertyGroup('MomentumMin', 'Loading')
        self.setPropertyGroup('MomentumMax', 'Loading')

        # Goniometer
        self.setPropertyGroup("SetGoniometer", "Goniometer")
        self.setPropertyGroup("Goniometers", "Goniometer")
        self.setPropertyGroup("Axis0", "Goniometer")
        self.setPropertyGroup("Axis1", "Goniometer")
        self.setPropertyGroup("Axis2", "Goniometer")

        # Corrections
        self.setPropertyGroup("LoadInstrument", "Corrections")
        self.setPropertyGroup("DetCal", "Corrections")
        self.setPropertyGroup("MaskFile", "Corrections")

        # ConvertToMD
        self.setPropertyGroup('QFrame', 'ConvertToMD')
        self.setPropertyGroup('Uproj', 'ConvertToMD')
        self.setPropertyGroup('Vproj', 'ConvertToMD')
        self.setPropertyGroup('Wproj', 'ConvertToMD')
        self.setPropertyGroup('MinValues', 'ConvertToMD')
        self.setPropertyGroup('MaxValues', 'ConvertToMD')
        self.setPropertyGroup('SplitInto', 'ConvertToMD')
        self.setPropertyGroup('SplitThreshold', 'ConvertToMD')
        self.setPropertyGroup('MaxRecursionDepth', 'ConvertToMD')
Esempio n. 13
0
    def PyInit(self):
        # files to reduce
        self.declareProperty(
            MultipleFileProperty(name="Filename",
                                 extensions=["_event.nxs", ".nxs.h5", ".nxs"]),
            "Files to combine in reduction")

        # background
        self.declareProperty(
            FileProperty(name="Background",
                         defaultValue="",
                         action=FileAction.OptionalLoad,
                         extensions=["_event.nxs", ".nxs.h5", ".nxs"]),
            "Background run")
        self.declareProperty(
            "BackgroundScale",
            1.0,
            doc=
            "The background will be scaled by this number before being subtracted."
        )

        # Filter by TOF
        self.copyProperties('LoadEventNexus',
                            ['FilterByTofMin', 'FilterByTofMax'])

        # Vanadium SA and flux
        self.declareProperty(
            FileProperty(name="SolidAngle",
                         defaultValue="",
                         action=FileAction.Load,
                         extensions=[".nxs"]),
            doc=
            "An input workspace containing momentum integrated vanadium (a measure"
            "of the solid angle). See :ref:`MDnormSCD <algm-MDnormSCD>` for details"
        )
        self.declareProperty(
            FileProperty(name="Flux",
                         defaultValue="",
                         action=FileAction.Load,
                         extensions=[".nxs"]),
            "An input workspace containing momentum dependent flux. See :ref:`MDnormSCD <algm-MDnormSCD>` for details"
        )

        # UBMatrix
        self.declareProperty(
            FileProperty(name="UBMatrix",
                         defaultValue="",
                         action=FileAction.Load,
                         extensions=[".mat", ".ub", ".txt"]),
            doc=
            "Path to an ISAW-style UB matrix text file. See :ref:`LoadIsawUB <algm-LoadIsawUB>`"
        )
        # Goniometer
        self.declareProperty(
            'SetGoniometer', False,
            "Set which Goniometer to use. See :ref:`SetGoniometer <algm-SetGoniometer>`"
        )
        condition = VisibleWhenProperty("SetGoniometer",
                                        PropertyCriterion.IsNotDefault)
        self.copyProperties('SetGoniometer',
                            ['Goniometers', 'Axis0', 'Axis1', 'Axis2'])
        self.setPropertySettings("Goniometers", condition)
        self.setPropertySettings('Axis0', condition)
        self.setPropertySettings('Axis1', condition)
        self.setPropertySettings('Axis2', condition)

        # Corrections
        self.declareProperty(
            FileProperty(name="LoadInstrument",
                         defaultValue="",
                         action=FileAction.OptionalLoad,
                         extensions=[".xml"]),
            "Load a different instrument IDF onto the data from a file. See :ref:`LoadInstrument <algm-LoadInstrument>`"
        )
        self.declareProperty(
            FileProperty(name="DetCal",
                         defaultValue="",
                         action=FileAction.OptionalLoad,
                         extensions=[".detcal"]),
            "Load an ISAW DetCal calibration onto the data from a file. See :ref:`LoadIsawDetCal <algm-LoadIsawDetCal>`"
        )
        self.declareProperty(
            FileProperty(name="MaskFile",
                         defaultValue="",
                         action=FileAction.OptionalLoad,
                         extensions=[".xml", ".msk"]),
            "Masking file for masking. Supported file format is XML and ISIS ASCII. See :ref:`LoadMask <algm-LoadMask>`"
        )

        # SymmetryOps, name, group unmber or list symmetries
        self.declareProperty(
            "SymmetryOps", "",
            "If specified the symmetry will be applied, can be space group name or number, or list individual symmetries."
        )

        # Binning output
        self.copyProperties('ConvertToMD', ['Uproj', 'Vproj', 'Wproj'])
        self.declareProperty(
            FloatArrayProperty("BinningDim0", [-5.05, 5.05, 101],
                               FloatArrayLengthValidator(3),
                               direction=Direction.Input),
            "Binning parameters for the 0th dimension. Enter it as a"
            "comma-separated list of values with the"
            "format: 'minimum,maximum,number_of_bins'.")
        self.declareProperty(
            FloatArrayProperty("BinningDim1", [-5.05, 5.05, 101],
                               FloatArrayLengthValidator(3),
                               direction=Direction.Input),
            "Binning parameters for the 1st dimension. Enter it as a"
            "comma-separated list of values with the"
            "format: 'minimum,maximum,number_of_bins'.")
        self.declareProperty(
            FloatArrayProperty("BinningDim2", [-5.05, 5.05, 101],
                               FloatArrayLengthValidator(3),
                               direction=Direction.Input),
            "Binning parameters for the 2nd dimension. Enter it as a"
            "comma-separated list of values with the"
            "format: 'minimum,maximum,number_of_bins'.")

        self.declareProperty(
            'KeepTemporaryWorkspaces', False,
            "If True the normalization and data workspaces in addition to the normalized data will be outputted"
        )

        self.declareProperty(
            WorkspaceProperty("OutputWorkspace",
                              "",
                              optional=PropertyMode.Mandatory,
                              direction=Direction.Output),
            "Output Workspace. If background is subtracted _data and _background workspaces will also be made."
        )

        # Background
        self.setPropertyGroup("Background", "Background")
        self.setPropertyGroup("BackgroundScale", "Background")

        # Vanadium
        self.setPropertyGroup("SolidAngle", "Vanadium")
        self.setPropertyGroup("Flux", "Vanadium")

        # Goniometer
        self.setPropertyGroup("SetGoniometer", "Goniometer")
        self.setPropertyGroup("Goniometers", "Goniometer")
        self.setPropertyGroup("Axis0", "Goniometer")
        self.setPropertyGroup("Axis1", "Goniometer")
        self.setPropertyGroup("Axis2", "Goniometer")

        # Corrections
        self.setPropertyGroup("LoadInstrument", "Corrections")
        self.setPropertyGroup("DetCal", "Corrections")
        self.setPropertyGroup("MaskFile", "Corrections")

        # Projection and binning
        self.setPropertyGroup("Uproj", "Projection and binning")
        self.setPropertyGroup("Vproj", "Projection and binning")
        self.setPropertyGroup("Wproj", "Projection and binning")
        self.setPropertyGroup("BinningDim0", "Projection and binning")
        self.setPropertyGroup("BinningDim1", "Projection and binning")
        self.setPropertyGroup("BinningDim2", "Projection and binning")
Esempio n. 14
0
    def PyInit(self):
        # files to reduce
        self.declareProperty(
            MultipleFileProperty(name="Filename",
                                 extensions=["_event.nxs", ".nxs.h5", ".nxs"]),
            "Files to combine in reduction")

        # background
        self.declareProperty(
            FileProperty(name="Background",
                         defaultValue="",
                         action=FileAction.OptionalLoad,
                         extensions=["_event.nxs", ".nxs.h5", ".nxs"]),
            "Background run")
        self.declareProperty(
            "BackgroundScale",
            1.0,
            doc=
            "The background will be scaled by this number before being subtracted."
        )

        # Filter by TOF
        self.copyProperties('LoadEventNexus',
                            ['FilterByTofMin', 'FilterByTofMax'])

        # Vanadium SA and flux
        self.declareProperty(
            "ReuseSAFlux", True,
            "If True then if a previous SolidAngle and Flux has been loaded "
            "it will be reused otherwise it will be loaded.")
        self.declareProperty(
            FileProperty(name="SolidAngle",
                         defaultValue="",
                         action=FileAction.Load,
                         extensions=[".nxs"]),
            doc=
            "An input workspace containing momentum integrated vanadium (a measure "
            "of the solid angle). See :ref:`MDNormSCDPreprocessIncoherent <algm-MDNormSCDPreprocessIncoherent>` "
            "for details")
        self.declareProperty(
            FileProperty(name="Flux",
                         defaultValue="",
                         action=FileAction.Load,
                         extensions=[".nxs"]),
            "An input workspace containing momentum dependent flux. See :ref:`MDnormSCD <algm-MDnormSCD>` for details"
        )
        self.declareProperty(
            'MomentumMin',
            Property.EMPTY_DBL,
            doc=
            "Minimum value in momentum. The max of this value and the flux momentum minimum will be used."
        )
        self.declareProperty(
            'MomentumMax',
            Property.EMPTY_DBL,
            doc=
            "Maximum value in momentum. The min of this value and the flux momentum maximum will be used."
        )

        # UBMatrix
        self.declareProperty(
            MultipleFileProperty(name="UBMatrix",
                                 extensions=[".mat", ".ub", ".txt"]),
            doc=
            "Path to an ISAW-style UB matrix text file. See :ref:`LoadIsawUB <algm-LoadIsawUB>`"
        )
        # Goniometer
        self.declareProperty(
            'SetGoniometer', False,
            "Set which Goniometer to use. See :ref:`SetGoniometer <algm-SetGoniometer>`"
        )
        condition = VisibleWhenProperty("SetGoniometer",
                                        PropertyCriterion.IsNotDefault)
        self.copyProperties('SetGoniometer',
                            ['Goniometers', 'Axis0', 'Axis1', 'Axis2'])
        self.setPropertySettings("Goniometers", condition)
        self.setPropertySettings('Axis0', condition)
        self.setPropertySettings('Axis1', condition)
        self.setPropertySettings('Axis2', condition)
        self.declareProperty(
            FloatArrayProperty('OmegaOffset', [], direction=Direction.Input),
            doc=
            "Offset to apply to the omega rotation of the Goniometer. Need to provide one value for every run."
        )

        # Corrections
        self.declareProperty(
            FileProperty(name="LoadInstrument",
                         defaultValue="",
                         action=FileAction.OptionalLoad,
                         extensions=[".xml"]),
            "Load a different instrument IDF onto the data from a file. See :ref:`LoadInstrument <algm-LoadInstrument>`"
        )
        self.declareProperty(
            ITableWorkspaceProperty("ApplyCalibration",
                                    '',
                                    optional=PropertyMode.Optional,
                                    direction=Direction.Input),
            doc='Calibration will be applied using this TableWorkspace using '
            ':ref:`ApplyCalibration <algm-ApplyCalibration>`.')
        self.declareProperty(
            FileProperty(name="DetCal",
                         defaultValue="",
                         action=FileAction.OptionalLoad,
                         extensions=[".detcal"]),
            "Load an ISAW DetCal calibration onto the data from a file. "
            "See :ref:`LoadIsawDetCal <algm-LoadIsawDetCal>`")
        self.declareProperty(
            MatrixWorkspaceProperty("CopyInstrumentParameters",
                                    '',
                                    optional=PropertyMode.Optional,
                                    direction=Direction.Input),
            doc=
            'The input workpsace from which :ref:`CopyInstrumentParameters <algm-CopyInstrumentParameters>` '
            'will copy parameters to data')
        self.declareProperty(
            FileProperty(name="MaskFile",
                         defaultValue="",
                         action=FileAction.OptionalLoad,
                         extensions=[".xml", ".msk"]),
            "Masking file for masking. Supported file format is XML and ISIS ASCII. See :ref:`LoadMask <algm-LoadMask>`"
        )

        self.copyProperties('MDNorm', ['SymmetryOperations'])

        self.declareProperty(
            FloatArrayProperty('QDimension0', [1, 0, 0],
                               FloatArrayLengthValidator(3),
                               direction=Direction.Input),
            "The first Q projection axis")
        self.declareProperty(
            FloatArrayProperty('QDimension1', [0, 1, 0],
                               FloatArrayLengthValidator(3),
                               direction=Direction.Input),
            "The second Q projection axis")
        self.declareProperty(
            FloatArrayProperty('QDimension2', [0, 0, 1],
                               FloatArrayLengthValidator(3),
                               direction=Direction.Input),
            "The third Q projection axis")

        self.copyProperties(
            'MDNorm',
            ['Dimension0Binning', 'Dimension1Binning', 'Dimension2Binning'])

        self.declareProperty(
            'KeepTemporaryWorkspaces', False,
            "If True the normalization and data workspaces in addition to the normalized data will be outputted"
        )

        self.declareProperty(
            WorkspaceProperty("OutputWorkspace",
                              "",
                              optional=PropertyMode.Mandatory,
                              direction=Direction.Output),
            "Output Workspace. If background is subtracted _data and _background workspaces will also be made."
        )

        # Background
        self.setPropertyGroup("Background", "Background")
        self.setPropertyGroup("BackgroundScale", "Background")

        # Vanadium
        self.setPropertyGroup("ReuseSAFlux", "Vanadium")
        self.setPropertyGroup("SolidAngle", "Vanadium")
        self.setPropertyGroup("Flux", "Vanadium")
        self.setPropertyGroup("MomentumMin", "Vanadium")
        self.setPropertyGroup("MomentumMax", "Vanadium")

        # Goniometer
        self.setPropertyGroup("SetGoniometer", "Goniometer")
        self.setPropertyGroup("Goniometers", "Goniometer")
        self.setPropertyGroup("Axis0", "Goniometer")
        self.setPropertyGroup("Axis1", "Goniometer")
        self.setPropertyGroup("Axis2", "Goniometer")
        self.setPropertyGroup("OmegaOffset", "Goniometer")

        # Corrections
        self.setPropertyGroup("LoadInstrument", "Corrections")
        self.setPropertyGroup("ApplyCalibration", "Corrections")
        self.setPropertyGroup("DetCal", "Corrections")
        self.setPropertyGroup("CopyInstrumentParameters", "Corrections")
        self.setPropertyGroup("MaskFile", "Corrections")

        # Projection and binning
        self.setPropertyGroup("QDimension0", "Projection and binning")
        self.setPropertyGroup("QDimension1", "Projection and binning")
        self.setPropertyGroup("QDimension2", "Projection and binning")
        self.setPropertyGroup("Dimension0Binning", "Projection and binning")
        self.setPropertyGroup("Dimension1Binning", "Projection and binning")
        self.setPropertyGroup("Dimension2Binning", "Projection and binning")
    def PyInit(self):
        # Sample options
        self.declareProperty(WorkspaceProperty('SampleWorkspace',
                                               '',
                                               direction=Direction.Input),
                             doc='Sample Workspace')
        self.declareProperty(name='SampleChemicalFormula',
                             defaultValue='',
                             doc='Chemical formula for the sample material')
        self.declareProperty(name='SampleDensityType',
                             defaultValue='Mass Density',
                             validator=StringListValidator(
                                 ['Mass Density', 'Number Density']),
                             doc='Sample density type')
        self.declareProperty(name='SampleDensity',
                             defaultValue=0.0,
                             validator=FloatBoundedValidator(0.0),
                             doc='Sample density')

        self.setPropertyGroup('SampleWorkspace', 'Sample Options')
        self.setPropertyGroup('SampleChemicalFormula', 'Sample Options')
        self.setPropertyGroup('SampleDensityType', 'Sample Options')
        self.setPropertyGroup('SampleDensity', 'Sample Options')

        # Beam Options
        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)')

        self.setPropertyGroup('BeamHeight', 'Beam Options')
        self.setPropertyGroup('BeamWidth', 'Beam Options')

        # 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')

        self.setPropertyGroup('NumberOfWavelengthPoints',
                              'Monte Carlo Options')
        self.setPropertyGroup('EventsPerPoint', 'Monte Carlo Options')
        self.setPropertyGroup('Interpolation', 'Monte Carlo Options')

        # Container options
        self.declareProperty(WorkspaceProperty('ContainerWorkspace',
                                               '',
                                               direction=Direction.Input,
                                               optional=PropertyMode.Optional),
                             doc='Container Workspace')

        container_condition = VisibleWhenProperty(
            'ContainerWorkspace', PropertyCriterion.IsNotDefault)

        self.declareProperty(name='ContainerChemicalFormula',
                             defaultValue='',
                             doc='Chemical formula for the container material')
        self.declareProperty(name='ContainerDensityType',
                             defaultValue='Mass Density',
                             validator=StringListValidator(
                                 ['Mass Density', 'Number Density']),
                             doc='Container density type')
        self.declareProperty(name='ContainerDensity',
                             defaultValue=0.0,
                             validator=FloatBoundedValidator(0.0),
                             doc='Container density')

        self.setPropertyGroup('ContainerWorkspace', 'Container Options')
        self.setPropertyGroup('ContainerChemicalFormula', 'Container Options')
        self.setPropertyGroup('ContainerDensityType', 'Container Options')
        self.setPropertyGroup('ContainerDensity', 'Container Options')

        self.setPropertySettings('ContainerChemicalFormula',
                                 container_condition)
        self.setPropertySettings('ContainerDensityType', container_condition)
        self.setPropertySettings('ContainerDensity', container_condition)

        # Shape options
        self.declareProperty(name='Shape',
                             defaultValue='FlatPlate',
                             validator=StringListValidator(
                                 ['FlatPlate', 'Cylinder', 'Annulus']),
                             doc='Geometric shape of the sample environment')

        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, and should be the same for sample and container
        self.declareProperty('Height',
                             defaultValue=0.0,
                             validator=FloatBoundedValidator(0.0),
                             doc='Height of the sample environment (cm)')

        self.setPropertyGroup('Shape', 'Shape Options')
        self.setPropertyGroup('Height', 'Shape Options')

        # ---------------------------Sample---------------------------
        # Flat Plate
        self.declareProperty(name='SampleWidth',
                             defaultValue=0.0,
                             validator=FloatBoundedValidator(0.0),
                             doc='Width of the sample environment (cm)')
        self.declareProperty(name='SampleThickness',
                             defaultValue=0.0,
                             validator=FloatBoundedValidator(0.0),
                             doc='Thickness of the sample environment (cm)')
        self.declareProperty(name='SampleCenter',
                             defaultValue=0.0,
                             doc='Center of the sample environment')
        self.declareProperty(
            name='SampleAngle',
            defaultValue=0.0,
            validator=FloatBoundedValidator(0.0),
            doc=
            'Angle of the sample environment with respect to the beam (degrees)'
        )

        self.setPropertySettings('SampleWidth', flat_plate_condition)
        self.setPropertySettings('SampleThickness', flat_plate_condition)
        self.setPropertySettings('SampleCenter', flat_plate_condition)
        self.setPropertySettings('SampleAngle', flat_plate_condition)

        self.setPropertyGroup('SampleWidth', 'Sample Shape Options')
        self.setPropertyGroup('SampleThickness', 'Sample Shape Options')
        self.setPropertyGroup('SampleCenter', 'Sample Shape Options')
        self.setPropertyGroup('SampleAngle', 'Sample Shape Options')

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

        self.setPropertySettings('SampleRadius', cylinder_condition)
        self.setPropertyGroup('SampleRadius', 'Sample Shape Options')

        # Annulus
        self.declareProperty(name='SampleInnerRadius',
                             defaultValue=0.0,
                             validator=FloatBoundedValidator(0.0),
                             doc='Inner radius of the sample environment (cm)')
        self.declareProperty(name='SampleOuterRadius',
                             defaultValue=0.0,
                             validator=FloatBoundedValidator(0.0),
                             doc='Outer radius of the sample environment (cm)')

        self.setPropertySettings('SampleInnerRadius', annulus_condition)
        self.setPropertySettings('SampleOuterRadius', annulus_condition)

        self.setPropertyGroup('SampleInnerRadius', 'Sample Shape Options')
        self.setPropertyGroup('SampleOuterRadius', 'Sample Shape Options')

        # ---------------------------Container---------------------------
        # Flat Plate
        self.declareProperty(
            name='ContainerFrontThickness',
            defaultValue=0.0,
            validator=FloatBoundedValidator(0.0),
            doc='Front thickness of the container environment (cm)')
        self.declareProperty(
            name='ContainerBackThickness',
            defaultValue=0.0,
            validator=FloatBoundedValidator(0.0),
            doc='Back thickness of the container environment (cm)')

        container_flat_plate_condition = VisibleWhenProperty(
            container_condition, flat_plate_condition, LogicOperator.And)

        self.setPropertySettings('ContainerFrontThickness',
                                 container_flat_plate_condition)
        self.setPropertySettings('ContainerBackThickness',
                                 container_flat_plate_condition)

        self.setPropertyGroup('ContainerFrontThickness',
                              'Container Shape Options')
        self.setPropertyGroup('ContainerBackThickness',
                              'Container Shape Options')

        # Both cylinder and annulus have an annulus container

        not_flat_plate_condition = VisibleWhenProperty(
            'Shape', PropertyCriterion.IsNotEqualTo, 'FlatPlate')

        container_n_f_p_condition = VisibleWhenProperty(
            container_condition, not_flat_plate_condition, LogicOperator.And)

        self.declareProperty(
            name='ContainerInnerRadius',
            defaultValue=0.0,
            validator=FloatBoundedValidator(0.0),
            doc='Inner radius of the container environment (cm)')
        self.declareProperty(
            name='ContainerOuterRadius',
            defaultValue=0.0,
            validator=FloatBoundedValidator(0.0),
            doc='Outer radius of the container environment (cm)')

        self.setPropertySettings('ContainerInnerRadius',
                                 container_n_f_p_condition)
        self.setPropertySettings('ContainerOuterRadius',
                                 container_n_f_p_condition)

        self.setPropertyGroup('ContainerInnerRadius',
                              'Container Shape Options')
        self.setPropertyGroup('ContainerOuterRadius',
                              'Container Shape Options')

        # output
        self.declareProperty(
            WorkspaceGroupProperty(name='CorrectionsWorkspace',
                                   defaultValue='corrections',
                                   direction=Direction.Output,
                                   optional=PropertyMode.Optional),
            doc='Name of the workspace group to save correction factors')
        self.setPropertyGroup('CorrectionsWorkspace', 'Output Options')
Esempio n. 16
0
    def PyInit(self):
        # files to reduce
        self.declareProperty(
            MultipleFileProperty(name="Filename",
                                 extensions=["_event.nxs", ".nxs.h5", ".nxs"]),
            "Files to combine in reduction")

        # Filter by time
        self.copyProperties(
            'LoadEventNexus',
            ['FilterByTofMin', 'FilterByTofMax', 'FilterByTimeStop'])

        # UBMatrix
        self.declareProperty(
            FileProperty(name="UBMatrix",
                         defaultValue="",
                         action=FileAction.OptionalLoad,
                         extensions=[".mat", ".ub", ".txt"]),
            doc=
            "Path to an ISAW-style UB matrix text file. See :ref:`LoadIsawUB <algm-LoadIsawUB>`"
        )
        # Goniometer
        self.declareProperty(
            'SetGoniometer', False,
            "Set which Goniometer to use. See :ref:`SetGoniometer <algm-SetGoniometer>`"
        )
        condition = VisibleWhenProperty("SetGoniometer",
                                        PropertyCriterion.IsNotDefault)
        self.copyProperties('SetGoniometer',
                            ['Goniometers', 'Axis0', 'Axis1', 'Axis2'])
        self.setPropertySettings("Goniometers", condition)
        self.setPropertySettings('Axis0', condition)
        self.setPropertySettings('Axis1', condition)
        self.setPropertySettings('Axis2', condition)

        # Corrections
        self.declareProperty(
            FileProperty(name="LoadInstrument",
                         defaultValue="",
                         action=FileAction.OptionalLoad,
                         extensions=[".xml"]),
            "Load a different instrument IDF onto the data from a file. See :ref:`LoadInstrument <algm-LoadInstrument>`"
        )
        self.declareProperty(
            FileProperty(name="DetCal",
                         defaultValue="",
                         action=FileAction.OptionalLoad,
                         extensions=[".detcal"]),
            "Load an ISAW DetCal calibration onto the data from a file. See :ref:`LoadIsawDetCal <algm-LoadIsawDetCal>`"
        )
        self.declareProperty(
            FileProperty(name="MaskFile",
                         defaultValue="",
                         action=FileAction.OptionalLoad,
                         extensions=[".xml", ".msk"]),
            "Masking file for masking. Supported file format is XML and ISIS ASCII. See :ref:`LoadMask <algm-LoadMask>`"
        )

        self.declareProperty(
            WorkspaceProperty("OutputWorkspace",
                              "",
                              optional=PropertyMode.Mandatory,
                              direction=Direction.Output), "Output Workspace")

        # Convert Settings
        self.copyProperties('ConvertToMD', [
            'Uproj', 'Vproj', 'Wproj', 'MinValues', 'MaxValues', 'SplitInto',
            'SplitThreshold', 'MaxRecursionDepth', 'OverwriteExisting'
        ])

        self.setPropertyGroup('FilterByTofMin', 'Loading')
        self.setPropertyGroup('FilterByTofMax', 'Loading')
        self.setPropertyGroup('FilterByTimeStop', 'Loading')

        # Goniometer
        self.setPropertyGroup("SetGoniometer", "Goniometer")
        self.setPropertyGroup("Goniometers", "Goniometer")
        self.setPropertyGroup("Axis0", "Goniometer")
        self.setPropertyGroup("Axis1", "Goniometer")
        self.setPropertyGroup("Axis2", "Goniometer")

        # Corrections
        self.setPropertyGroup("LoadInstrument", "Corrections")
        self.setPropertyGroup("DetCal", "Corrections")
        self.setPropertyGroup("MaskFile", "Corrections")

        # ConvertToMD
        self.setPropertyGroup('Uproj', 'ConvertToMD')
        self.setPropertyGroup('Vproj', 'ConvertToMD')
        self.setPropertyGroup('Wproj', 'ConvertToMD')
        self.setPropertyGroup('MinValues', 'ConvertToMD')
        self.setPropertyGroup('MaxValues', 'ConvertToMD')
        self.setPropertyGroup('SplitInto', 'ConvertToMD')
        self.setPropertyGroup('SplitThreshold', 'ConvertToMD')
        self.setPropertyGroup('MaxRecursionDepth', 'ConvertToMD')
    def PyInit(self):
        self.declareProperty(MatrixWorkspaceProperty(
            'ReducedWorkspace', '', direction=Direction.Input),
                             doc='Reduced Workspace')
        self.declareProperty(MatrixWorkspaceProperty(
            'SqwWorkspace', '', direction=Direction.Input),
                             doc='S(Q,w) Workspace')
        self.declareProperty(WorkspaceGroupProperty(
            name='OutputWorkspace',
            defaultValue='MuscatResults',
            direction=Direction.Output,
            optional=PropertyMode.Optional),
                             doc='Name for results workspaces')

        self.declareProperty(name='SampleMassDensity',
                             defaultValue=1.0,
                             validator=FloatBoundedValidator(0.0),
                             doc='Sample mass density. Default=1.0')

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

        self.declareProperty(name='Height',
                             defaultValue=1.0,
                             validator=FloatBoundedValidator(0.0),
                             doc='Height of the sample environment (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')

        # flat plate options

        self.declareProperty(
            name='Width',
            defaultValue=1.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.1,
            validator=FloatBoundedValidator(0.0),
            doc='Thickness of the FlatPlate sample environment (cm)')
        self.setPropertySettings('Thickness', 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='SampleRadius',
                             defaultValue=0.5,
                             validator=FloatBoundedValidator(0.0),
                             doc='Sample radius (cm). Default=0.5')
        self.setPropertySettings('SampleRadius', cylinder_condition)

        # annulus options

        self.declareProperty(name='SampleInnerRadius',
                             defaultValue=0.5,
                             validator=FloatBoundedValidator(0.0),
                             doc='Sample inner radius (cm). Default=0.5')
        self.setPropertySettings('SampleInnerRadius', annulus_condition)

        self.declareProperty(name='SampleOuterRadius',
                             defaultValue=0.6,
                             validator=FloatBoundedValidator(0.0),
                             doc='Sample outer radius (cm). Default=0.6')
        self.setPropertySettings('SampleOuterRadius', annulus_condition)

        # MC options

        self.declareProperty(
            name='NeutronPathsSingle',
            defaultValue=1000,
            validator=IntBoundedValidator(1),
            doc='Number of paths for single scattering. Default=1000')
        self.declareProperty(
            name='NeutronPathsMultiple',
            defaultValue=1000,
            validator=IntBoundedValidator(1),
            doc='Number of paths for multiple scattering. Default=1000')
        self.declareProperty(name='NumberScatterings',
                             defaultValue=1,
                             validator=IntBoundedValidator(1),
                             doc='Number of scatterings. Default=1')
    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='CoherentXSection',
            defaultValue=Property.EMPTY_DBL,
            doc=
            'The coherent cross section of the sample in barns. It can be used instead of the'
            'Chemical Formula.')
        self.setPropertySettings('CoherentXSection', material_defined_prop)

        self.declareProperty(
            name='IncoherentXSection',
            defaultValue=Property.EMPTY_DBL,
            doc=
            'The incoherent cross section of the sample in barns. It can be used instead of the'
            'Chemical Formula.')
        self.setPropertySettings('IncoherentXSection', material_defined_prop)

        self.declareProperty(
            name='AttenuationXSection',
            defaultValue=Property.EMPTY_DBL,
            doc=
            'The absorption cross section of the sample in barns. It can be used instead of the'
            'Chemical Formula.')
        self.setPropertySettings('AttenuationXSection', 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=
            'The value for the Mass density (g/cm^3) or Number density (1/Angstrom^3).'
        )
        self.setPropertySettings('Density', material_defined_prop)

        self.declareProperty(
            name='NumberDensityUnit',
            defaultValue='Atoms',
            validator=StringListValidator(['Atoms', 'Formula Units']),
            doc=
            'Choose which units Density refers to. Allowed values: [Atoms, Formula Units]'
        )
        self.setPropertySettings('NumberDensityUnit', 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')

        self.declareProperty(
            name='MaxScatterPtAttempts',
            defaultValue=5000,
            validator=IntBoundedValidator(0),
            doc='Maximum number of tries made to generate a scattering point')

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

        # 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.')