def PyInit(self):
        ws_validator = InstrumentValidator()

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

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

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

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

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

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

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

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

        self.declareProperty(name='SampleInnerRadius',
                             defaultValue=0.05,
                             validator=FloatBoundedValidator(0.0),
                             doc='Sample inner radius')

        self.declareProperty(name='SampleOuterRadius',
                             defaultValue=0.1,
                             validator=FloatBoundedValidator(0.0),
                             doc='Sample outer radius')

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

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

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

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

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

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

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

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

        self.declareProperty(name='CanOuterRadius',
                             defaultValue=0.15,
                             validator=FloatBoundedValidator(0.0),
                             doc='Can outer radius')

        self.declareProperty(name='BeamHeight',
                             defaultValue=3.0,
                             validator=FloatBoundedValidator(0.0),
                             doc='Beam height')

        self.declareProperty(name='BeamWidth',
                             defaultValue=2.0,
                             validator=FloatBoundedValidator(0.0),
                             doc='Beam width')

        self.declareProperty(name='StepSize',
                             defaultValue=0.002,
                             validator=FloatBoundedValidator(0.0),
                             doc='Step size')

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

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

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

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

        self.declareProperty(WorkspaceGroupProperty(
            'OutputWorkspace', '', direction=Direction.Output),
                             doc='The output corrections workspace group')
Beispiel #2
0
    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')

        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.')
Beispiel #3
0
    def PyInit(self):

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        self.copyProperties('SANSILLReduction', ['NormaliseBy'], version=1)

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

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

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

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

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

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

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

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

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

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

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

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

        self.copyProperties('SANSILLReduction', 'Wavelength', 1)
    def PyInit(self):

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

        self.declareProperty(
            name='NormaliseTo',
            defaultValue='Monitor',
            validator=StringListValidator(['None', 'Monitor']),
            doc='Normalise to monitor, or skip normalisation.')

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

        self.declareProperty(
            name='UseCalibratedData',
            defaultValue=True,
            doc='Whether or not to use the calibrated data in the NeXus files.'
        )

        self.declareProperty(
            name='Output2DTubes',
            defaultValue=False,
            doc=
            'Output a 2D workspace of height along tube against tube scattering angle.'
        )

        self.declareProperty(
            name='Output2D',
            defaultValue=False,
            doc=
            'Output a 2D workspace of height along tube against the real scattering angle.'
        )

        self.declareProperty(
            name='Output1D',
            defaultValue=True,
            doc='Output a 1D workspace with counts against scattering angle.')

        self.declareProperty(
            name='CropNegativeScatteringAngles',
            defaultValue=True,
            doc='Whether or not to crop the negative scattering angles.')

        self.declareProperty(
            FloatArrayProperty(name='HeightRange',
                               values=[],
                               validator=CompositeValidator([
                                   FloatArrayOrderedPairsValidator(),
                                   FloatArrayLengthValidator(0, 2)
                               ])),
            doc=
            'A pair of values, comma separated, to give the minimum and maximum height range (in m). If not specified '
            'the full height range is used.')

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

        self.declareProperty(
            name='InitialMask',
            defaultValue=20,
            validator=IntBoundedValidator(lower=0, upper=64),
            doc=
            'Number of pixels to mask from the bottom and the top of each tube before superposition.'
        )

        self.declareProperty(
            name='FinalMask',
            defaultValue=30,
            validator=IntBoundedValidator(lower=0, upper=70),
            doc=
            'Number of spectra to mask from the bottom and the top of the result of 2D options.'
        )

        self.declareProperty(
            name='ComponentsToMask',
            defaultValue='',
            doc=
            'Comma separated list of component names to mask, for instance: tube_1, tube_2'
        )

        self.declareProperty(
            name='ComponentsToReduce',
            defaultValue='',
            doc=
            'Comma separated list of component names to output the reduced data for; for example tube_1'
        )

        self.declareProperty(
            name='AlignTubes',
            defaultValue=True,
            doc='Align the tubes vertically and horizontally according to IPF.'
        )
    def PyInit(self):
        """Initialize the algorithm's input and output properties."""
        PROPGROUP_FLAT_BKG = 'Flat Time-Independent Background'
        PROPGROUP_INCIDENT_ENERGY_CALIBRATION = 'Indicent Energy Calibration'
        PROPGROUP_MON_NORMALISATION = 'Neutron Flux Normalisation'
        # Validators.
        mandatoryPositiveInt = CompositeValidator()
        mandatoryPositiveInt.add(IntMandatoryValidator())
        mandatoryPositiveInt.add(IntBoundedValidator(lower=0))
        positiveFloat = FloatBoundedValidator(lower=0)
        positiveInt = IntBoundedValidator(lower=0)
        inputWorkspaceValidator = CompositeValidator()
        inputWorkspaceValidator.add(InstrumentValidator())
        inputWorkspaceValidator.add(WorkspaceUnitValidator('TOF'))

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        lambda_range_validator = CompositeValidator()
        lambda_range_validator.add(FloatArrayOrderedPairsValidator())
        lambda_range_validator.add(FloatArrayLengthValidator(2))
        self.declareProperty(
            FloatArrayProperty('WavelengthRange', [1., 10.],
                               validator=lambda_range_validator),
            doc=
            'Wavelength range [Angstrom] to be used in integration (TOF only).'
        )
Beispiel #7
0
    def PyInit(self):
        self.declareProperty(MatrixWorkspaceProperty(
            'SampleWorkspace',
            '',
            optional=PropertyMode.Mandatory,
            direction=Direction.Input),
                             doc="Name for the sample workspace.")

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

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

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

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

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

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

        self.declareProperty(name='DryRun',
                             defaultValue=False,
                             doc='Only calculate and output the parameters')
        self.declareProperty('CalculateErrors',
                             defaultValue=True,
                             doc="Calculate monte-carlo errors.")
    def PyInit(self):
        ws_validator = InstrumentValidator()

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        self.declareProperty(WorkspaceGroupProperty(
            'OutputWorkspace', '', direction=Direction.Output),
                             doc='The output corrections workspace group')
    def PyInit(self):
        self.declareProperty(MultipleFileProperty('CalibrationRun', action=FileAction.Load, extensions=['nxs']),
                             doc='File path of calibration runs (numors). Must be detector scans.')

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

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

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

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

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

        thetaRangeValidator = FloatArrayOrderedPairsValidator()

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

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

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

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

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

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

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

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

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

        self.declareProperty(FloatArrayProperty(name='MaskCriterion', values=[], validator=maskCriterionValidator),
                             doc='Efficiency constants outside this range will be set to zero.')
Beispiel #10
0
    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.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='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')
Beispiel #11
0
    def PyInit(self):
        """Initialize the algorithm's input and output properties."""
        PROPGROUP_SIMULATION_INSTRUMENT = 'Simulation Instrument Settings'
        greaterThanOneInt = IntBoundedValidator(lower=2)
        greaterThanTwoInt = IntBoundedValidator(lower=3)
        inputWorkspaceValidator = CompositeValidator()
        inputWorkspaceValidator.add(InstrumentValidator())
        inputWorkspaceValidator.add(WorkspaceUnitValidator('TOF'))

        # Properties.
        self.declareProperty(MatrixWorkspaceProperty(
            name=common.PROP_INPUT_WS,
            defaultValue='',
            validator=inputWorkspaceValidator,
            optional=PropertyMode.Optional,
            direction=Direction.Input),
                             doc='Input workspace.')
        self.declareProperty(MatrixWorkspaceProperty(
            name=common.PROP_OUTPUT_WS,
            defaultValue='',
            direction=Direction.Output),
                             doc='The output corrections workspace.')
        self.declareProperty(name=common.PROP_CLEANUP_MODE,
                             defaultValue=common.CLEANUP_ON,
                             validator=StringListValidator(
                                 [common.CLEANUP_ON, common.CLEANUP_OFF]),
                             direction=Direction.Input,
                             doc='What to do with intermediate workspaces.')
        self.declareProperty(
            name=common.PROP_SUBALG_LOGGING,
            defaultValue=common.SUBALG_LOGGING_OFF,
            validator=StringListValidator(
                [common.SUBALG_LOGGING_OFF, common.SUBALG_LOGGING_ON]),
            direction=Direction.Input,
            doc='Enable or disable subalgorithms to ' + 'print in the logs.')
        self.declareProperty(
            name=common.PROP_SIMULATION_INSTRUMENT,
            defaultValue=common.SIMULATION_INSTRUMEN_SPARSE,
            validator=StringListValidator([
                common.SIMULATION_INSTRUMEN_SPARSE,
                common.SIMULATION_INSTRUMENT_FULL
            ]),
            direction=Direction.Input,
            doc=
            'Select if the simulation should be performed on full or approximated instrument.'
        )
        self.setPropertyGroup(common.PROP_SIMULATION_INSTRUMENT,
                              PROPGROUP_SIMULATION_INSTRUMENT)
        self.declareProperty(
            name=common.PROP_SPARSE_INSTRUMENT_ROWS,
            defaultValue=5,
            validator=greaterThanTwoInt,
            direction=Direction.Input,
            doc='Number of detector rows in sparse simulation instrument.')
        self.setPropertyGroup(common.PROP_SPARSE_INSTRUMENT_ROWS,
                              PROPGROUP_SIMULATION_INSTRUMENT)
        self.setPropertySettings(
            common.PROP_SPARSE_INSTRUMENT_ROWS,
            EnabledWhenProperty(common.PROP_SIMULATION_INSTRUMENT,
                                PropertyCriterion.IsEqualTo,
                                common.SIMULATION_INSTRUMEN_SPARSE))
        self.declareProperty(
            name=common.PROP_SPARSE_INSTRUMENT_COLUMNS,
            defaultValue=20,
            validator=greaterThanOneInt,
            direction=Direction.Input,
            doc='Number of detector columns in sparse simulation instrument.')
        self.setPropertyGroup(common.PROP_SPARSE_INSTRUMENT_COLUMNS,
                              PROPGROUP_SIMULATION_INSTRUMENT)
        self.setPropertySettings(
            common.PROP_SPARSE_INSTRUMENT_COLUMNS,
            EnabledWhenProperty(common.PROP_SIMULATION_INSTRUMENT,
                                PropertyCriterion.IsEqualTo,
                                common.SIMULATION_INSTRUMEN_SPARSE))
        self.declareProperty(
            name=common.PROP_NUMBER_OF_SIMULATION_WAVELENGTHS,
            defaultValue=Property.EMPTY_INT,
            validator=greaterThanTwoInt,
            direction=Direction.Input,
            doc=
            'Number of wavelength points where the simulation is performed (default: all).'
        )
    def PyInit(self):
        ws_validator = InstrumentValidator()

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

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

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

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

        self.declareProperty(name='SampleInnerRadius',
                             defaultValue=0.05,
                             validator=FloatBoundedValidator(0.0),
                             doc='Sample inner radius')

        self.declareProperty(name='SampleOuterRadius',
                             defaultValue=0.1,
                             validator=FloatBoundedValidator(0.0),
                             doc='Sample outer radius')

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

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

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

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

        self.declareProperty(name='CanOuterRadius',
                             defaultValue=0.15,
                             validator=FloatBoundedValidator(0.0),
                             doc='Can outer radius')

        self.declareProperty(name='BeamHeight',
                             defaultValue=3.0,
                             validator=FloatBoundedValidator(0.0),
                             doc='Beam height')

        self.declareProperty(name='BeamWidth',
                             defaultValue=2.0,
                             validator=FloatBoundedValidator(0.0),
                             doc='Beam width')

        self.declareProperty(name='StepSize',
                             defaultValue=0.002,
                             validator=FloatBoundedValidator(0.0),
                             doc='Step size')

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

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

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

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

        self.declareProperty(WorkspaceGroupProperty(
            'OutputWorkspace', '', direction=Direction.Output),
                             doc='The output corrections workspace group')
Beispiel #13
0
    def PyInit(self):
        self.declareProperty(MatrixWorkspaceProperty('InputWorkspace', '', direction=Direction.Input,
                             validator=WorkspaceUnitValidator('Wavelength')),
                             doc='The input workspace.')

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        self.declareProperty(name='BinMaskingCriteria', defaultValue='',
                             doc='Criteria to mask bins, used for TOF mode,'
                                 ' for example to discard high and low lambda ranges;'
                                 'see MaskBinsIf algorithm for details.')

        self.declareProperty(WorkspaceGroupProperty('PanelOutputWorkspaces', '',
                                                    direction=Direction.Output,
                                                    optional=PropertyMode.Optional),
                             doc='The name of the output workspace group for detector panels (D33).')
        self.setPropertyGroup('PanelOutputWorkspaces', 'I(Q) Options')