Пример #1
0
    def PyInit(self):
        self.declareProperty(
            IMDHistoWorkspaceProperty("InputWorkspace",
                                      "",
                                      optional=PropertyMode.Mandatory,
                                      direction=Direction.Input),
            "Input Workspace with HKL dimensions centered on zero.")
        self.declareProperty(
            WorkspaceProperty("IntermediateWorkspace",
                              "",
                              optional=PropertyMode.Optional,
                              direction=Direction.Output),
            "The resulting workspace after reflection removal and filters applied. What is the input of the FFT."
        )
        self.declareProperty(
            WorkspaceProperty("OutputWorkspace",
                              "",
                              optional=PropertyMode.Mandatory,
                              direction=Direction.Output), "Output Workspace")

        self.declareProperty(
            "Method", 'KAREN',
            StringListValidator(['None', 'Punch and fill', 'KAREN']),
            "Bragg peak removal method")
        self.declareProperty(
            "WindowFunction", 'Blackman',
            StringListValidator(
                ['None', 'Gaussian', 'Blackman', 'Tukey', 'Kaiser']),
            "Apply a window function to the data")
        self.declareProperty(
            "WindowParameter",
            defaultValue=0.5,
            validator=FloatBoundedValidator(0.),
            doc=
            "Parameter for window function, depends on window type, see algorithm docs"
        )

        # Punch and fill
        condition = EnabledWhenProperty("Method", PropertyCriterion.IsEqualTo,
                                        'Punch and fill')
        self.declareProperty("Shape",
                             "sphere",
                             doc="Shape to punch out reflections",
                             validator=StringListValidator(['sphere', 'cube']))
        self.setPropertySettings("Shape", condition)
        val_min_zero = FloatArrayBoundedValidator(lower=0.)
        self.declareProperty(
            FloatArrayProperty("Size", [0.2], validator=val_min_zero),
            "Width of cube/diameter of sphere used to remove reflections, in (HKL) (one or three values)"
        )
        self.setPropertySettings("Size", condition)
        self.declareProperty(
            "SpaceGroup",
            "",
            doc=
            "Space group for reflection removal, either full name or number. If empty all HKL's will be removed."
        )
        self.setPropertySettings("SpaceGroup", condition)
        self.declareProperty(
            "Convolution", True,
            "Apply convolution to fill in removed reflections")
        self.setPropertySettings("Convolution", condition)
        self.declareProperty("ConvolutionWidth",
                             2.0,
                             validator=FloatBoundedValidator(0.),
                             doc="Width of gaussian convolution in pixels")
        self.setPropertySettings("ConvolutionWidth", condition)

        self.declareProperty(
            "CropSphere", False,
            "Limit min/max q values. Can help with edge effects.")
        condition = EnabledWhenProperty("CropSphere",
                                        PropertyCriterion.IsNotDefault)
        self.declareProperty(
            FloatArrayProperty("SphereMin", [Property.EMPTY_DBL],
                               validator=val_min_zero),
            "HKL values below which will be removed (one or three values)")
        self.setPropertySettings("SphereMin", condition)
        self.declareProperty(
            FloatArrayProperty("SphereMax", [Property.EMPTY_DBL],
                               validator=val_min_zero),
            "HKL values above which will be removed (one or three values)")
        self.setPropertySettings("SphereMax", condition)
        self.declareProperty("FillValue", Property.EMPTY_DBL,
                             "Value to replace with outside sphere")
        self.setPropertySettings("FillValue", condition)

        # KAREN
        self.declareProperty("KARENWidth", 7, "Size of filter window")

        # Reflections
        self.setPropertyGroup("Shape", "Punch and fill")
        self.setPropertyGroup("Size", "Punch and fill")
        self.setPropertyGroup("SpaceGroup", "Punch and fill")

        # Sphere
        self.setPropertyGroup("CropSphere", "Cropping to a sphere")
        self.setPropertyGroup("SphereMin", "Cropping to a sphere")
        self.setPropertyGroup("SphereMax", "Cropping to a sphere")
        self.setPropertyGroup("FillValue", "Cropping to a sphere")

        # Convolution
        self.setPropertyGroup("Convolution", "Convolution")
        self.setPropertyGroup("ConvolutionWidth", "Convolution")
Пример #2
0
    def PyInit(self):
        arrvalidator = StringArrayMandatoryValidator()
        lrg = 'Input'
        self.declareProperty(StringArrayProperty('Workspaces',
                                                 values=[],
                                                 validator=arrvalidator,
                                                 direction=Direction.Input),
                             doc='list of input workspaces')
        self.declareProperty(
            'LoadErrors',
            True,
            direction=Direction.Input,
            doc='Do we load error data contained in the workspaces?')
        self.declareProperty(FloatArrayProperty(
            'ParameterValues',
            values=[],
            validator=FloatArrayMandatoryValidator(),
            direction=Direction.Input),
                             doc='list of input parameter values')
        self.setPropertyGroup('Workspaces', lrg)
        self.setPropertyGroup('LoadErrors', lrg)
        self.setPropertyGroup('ParameterValues', lrg)

        self.declareProperty('LocalRegression',
                             True,
                             direction=Direction.Input,
                             doc='Perform running local-regression?')
        condition = EnabledWhenProperty("LocalRegression",
                                        PropertyCriterion.IsDefault)
        self.declareProperty(
            'RegressionWindow',
            6,
            direction=Direction.Input,
            doc='window size for the running local-regression')
        self.setPropertySettings("RegressionWindow", condition)
        regtypes = ['linear', 'quadratic']
        self.declareProperty(
            'RegressionType',
            'quadratic',
            StringListValidator(regtypes),
            direction=Direction.Input,
            doc='type of local-regression; linear and quadratic are available')
        self.setPropertySettings("RegressionType", condition)
        lrg = 'Running Local Regression Options'
        self.setPropertyGroup('LocalRegression', lrg)
        self.setPropertyGroup('RegressionWindow', lrg)
        self.setPropertyGroup('RegressionType', lrg)

        lrg = 'Output'
        self.declareProperty(
            FloatArrayProperty(
                'TargetParameters',
                values=[],
            ),
            doc="Parameters to interpolate the structure factor")
        self.declareProperty(
            StringArrayProperty('OutputWorkspaces',
                                values=[],
                                validator=arrvalidator),
            doc=
            'list of output workspaces to save the interpolated structure factors'
        )
        self.setPropertyGroup('TargetParameters', lrg)
        self.setPropertyGroup('OutputWorkspaces', lrg)
        self.channelgroup = None
Пример #3
0
 def PyInit(self):
     self.declareProperty("InValue", 0)
     self.declareProperty("DoubleValue", 1.0)
     self.declareProperty(
         FloatArrayProperty("Floats", direction=Direction.Input))
     self.declareProperty("OutValue", 0, direction=Direction.Output)
Пример #4
0
 def PyInit(self):
     self.declareProperty("StringInput", "",
                          StringMandatoryValidator())
     self.declareProperty(
         FloatArrayProperty("ArrayInput",
                            FloatArrayMandatoryValidator()))
Пример #5
0
    def PyInit(self):
        self.declareProperty(MultipleFileProperty('CalibrationRun', action=FileAction.Load, extensions=['nxs']),
                             doc='File path of calibration runs (numors). Must be detector scans.')

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

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

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

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

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

        thetaRangeValidator = FloatArrayOrderedPairsValidator()

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

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

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

        pixelRangeValidator = CompositeValidator()
        greaterThanOne = IntArrayBoundedValidator()
        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.')

        self.declareProperty(name='UseCalibratedData',
                             defaultValue=False,
                             doc='Whether or not to use the calibrated data in the NeXus files (D2B only).')
Пример #6
0
    def PyInit(self):
        # files to reduce
        self.declareProperty(
            MultipleFileProperty(name="Filename",
                                 extensions=["_event.nxs", ".nxs.h5", ".nxs"]),
            "Files to combine in reduction")

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        # Projection and binning
        self.setPropertyGroup("QDimension0", "Projection and binning")
        self.setPropertyGroup("QDimension1", "Projection and binning")
        self.setPropertyGroup("QDimension2", "Projection and binning")
        self.setPropertyGroup("Dimension0Binning", "Projection and binning")
        self.setPropertyGroup("Dimension1Binning", "Projection and binning")
        self.setPropertyGroup("Dimension2Binning", "Projection and binning")
Пример #7
0
    def PyInit(self):

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

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

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


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

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

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

        GRP_RESULTS = "Results"

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

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

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

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

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

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

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

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

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

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


        GRP_PAWLEY_OPTIONS = "Pawley refinement options"

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

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

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

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

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

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

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

        GRP_PARAMS = "Refinement of peak parameters"

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

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

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

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

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

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

        self.setPropertyGroup(self.PROP_REFINE_CENTER, GRP_PARAMS)
        self.setPropertyGroup(self.PROP_REFINE_INTENSITY, GRP_PARAMS)
        self.setPropertyGroup(self.PROP_REFINE_ALPHA, GRP_PARAMS)
        self.setPropertyGroup(self.PROP_REFINE_BETA, GRP_PARAMS)
        self.setPropertyGroup(self.PROP_REFINE_SIGMA, GRP_PARAMS)
        self.setPropertyGroup(self.PROP_REFINE_GAMMA, GRP_PARAMS)
    def PyInit(self):
        # files to reduce
        self.declareProperty(
            MultipleFileProperty(name="Filename",
                                 extensions=["_event.nxs", ".nxs.h5", ".nxs"]),
            "Files to combine in reduction")

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

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

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

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

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

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

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

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

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

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

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

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

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

        # Projection and binning
        self.setPropertyGroup("Uproj", "Projection and binning")
        self.setPropertyGroup("Vproj", "Projection and binning")
        self.setPropertyGroup("Wproj", "Projection and binning")
        self.setPropertyGroup("BinningDim0", "Projection and binning")
        self.setPropertyGroup("BinningDim1", "Projection and binning")
        self.setPropertyGroup("BinningDim2", "Projection and binning")
Пример #9
0
 def PyInit(self):
     self.declareProperty(
         IMDHistoWorkspaceProperty("InputWorkspace",
                                   "",
                                   optional=PropertyMode.Mandatory,
                                   direction=Direction.Input),
         "Input Workspace")
     self.declareProperty(
         IMDHistoWorkspaceProperty("NormalisationWorkspace",
                                   "",
                                   optional=PropertyMode.Optional,
                                   direction=Direction.Input),
         "Workspace to use for normalisation")
     self.declareProperty(
         WorkspaceProperty("UBWorkspace",
                           "",
                           optional=PropertyMode.Optional,
                           direction=Direction.Input),
         "Workspace containing the UB matrix to use")
     self.declareProperty("Wavelength",
                          1.488,
                          validator=FloatBoundedValidator(0.0),
                          doc="Wavelength to set the workspace")
     self.declareProperty(
         "S1Offset",
         0.,
         doc="Offset to apply (in degrees) to the s1 of the input workspace"
     )
     self.declareProperty('NormaliseBy', 'Monitor',
                          StringListValidator(['None', 'Time', 'Monitor']),
                          "Normalise to monitor, time or None.")
     self.declareProperty('Frame', 'Q_sample',
                          StringListValidator(['Q_sample', 'HKL']),
                          "Selects Q-dimensions of the output workspace")
     self.declareProperty(
         FloatArrayProperty("Uproj", [1, 0, 0],
                            FloatArrayLengthValidator(3),
                            direction=Direction.Input),
         "Defines the first projection vector of the target Q coordinate system in HKL mode"
     )
     self.declareProperty(
         FloatArrayProperty("Vproj", [0, 1, 0],
                            FloatArrayLengthValidator(3),
                            direction=Direction.Input),
         "Defines the second projection vector of the target Q coordinate system in HKL mode"
     )
     self.declareProperty(
         FloatArrayProperty("Wproj", [0, 0, 1],
                            FloatArrayLengthValidator(3),
                            direction=Direction.Input),
         "Defines the third projection vector of the target Q coordinate system in HKL mode"
     )
     self.declareProperty(
         FloatArrayProperty("BinningDim0", [-8.02, 8.02, 401],
                            FloatArrayLengthValidator(3),
                            direction=Direction.Input),
         "Binning parameters for the 0th dimension. Enter it as a"
         "comma-separated list of values with the"
         "format: 'minimum,maximum,number_of_bins'.")
     self.declareProperty(
         FloatArrayProperty("BinningDim1", [-0.82, 0.82, 41],
                            FloatArrayLengthValidator(3),
                            direction=Direction.Input),
         "Binning parameters for the 1st dimension. Enter it as a"
         "comma-separated list of values with the"
         "format: 'minimum,maximum,number_of_bins'.")
     self.declareProperty(
         FloatArrayProperty("BinningDim2", [-8.02, 8.02, 401],
                            FloatArrayLengthValidator(3),
                            direction=Direction.Input),
         "Binning parameters for the 2nd dimension. Enter it as a"
         "comma-separated list of values with the"
         "format: 'minimum,maximum,number_of_bins'.")
     self.declareProperty(
         'KeepTemporaryWorkspaces', False,
         "If True the normalization and data workspaces in addition to the normalized data will be outputted"
     )
     self.declareProperty(
         "ObliquityParallaxCoefficient",
         1.0,
         validator=FloatBoundedValidator(0.0),
         doc=
         "Geometrical correction for shift in vertical beam position due to wide beam."
     )
     self.declareProperty(
         WorkspaceProperty("OutputWorkspace",
                           "",
                           optional=PropertyMode.Mandatory,
                           direction=Direction.Output), "Output Workspace")
Пример #10
0
    def PyInit(self):
        """Initialize the algorithm's input and output properties."""
        PROPGROUP_REBINNING = 'Rebinning for SofQW'
        inputWorkspaceValidator = CompositeValidator()
        inputWorkspaceValidator.add(InstrumentValidator())
        inputWorkspaceValidator.add(WorkspaceUnitValidator('TOF'))
        validRebinParams = RebinParamsValidator(AllowEmpty=True)

        # Properties.
        self.declareProperty(MatrixWorkspaceProperty(
            name=common.PROP_INPUT_WS,
            defaultValue='',
            validator=inputWorkspaceValidator,
            direction=Direction.Input),
                             doc='A workspace to reduce.')
        self.declareProperty(WorkspaceProperty(name=common.PROP_OUTPUT_WS,
                                               defaultValue='',
                                               direction=Direction.Output),
                             doc='The reduced S(Q, DeltaE) workspace.')
        self.declareProperty(name=common.PROP_CLEANUP_MODE,
                             defaultValue=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_VANA_WS,
            defaultValue='',
            validator=inputWorkspaceValidator,
            direction=Direction.Input,
            optional=PropertyMode.Optional),
                             doc='An integrated vanadium workspace.')
        self.declareProperty(
            name=common.PROP_ABSOLUTE_UNITS,
            defaultValue=common.ABSOLUTE_UNITS_OFF,
            validator=StringListValidator(
                [common.ABSOLUTE_UNITS_OFF, common.ABSOLUTE_UNITS_ON]),
            direction=Direction.Input,
            doc='Enable or disable normalisation to absolute units.')
        self.declareProperty(MatrixWorkspaceProperty(
            name=common.PROP_DIAGNOSTICS_WS,
            defaultValue='',
            direction=Direction.Input,
            optional=PropertyMode.Optional),
                             doc='Detector diagnostics workspace for masking.')
        self.declareProperty(FloatArrayProperty(
            name=common.PROP_REBINNING_PARAMS_W, validator=validRebinParams),
                             doc='Manual energy rebinning parameters.')
        self.setPropertyGroup(common.PROP_REBINNING_PARAMS_W,
                              PROPGROUP_REBINNING)
        self.declareProperty(
            name=common.PROP_REBINNING_W,
            defaultValue='',
            doc=
            'Energy rebinning when mixing manual and automatic binning parameters.'
        )
        self.declareProperty(FloatArrayProperty(
            name=common.PROP_BINNING_PARAMS_Q, validator=validRebinParams),
                             doc='Manual q rebinning parameters.')
        self.setPropertyGroup(common.PROP_BINNING_PARAMS_Q,
                              PROPGROUP_REBINNING)
        self.declareProperty(
            name=common.PROP_TRANSPOSE_SAMPLE_OUTPUT,
            defaultValue=common.TRANSPOSING_ON,
            validator=StringListValidator(
                [common.TRANSPOSING_ON, common.TRANSPOSING_OFF]),
            direction=Direction.Input,
            doc='Enable or disable ' + common.PROP_OUTPUT_WS + ' transposing.')
        self.declareProperty(
            WorkspaceProperty(name=common.PROP_OUTPUT_THETA_W_WS,
                              defaultValue='',
                              direction=Direction.Output,
                              optional=PropertyMode.Optional),
            doc='Output workspace for reduced S(theta, DeltaE).')
        self.setPropertyGroup(common.PROP_OUTPUT_THETA_W_WS,
                              common.PROPGROUP_OPTIONAL_OUTPUT)
 def PyInit(self):
     """Initialize the input and output properties of the algorithm."""
     nonnegativeInt = IntBoundedValidator(lower=0)
     nonnegativeIntArray = IntArrayBoundedValidator()
     nonnegativeIntArray.setLower(0)
     nonnegativeFloatArray = FloatArrayBoundedValidator()
     nonnegativeFloatArray.setLower(0.)
     twoNonnegativeFloats = CompositeValidator()
     twoNonnegativeFloats.add(FloatArrayLengthValidator(length=2))
     twoNonnegativeFloats.add(nonnegativeFloatArray)
     maxTwoNonnegativeInts = CompositeValidator()
     maxTwoNonnegativeInts.add(IntArrayLengthValidator(lenmin=0, lenmax=2))
     maxTwoNonnegativeInts.add(nonnegativeIntArray)
     self.declareProperty(MultipleFileProperty(Prop.RUN,
                                               action=FileAction.OptionalLoad,
                                               extensions=['nxs']),
                          doc='A list of input run numbers/files.')
     self.declareProperty(MatrixWorkspaceProperty(Prop.INPUT_WS,
                                                  defaultValue='',
                                                  direction=Direction.Input,
                                                  validator=WorkspaceUnitValidator('TOF'),
                                                  optional=PropertyMode.Optional),
                          doc='An input workspace (units TOF) if no Run is specified.')
     self.declareProperty(ITableWorkspaceProperty(Prop.BEAM_POS_WS,
                                                  defaultValue='',
                                                  direction=Direction.Input,
                                                  optional=PropertyMode.Optional),
                          doc='A beam position table corresponding to InputWorkspace.')
     self.declareProperty(Prop.BEAM_ANGLE,
                          defaultValue=Property.EMPTY_DBL,
                          doc='A user-defined beam angle (unit degrees).')
     self.declareProperty(name=Prop.BEAM_CENTRE,
                          defaultValue=Property.EMPTY_DBL,
                          doc='A workspace index corresponding to the beam centre.')
     self.declareProperty(MatrixWorkspaceProperty(Prop.OUTPUT_WS,
                                                  defaultValue='',
                                                  direction=Direction.Output),
                          doc='The preprocessed output workspace (unit wavelength), single histogram.')
     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(ITableWorkspaceProperty(Prop.DIRECT_BEAM_POS_WS,
                                                  defaultValue='',
                                                  direction=Direction.Input,
                                                  optional=PropertyMode.Optional),
                          doc='A beam position table from a direct beam measurement.')
     self.declareProperty(MatrixWorkspaceProperty(Prop.WATER_REFERENCE,
                                                  defaultValue='',
                                                  direction=Direction.Input,
                                                  validator=WorkspaceUnitValidator("TOF"),
                                                  optional=PropertyMode.Optional),
                          doc='A (water) calibration workspace (unit TOF).')
     self.declareProperty(Prop.SLIT_NORM,
                          defaultValue=SlitNorm.OFF,
                          validator=StringListValidator([SlitNorm.OFF, SlitNorm.ON]),
                          doc='Enable or disable slit normalisation.')
     self.declareProperty(Prop.FLUX_NORM_METHOD,
                          defaultValue=FluxNormMethod.TIME,
                          validator=StringListValidator([FluxNormMethod.TIME, FluxNormMethod.MONITOR, FluxNormMethod.OFF]),
                          doc='Neutron flux normalisation method.')
     self.declareProperty(FloatArrayProperty(Prop.WAVELENGTH_RANGE,
                                             values=[0, Property.EMPTY_DBL],
                                             validator=twoNonnegativeFloats),
                          doc='The wavelength bounds of the output workspace.')
     self.declareProperty(IntArrayProperty(Prop.FOREGROUND_HALF_WIDTH,
                                           validator=maxTwoNonnegativeInts),
                          doc='Number of foreground pixels at lower and higher angles from the centre pixel.')
     self.declareProperty(Prop.BKG_METHOD,
                          defaultValue=BkgMethod.CONSTANT,
                          validator=StringListValidator([BkgMethod.CONSTANT, BkgMethod.LINEAR, BkgMethod.OFF]),
                          doc='Flat background calculation method for background subtraction.')
     self.declareProperty(Prop.LOW_BKG_OFFSET,
                          defaultValue=7,
                          validator=nonnegativeInt,
                          doc='Distance of flat background region towards smaller detector angles from the foreground centre, ' +
                              'in pixels.')
     self.declareProperty(Prop.LOW_BKG_WIDTH,
                          defaultValue=5,
                          validator=nonnegativeInt,
                          doc='Width of flat background region towards smaller detector angles from the foreground centre, in pixels.')
     self.declareProperty(Prop.HIGH_BKG_OFFSET,
                          defaultValue=7,
                          validator=nonnegativeInt,
                          doc='Distance of flat background region towards larger detector angles from the foreground centre, in pixels.')
     self.declareProperty(Prop.HIGH_BKG_WIDTH,
                          defaultValue=5,
                          validator=nonnegativeInt,
                          doc='Width of flat background region towards larger detector angles from the foreground centre, in pixels.')
     self.declareProperty(ITableWorkspaceProperty(Prop.OUTPUT_BEAM_POS_WS,
                                                  defaultValue='',
                                                  direction=Direction.Output,
                                                  optional=PropertyMode.Optional),
                          doc='Output the beam position table.')
    def PyInit(self):
        """Initialize the input and output properties of the algorithm."""
        nonnegativeInts = IntArrayBoundedValidator()
        nonnegativeInts.setLower(0)
        maxTwoNonnegativeInts = CompositeValidator()
        maxTwoNonnegativeInts.add(IntArrayLengthValidator(lenmin=0, lenmax=2))
        maxTwoNonnegativeInts.add(nonnegativeInts)
        nonnegativeFloatArray = FloatArrayBoundedValidator()
        nonnegativeFloatArray.setLower(0.)
        stringArrayValidator = StringArrayLengthValidator()
        stringArrayValidator.setLengthMin(1)

        #======================== Main Properties ========================
        self.declareProperty(
            PropertyNames.POLARIZATION_OPTION, 'NonPolarized',
            StringListValidator(['NonPolarized', 'Polarized']),
            'Indicate whether measurements are polarized')

        is_polarized = EnabledWhenProperty(PropertyNames.POLARIZATION_OPTION,
                                           PropertyCriterion.IsEqualTo,
                                           'Polarized')
        is_not_polarized = EnabledWhenProperty(
            PropertyNames.POLARIZATION_OPTION, PropertyCriterion.IsEqualTo,
            'NonPolarized')
        polarized = 'Inputs for polarized measurements'

        self.declareProperty(MultipleFileProperty(
            PropertyNames.RB,
            action=FileAction.OptionalLoad,
            extensions=['nxs']),
                             doc='A list of reflected run numbers/files.')
        self.setPropertySettings(PropertyNames.RB, is_not_polarized)

        self.declareProperty(
            MultipleFileProperty(PropertyNames.RB00,
                                 action=FileAction.OptionalLoad,
                                 extensions=['nxs']),
            doc='A list of reflected run numbers/files for 00.')
        self.setPropertySettings(PropertyNames.RB00, is_polarized)
        self.setPropertyGroup(PropertyNames.RB00, polarized)

        self.declareProperty(
            MultipleFileProperty(PropertyNames.RB01,
                                 action=FileAction.OptionalLoad,
                                 extensions=['nxs']),
            doc='A list of reflected run numbers/files for 01.')
        self.setPropertySettings(PropertyNames.RB01, is_polarized)
        self.setPropertyGroup(PropertyNames.RB01, polarized)

        self.declareProperty(
            MultipleFileProperty(PropertyNames.RB10,
                                 action=FileAction.OptionalLoad,
                                 extensions=['nxs']),
            doc='A list of reflected run numbers/files for 10.')
        self.setPropertySettings(PropertyNames.RB10, is_polarized)
        self.setPropertyGroup(PropertyNames.RB10, polarized)

        self.declareProperty(
            MultipleFileProperty(PropertyNames.RB11,
                                 action=FileAction.OptionalLoad,
                                 extensions=['nxs']),
            doc='A list of reflected run numbers/files for 11.')
        self.setPropertySettings(PropertyNames.RB11, is_polarized)
        self.setPropertyGroup(PropertyNames.RB11, polarized)

        self.declareProperty(
            FileProperty(PropertyNames.EFFICIENCY_FILE,
                         defaultValue='',
                         action=FileAction.OptionalLoad),
            doc='A file containing the polarization efficiency factors.')
        self.setPropertySettings(PropertyNames.EFFICIENCY_FILE, is_polarized)
        self.setPropertyGroup(PropertyNames.EFFICIENCY_FILE, polarized)

        self.declareProperty(MultipleFileProperty(PropertyNames.DB,
                                                  action=FileAction.Load,
                                                  extensions=['nxs']),
                             doc='A list of direct run numbers/files.')
        self.declareProperty(WorkspaceGroupProperty(
            Prop.OUTPUT_WS, defaultValue='', direction=Direction.Output),
                             doc='The output workspace group.')
        self.declareProperty(
            PropertyNames.BKG_METHOD_DIRECT,
            defaultValue=BkgMethod.CONSTANT,
            validator=StringListValidator(
                [BkgMethod.CONSTANT, BkgMethod.LINEAR, BkgMethod.OFF]),
            doc='Flat background calculation method for background subtraction.'
        )
        self.declareProperty(
            PropertyNames.BKG_METHOD,
            defaultValue=BkgMethod.CONSTANT,
            validator=StringListValidator(
                [BkgMethod.CONSTANT, BkgMethod.LINEAR, BkgMethod.OFF]),
            doc='Flat background calculation method for background subtraction.'
        )
        self.copyProperties('ReflectometryILLPreprocess', [
            Prop.SUBALG_LOGGING, Prop.CLEANUP, Prop.WATER_REFERENCE,
            Prop.SLIT_NORM, Prop.FLUX_NORM_METHOD
        ])
        self.declareProperty(PropertyNames.SCALE_FACTOR,
                             defaultValue=1.0,
                             doc='Scale factor.')

        self.declareProperty(
            PropertyNames.USE_MANUAL_SCALE_FACTORS,
            defaultValue=False,
            doc='Choose to apply manual scale factors for stitching.')

        self.declareProperty(
            FloatArrayProperty(PropertyNames.MANUAL_SCALE_FACTORS, values=[]),
            doc=
            'A list of manual scale factors for stitching (number of anlge configurations minus 1)'
        )

        self.setPropertySettings(
            PropertyNames.MANUAL_SCALE_FACTORS,
            EnabledWhenProperty(PropertyNames.USE_MANUAL_SCALE_FACTORS,
                                PropertyCriterion.IsNotDefault))

        self.declareProperty(
            PropertyNames.CACHE_DIRECT_BEAM,
            defaultValue=False,
            doc=
            'Cache the processed direct beam in ADS for ready use with further reflected beams;'
            'saves important execution time, however assumes that the direct beam processing '
            'configuration must be invariant for different reflected beams.')

        # ======================== Common Properties ========================
        commonProp = 'Preprocessing common properties: provide a list or a single value'

        self.declareProperty(StringArrayProperty(
            PropertyNames.ANGLE_OPTION,
            values=[PropertyNames.DAN],
            validator=stringArrayValidator,
            direction=Direction.Input,
        ),
                             doc='Angle option used for detector positioning')
        self.declareProperty(FloatArrayProperty(PropertyNames.THETA,
                                                values=[-1.]),
                             doc='A user-defined angle theta in degree')
        self.declareProperty(StringArrayProperty(
            PropertyNames.SUM_TYPE,
            values=[PropertyNames.INCOHERENT],
            validator=stringArrayValidator,
            direction=Direction.Input,
        ),
                             doc='Type of summation to perform')
        self.declareProperty(FloatArrayProperty(
            PropertyNames.WAVELENGTH_LOWER,
            values=[0.],
            validator=nonnegativeFloatArray),
                             doc='The lower wavelength bound (Angstrom)')
        self.declareProperty(FloatArrayProperty(
            PropertyNames.WAVELENGTH_UPPER,
            values=[35.],
            validator=nonnegativeFloatArray),
                             doc='The upper wavelength bound (Angstrom)')
        self.declareProperty(
            FloatArrayProperty(
                PropertyNames.GROUPING_FRACTION,
                values=[0.5],
                validator=nonnegativeFloatArray,
            ),
            doc=
            'If set, group the output by steps of this fraction multiplied by Q resolution'
        )
        self.setPropertyGroup(PropertyNames.ANGLE_OPTION, commonProp)
        self.setPropertyGroup(PropertyNames.THETA, commonProp)
        self.setPropertyGroup(PropertyNames.SUM_TYPE, commonProp)
        self.setPropertyGroup(PropertyNames.WAVELENGTH_LOWER, commonProp)
        self.setPropertyGroup(PropertyNames.WAVELENGTH_UPPER, commonProp)
        self.setPropertyGroup(PropertyNames.GROUPING_FRACTION, commonProp)

        # ======================== Direct Run Properties ========================
        preProcessDirect = 'Preprocessing for direct runs: provide a list or a single value'

        self.declareProperty(
            IntArrayProperty(PropertyNames.LOW_FRG_HALF_WIDTH_DIRECT,
                             values=[0],
                             validator=nonnegativeInts),
            doc=
            'Number of foreground pixels at lower angles from the centre pixel.'
        )
        self.setPropertyGroup(PropertyNames.LOW_FRG_HALF_WIDTH_DIRECT,
                              preProcessDirect)
        self.declareProperty(
            IntArrayProperty(
                PropertyNames.LOW_BKG_OFFSET_DIRECT,
                values=[7],
                validator=nonnegativeInts,
            ),
            doc=
            'Distance of flat background region towards smaller detector angles from the '
            + 'foreground centre, in pixels')
        self.setPropertyGroup(PropertyNames.LOW_BKG_OFFSET_DIRECT,
                              preProcessDirect)
        self.declareProperty(
            IntArrayProperty(
                PropertyNames.LOW_BKG_WIDTH_DIRECT,
                values=[5],
                validator=nonnegativeInts,
            ),
            doc=
            'Width of flat background region towards smaller detector angles from the '
            + 'foreground centre, in pixels')
        self.setPropertyGroup(PropertyNames.LOW_BKG_WIDTH_DIRECT,
                              preProcessDirect)
        self.declareProperty(
            IntArrayProperty(PropertyNames.HIGH_FRG_HALF_WIDTH_DIRECT,
                             values=[0],
                             validator=nonnegativeInts),
            doc=
            'Number of foreground pixels at higher angles from the centre pixel.'
        )
        self.setPropertyGroup(PropertyNames.HIGH_FRG_HALF_WIDTH_DIRECT,
                              preProcessDirect)
        self.declareProperty(
            IntArrayProperty(
                PropertyNames.HIGH_BKG_OFFSET_DIRECT,
                values=[7],
                validator=nonnegativeInts,
            ),
            doc=
            'Distance of flat background region towards larger detector angles from the '
            + 'foreground centre, in pixels')
        self.setPropertyGroup(PropertyNames.HIGH_BKG_OFFSET_DIRECT,
                              preProcessDirect)
        self.declareProperty(
            IntArrayProperty(
                PropertyNames.HIGH_BKG_WIDTH_DIRECT,
                values=[5],
                validator=nonnegativeInts,
            ),
            doc=
            'Width of flat background region towards larger detector angles from the '
            + 'foreground centre, in pixels')
        self.setPropertyGroup(PropertyNames.HIGH_BKG_WIDTH_DIRECT,
                              preProcessDirect)
        self.declareProperty(IntArrayProperty(
            PropertyNames.START_WS_INDEX_DIRECT,
            values=[0],
            validator=nonnegativeInts,
        ),
                             doc='Start histogram index used for peak fitting')
        self.setPropertyGroup(PropertyNames.START_WS_INDEX_DIRECT,
                              preProcessDirect)
        self.declareProperty(IntArrayProperty(
            PropertyNames.END_WS_INDEX_DIRECT,
            values=[255],
            validator=nonnegativeInts,
        ),
                             doc='Last histogram index used for peak fitting')
        self.setPropertyGroup(PropertyNames.END_WS_INDEX_DIRECT,
                              preProcessDirect)
        self.declareProperty(
            PropertyNames.XMIN_DIRECT,
            defaultValue=-1.,
            doc='Minimum x value (unit wavelength) used for peak fitting.')
        self.setPropertyGroup(PropertyNames.XMIN_DIRECT, preProcessDirect)
        self.declareProperty(
            PropertyNames.XMAX_DIRECT,
            defaultValue=-1.,
            doc='Maximum x value (unit wavelength) used for peak fitting.')
        self.setPropertyGroup(PropertyNames.XMAX_DIRECT, preProcessDirect)

        # ======================== Preprocessing For Reflected Runs ========================
        preProcessReflected = 'Preprocessing for reflected runs: provide a list or a single value'

        self.declareProperty(
            IntArrayProperty(
                PropertyNames.LOW_FRG_HALF_WIDTH,
                values=[0],
                validator=nonnegativeInts,
            ),
            doc=
            'Number of foreground pixels at lower angles from the centre pixel.'
        )
        self.setPropertyGroup(PropertyNames.LOW_FRG_HALF_WIDTH,
                              preProcessReflected)
        self.declareProperty(
            IntArrayProperty(
                PropertyNames.LOW_BKG_OFFSET,
                values=[7],
                validator=nonnegativeInts,
            ),
            doc=
            'Distance of flat background region towards smaller detector angles from the '
            + 'foreground centre, in pixels.')
        self.setPropertyGroup(PropertyNames.LOW_BKG_OFFSET,
                              preProcessReflected)
        self.declareProperty(
            IntArrayProperty(
                PropertyNames.LOW_BKG_WIDTH,
                values=[5],
                validator=nonnegativeInts,
            ),
            doc=
            'Width of flat background region towards smaller detector angles from the '
            + 'foreground centre, in pixels')
        self.setPropertyGroup(PropertyNames.LOW_BKG_WIDTH, preProcessReflected)
        self.declareProperty(
            IntArrayProperty(
                PropertyNames.HIGH_FRG_HALF_WIDTH,
                values=[0],
                validator=nonnegativeInts,
            ),
            doc=
            'Number of foreground pixels at higher angles from the centre pixel.'
        )
        self.setPropertyGroup(PropertyNames.HIGH_FRG_HALF_WIDTH,
                              preProcessReflected)
        self.declareProperty(
            IntArrayProperty(
                PropertyNames.HIGH_BKG_OFFSET,
                values=[7],
                validator=nonnegativeInts,
            ),
            doc=
            'Distance of flat background region towards larger detector angles from the '
            + 'foreground centre, in pixels')
        self.setPropertyGroup(PropertyNames.HIGH_BKG_OFFSET,
                              preProcessReflected)
        self.declareProperty(
            IntArrayProperty(
                PropertyNames.HIGH_BKG_WIDTH,
                values=[5],
                validator=nonnegativeInts,
            ),
            doc=
            'Width of flat background region towards larger detector angles from the '
            + 'foreground centre, in pixels.')
        self.setPropertyGroup(PropertyNames.HIGH_BKG_WIDTH,
                              preProcessReflected)
        self.declareProperty(IntArrayProperty(
            PropertyNames.START_WS_INDEX,
            values=[0],
            validator=nonnegativeInts,
        ),
                             doc='Start histogram index used for peak fitting')
        self.setPropertyGroup(PropertyNames.START_WS_INDEX,
                              preProcessReflected)
        self.declareProperty(IntArrayProperty(
            PropertyNames.END_WS_INDEX,
            values=[255],
            validator=nonnegativeInts,
        ),
                             doc='Last histogram index used for peak fitting')
        self.setPropertyGroup(PropertyNames.END_WS_INDEX, preProcessReflected)
        self.declareProperty(
            FloatArrayProperty(PropertyNames.XMIN, values=[-1.]),
            doc='Minimum x value (unit wavelength) used for peak fitting')
        self.setPropertyGroup(PropertyNames.XMIN, preProcessReflected)
        self.declareProperty(
            FloatArrayProperty(PropertyNames.XMAX, values=[-1.]),
            doc='Maximum x value (unit wavelength) used for peak fitting')
        self.setPropertyGroup(PropertyNames.XMAX, preProcessReflected)
Пример #13
0
    def PyInit(self):

        #
        # Reference and input data
        self.declareProperty(ITableWorkspaceProperty(
            "PeakCentersTofTable",
            "",
            optional=PropertyMode.Mandatory,
            direction=Direction.Input),
                             doc="Table of found peak centers, in TOF units")

        self.declareProperty(
            FloatArrayProperty("PeakPositions",
                               values=[],
                               direction=Direction.Input),
            doc=
            "Comma separated list of reference peak center d-spacings, sorted by increasing value."
        )

        properties = ["PeakCentersTofTable", "PeakPositions"]
        [
            self.setPropertyGroup(name, 'Reference and Input Data')
            for name in properties
        ]

        #
        # Output Tables
        self.declareProperty(
            "AdjustmentsTable",
            "",
            direction=Direction.Input,
            doc=
            "Name of output table containing optimized locations and orientations for each component"
        )

        self.declareProperty(
            "DisplacementsTable",
            "",
            direction=Direction.Input,
            doc=
            "Name of output table containing changes in position and euler angles for each bank component"
        )

        properties = ["AdjustmentsTable", "DisplacementsTable"]
        [self.setPropertyGroup(name, 'Output Tables') for name in properties]

        #
        # Selection of the instrument and mask
        self.declareProperty(MatrixWorkspaceProperty(
            "MaskWorkspace",
            "",
            optional=PropertyMode.Optional,
            direction=Direction.Input),
                             doc="Mask workspace")

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

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

        self.declareProperty(
            WorkspaceProperty("OutputWorkspace",
                              "",
                              optional=PropertyMode.Mandatory,
                              direction=Direction.Output),
            doc='Workspace containing the calibrated instrument')

        properties = [
            'MaskWorkspace', "InstrumentFilename", "InputWorkspace",
            "OutputWorkspace"
        ]
        [
            self.setPropertyGroup(name, 'Instrument Options')
            for name in properties
        ]

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

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

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

        properties = [
            "FitSourcePosition", "FitSamplePosition", "ComponentList"
        ]
        [
            self.setPropertyGroup(name, 'Declaration of Components')
            for name in properties
        ]

        #
        # Translation Properties
        # X position
        self.declareProperty(
            name="Xposition",
            defaultValue=False,
            doc="Refine Xposition of source and/or sample and/or components")
        condition = EnabledWhenProperty("Xposition",
                                        PropertyCriterion.IsNotDefault)
        self.declareProperty(name="MinXposition",
                             defaultValue=-0.1,
                             validator=FloatBoundedValidator(-10.0, 10.0),
                             doc="Minimum relative X bound (m)")
        self.setPropertySettings("MinXposition", condition)
        self.declareProperty(name="MaxXposition",
                             defaultValue=0.1,
                             validator=FloatBoundedValidator(-10.0, 10.0),
                             doc="Maximum relative X bound (m)")
        self.setPropertySettings("MaxXposition", condition)

        self.declareProperty(
            name="Yposition",
            defaultValue=False,
            doc="Refine Yposition of source and/or sample and/or components")
        condition = EnabledWhenProperty("Yposition",
                                        PropertyCriterion.IsNotDefault)
        self.declareProperty(name="MinYposition",
                             defaultValue=-0.1,
                             validator=FloatBoundedValidator(-10.0, 10.0),
                             doc="Minimum relative Y bound (m)")
        self.setPropertySettings("MinYposition", condition)
        self.declareProperty(name="MaxYposition",
                             defaultValue=0.1,
                             validator=FloatBoundedValidator(-10.0, 10.0),
                             doc="Maximum relative Y bound (m)")
        self.setPropertySettings("MaxYposition", condition)

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

        properties = [
            "Xposition", "MinXposition", "MaxXposition", "Yposition",
            "MinYposition", "MaxYposition", "Zposition", "MinZposition",
            "MaxZposition"
        ]
        [self.setPropertyGroup(name, "Translation") for name in properties]

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

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

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

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

        properties = [
            "EulerConvention", "AlphaRotation", "MinAlphaRotation",
            "MaxAlphaRotation", "BetaRotation", "MinBetaRotation",
            "MaxBetaRotation", "GammaRotation", "MinGammaRotation",
            "MaxGammaRotation"
        ]
        [self.setPropertyGroup(name, "Rotation") for name in properties]

        #
        # Minimization Properties
        self.declareProperty(name='Minimizer',
                             defaultValue='L-BFGS-B',
                             direction=Direction.Input,
                             validator=StringListValidator(
                                 ['L-BFGS-B', 'differential_evolution']),
                             doc='Minimizer to Use')
        self.declareProperty(
            name='MaxIterations',
            defaultValue=100,
            direction=Direction.Input,
            doc=
            'Maximum number of iterations for minimizer differential_evolution'
        )

        properties = ['Minimizer', 'MaxIterations']
        [self.setPropertyGroup(name, "Minimization") for name in properties]
Пример #14
0
 def PyInit(self):
     validator = FloatArrayLengthValidator(fixedlength)
     self.declareProperty(FloatArrayProperty("Input", validator))
Пример #15
0
    def PyInit(self):

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        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'])
Пример #16
0
    def PyInit(self):
        #
        # Properties
        #
        self.declareProperty('RunNumbers', '', 'Sample run numbers')

        #
        #  Normalization selector
        #
        title_flux_normalization = 'Flux Normalization'
        self.declareProperty('DoFluxNormalization',
                             True,
                             direction=Direction.Input,
                             doc='Do we normalize data by incoming flux?')
        self.setPropertyGroup('DoFluxNormalization', title_flux_normalization)
        if_flux_normalization = EnabledWhenProperty(
            'DoFluxNormalization', PropertyCriterion.IsDefault)
        flux_normalization_types = ['Monitor', 'Proton Charge', 'Duration']
        default_flux_normalization = flux_normalization_types[0]
        self.declareProperty('FluxNormalizationType',
                             default_flux_normalization,
                             StringListValidator(flux_normalization_types),
                             'Flux Normalization Type')
        self.setPropertySettings('FluxNormalizationType',
                                 if_flux_normalization)
        self.setPropertyGroup('FluxNormalizationType',
                              title_flux_normalization)

        self.declareProperty(
            FloatArrayProperty(
                'MomentumTransferBins',
                [0.1, 0.0025, 2.5],  # invers A
                direction=Direction.Input),
            'Momentum transfer binning scheme')

        self.declareProperty(WorkspaceProperty('OutputWorkspace',
                                               '',
                                               optional=PropertyMode.Mandatory,
                                               direction=Direction.Output),
                             doc='Output reduced workspace')

        self.declareProperty(FileProperty(name='MaskFile',
                                          defaultValue=self._mask_file,
                                          action=FileAction.OptionalLoad,
                                          extensions=['.xml']),
                             doc='See documentation for latest mask files.')
        #
        # Background for the sample runs
        #
        background_title = 'Background runs'
        self.declareProperty('BackgroundRuns', '', 'Background run numbers')
        self.setPropertyGroup('BackgroundRuns', background_title)
        self.declareProperty("BackgroundScale",
                             1.0,
                             doc='The background will be scaled by this ' +
                             'number before being subtracted.')
        self.setPropertyGroup('BackgroundScale', background_title)
        self.declareProperty(WorkspaceProperty('OutputBackground',
                                               '',
                                               optional=PropertyMode.Optional,
                                               direction=Direction.Output),
                             doc='Reduced workspace for background runs')
        self.setPropertyGroup('OutputBackground', background_title)
        #
        # Vanadium
        #
        vanadium_title = 'Vanadium runs'
        self.declareProperty('VanadiumRuns', '', 'Vanadium run numbers')
        self.setPropertyGroup('VanadiumRuns', vanadium_title)
        #
        # Aditional output properties
        #
        titleAddionalOutput = 'Additional Output'
        self.declareProperty('RemoveTemporaryWorkspaces',
                             True,
                             direction=Direction.Input,
                             doc='Remove temporary workspaces and files')
        self.setPropertyGroup('RemoveTemporaryWorkspaces', titleAddionalOutput)
Пример #17
0
    def PyInit(self):
        # Input properties
        self.declareProperty(StringArrayProperty(name='InputFiles'),
                             doc='A comma separated list of run numbers.')

        # Instrument configuration properties
        self.declareProperty(name='Instrument',
                             defaultValue='',
                             validator=StringListValidator(['IRIS', 'OSIRIS']),
                             doc='Instrument used during run.')
        self.declareProperty(name='Analyser',
                             defaultValue='',
                             validator=StringListValidator(
                                 ['graphite', 'mica', 'fmica']),
                             doc='Analyser bank used during run.')
        self.declareProperty(
            name='Reflection',
            defaultValue='',
            validator=StringListValidator(['002', '004', '006']),
            doc='Reflection number for instrument setup during run.')

        self.declareProperty(
            IntArrayProperty(name='SpectraRange',
                             values=[0, 1],
                             validator=IntArrayMandatoryValidator()),
            doc='Comma separated range of spectra number to use.')
        self.declareProperty(FloatArrayProperty(
            name='ElasticRange', validator=FloatArrayLengthValidator(2)),
                             doc='Energy range for the elastic component.')
        self.declareProperty(FloatArrayProperty(
            name='InelasticRange', validator=FloatArrayLengthValidator(2)),
                             doc='Energy range for the inelastic component.')
        self.declareProperty(
            FloatArrayProperty(name='TotalRange',
                               validator=FloatArrayLengthValidator(2)),
            doc='Energy range for the total energy component.')

        self.declareProperty(name='SampleEnvironmentLogName',
                             defaultValue='sample',
                             doc='Name of the sample environment log entry')

        sample_environment_log_values = ['last_value', 'average']
        self.declareProperty(
            'SampleEnvironmentLogValue',
            'last_value',
            StringListValidator(sample_environment_log_values),
            doc='Value selection of the sample environment log entry')

        self.declareProperty(name='MSDFit',
                             defaultValue=False,
                             doc='Perform an MSDFit.')

        self.declareProperty(name='WidthFit',
                             defaultValue=False,
                             doc='Perform a 2 peak width Fit.')

        self.declareProperty(name='Plot',
                             defaultValue=False,
                             doc='Switch Plot Off/On')
        self.declareProperty(name='Save',
                             defaultValue=False,
                             doc='Switch Save result to nxs file Off/On')
    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 input and output properties of the algorithm."""
     threeNonnegativeInts = CompositeValidator()
     threeNonnegativeInts.add(IntArrayLengthValidator(3))
     nonnegativeInts = IntArrayBoundedValidator()
     nonnegativeInts.setLower(0)
     threeNonnegativeInts.add(nonnegativeInts)
     nonnegativeFloatArray = FloatArrayBoundedValidator()
     nonnegativeFloatArray.setLower(0.)
     inWavelength = WorkspaceUnitValidator('Wavelength')
     self.declareProperty(
         MatrixWorkspaceProperty(Prop.INPUT_WS,
                                 defaultValue='',
                                 direction=Direction.Input,
                                 validator=inWavelength),
         doc='A reflected beam workspace (units wavelength).')
     self.declareProperty(MatrixWorkspaceProperty(
         Prop.OUTPUT_WS, defaultValue='', direction=Direction.Output),
                          doc='The summed foreground workspace.')
     self.declareProperty(Prop.SUBALG_LOGGING,
                          defaultValue=SubalgLogging.OFF,
                          validator=StringListValidator(
                              [SubalgLogging.OFF, SubalgLogging.ON]),
                          doc='Enable or disable child algorithm logging.')
     self.declareProperty(
         Prop.CLEANUP,
         defaultValue=common.WSCleanup.ON,
         validator=StringListValidator(
             [common.WSCleanup.ON, common.WSCleanup.OFF]),
         doc='Enable or disable intermediate workspace cleanup.')
     self.declareProperty(Prop.SUM_TYPE,
                          defaultValue=SumType.IN_LAMBDA,
                          validator=StringListValidator(
                              [SumType.IN_LAMBDA, SumType.IN_Q]),
                          doc='Type of summation to perform.')
     self.declareProperty(MatrixWorkspaceProperty(
         Prop.DIRECT_FOREGROUND_WS,
         defaultValue='',
         direction=Direction.Input,
         optional=PropertyMode.Optional,
         validator=inWavelength),
                          doc='Summed direct beam workspace.')
     self.declareProperty(
         IntArrayProperty(Prop.FOREGROUND_INDICES,
                          values=[
                              Property.EMPTY_INT, Property.EMPTY_INT,
                              Property.EMPTY_INT
                          ],
                          validator=threeNonnegativeInts),
         doc=
         'A three element array of foreground start, centre and end workspace indices.'
     )
     self.declareProperty(
         MatrixWorkspaceProperty(Prop.DIRECT_WS,
                                 defaultValue='',
                                 direction=Direction.Input,
                                 optional=PropertyMode.Optional,
                                 validator=inWavelength),
         doc='The (not summed) direct beam workspace in wavelength.')
     self.declareProperty(FloatArrayProperty(
         Prop.WAVELENGTH_RANGE,
         values=[0.],
         validator=nonnegativeFloatArray),
                          doc='The wavelength bounds when summing in Q.')
Пример #20
0
    def PyInit(self):

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

        self.declareProperty(
            FileProperty('MapFile',
                         '',
                         action=FileAction.OptionalLoad,
                         extensions=['map', 'xml']),
            doc='Filename of the detector grouping map file to use. \n'
            'By default all the pixels will be summed per each tube. \n'
            'Use .map or .xml file (see GroupDetectors documentation) '
            'only if different range is needed for each tube.')

        self.declareProperty(
            name='ManualPSDIntegrationRange',
            defaultValue=[1, 128],
            doc='Integration range of vertical pixels in each PSD tube. \n'
            'By default all the pixels will be summed per each tube. \n'
            'Use this option if the same range (other than default) '
            'is needed for all the tubes.')

        self.declareProperty(name='Analyser',
                             defaultValue='silicon',
                             validator=StringListValidator(['silicon']),
                             doc='Analyser crystal.')

        self.declareProperty(name='Reflection',
                             defaultValue='111',
                             validator=StringListValidator(['111', '311']),
                             doc='Analyser reflection.')

        self.declareProperty(
            name='CropDeadMonitorChannels',
            defaultValue=False,
            doc='Whether or not to exclude the first and last few channels '
            'with 0 monitor count in the energy transfer formula.')

        self.declareProperty(WorkspaceGroupProperty(
            'OutputWorkspace', '', direction=Direction.Output),
                             doc='Group name for the reduced workspace(s).')

        self.declareProperty(name='SpectrumAxis',
                             defaultValue='SpectrumNumber',
                             validator=StringListValidator(
                                 ['SpectrumNumber', '2Theta', 'Q', 'Q2']),
                             doc='The spectrum axis conversion target.')

        self.declareProperty(name='NormaliseTo',
                             defaultValue='Monitor',
                             validator=StringListValidator(['Monitor',
                                                            'None']),
                             doc='Choose to normalise to monitor.')

        self.declareProperty(
            name='MonitorCutoff',
            defaultValue=0.5,
            validator=FloatBoundedValidator(lower=0., upper=1.),
            doc=
            'Choose the cutoff fraction wrt the maximum of the monitor counts.'
        )

        self.declareProperty(
            WorkspaceProperty('InputElasticChannelWorkspace',
                              '',
                              direction=Direction.Input,
                              optional=PropertyMode.Optional),
            doc='The name of the input elastic channel workspace.')

        self.declareProperty(
            WorkspaceProperty('OutputElasticChannelWorkspace',
                              '',
                              direction=Direction.Output,
                              optional=PropertyMode.Optional),
            doc='The name of the output elastic channel workspace.')

        self.declareProperty(name='ElasticPeakFitting',
                             defaultValue='FitAllPixelGroups',
                             validator=StringListValidator(
                                 ['FitAllPixelGroups', 'FitEquatorialOnly']),
                             doc='Choose the method for calibrating TOF axes.')

        self.declareProperty(
            name='GroupPixelsBy',
            defaultValue=4,
            validator=IntBoundedValidator(lower=1, upper=128),
            doc=
            'Choose how to group the pixels for elastic peak fitting; must be a power of 2.'
        )

        self.declareProperty(FloatArrayProperty("SampleCoordinates",
                                                [0., 0., 0.],
                                                FloatArrayLengthValidator(3),
                                                direction=Direction.Input),
                             doc='The sample coordinates X, Y, Z.')

        self.declareProperty(name='PulseChopper',
                             defaultValue='Auto',
                             validator=StringListValidator(
                                 ['Auto', '12', '34']),
                             doc='Define the pulse chopper.')

        bats_options = 'BATS only options'
        self.setPropertyGroup('MonitorCutoff', bats_options)
        self.setPropertyGroup('InputElasticChannelWorkspace', bats_options)
        self.setPropertyGroup('OutputElasticChannelWorkspace', bats_options)
        self.setPropertyGroup('ElasticPeakFitting', bats_options)
        self.setPropertyGroup('GroupPixelsBy', bats_options)
        self.setPropertyGroup('SampleCoordinates', bats_options)
        self.setPropertyGroup('PulseChopper', bats_options)

        self.declareProperty(
            name='GroupDetectors',
            defaultValue=True,
            doc=
            'Group the pixels using the range, tube-by-tube (default) or in a custom way; \n'
            'it is not recommended to group the detectors at this stage, \n'
            'in order to get absorption corrections right, \n'
            'however the default value is True for backwards compatibility.')
    def PyInit(self):
        # Input validators
        array_length_three = FloatArrayLengthValidator(3)
        # Properties
        self.declareProperty('RunNumbers', '', 'Sample run numbers')

        self.declareProperty(FileProperty(name='MaskFile',
                                          defaultValue=self._mask_file,
                                          action=FileAction.OptionalLoad,
                                          extensions=['.xml']),
                             doc='See documentation for latest mask files.')

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

        #
        # Background for the sample runs
        #
        background_title = 'Background runs'
        self.declareProperty('BackgroundRuns', '', 'Background run numbers')
        self.setPropertyGroup('BackgroundRuns', background_title)
        self.declareProperty("BackgroundScale",
                             1.0,
                             doc='The background will be scaled by this ' +
                             'number before being subtracted.')
        self.setPropertyGroup('BackgroundScale', background_title)
        #
        # Vanadium
        #
        vanadium_title = 'Vanadium runs'
        self.declareProperty('VanadiumRuns', '', 'Vanadium run numbers')
        self.setPropertyGroup('VanadiumRuns', vanadium_title)

        #
        # Single Crystal Diffraction
        #
        crystal_diffraction_title = 'Single Crystal Diffraction'
        self.declareProperty('PsiAngleLog',
                             'SE50Rot',
                             direction=Direction.Input,
                             doc='log entry storing rotation of the sample'
                             'around the vertical axis')
        self.declareProperty('PsiOffset',
                             0.0,
                             direction=Direction.Input,
                             doc='Add this quantity to PsiAngleLog')
        self.declareProperty(FloatArrayProperty('LatticeSizes', [0, 0, 0],
                                                array_length_three,
                                                direction=Direction.Input),
                             doc='three item comma-separated list "a, b, c"')
        self.declareProperty(
            FloatArrayProperty('LatticeAngles', [90.0, 90.0, 90.0],
                               array_length_three,
                               direction=Direction.Input),
            doc='three item comma-separated ' + 'list "alpha, beta, gamma"')
        #    Reciprocal vector to be aligned with incoming beam
        self.declareProperty(FloatArrayProperty('VectorU', [1, 0, 0],
                                                array_length_three,
                                                direction=Direction.Input),
                             doc='three item, comma-separated, HKL indexes'
                             'of the diffracting plane')
        #    Reciprocal vector orthogonal to VectorU and in-plane with
        #    incoming beam
        self.declareProperty(FloatArrayProperty('VectorV', [0, 1, 0],
                                                array_length_three,
                                                direction=Direction.Input),
                             doc='three item, comma-separated, HKL indexes'
                             'of the direction perpendicular to VectorV'
                             'and the vertical axis')
        #    Abscissa view
        self.declareProperty(FloatArrayProperty('Uproj', [1, 0, 0],
                                                array_length_three,
                                                direction=Direction.Input),
                             doc='three item comma-separated Abscissa view'
                             'of the diffraction pattern')
        #    Ordinate view
        self.declareProperty(FloatArrayProperty('Vproj', [0, 1, 0],
                                                array_length_three,
                                                direction=Direction.Input),
                             doc='three item comma-separated Ordinate view'
                             'of the diffraction pattern')
        #    Hidden axis
        self.declareProperty(FloatArrayProperty('Wproj', [0, 0, 1],
                                                array_length_three,
                                                direction=Direction.Input),
                             doc='Hidden axis view')
        #    Binnin in reciprocal slice
        self.declareProperty('NBins',
                             400,
                             direction=Direction.Input,
                             doc='number of bins in the HKL slice')

        for a_property in ('PsiAngleLog', 'PsiOffset', 'LatticeSizes',
                           'LatticeAngles', 'VectorU', 'VectorV', 'Uproj',
                           'Vproj', 'Wproj', 'NBins'):
            self.setPropertyGroup(a_property, crystal_diffraction_title)
Пример #22
0
 def PyInit(self):
     validator = FloatArrayBoundedValidator(lower, upper)
     self.declareProperty(FloatArrayProperty("Input", validator))
    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.')
Пример #24
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')
Пример #25
0
    def PyInit(self):
        self.declareProperty(IMDHistoWorkspaceProperty("InputWorkspace", "",
                                                       optional=PropertyMode.Mandatory,
                                                       direction=Direction.Input),
                             "Input Workspace with HKL dimensions centered on zero.")
        self.declareProperty(WorkspaceProperty("IntermediateWorkspace", "",
                                               optional=PropertyMode.Optional,
                                               direction=Direction.Output),
                             "The resulting workspace after reflection removal and filters applied. What is the input of the FFT.")
        self.declareProperty(WorkspaceProperty("OutputWorkspace", "",
                                               optional=PropertyMode.Mandatory,
                                               direction=Direction.Output),
                             "Output Workspace")

        self.declareProperty("RemoveReflections", True, "Remove HKL reflections")
        condition = EnabledWhenProperty("RemoveReflections", PropertyCriterion.IsDefault)
        self.declareProperty("Shape", "sphere", doc="Shape to cut out reflections",
                             validator=StringListValidator(['sphere', 'cube']))
        self.setPropertySettings("Shape", condition)
        val_min_zero = FloatArrayBoundedValidator()
        val_min_zero.setLower(0.)
        self.declareProperty(FloatArrayProperty("Size", [0.2], validator=val_min_zero),
                             "Width of cube/diameter of sphere used to remove reflections, in (HKL) (one or three values)")
        self.setPropertySettings("Size", condition)
        self.declareProperty("SpaceGroup", "",
                             doc="Space group for reflection removal, either full name or number. If empty all HKL's will be removed.")
        self.setPropertySettings("SpaceGroup", condition)

        self.declareProperty("CropSphere", False, "Limit min/max q values. Can help with edge effects.")
        condition = EnabledWhenProperty("CropSphere", PropertyCriterion.IsNotDefault)
        self.declareProperty(FloatArrayProperty("SphereMin", [Property.EMPTY_DBL], validator=val_min_zero),
                             "HKL values below which will be removed (one or three values)")
        self.setPropertySettings("SphereMin", condition)
        self.declareProperty(FloatArrayProperty("SphereMax", [Property.EMPTY_DBL], validator=val_min_zero),
                             "HKL values above which will be removed (one or three values)")
        self.setPropertySettings("SphereMax", condition)
        self.declareProperty("FillValue", Property.EMPTY_DBL, "Value to replace with outside sphere")
        self.setPropertySettings("FillValue", condition)

        self.declareProperty("Convolution", True, "Apply convolution to fill in removed reflections")
        condition = EnabledWhenProperty("Convolution", PropertyCriterion.IsDefault)
        self.declareProperty("ConvolutionWidth", 2.0, validator=FloatBoundedValidator(0.),
                             doc="Width of gaussian convolution in pixels")
        self.setPropertySettings("ConvolutionWidth", condition)
        self.declareProperty("Deconvolution", False, "Apply deconvolution after fourier transform")
        self.setPropertySettings("Deconvolution", condition)

        # Reflections
        self.setPropertyGroup("RemoveReflections","Reflection Removal")
        self.setPropertyGroup("Shape","Reflection Removal")
        self.setPropertyGroup("Size","Reflection Removal")
        self.setPropertyGroup("SpaceGroup","Reflection Removal")

        # Sphere
        self.setPropertyGroup("CropSphere","Cropping to a sphere")
        self.setPropertyGroup("SphereMin","Cropping to a sphere")
        self.setPropertyGroup("SphereMax","Cropping to a sphere")
        self.setPropertyGroup("FillValue","Cropping to a sphere")

        # Convolution
        self.setPropertyGroup("Convolution","Convolution")
        self.setPropertyGroup("ConvolutionWidth","Convolution")
        self.setPropertyGroup("Deconvolution","Convolution")
 def PyInit(self):
     int_validator = IntArrayOrderedPairsValidator()
     self.declareProperty(IntArrayProperty("IntInput", int_validator))
     float_validator = FloatArrayOrderedPairsValidator()
     self.declareProperty(FloatArrayProperty("FloatInput", float_validator))
Пример #27
0
    def PyInit(self):
        # ----------
        # INPUT
        # ----------
        self.declareProperty(
            PropertyManagerProperty('SANSState'),
            doc='A property manager which fulfills the SANSState contract.')

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

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

        self.declareProperty(
            "MoveWorkspace",
            defaultValue=False,
            direction=Direction.Input,
            doc=
            "Move the workspace according to the SANSState setting. This might be useful"
            "for manual inspection.")

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

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

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

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

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

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

        self.declareProperty('NumberOfCanScatterWorkspaces',
                             defaultValue=default_number_of_workspaces,
                             direction=Direction.Output,
                             doc='The number of workspace for can scatter.')
        self.declareProperty(
            'NumberOfCanTransmissionWorkspaces',
            defaultValue=default_number_of_workspaces,
            direction=Direction.Output,
            doc='The number of workspace for can transmission.')
        self.declareProperty('NumberOfCanDirectWorkspaces',
                             defaultValue=default_number_of_workspaces,
                             direction=Direction.Output,
                             doc='The number of workspace for can direct.')
    def PyInit(self):
        # Input properties
        self.declareProperty(StringArrayProperty(name='InputFiles'),
                             doc='Comma separated list of input files')

        self.declareProperty(
            name='SumFiles',
            defaultValue=False,
            doc='Toggle input file summing or sequential processing')

        self.declareProperty(name='LoadLogFiles',
                             defaultValue=True,
                             doc='Load log files when loading runs')

        self.declareProperty(WorkspaceProperty('CalibrationWorkspace',
                                               '',
                                               direction=Direction.Input,
                                               optional=PropertyMode.Optional),
                             doc='Workspace containing calibration data')

        # Instrument configuration properties
        self.declareProperty(name='Instrument',
                             defaultValue='',
                             validator=StringListValidator(
                                 ['IRIS', 'OSIRIS', 'TOSCA', 'TFXA']),
                             doc='Instrument used during run.')
        self.declareProperty(name='Analyser',
                             defaultValue='',
                             validator=StringListValidator(
                                 ['graphite', 'mica', 'fmica']),
                             doc='Analyser bank used during run.')
        self.declareProperty(
            name='Reflection',
            defaultValue='',
            validator=StringListValidator(['002', '004', '006']),
            doc='Reflection number for instrument setup during run.')

        self.declareProperty(
            name='Efixed',
            defaultValue=Property.EMPTY_DBL,
            validator=FloatBoundedValidator(0.0),
            doc=
            'Overrides the default Efixed value for the analyser/reflection selection.'
        )

        self.declareProperty(
            IntArrayProperty(name='SpectraRange',
                             values=[0, 1],
                             validator=IntArrayMandatoryValidator()),
            doc='Comma separated range of spectra number to use.')
        self.declareProperty(
            FloatArrayProperty(name='BackgroundRange'),
            doc=
            'Range of background to subtract from raw data in time of flight.')
        self.declareProperty(name='RebinString',
                             defaultValue='',
                             doc='Rebin string parameters.')
        self.declareProperty(name='DetailedBalance',
                             defaultValue=Property.EMPTY_DBL,
                             doc='')
        self.declareProperty(name='ScaleFactor',
                             defaultValue=1.0,
                             doc='Factor by which to scale result.')
        self.declareProperty(
            name='FoldMultipleFrames',
            defaultValue=True,
            doc='Folds multiple framed data sets into a single workspace.')

        # Spectra grouping options
        self.declareProperty(name='GroupingMethod',
                             defaultValue='IPF',
                             validator=StringListValidator([
                                 'Individual', 'All', 'File', 'Workspace',
                                 'IPF', 'Custom'
                             ]),
                             doc='Method used to group spectra.')
        self.declareProperty(WorkspaceProperty('GroupingWorkspace',
                                               '',
                                               direction=Direction.Input,
                                               optional=PropertyMode.Optional),
                             doc='Workspace containing spectra grouping.')
        self.declareProperty(name='GroupingString',
                             defaultValue='',
                             direction=Direction.Input,
                             doc='Spectra to group as string')
        self.declareProperty(FileProperty('MapFile',
                                          '',
                                          action=FileAction.OptionalLoad,
                                          extensions=['.map']),
                             doc='Workspace containing spectra grouping.')

        # Output properties
        self.declareProperty(name='UnitX',
                             defaultValue='DeltaE',
                             validator=StringListValidator(
                                 ['DeltaE', 'DeltaE_inWavenumber']),
                             doc='X axis units for the result workspace.')

        self.declareProperty(
            WorkspaceGroupProperty('OutputWorkspace',
                                   '',
                                   direction=Direction.Output),
            doc='Workspace group for the resulting workspaces.')
Пример #29
0
    def PyInit(self):
        validator = IntArrayBoundedValidator(lower=0)
        self.declareProperty(
            IntArrayProperty("RunNumbers",
                             values=[0],
                             direction=Direction.Input,
                             validator=validator),
            "Run numbers to process, comma separated")
        self.declareProperty(
            'Background',
            Property.EMPTY_INT,
            doc='Background to subtract from each individual run')

        self.declareProperty(
            "LiveData", False,
            "Read live data - requires a saved run in the current IPTS " +
            "with the same Instrument configuration as the live run")

        mask = [
            "None", "Horizontal", "Vertical", "Masking Workspace",
            "Custom - xml masking file"
        ]
        self.declareProperty("Masking", "None", StringListValidator(mask),
                             "Mask to be applied to the data")

        self.declareProperty(
            WorkspaceProperty("MaskingWorkspace", "", Direction.Input,
                              PropertyMode.Optional),
            "The workspace containing the mask.")

        self.declareProperty(FileProperty(name="MaskingFilename",
                                          defaultValue="",
                                          direction=Direction.Input,
                                          action=FileAction.OptionalLoad),
                             doc="The file containing the xml mask.")

        self.declareProperty(
            name="Calibration",
            defaultValue="Convert Units",
            validator=StringListValidator(
                ['Convert Units', 'Calibration File', 'DetCal File']),
            direction=Direction.Input,
            doc="The type of conversion to d_spacing to be used.")

        self.declareProperty(
            FileProperty(name="CalibrationFilename",
                         defaultValue="",
                         extensions=['.h5', '.cal'],
                         direction=Direction.Input,
                         action=FileAction.OptionalLoad),
            doc="The calibration file to convert to d_spacing.")

        self.declareProperty(
            MultipleFileProperty(name='DetCalFilename',
                                 extensions=['.detcal'],
                                 action=FileAction.OptionalLoad),
            'ISAW DetCal file')

        self.declareProperty(
            FloatArrayProperty("Binning", [0.5, -0.004, 7.0]),
            "Min, Step, and Max of d-space bins.  Logarithmic binning is used if Step is negative."
        )

        nor_corr = [
            "None", "From Workspace", "From Processed Nexus",
            "Extracted from Data"
        ]
        self.declareProperty(
            "Normalization", nor_corr[0], StringListValidator(nor_corr),
            "If needed what type of input to use as normalization, Extracted from "
            +
            "Data uses a background determination that is peak independent.This "
            +
            "implemantation can be tested in algorithm SNAP Peak Clipping Background"
        )

        self.declareProperty(
            FileProperty(name="NormalizationFilename",
                         defaultValue="",
                         direction=Direction.Input,
                         action=FileAction.OptionalLoad),
            doc="The file containing the processed nexus for normalization.")

        self.declareProperty(
            WorkspaceProperty("NormalizationWorkspace", "", Direction.Input,
                              PropertyMode.Optional),
            "The workspace containing the normalization data.")

        self.declareProperty(
            "PeakClippingWindowSize", 10,
            "Read live data - requires a saved run in the current " +
            "IPTS with the same Instrumnet configuration")

        self.declareProperty(
            "SmoothingRange", 10,
            "Read live data - requires a saved run in the " +
            "current IPTS with the same Instrumnet configuration")

        grouping = ["All", "Column", "Banks", "Modules", "2_4 Grouping"]
        self.declareProperty(
            "GroupDetectorsBy", grouping[0], StringListValidator(grouping),
            "Detector groups to use for future focussing: " +
            "All detectors as one group, Groups (East,West for " +
            "SNAP), Columns for SNAP, detector banks")

        self.declareProperty(
            "MaxChunkSize", 16.,
            "Specify maximum Gbytes of file to read in one chunk. Zero reads the whole file at once."
        )

        mode = ["Set-Up", "Production"]
        self.declareProperty(
            "ProcessingMode", mode[1], StringListValidator(mode),
            "Set-Up Mode is used for establishing correct parameters. Production "
            + "Mode only Normalized workspace is kept for each run.")

        final_units = ['dSpacing', 'MomentumTransfer', 'Wavelength']
        self.declareProperty(
            "FinalUnits", final_units[0], StringListValidator(final_units),
            "Units to convert the data to at the end of processing")

        self.declareProperty(
            name="OptionalPrefix",
            defaultValue="",
            direction=Direction.Input,
            doc="Optional Prefix to be added to workspaces and output filenames"
        )

        self.declareProperty(
            "SaveData", False, "Save data in the following formats: Ascii- " +
            "d-spacing ,Nexus Processed,GSAS and Fullprof")

        self.declareProperty(FileProperty(name="OutputDirectory",
                                          defaultValue="",
                                          action=FileAction.OptionalDirectory),
                             doc='Default value is proposal shared directory')
Пример #30
0
    def PyInit(self):
        # input
        self.declareProperty(MatrixWorkspaceProperty(
            'InputWorkspace',
            '',
            direction=Direction.Input,
            optional=PropertyMode.Mandatory),
                             doc='Particle counts as a function of wavelength')

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        self.declareProperty(
            MatrixWorkspaceProperty('OutputWorkspaceTransmissionFit',
                                    '',
                                    direction=Direction.Output),
            # This works only when transmission is True. Problems starts when it is not...
            doc='Counts vs wavelength, fit for the sample transmission')