Example #1
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")
 def PyInit(self):
     self.declareProperty(StringArrayProperty('InputWorkspaces', direction=Direction.Input, validator=ADSValidator()),
                          doc='List of workspaces or group workspace containing workspaces to be merged.')
     self.declareProperty(WorkspaceProperty('OutputWorkspace', '', direction=Direction.Output),
                          doc='The merged workspace.')
     self.declareProperty(FloatArrayProperty('XMin', [], direction=Direction.Input),
                          doc='Array of minimum X values for each workspace.')
     self.declareProperty(FloatArrayProperty('XMax', [], direction=Direction.Input),
                          doc='Array of maximum X values for each workspace.')
     self.declareProperty('CalculateScale', True,
                          doc='Calculate scale factor when matching spectra.')
     self.declareProperty('CalculateOffset', True,
                          doc='Calculate vertical shift when matching spectra.')
Example #3
0
    def PyInit(self):
        self.declareProperty(StringArrayProperty('InputWorkspace', direction=Direction.Input, validator=ADSValidator()),
                             doc="Input MD workspace (in Q-space) to use for peak finding")
        cell_type = StringListValidator()
        cell_type.addAllowedValue("Cubic")
        cell_type.addAllowedValue("Hexagonal")
        cell_type.addAllowedValue("Rhombohedral")
        cell_type.addAllowedValue("Tetragonal")
        cell_type.addAllowedValue("Orthorhombic")
        cell_type.addAllowedValue("Monoclinic")
        cell_type.addAllowedValue("Triclinic")
        self.declareProperty("CellType", "", cell_type, doc="Cell type to use for UB refining")

        centering_type = StringListValidator()
        centering_type.addAllowedValue("F")
        centering_type.addAllowedValue("I")
        centering_type.addAllowedValue("C")
        centering_type.addAllowedValue("P")
        centering_type.addAllowedValue("R")
        self.declareProperty("Centering", "P", centering_type, doc="Centering to use for selecting cells")

        # Some of the options to pass through to FindPeaksMD (options like CalculateGoniometerForCW, FlipX, etc are
        # assumed to be True)
        self.declareProperty("MaxPeaks", 1000, doc="Maximum number of peaks to find.")
        self.declareProperty("PeakDistanceThreshold", 0.25, doc="Threshold distance for rejecting peaks that are found "
                                                                "to be too close from each other")
        # Having this number too low will likely cause FindUBUsingFFT to fail since not enough peaks will be found
        self.declareProperty("DensityThresholdFactor", 2000.0,
                             doc="Scaling factor which the overall signal density will be multiplied by to determine "
                                 "a threshold for determining peaks.")

        self.declareProperty("Wavelength", FloatPropertyWithValue.EMPTY_DBL,
                             doc="Wavelength value to use only if one was not found in the sample log")

        # Lattice parameter validators from same as FindUBUsingLatticeParameters
        self.declareProperty("UseLattice", False, direction=Direction.Input,
                             doc="Whether to refine UB matrix based on given lattice parameters")

        self.declareProperty("LatticeA", FloatPropertyWithValue.EMPTY_DBL, doc="The a value of the lattice")
        self.declareProperty("LatticeB", FloatPropertyWithValue.EMPTY_DBL, doc="The b value of the lattice")
        self.declareProperty("LatticeC", FloatPropertyWithValue.EMPTY_DBL, doc="The c value of the lattice")
        self.declareProperty("LatticeAlpha", FloatPropertyWithValue.EMPTY_DBL, doc="The alpha value of the lattice")
        self.declareProperty("LatticeBeta", FloatPropertyWithValue.EMPTY_DBL, doc="The beta value of the lattice")
        self.declareProperty("LatticeGamma", FloatPropertyWithValue.EMPTY_DBL, doc="The gamma value of the lattice")

        self.declareProperty(WorkspaceProperty("OutputWorkspace", defaultValue="", direction=Direction.Output,
                                               optional=PropertyMode.Mandatory), doc="Output peaks workspace")

        lattice_params = ["LatticeA", "LatticeB", "LatticeC", "LatticeAlpha", "LatticeBeta", "LatticeGamma"]
        for param in lattice_params:
            self.setPropertyGroup(param, "Lattice Settings")
            self.setPropertySettings(param, EnabledWhenProperty("UseLattice", PropertyCriterion.IsNotDefault))
Example #4
0
 def test_empty_constructor(self):
     validator = ADSValidator()
     self.assertTrue(validator.isMultipleSelectionAllowed())
     self.assertFalse(validator.isOptional())
    def PyInit(self):
        self.declareProperty(
            StringArrayProperty(
                "InputWorkspace", direction=Direction.Input, validator=ADSValidator(),
            ),
            doc="The main input workspace[s].",
        )

        self.declareProperty(
            "BackgroundWorkspace",
            "",
            direction=Direction.Input,
            doc="The background workspace to be subtracted.",
        )

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

        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",
        )
Example #6
0
    def PyInit(self):
        self.declareProperty(
            StringArrayProperty("InputWorkspace",
                                direction=Direction.Input,
                                validator=ADSValidator()),
            doc=
            "Workspace or comma-separated workspace list containing input MDHisto scan data."
        )

        self.declareProperty("Method",
                             direction=Direction.Input,
                             defaultValue="Fitted",
                             validator=StringListValidator(
                                 ["Counts", "CountsWithFitting", "Fitted"]),
                             doc="Integration method to use")

        self.declareProperty(
            "NumBackgroundPts",
            direction=Direction.Input,
            defaultValue=3,
            validator=IntBoundedValidator(lower=0),
            doc=
            "Number of background points from beginning and end of scan to use for background estimation"
        )
        self.setPropertySettings(
            "NumBackgroundPts",
            EnabledWhenProperty("Method", PropertyCriterion.IsEqualTo,
                                "Counts"))

        self.declareProperty(
            "WidthScale",
            direction=Direction.Input,
            defaultValue=2,
            validator=IntBoundedValidator(lower=0, exclusive=True),
            doc=
            "Controls integration range (+/- WidthScale/2*FWHM) defined around motor positions "
            "for CountsWithFitting method")
        self.setPropertySettings(
            "WidthScale",
            EnabledWhenProperty("Method", PropertyCriterion.IsEqualTo,
                                "CountsWithFitting"))

        self.declareProperty(
            IntArrayProperty("LowerLeft", [128, 128],
                             IntArrayLengthValidator(2),
                             direction=Direction.Input),
            doc="Region of interest lower-left corner, in detector pixels")
        self.declareProperty(
            IntArrayProperty("UpperRight", [384, 384],
                             IntArrayLengthValidator(2),
                             direction=Direction.Input),
            doc="Region of interest upper-right corner, in detector pixels")

        self.declareProperty(
            "StartX",
            Property.EMPTY_DBL,
            doc=
            "The start of the scan axis fitting range in degrees, either omega or chi axis."
        )
        self.declareProperty(
            "EndX",
            Property.EMPTY_DBL,
            doc=
            "The end of the scan axis fitting range in degrees, either omega or chi axis."
        )

        self.declareProperty(
            "ScaleFactor",
            1.0,
            doc="scale the integrated intensity by this value")
        self.declareProperty(
            "ChiSqMax",
            10.0,
            doc=
            "Fitting resulting in chi-sqaured higher than this won't be added to the output"
        )
        self.declareProperty(
            "SignalNoiseMin",
            1.0,
            doc=
            "Minimum Signal/Noice ratio (Intensity/SigmaIntensity) of peak to be added to the output"
        )
        self.declareProperty("ApplyLorentz",
                             True,
                             doc="If to apply Lorentz Correction to intensity")

        self.declareProperty(
            "OutputFitResults",
            False,
            doc=
            "This will output the fitting result workspace and a ROI workspace"
        )
        self.setPropertySettings(
            "OutputFitResults",
            EnabledWhenProperty("Method", PropertyCriterion.IsNotEqualTo,
                                "Counts"))
        self.declareProperty(
            "OptimizeQVector",
            True,
            doc=
            "This will convert the data to q and optimize the peak location using CentroidPeaksdMD"
        )

        self.declareProperty(IPeaksWorkspaceProperty(
            "OutputWorkspace",
            "",
            optional=PropertyMode.Mandatory,
            direction=Direction.Output),
                             doc="Output Peaks Workspace")
Example #7
0
    def PyInit(self):
        self.declareProperty(
            StringArrayProperty(
                "InputWorkspace",
                "",
                direction=Direction.Input,
                validator=ADSValidator(),
            ),
            doc="The main input workspace[s].",
        )

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

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

        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.declareProperty(
            "Wavelength",
            1.4865,  # A
            FloatBoundedValidator(lower=0.0),  # must be positive
            "Wavelength to set the workspace (A)",
        )

        self.declareProperty(
            "Target",
            "",
            StringListValidator(["Theta", "ElasticQ", "ElasticDSpacing"]),
            "The unit to which spectrum axis is converted to",
        )

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

        self.declareProperty(
            "NumberBins",
            1000,
            IntBoundedValidator(lower=1),  # need at least one bin
            "Number of bins to split up each spectrum into.",
        )

        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(
            WorkspaceProperty("OutputWorkspace",
                              "",
                              direction=Direction.Output),
            doc="Output Workspace",
        )

        self.declareProperty(
            "Sum",
            False,
            doc=
            "Specifies either single output workspace or output group workspace containing several workspaces.",
        )
Example #8
0
    def PyInit(self):
        self.declareProperty(
            StringArrayProperty("InputWorkspace",
                                direction=Direction.Input,
                                validator=ADSValidator()),
            doc="Input MDEvent workspace to use for integration")

        self.declareProperty(
            StringArrayProperty("PeaksWorkspace",
                                direction=Direction.Input,
                                validator=ADSValidator()),
            doc="Peaks workspace containing peaks to integrate")

        positive_val = FloatBoundedValidator(lower=0.0)
        self.declareProperty(
            "PeakRadius",
            defaultValue=1.0,
            validator=positive_val,
            doc="Fixed radius around each peak position in which to integrate"
            " (same units as input workspace) ")

        self.declareProperty(
            "BackgroundInnerRadius",
            defaultValue=0.0,
            validator=positive_val,
            doc="Inner radius used to evaluate the peak background")
        self.declareProperty(
            "BackgroundOuterRadius",
            defaultValue=0.0,
            validator=positive_val,
            doc="Outer radius used to evaluate the peak background")

        self.declareProperty(
            "ApplyLorentz",
            defaultValue=True,
            doc=
            "Whether the Lorentz correction should be applied to the integrated peaks"
        )

        self.declareProperty(
            "RemoveZeroIntensity",
            defaultValue=True,
            doc="If to remove peaks with 0 or less intensity from the output")

        formats = StringListValidator()
        formats.addAllowedValue("SHELX")
        formats.addAllowedValue("Fullprof")
        self.declareProperty(
            "OutputFormat",
            defaultValue="SHELX",
            validator=formats,
            doc="Save direction cosines in HKL, or the fullprof format")

        self.declareProperty(
            FileProperty(name="OutputFile",
                         defaultValue="",
                         direction=Direction.Input,
                         action=FileAction.OptionalSave),
            doc="Filepath to save the integrated peaks workspace in HKL format"
        )

        self.declareProperty(
            WorkspaceProperty("OutputWorkspace",
                              defaultValue="",
                              direction=Direction.Output,
                              optional=PropertyMode.Mandatory),
            doc=
            "Output peaks workspace (copy of input with updated peak intensities)"
        )
    def PyInit(self):
        self.declareProperty(
            StringArrayProperty("InputWorkspace",
                                direction=Direction.Input,
                                validator=ADSValidator()),
            doc=
            "Workspace or comma-separated workspace list containing input MDHisto scan data."
        )

        self.declareProperty(
            IntArrayProperty("LowerLeft", [128, 128],
                             IntArrayLengthValidator(2),
                             direction=Direction.Input),
            doc="Region of interest lower-left corner, in detector pixels")
        self.declareProperty(
            IntArrayProperty("UpperRight", [384, 384],
                             IntArrayLengthValidator(2),
                             direction=Direction.Input),
            doc="Region of interest upper-right corner, in detector pixels")

        self.declareProperty(
            "StartX",
            Property.EMPTY_DBL,
            doc=
            "The start of the scan axis fitting range in degrees, either omega or chi axis."
        )
        self.declareProperty(
            "EndX",
            Property.EMPTY_DBL,
            doc=
            "The end of the scan axis fitting range in degrees, either omega or chi axis."
        )

        self.declareProperty(
            "ScaleFactor",
            1.0,
            doc="scale the integrated intensity by this value")
        self.declareProperty(
            "ChiSqMax",
            10.0,
            doc=
            "Fitting resulting in chi-sqaured higher than this won't be added to the output"
        )
        self.declareProperty(
            "SignalNoiseMin",
            1.0,
            doc=
            "Minimum Signal/Noice ratio (Intensity/SigmaIntensity) of peak to be added to the output"
        )
        self.declareProperty("ApplyLorentz",
                             True,
                             doc="If to apply Lorentz Correction to intensity")

        self.declareProperty(
            "OutputFitResults",
            False,
            doc=
            "This will output the fitting result workspace and a ROI workspace"
        )

        self.declareProperty(
            "OptimizeQVector",
            True,
            doc=
            "This will convert the data to q and optimize the peak location using CentroidPeaksdMD"
        )

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