def PyInit(self):
     """ Declare properties
     """
     val=FloatBoundedValidator()
     val.setBounds(3,100) #reasonable incident nergy range for HYSPEC
     self.declareProperty("IncidentEnergy",0.,val,"Incident energy (3 to 100 meV)")
     self.declareProperty("TibMin",0.,Direction.Output)
     self.declareProperty("TibMax",0.,Direction.Output)
     return
Beispiel #2
0
 def PyInit(self):
     """ Declare properties """
     self.declareProperty(
         WorkspaceProperty("Workspace", "", Direction.Input),
         "Workspace containing MR data")
     self.declareProperty("AngleOffset", 0.,
                          FloatBoundedValidator(lower=0.),
                          "Angle offset (rad)")
     self.declareProperty(
         "UseSANGLE",
         False,
         doc=
         "If True, use SANGLE as the scattering angle. If False, use DANGLE."
     )
     self.declareProperty(
         "SpecularPixel",
         0.,
         doc="Pixel position of the specular reflectivity [optional]")
     self.declareProperty("DirectPixelOverwrite",
                          Property.EMPTY_DBL,
                          doc="DIRPIX overwrite value")
     self.declareProperty("DAngle0Overwrite",
                          Property.EMPTY_DBL,
                          doc="DANGLE0 overwrite value (degrees)")
     self.declareProperty("Theta",
                          0.,
                          direction=Direction.Output,
                          doc="Scattering angle theta (rad)")
     return
Beispiel #3
0
    def PyInit(self):
        # State
        self.declareProperty(
            PropertyManagerProperty('SANSState'),
            doc='A property manager which fulfills the SANSState contract.')

        # Input workspace in TOF
        self.declareProperty(
            MatrixWorkspaceProperty("InputWorkspace",
                                    '',
                                    optional=PropertyMode.Mandatory,
                                    direction=Direction.Input),
            doc='The monitor workspace in time-of-flight units.')

        # A scale factor which could come from event workspace slicing. If the actual data workspace was sliced,
        # then one needs to scale the monitor measurement proportionally. This input is intended for this matter
        self.declareProperty(
            'ScaleFactor',
            defaultValue=1.0,
            direction=Direction.Input,
            validator=FloatBoundedValidator(0.0),
            doc='Optional scale factor for the input workspace.')

        # Output workspace
        self.declareProperty(
            MatrixWorkspaceProperty("OutputWorkspace",
                                    '',
                                    direction=Direction.Output),
            doc='A monitor normalization workspace in units of wavelength.')
Beispiel #4
0
 def PyInit(self):
     self.declareProperty(MultipleFileProperty(name="Filename", action=FileAction.OptionalLoad,
                                               extensions=[".dat"]), "Data files to load")
     condition = EnabledWhenProperty("Filename", PropertyCriterion.IsDefault)
     self.declareProperty('IPTS', Property.EMPTY_INT, "IPTS number to load from")
     self.setPropertySettings("IPTS", condition)
     self.declareProperty('Exp', Property.EMPTY_INT, "Experiment number to load from")
     self.setPropertySettings("Exp", condition)
     self.declareProperty(IntArrayProperty("ScanNumbers", []), 'Scan numbers to load')
     self.setPropertySettings("ScanNumbers", condition)
     self.declareProperty(FileProperty(name="Vanadium", defaultValue="", action=FileAction.OptionalLoad, extensions=[".dat", ".txt"]),
                          doc="Vanadium file, can be either the vanadium scan file or the reduced vcorr file. "
                          "If not provided the vcorr file adjacent to the data file will be used")
     self.declareProperty('Normalise', True, "If False vanadium normalisation will not be performed")
     self.declareProperty(IntArrayProperty("ExcludeDetectors", []),
                          doc="Detectors to exclude. If not provided the HB2A_exp???__exclude_detectors.txt adjacent "
                          "to the data file will be used if it exist")
     self.declareProperty('DefX', '',
                          "By default the def_x (x-axis) from the file will be used, it can be overridden by setting it here")
     self.declareProperty('IndividualDetectors', False,
                          "If True the workspace will include each anode as a separate spectrum, useful for debugging issues")
     condition = EnabledWhenProperty("IndividualDetectors", PropertyCriterion.IsDefault)
     self.declareProperty('BinData', True, "Data will be binned using BinWidth. If False then all data will be unbinned")
     self.setPropertySettings("BinData", condition)
     positiveFloat = FloatBoundedValidator(lower=0., exclusive=True)
     self.declareProperty('BinWidth', 0.05, positiveFloat, "Bin size of the output workspace")
     self.setPropertySettings("BinWidth", condition)
     self.declareProperty('Scale', 1.0, positiveFloat, "The output will be scaled by this value")
     self.declareProperty(WorkspaceProperty("OutputWorkspace", "",
                                            optional=PropertyMode.Mandatory,
                                            direction=Direction.Output),
                          "Output Workspace")
Beispiel #5
0
    def PyInit(self):
        self.declareProperty(MatrixWorkspaceProperty("InputWorkspace", "", Direction.Input),
                             "Workspace with focussed spectra")

        self.declareProperty(MatrixWorkspaceProperty("OutputWorkspace", "", Direction.Output),
                             "Workspace to contain the estimated background (one for each spectrum in the "
                             "InputWorkspace)")

        self.declareProperty(
            name="NIterations",
            defaultValue=40,
            direction=Direction.Input,
            validator=IntBoundedValidator(lower=1),
            doc="Number of iterations of the smoothing procedure to perform. Too few iterations and the background will"
                " be enhanced in the peak regions. Too many iterations and the background will be unrealistically"
                " low and not catch the rising edge at low TOF/d-spacing (typical values are in range 20-100).")

        self.declareProperty(
            name="XWindow",
            defaultValue=1000.0,
            direction=Direction.Input,
            validator=FloatBoundedValidator(lower=0.0),
            doc="Extent of the convolution window in the x-axis for all spectra. A reasonable value is about 4-8 times"
                " the FWHM of a typical peak/feature to be suppressed (default is reasonable for TOF spectra). This is "
                "converted to an odd number of points using the median bin width of each spectra.")

        self.declareProperty('ApplyFilterSG', True, direction=Direction.Input,
                             doc='Apply a Savitzky–Golay filter with a linear polynomial over the same XWindow before'
                                 ' the iterative smoothing procedure (recommended for noisy data)')
Beispiel #6
0
 def PyInit(self):
     """ Declare properties
     """
     self.declareProperty(
         MatrixWorkspaceProperty("VanadiumWorkspace",
                                 "",
                                 direction=Direction.Input,
                                 validator=InstrumentValidator()),
         "Input Vanadium workspace")
     self.declareProperty(
         ITableWorkspaceProperty("EPPTable", "", direction=Direction.Input),
         ("Input EPP table. May be produced by FindEPP " + "algorithm."))
     self.declareProperty(
         MatrixWorkspaceProperty("OutputWorkspace",
                                 "",
                                 direction=Direction.Output),
         ("Name the workspace that will contain the " +
          "calibration coefficients"))
     self.declareProperty("Temperature",
                          defaultValue=Property.EMPTY_DBL,
                          validator=FloatBoundedValidator(lower=0.0),
                          direction=Direction.Input,
                          doc=("Temperature during the experiment (in " +
                               "Kelvins) if the 'temperature' sample log " +
                               "is missing or needs to be overriden."))
     return
    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)
Beispiel #8
0
    def PyInit(self):
        validator = StringArrayLengthValidator()
        validator.setLengthMin(
            2)  # even for workspacegroups at least 2 (SF, NSF) must be given

        self.declareProperty(
            StringArrayProperty(name="VanadiumWorkspaces",
                                direction=Direction.Input,
                                validator=validator),
            doc=
            "Comma separated list of Vanadium workspaces or groups of workspaces."
        )
        self.declareProperty(
            StringArrayProperty(name="BackgroundWorkspaces",
                                direction=Direction.Input,
                                validator=validator),
            doc=
            "Comma separated list of Background workspaces or groups of workspaces."
        )
        self.declareProperty(
            WorkspaceProperty("OutputWorkspace",
                              "",
                              direction=Direction.Output),
            doc=
            "Name of the workspace or group of workspaces that will contain computed coefficients."
        )
        self.declareProperty(
            "TwoThetaTolerance",
            0.05,
            FloatBoundedValidator(lower=0, upper=0.1),
            doc=
            "Tolerance for 2theta comparison (degrees). Number between 0 and 0.1."
        )

        return
Beispiel #9
0
    def PyInit(self):
        validator = StringArrayLengthValidator()
        validator.setLengthMin(1)  # one group may be given
        self.declareProperty(
            StringArrayProperty(name="InputWorkspaces",
                                direction=Direction.Input,
                                validator=validator),
            doc="Comma separated list of workspaces or groups of workspaces.")

        self.declareProperty(
            StringArrayProperty(name="SampleLogs",
                                direction=Direction.Input,
                                validator=validator),
            doc="Comma separated list of sample logs to compare.")
        self.declareProperty("Tolerance",
                             1e-3,
                             validator=FloatBoundedValidator(lower=1e-7,
                                                             upper=1.0),
                             doc="Tolerance for comparison of double values.")
        self.declareProperty(
            "Result", "A string that will be empty if all the logs match, "
            "otherwise will contain a comma separated list of  not matching logs",
            Direction.Output)

        return
    def PyInit(self):
        # Sample options
        self.declareProperty(MatrixWorkspaceProperty('SampleWorkspace', '', direction=Direction.Input),
                             doc='Sample workspace.')
        self.declareProperty(name='SampleChemicalFormula', defaultValue='', validator=StringMandatoryValidator(),
                             doc='Sample chemical formula')
        self.declareProperty(name='SampleDensityType', defaultValue = 'Mass Density',
                             validator=StringListValidator(['Mass Density', 'Number Density']),
                             doc = 'Use of Mass density or Number density')
        self.declareProperty(name='SampleDensity', defaultValue=0.1,
                             doc='Mass density (g/cm^3) or Number density (atoms/Angstrom^3)')
        self.declareProperty(name='SampleRadius', defaultValue=0.1,
                             validator=FloatBoundedValidator(0.0),
                             doc='Sample radius')

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

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

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

        self.declareProperty(WorkspaceGroupProperty('CorrectionsWorkspace', '', direction=Direction.Output,
                                                    optional=PropertyMode.Optional),
                             doc='The corrections workspace for scattering and absorptions in sample.')
Beispiel #11
0
 def PyInit(self):
     """
         Declare properties
     """
     self.declareProperty('DataDistribution', '', direction = Direction.Input,
                          doc='Name of the input workspace or file path')
     self.declareProperty('Background', '', direction = Direction.Input,
                          doc='Name of the background workspace or file path')
     self.declareProperty("ScaleFactor", 1., FloatBoundedValidator(),
                          doc="Scaling factor [Default: 1]")
     self.declareProperty("Constant", 0., FloatBoundedValidator(),
                          doc="Additive constant [Default:0]")
     self.declareProperty(FileProperty("OutputDirectory","", FileAction.OptionalDirectory),
                          doc="Directory to write the output files in [optional]")
     self.declareProperty(MatrixWorkspaceProperty("OutputWorkspace", "", Direction.Output),
                          doc="Workspace containing data from detectors")
     return
 def PyInit(self):
     validators = CompositeValidator()
     validators.add(HistogramValidator(True))
     validators.add(CommonBinsValidator())
     self.declareProperty(
         MatrixWorkspaceProperty(name='InputWorkspace',
                                 defaultValue='',
                                 direction=Direction.Input,
                                 validator=validators),
         doc=
         'Input MatrixWorkspace containing the reduced inelastic neutron spectrum in (Q,E) space.'
     )
     self.declareProperty(name='Temperature',
                          defaultValue=300.,
                          validator=FloatBoundedValidator(lower=0),
                          doc='Sample temperature in Kelvin.')
     self.declareProperty(
         name='MeanSquareDisplacement',
         defaultValue=0.,
         validator=FloatBoundedValidator(lower=0),
         doc='Average mean square displacement in Angstrom^2.')
     self.declareProperty(
         name='QSumRange',
         defaultValue='0,Qmax',
         doc='Range in Q (in Angstroms^-1) to sum data over.')
     self.declareProperty(
         name='EnergyBinning',
         defaultValue='0,Emax/50,Emax*0.9',
         doc='Energy binning parameters [Emin, Estep, Emax] in meV.')
     self.declareProperty(
         name='Wavenumbers',
         defaultValue=False,
         doc='Should the output be in Wavenumbers (cm^-1)?')
     self.declareProperty(
         name='StatesPerEnergy',
         defaultValue=False,
         doc=
         'Should the output be in states per unit energy rather than mb/sr/fu/energy?\n'
         +
         '(Only for pure elements, need to set the sample material information)'
     )
     self.declareProperty(MatrixWorkspaceProperty(
         name='OutputWorkspace',
         defaultValue='',
         direction=Direction.Output),
                          doc='Output workspace name.')
Beispiel #13
0
 def test_construction_with_lower_sets_only_lower(self):
     validator = FloatBoundedValidator()
     lower = 1.4
     validator.setLower(lower)
     self.assertEqual(validator.hasLower(), True)
     self.assertFalse(validator.hasUpper())
     self.assertEqual(validator.lower(), lower)
Beispiel #14
0
 def PyInit(self):
     # Input
     self.declareProperty(
         StringArrayProperty(name="PeakWorkspaces",
                             direction=Direction.Input,
                             validator=ADSValidator()),
         doc='List of peak workspaces to use (must be more than'
         ' two peaks workspaces and each must contain at least 6 peaks.')
     positiveFloatValidator = FloatBoundedValidator(lower=0.0)
     angleValidator = FloatBoundedValidator(lower=0.0, upper=180.0)
     self.declareProperty(name="a",
                          defaultValue=-1.0,
                          direction=Direction.Input,
                          validator=positiveFloatValidator,
                          doc="Lattice parameter a")
     self.declareProperty(name="b",
                          defaultValue=-1.0,
                          direction=Direction.Input,
                          validator=positiveFloatValidator,
                          doc="Lattice parameter b")
     self.declareProperty(name="c",
                          defaultValue=-1.0,
                          direction=Direction.Input,
                          validator=positiveFloatValidator,
                          doc="Lattice parameter c")
     self.declareProperty(name="alpha",
                          defaultValue=-1.0,
                          direction=Direction.Input,
                          validator=angleValidator,
                          doc="Lattice angle alpha")
     self.declareProperty(name="beta",
                          defaultValue=-1.0,
                          direction=Direction.Input,
                          validator=angleValidator,
                          doc="Lattice angle beta")
     self.declareProperty(name="gamma",
                          defaultValue=-1.0,
                          direction=Direction.Input,
                          validator=angleValidator,
                          doc="Lattice angle gamma")
     self.declareProperty(name="Tolerance",
                          defaultValue=0.15,
                          direction=Direction.Input,
                          validator=positiveFloatValidator,
                          doc="Tolerance to index peaks in in H,K and L")
Beispiel #15
0
 def test_construction_with_upper_sets_only_upper(self):
     validator = FloatBoundedValidator()
     upper = 5.4
     validator.setUpper(upper)
     self.assertEqual(validator.hasUpper(), True)
     self.assertEqual(validator.hasLower(), False)
     self.assertEqual(validator.upper(), upper)
Beispiel #16
0
    def PyInit(self):
        inputWorkspaceValidator = CompositeValidator()
        inputWorkspaceValidator.add(InstrumentValidator())
        inputWorkspaceValidator.add(WorkspaceUnitValidator('TOF'))
        positiveFloat = FloatBoundedValidator(lower=0)

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

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

        test_alg = self._create_test_algorithm(validation)

        prop = test_alg.getProperty("Input")
        self.assertNotEquals(prop.isValid, "")

        test_alg.setProperty("Input", 6.8)
        self.assertEqual(prop.isValid, "")

        test_alg.setProperty("Input", 17.3)
        self.assertEqual(prop.isValid, "")

        self.assertRaises(ValueError, test_alg.setProperty, "Input", 3.0)
        self.assertRaises(ValueError, test_alg.setProperty, "Input", 13.0)
        self.assertRaises(ValueError, test_alg.setProperty, "Input", 23.0)
 def PyInit(self):
     """Initialize the input and output properties of the algorithm."""
     positiveFloat = FloatBoundedValidator(lower=0., exclusive=True)
     self.declareProperty(
         MatrixWorkspaceProperty(
             Prop.INPUT_WS,
             defaultValue='',
             direction=Direction.Input,
             validator=WorkspaceUnitValidator('Wavelength')),
         doc='A reflectivity workspace in wavelength to be converted to Q.')
     self.declareProperty(MatrixWorkspaceProperty(
         Prop.OUTPUT_WS, defaultValue='', direction=Direction.Output),
                          doc='The input workspace in momentum transfer.')
     self.declareProperty(Prop.SUBALG_LOGGING,
                          defaultValue=SubalgLogging.OFF,
                          validator=StringListValidator(
                              [SubalgLogging.OFF, SubalgLogging.ON]),
                          doc='Enable or disable child algorithm logging.')
     self.declareProperty(
         Prop.CLEANUP,
         defaultValue=common.WSCleanup.ON,
         validator=StringListValidator(
             [common.WSCleanup.ON, common.WSCleanup.OFF]),
         doc='Enable or disable intermediate workspace cleanup.')
     self.declareProperty(
         MatrixWorkspaceProperty(
             Prop.REFLECTED_WS,
             defaultValue='',
             direction=Direction.Input,
             validator=WorkspaceUnitValidator('Wavelength')),
         doc=
         'A non-summed reflected beam workspace, needed for Q resolution calculation.'
     )
     self.declareProperty(
         MatrixWorkspaceProperty(
             Prop.DIRECT_WS,
             defaultValue='',
             direction=Direction.Input,
             validator=WorkspaceUnitValidator('Wavelength')),
         doc=
         'A non-summed direct beam workspace, needed for Q resolution calculation.'
     )
     self.declareProperty(
         Prop.POLARIZED,
         defaultValue=False,
         doc=
         'True if input workspace has been corrected for polarization efficiencies.'
     )
     self.declareProperty(
         Prop.GROUPING_FRACTION,
         defaultValue=Property.EMPTY_DBL,
         validator=positiveFloat,
         doc=
         'If set, group the output by steps of this fraction multiplied by Q resolution'
     )
Beispiel #21
0
    def PyInit(self):
        # Sample
        self.declareProperty(MatrixWorkspaceProperty('SampleWorkspace', '', direction=Direction.Input),
                             doc='Sample workspace')
        self.declareProperty(name='SampleChemicalFormula', defaultValue='',
                             validator=StringMandatoryValidator(),
                             doc='Chemical formula for the sample')
        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='SampleHeight', defaultValue=1.0,
                             validator=FloatBoundedValidator(0.0),
                             doc='Sample height')
        self.declareProperty(name='SampleWidth', defaultValue=1.0,
                             validator=FloatBoundedValidator(0.0),
                             doc='Sample width')
        self.declareProperty(name='SampleThickness', defaultValue=0.5,
                             validator=FloatBoundedValidator(0.0),
                             doc='Sample thickness')

        # Container
        self.declareProperty(MatrixWorkspaceProperty('CanWorkspace', '', optional=PropertyMode.Optional,
                                                     direction=Direction.Input),
                             doc='Container workspace')
        self.declareProperty(name='UseCanCorrections', defaultValue=False,
                             doc='Use can corrections in subtraction')
        self.declareProperty(name='CanChemicalFormula', defaultValue='',
                             doc='Chemical formula for the Container')
        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.1,
                             validator=FloatBoundedValidator(0.0),
                             doc='Can front thickness')
        self.declareProperty(name='CanBackThickness', defaultValue=0.1,
                             validator=FloatBoundedValidator(0.0),
                             doc='Can back thickness')
        self.declareProperty(name='CanScaleFactor', defaultValue=1.0,
                             validator=FloatBoundedValidator(0.0),
                             doc='Scale factor to multiply can data')

        # General
        self.declareProperty(name='ElementSize', defaultValue=0.1,
                             validator=FloatBoundedValidator(0.0),
                             doc='Element size in mm')

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

        self.declareProperty(WorkspaceGroupProperty('CorrectionsWorkspace', '', direction=Direction.Output,
                                                    optional=PropertyMode.Optional),
                             doc='The workspace group to save correction factors')
Beispiel #22
0
 def PyInit(self):
     self.declareProperty(name='DSpacing',
                          defaultValue=2.8589,
                          validator=FloatBoundedValidator(lower=2, upper=2.95),
                          doc="Position of (111) reflection in dSpacing",
                          direction=Direction.Input)
     self.declareProperty(name='T',
                          defaultValue=300.0,
                          validator=FloatBoundedValidator(lower=100),
                          doc="Sample temperature in K",
                          direction=Direction.Input)
     self.declareProperty(name='TargetPressure',
                          defaultValue=0.0,
                          validator=FloatBoundedValidator(lower=0),
                          doc="Optional: search for (111) position for a given pressure (GPa) and temperature, "
                              "leave at default value to disable.")
     self.declareProperty(ITableWorkspaceProperty(name='OutputWorkspace',
                                                  direction=Direction.Output,
                                                  defaultValue='LeadPressureCalcResults'),
                          doc='Name of Output Table workspace holding the values')
Beispiel #23
0
    def PyInit(self):

        self.declareProperty(MatrixWorkspaceProperty(
            "InputWorkspace", '', direction=Direction.Input),
                             doc='The main input workspace.')

        self.declareProperty(MatrixWorkspaceProperty(
            "CalibrationWorkspace",
            '',
            optional=PropertyMode.Optional,
            direction=Direction.Input),
                             doc='The calibration (vandiaum) workspace.')

        self.declareProperty(MatrixWorkspaceProperty(
            "BackgroundWorkspace",
            '',
            optional=PropertyMode.Optional,
            direction=Direction.Input),
                             doc='The background workspace to be subtracted.')

        self.declareProperty(
            "BackgroundScale",
            1.0,
            validator=FloatBoundedValidator(0.0),
            doc=
            "The background will be scaled by this number before being subtracted."
        )

        self.declareProperty(
            MaskWorkspaceProperty("MaskWorkspace",
                                  '',
                                  optional=PropertyMode.Optional,
                                  direction=Direction.Input),
            doc='The mask from this workspace will be applied before reduction'
        )

        self.copyProperties('ConvertSpectrumAxis', ['Target', 'EFixed'])

        self.copyProperties('ResampleX',
                            ['XMin', 'XMax', 'NumberBins', 'LogBinning'])

        self.declareProperty('NormaliseBy', 'Monitor',
                             StringListValidator(['None', 'Time', 'Monitor']),
                             "Normalise to monitor or time. ")

        self.declareProperty(
            'MaskAngle', Property.EMPTY_DBL,
            "Phi angle above which will be masked. See :ref:`MaskAngle <algm-MaskAngle>` for details."
        )

        self.declareProperty(MatrixWorkspaceProperty(
            "OutputWorkspace", "", direction=Direction.Output),
                             doc="Output Workspace")
Beispiel #24
0
    def PyInit(self):
        self.declareProperty(
            WorkspaceProperty(name='InputWorkspace', defaultValue='', direction=Direction.Input),
            'Workspace with peaks to be identified')
        self.declareProperty(
            ITableWorkspaceProperty(name='PeakGuessTable',
                                    defaultValue='peak_guess',
                                    direction=Direction.Input),
            'Table containing the guess for the peak position')
        self.declareProperty('CentreTolerance',
                             1.0,
                             doc='Tolerance value used in looking for peak centre',
                             validator=FloatBoundedValidator(lower=0.0))
        self.declareProperty('EstimatedPeakSigma',
                             3.0,
                             doc='Estimate of the peak half width',
                             validator=FloatBoundedValidator(lower=0.0))
        self.declareProperty('MinPeakSigma',
                             0.1,
                             doc='Minimum value for the standard deviation of a peak',
                             validator=FloatBoundedValidator(lower=0.0))
        self.declareProperty('MaxPeakSigma',
                             30.0,
                             doc='Maximum value for the standard deviation of a peak',
                             validator=FloatBoundedValidator(lower=0.0))
        self.declareProperty('EstimateFitWindow',
                             True,
                             doc='If checked, algorithm attempts to calculate number of data points to use from'
                                 ' EstimatePeakSigma, if unchecked algorithm will use FitWindowSize argument')
        self.declareProperty('FitWindowSize',
                             5,
                             doc='Number of data point used to fit peaks, minimum allowed value is 5, '
                                 'value must be an odd number ',
                             validator=IntBoundedValidator(lower=5))
        self.declareProperty('GeneralFitTolerance',
                             0.1,
                             doc='Tolerance for the constraint in the general fit',
                             validator=FloatBoundedValidator(lower=0.0))
        self.declareProperty('RefitTolerance',
                             0.001,
                             doc='Tolerance for the constraint in the refitting',
                             validator=FloatBoundedValidator(lower=0.0))

        # Output table
        self.declareProperty(
            ITableWorkspaceProperty(name='PeakProperties',
                                    defaultValue='peak_table',
                                    direction=Direction.Output),
            'Table containing the properties of the peaks')
        self.declareProperty(
            ITableWorkspaceProperty(name='RefitPeakProperties',
                                    defaultValue='refit_peak_table',
                                    direction=Direction.Output),
            'Table containing the properties of the peaks that had to be fitted twice as the first'
            'time the error was unreasonably large')
        self.declareProperty(
            ITableWorkspaceProperty(name='FitCost',
                                    defaultValue='fit_cost',
                                    direction=Direction.Output),
            'Table containing the value of both chi2 and poisson cost functions for the fit')
Beispiel #25
0
 def test_construction_with_upper_sets_only_upper(self):
     validator = FloatBoundedValidator()
     upper = 5.4
     validator.setUpper(upper)
     self.assertEquals(validator.hasUpper(), True)
     self.assertEquals(validator.hasLower(), False)
     self.assertEquals(validator.upper(), upper)
Beispiel #26
0
 def test_construction_with_lower_sets_only_lower(self):
     validator = FloatBoundedValidator()
     lower = 1.4
     validator.setLower(lower)
     self.assertEquals(validator.hasLower(), True)
     self.assertFalse(validator.hasUpper())
     self.assertEquals(validator.lower(), lower)
    def PyInit(self):

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

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

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

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

        thetaRangeValidator = FloatArrayOrderedPairsValidator()

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

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

        self.declareProperty(name='Observable',
                             defaultValue='sample.temperature',
                             doc='Scanning observable, a Sample Log entry.')

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

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

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

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

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

        self.declareProperty(MatrixWorkspaceProperty('OutputWorkspace', '',
                                                     direction=Direction.Output),
                             doc='Output workspace containing the reduced data.')
 def invalid_init(self, input_case):
     if input_case == "String List":
         self.declareAttribute("StringAtt", "error",
                               StringListValidator(["filename", "test"]))
     elif input_case == "Float Bounded":
         self.declareAttribute("FloatAtt", 10.0,
                               FloatBoundedValidator(0.0, 5.0))
     elif input_case == "Array Bounded":
         self.declareAttribute("ListAtt", [1.0, 2.0, 3.0, 10.0],
                               FloatArrayBoundedValidator(0.0, 5.0))
     elif input_case == "String Contains":
         self.declareAttribute("StringContainsAtt", "error",
                               StringContainsValidator(["Contains"]))
Beispiel #29
0
    def PyInit(self):
        self.declareProperty(
            WorkspaceProperty(name='InputWorkspace',
                              defaultValue='',
                              direction=Direction.Input),
            'Workspace with peaks to be identified')
        self.declareProperty(
            ITableWorkspaceProperty(name='PeakGuessTable',
                                    defaultValue='peak_guess',
                                    direction=Direction.Input),
            'Table containing the guess for the peak position')
        self.declareProperty(
            'CentreTolerance',
            1.0,
            doc='Tolerance value used in looking for peak centre',
            validator=FloatBoundedValidator(lower=0.0))
        self.declareProperty('EstimatedPeakSigma',
                             3.0,
                             doc='Estimate of the peak half width',
                             validator=FloatBoundedValidator(lower=0.0))
        self.declareProperty(
            'MinPeakSigma',
            0.1,
            doc='Minimum value for the standard deviation of a peak',
            validator=FloatBoundedValidator(lower=0.0))
        self.declareProperty(
            'MaxPeakSigma',
            30.0,
            doc='Maximum value for the standard deviation of a peak',
            validator=FloatBoundedValidator(lower=0.0))
        self.declareProperty(
            'GeneralFitTolerance',
            0.1,
            doc='Tolerance for the constraint in the general fit',
            validator=FloatBoundedValidator(lower=0.0))
        self.declareProperty(
            'RefitTolerance',
            0.001,
            doc='Tolerance for the constraint in the refitting',
            validator=FloatBoundedValidator(lower=0.0))

        # Output table
        self.declareProperty(
            ITableWorkspaceProperty(name='PeakProperties',
                                    defaultValue='peak_table',
                                    direction=Direction.Output),
            'Table containing the properties of the peaks')
        self.declareProperty(
            ITableWorkspaceProperty(name='RefitPeakProperties',
                                    defaultValue='refit_peak_table',
                                    direction=Direction.Output),
            'Table containing the properties of the peaks that had to be fitted twice as the first'
            'time the error was unreasonably large')
        self.declareProperty(
            ITableWorkspaceProperty(name='FitCost',
                                    defaultValue='fit_cost',
                                    direction=Direction.Output),
            'Table containing the value of both chi2 and poisson cost functions for the fit'
        )
Beispiel #30
0
    def PyInit(self):
        """Initialize the algorithm's input and output properties."""
        inputWorkspaceValidator = CompositeValidator()
        inputWorkspaceValidator.add(InstrumentValidator())
        inputWorkspaceValidator.add(WorkspaceUnitValidator('TOF'))
        scalingFactor = FloatBoundedValidator(lower=0, upper=1)

        # Properties.
        self.declareProperty(MatrixWorkspaceProperty(
            name=common.PROP_INPUT_WS,
            defaultValue='',
            validator=inputWorkspaceValidator,
            direction=Direction.Input),
                             doc='Input workspace.')
        self.declareProperty(WorkspaceProperty(name=common.PROP_OUTPUT_WS,
                                               defaultValue='',
                                               direction=Direction.Output),
                             doc='The output of the algorithm.')
        self.declareProperty(name=common.PROP_CLEANUP_MODE,
                             defaultValue=common.CLEANUP_ON,
                             validator=StringListValidator(
                                 [common.CLEANUP_ON, common.CLEANUP_OFF]),
                             direction=Direction.Input,
                             doc='What to do with intermediate workspaces.')
        self.declareProperty(
            name=common.PROP_SUBALG_LOGGING,
            defaultValue=common.SUBALG_LOGGING_OFF,
            validator=StringListValidator(
                [common.SUBALG_LOGGING_OFF, common.SUBALG_LOGGING_ON]),
            direction=Direction.Input,
            doc='Enable or disable subalgorithms to ' + 'print in the logs.')
        self.declareProperty(MatrixWorkspaceProperty(
            name=common.PROP_EC_WS,
            defaultValue='',
            validator=inputWorkspaceValidator,
            direction=Direction.Input,
            optional=PropertyMode.Optional),
                             doc='Reduced empty container workspace.')
        self.declareProperty(name=common.PROP_EC_SCALING,
                             defaultValue=1.0,
                             validator=scalingFactor,
                             direction=Direction.Input,
                             doc='Scaling factor (transmission, if no self ' +
                             'shielding is applied) for empty container.')
        self.declareProperty(
            MatrixWorkspaceProperty(
                name=common.PROP_SELF_SHIELDING_CORRECTION_WS,
                defaultValue='',
                direction=Direction.Input,
                optional=PropertyMode.Optional),
            doc='A workspace containing self shielding correction factors.')
    def PyInit(self):
        # Sample options
        self.declareProperty(MatrixWorkspaceProperty('SampleWorkspace', '', direction=Direction.Input),
                             doc='Sample workspace.')

        self.declareProperty(name='SampleChemicalFormula', defaultValue='',
                             validator=StringMandatoryValidator(),
                             doc='Chemical formula for the sample')
        self.declareProperty(name='SampleNumberDensity', defaultValue=0.1,
                             validator=FloatBoundedValidator(0.0),
                             doc='Sample number density')
        self.declareProperty(name='SampleInnerRadius', defaultValue=0.2,
                             validator=FloatBoundedValidator(0.0),
                             doc='Sample radius')
        self.declareProperty(name='SampleOuterRadius', defaultValue=0.25,
                             validator=FloatBoundedValidator(0.0),
                             doc='Sample radius')

        # Container options
        self.declareProperty(MatrixWorkspaceProperty('CanWorkspace', '', optional=PropertyMode.Optional,
                                                     direction=Direction.Input),
                             doc='Container workspace.')
        self.declareProperty(name='UseCanCorrections', defaultValue=False,
                             doc='Use can corrections in subtraction')
        self.declareProperty(name='CanChemicalFormula', defaultValue='',
                             doc='Chemical formula for the can')
        self.declareProperty(name='CanNumberDensity', defaultValue=0.1,
                             validator=FloatBoundedValidator(0.0),
                             doc='Can number density')
        self.declareProperty(name='CanInnerRadius', defaultValue=0.19,
                             validator=FloatBoundedValidator(0.0),
                             doc='Sample radius')
        self.declareProperty(name='CanOuterRadius', defaultValue=0.26,
                             validator=FloatBoundedValidator(0.0),
                             doc='Sample radius')
        self.declareProperty(name='CanScaleFactor', defaultValue=1.0,
                             validator=FloatBoundedValidator(0.0),
                             doc='Scale factor to multiply can data')

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

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

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

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

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

        self.declareProperty(MatrixWorkspaceProperty(
            'OutputWorkspace', defaultValue='', direction=Direction.Output),
                             doc='The output workspace')
Beispiel #33
0
    def PyInit(self):
        validator = CompositeValidator()
        validator.add(WorkspaceUnitValidator('Wavelength'))
        validator.add(HistogramValidator())
        validator.add(InstrumentValidator())

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

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

        self.declareProperty(MatrixWorkspaceProperty('OutputWorkspace',
                                                     defaultValue='',
                                                     direction = Direction.Output),
                             doc='The output workspace')
 def PyInit(self):
     """Initialize the input and output properties of the algorithm."""
     positiveFloat = FloatBoundedValidator(lower=0., exclusive=True)
     self.declareProperty(
         MatrixWorkspaceProperty(
             Prop.INPUT_WS,
             defaultValue='',
             direction=Direction.Input,
             validator=WorkspaceUnitValidator('Wavelength')),
         doc='A reflectivity workspace in wavelength to be converted to Q.')
     self.declareProperty(
         MatrixWorkspaceProperty(
             Prop.OUTPUT_WS,
             defaultValue='',
             direction=Direction.Output),
         doc='The input workspace in momentum transfer.')
     self.declareProperty(
         Prop.SUBALG_LOGGING,
         defaultValue=SubalgLogging.OFF,
         validator=StringListValidator([SubalgLogging.OFF, SubalgLogging.ON]),
         doc='Enable or disable child algorithm logging.')
     self.declareProperty(
         Prop.CLEANUP,
         defaultValue=utils.Cleanup.ON,
         validator=StringListValidator([utils.Cleanup.ON, utils.Cleanup.OFF]),
         doc='Enable or disable intermediate workspace cleanup.')
     self.declareProperty(
         MatrixWorkspaceProperty(
             Prop.DIRECT_FOREGROUND_WS,
             defaultValue='',
             direction=Direction.Input,
             validator=WorkspaceUnitValidator('Wavelength')),
         doc='Summed direct beam workspace.')
     self.declareProperty(
         Prop.GROUPING_FRACTION,
         defaultValue=Property.EMPTY_DBL,
         validator=positiveFloat,
         doc='If set, group the output by steps of this fraction multiplied by Q resolution')
Beispiel #35
0
 def test_upper_only_keyword_in_constructor(self):
     validator = FloatBoundedValidator(upper=5.5)
     self.assertFalse(validator.hasLower())
     self.assertTrue(validator.hasUpper())
     self.assertEquals(validator.upper(), 5.5)