def PyInit(self):
        validator = StringArrayLengthValidator()
        validator.setLengthMin(
            2)  # even for workspacegroups at least 2 (SF, NSF) must be given

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

        return
Exemplo n.º 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
Exemplo n.º 3
0
    def test_dtype_function_calls(self):
        """
        Tests the dtype() function call for the data types stored in the array.
        """
        # Set up
        direc = Direction.Output
        validator = NullValidator()

        # Create float array
        float_input_values = [1.1, 2.5, 5.6, 4.6, 9.0, 6.0]
        float_arr = FloatArrayProperty("floats", float_input_values, validator,
                                       direc)

        # Create int array
        int_input_values = [1, 2, 5, 4, 9, 6]
        int_arr = IntArrayProperty("integers", int_input_values, validator,
                                   direc)

        # Create string array
        str_input_values = ["a", "b", "c", "d", "e"]
        str_arr = StringArrayProperty("letters", str_input_values, validator,
                                      direc)

        # Test
        self.assertEquals(float_arr.dtype(), "f")
        self.assertEquals(int_arr.dtype(), "i")
        self.assertEquals(str_arr.dtype(), "S1")
Exemplo n.º 4
0
    def PyInit(self):
        validator = StringArrayLengthValidator()
        validator.setLengthMin(1)  # one group may be given
        self.declareProperty(
            StringArrayProperty(name="InputWorkspaces",
                                direction=Direction.Input,
                                validator=validator),
            doc="Comma separated list of workspaces or groups of workspaces.")

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

        return
 def PyInit(self):
     """Initialize the input and output properties of the algorithm."""
     mandatoryInputRuns = CompositeValidator()
     mandatoryInputRuns.add(StringArrayMandatoryValidator())
     lenValidator = StringArrayLengthValidator()
     lenValidator.setLengthMin(1)
     mandatoryInputRuns.add(lenValidator)
     self.declareProperty(
         StringArrayProperty(Prop.RUNS,
                             values=[],
                             validator=mandatoryInputRuns),
         doc='A list of run numbers or workspace names for the input runs. '
         'Multiple runs will be summed before reduction.')
     self.declareProperty(
         StringArrayProperty(Prop.FIRST_TRANS_RUNS, values=[]),
         doc=
         'A list of run numbers or workspace names for the first transmission run. '
         'Multiple runs will be summed before reduction.')
     self.declareProperty(
         StringArrayProperty(Prop.SECOND_TRANS_RUNS, values=[]),
         doc=
         'A list of run numbers or workspace names for the second transmission run. '
         'Multiple runs will be summed before reduction.')
     self._declareSliceAlgorithmProperties()
     self._declareReductionAlgorithmProperties()
     self.declareProperty(Prop.GROUP_TOF,
                          True,
                          doc='If true, group the input TOF workspace')
     self.declareProperty(
         Prop.RELOAD,
         True,
         doc=
         'If true, reload input workspaces if they are of the incorrect type'
     )
     self.declareProperty(
         WorkspaceProperty(Prop.OUTPUT_WS,
                           '',
                           optional=PropertyMode.Optional,
                           direction=Direction.Output),
         doc='The output workspace, or workspace group if sliced.')
     self.declareProperty(
         WorkspaceProperty(Prop.OUTPUT_WS_BINNED,
                           '',
                           optional=PropertyMode.Optional,
                           direction=Direction.Output),
         doc='The binned output workspace, or workspace group if sliced.')
     self.declareProperty(
         WorkspaceProperty(Prop.OUTPUT_WS_LAM,
                           '',
                           optional=PropertyMode.Optional,
                           direction=Direction.Output),
         doc=
         'The output workspace in wavelength, or workspace group if sliced.'
     )
Exemplo n.º 6
0
    def test_construct_numpy_array_with_given_dtype_string(self):
        # Set up
        direc = Direction.Output
        validator = NullValidator()

        # Create string array
        str_input_values = ["hello", "testing", "word", "another word", "word"]
        str_arr = StringArrayProperty("letters", str_input_values, validator, direc)

        # Use the returned dtype() to check it works with numpy arrays
        x = np.array(str_input_values, dtype=str_arr.dtype())
        self.assertIsInstance(x, np.ndarray)
        # Expect longest string to be returned
        self.assertEquals(x.dtype, "S12")
Exemplo n.º 7
0
    def test_construct_numpy_array_with_given_dtype_string(self):
        # Set up
        direc = Direction.Output
        validator = NullValidator()

        # Create string array
        str_input_values = ["hello", "testing", "word", "another word", "word"]
        str_arr = StringArrayProperty("letters", str_input_values, validator,
                                      direc)

        # Use the returned dtype() to check it works with numpy arrays
        x = np.array(str_input_values, dtype=str_arr.dtype())
        self.assertIsInstance(x, np.ndarray)
        # Expect longest string to be returned
        self.assertEquals(x.dtype, "S12")
Exemplo n.º 8
0
    def PyInit(self):
        self.declareProperty(
            mantid.api.WorkspaceProperty('InputWorkspace', '',
                                         mantid.kernel.Direction.Input),
            'Workspace to plot')
        self.declareProperty(mantid.api.FileProperty(
            'OutputFilename',
            '',
            action=mantid.api.FileAction.OptionalSave,
            extensions=['.png']),
                             doc='Name of the image file to savefile.')
        if have_plotly:
            outputTypes = ['image', 'plotly', 'plotly-full']
        else:
            outputTypes = ['image']
        self.declareProperty('OutputType', 'image',
                             StringListValidator(outputTypes),
                             'Method for rendering plot')
        self.declareProperty(
            'XLabel', '',
            'Label on the X axis. If empty, it will be taken from workspace')
        self.declareProperty(
            'YLabel', '',
            'Label on the Y axis. If empty, it will be taken from workspace')
        self.declareProperty(
            StringArrayProperty('SpectraNames', [], direction=Direction.Input),
            'Override with custom names for spectra')
        self.declareProperty('Result', '', Direction.Output)

        self.declareProperty(
            'PopCanvas', False,
            'If true, a Matplotlib canvas will be popped out '
            ', which contains the saved plot.')
 def PyInit(self):
     self.declareProperty(
         StringArrayProperty(self._RUNS,
                             values=[],
                             validator=self._get_input_runs_validator()),
         doc=
         'A list of run numbers or workspace names to load and preprocess')
     self.declareProperty(
         self._EVENT_MODE,
         False,
         direction=Direction.Input,
         doc='If true, load the input workspaces as event data')
     self.declareProperty(
         MatrixWorkspaceProperty(self._OUTPUT_WS,
                                 '',
                                 direction=Direction.Output),
         doc=
         'The preprocessed output workspace. If multiple input runs are specified '
         'they will be summed into a single output workspace.')
     self.declareProperty(
         MatrixWorkspaceProperty(self._MONITOR_WS,
                                 '',
                                 direction=Direction.Output,
                                 optional=PropertyMode.Optional),
         doc=
         'The loaded monitors workspace. This is only output in event mode.'
     )
Exemplo n.º 10
0
 def _declareRunProperties(self):
     mandatoryInputRuns = CompositeValidator()
     mandatoryInputRuns.add(StringArrayMandatoryValidator())
     lenValidator = StringArrayLengthValidator()
     lenValidator.setLengthMin(1)
     mandatoryInputRuns.add(lenValidator)
     # Add property for the input runs
     self.declareProperty(
         StringArrayProperty(Prop.RUNS,
                             values=[],
                             validator=mandatoryInputRuns),
         doc='A list of run numbers or workspace names for the input runs. '
         'Multiple runs will be summed before reduction.')
     # Add properties from child algorithm
     properties = [
         'ThetaIn',
         'ThetaLogName',
     ]
     self.copyProperties('ReflectometryReductionOneAuto', properties)
     self._reduction_properties += properties
     # Add properties for settings to apply to input runs
     self.declareProperty(
         Prop.RELOAD,
         True,
         doc=
         'If true, reload input workspaces if they are of the incorrect type'
     )
     self.declareProperty(Prop.GROUP_TOF,
                          True,
                          doc='If true, group the TOF workspaces')
 def PyInit(self):
     """Initialize the input and output properties of the algorithm."""
     mandatoryInputWorkspaces = CompositeValidator()
     mandatoryInputWorkspaces.add(StringArrayMandatoryValidator())
     mandatoryInputWorkspaces.add(StringArrayLengthValidator(1, 4))
     self.declareProperty(
         StringArrayProperty(Prop.INPUT_WS,
                             values=[],
                             validator=mandatoryInputWorkspaces),
         doc='A set of polarized workspaces, in wavelength.')
     self.declareProperty(
         WorkspaceGroupProperty(Prop.OUTPUT_WS,
                                defaultValue='',
                                direction=Direction.Output),
         doc='A group of polarization efficiency corrected workspaces.')
     self.declareProperty(Prop.SUBALG_LOGGING,
                          defaultValue=SubalgLogging.OFF,
                          validator=StringListValidator(
                              [SubalgLogging.OFF, SubalgLogging.ON]),
                          doc='Enable or disable child algorithm logging.')
     self.declareProperty(
         Prop.CLEANUP,
         defaultValue=utils.Cleanup.ON,
         validator=StringListValidator(
             [utils.Cleanup.ON, utils.Cleanup.OFF]),
         doc='Enable or disable intermediate workspace cleanup.')
     self.declareProperty(
         FileProperty(Prop.EFFICIENCY_FILE,
                      defaultValue='',
                      action=FileAction.Load),
         doc='A file containing the polarization efficiency factors.')
Exemplo n.º 12
0
 def PyInit(self):
     self.declareProperty(
         mantid.api.WorkspaceProperty(
             "Workspace",
             "",
             direction=Direction.InOut,
             optional=mantid.api.PropertyMode.Optional),
         "Input workspace (optional)")
     allowedInstrumentList = StringListValidator([''] +
                                                 self.INSTRUMENT_LIST)
     self.declareProperty("Instrument",
                          "",
                          validator=allowedInstrumentList,
                          doc="One of the following instruments: " +
                          ', '.join(self.INSTRUMENT_LIST))
     self.declareProperty(StringArrayProperty(name='Components', values=[]),
                          doc='Component names to mask')
     self.declareProperty(
         IntArrayProperty(name="Bank", values=[]),
         doc="Bank(s) to be masked. If empty, will apply to all banks")
     self.declareProperty(
         "Tube",
         "",
         doc="Tube(s) to be masked. If empty, will apply to all tubes")
     self.declareProperty(
         "Pixel",
         "",
         doc="Pixel(s) to be masked. If empty, will apply to all pixels")
     self.declareProperty(IntArrayProperty(name="MaskedDetectors",
                                           direction=Direction.Output),
                          doc="List of  masked detectors")
Exemplo n.º 13
0
 def PyInit(self):
     self.declareProperty(
         FloatArrayProperty("FloatInput", FloatArrayMandatoryValidator()))
     self.declareProperty(
         IntArrayProperty("IntInput", IntArrayMandatoryValidator()))
     self.declareProperty(
         StringArrayProperty("StringInput",
                             StringArrayMandatoryValidator()))
Exemplo n.º 14
0
 def PyInit(self):
     """ Declare properties
     """
     validator = StringArrayLengthValidator()
     validator.setLengthMin(1)
     self.declareProperty(StringArrayProperty(name="InputWorkspaces", direction=Direction.Input, validator=validator),
                          doc="Comma separated list of workspaces or groups of workspaces.")
     self.declareProperty(WorkspaceProperty("OutputWorkspace", "", direction=Direction.Output),
                          doc="Name of the workspace that will contain the merged workspaces.")
     return
Exemplo n.º 15
0
 def _declareTransmissionProperties(self):
     # Add input transmission run properties
     self.declareProperty(
         StringArrayProperty(Prop.FIRST_TRANS_RUNS, values=[]),
         doc=
         'A list of run numbers or workspace names for the first transmission run. '
         'Multiple runs will be summed before reduction.')
     self.setPropertyGroup(Prop.FIRST_TRANS_RUNS, 'Transmission')
     self.declareProperty(
         StringArrayProperty(Prop.SECOND_TRANS_RUNS, values=[]),
         doc=
         'A list of run numbers or workspace names for the second transmission run. '
         'Multiple runs will be summed before reduction.')
     self.setPropertyGroup(Prop.SECOND_TRANS_RUNS, 'Transmission')
     # Add properties copied from child algorithm
     properties = [
         'Params', 'StartOverlap', 'EndOverlap', 'ScaleRHSWorkspace',
         'TransmissionProcessingInstructions'
     ]
     self.copyProperties('ReflectometryReductionOneAuto', properties)
     self._reduction_properties += properties
Exemplo n.º 16
0
    def declare_common_properties(self) -> None:
        """Declare properties common to Abins 1D and 2D versions"""
        self.declareProperty(FileProperty("VibrationalOrPhononFile", "",
                                          action=FileAction.Load,
                                          direction=Direction.Input,
                                          extensions=AB_INITIO_FILE_EXTENSIONS),
                             doc="File with the data from a vibrational or phonon calculation.")

        self.declareProperty(name="AbInitioProgram",
                             direction=Direction.Input,
                             defaultValue="CASTEP",
                             validator=StringListValidator(["CASTEP", "CRYSTAL", "DMOL3", "GAUSSIAN", "VASP"]),
                             doc="An ab initio program which was used for vibrational or phonon calculation.")

        self.declareProperty(WorkspaceProperty("OutputWorkspace", '', Direction.Output),
                             doc="Name to give the output workspace.")

        self.declareProperty(name="TemperatureInKelvin",
                             direction=Direction.Input,
                             defaultValue=10.0,
                             doc="Temperature in K for which dynamical structure factor S should be calculated.")

        self.declareProperty(name="BinWidthInWavenumber", defaultValue=1.0, doc="Width of bins used during rebining.")

        self.declareProperty(name="SampleForm",
                             direction=Direction.Input,
                             defaultValue="Powder",
                             validator=StringListValidator(ALL_SAMPLE_FORMS),
                             doc="Form of the sample: Powder.")

        self.declareProperty(StringArrayProperty("Atoms", Direction.Input),
                             doc="List of atoms to use to calculate partial S."
                                 "If left blank, workspaces with S for all types of atoms will be calculated. "
                                 "Element symbols will be interpreted as a sum of all atoms of that element in the "
                                 "cell. 'atomN' or 'atom_N' (where N is a positive integer) will be interpreted as "
                                 "individual atoms, indexing from 1 following the order of the input data.")

        self.declareProperty(name="SumContributions", defaultValue=False,
                             doc="Sum the partial dynamical structure factors into a single workspace.")

        self.declareProperty(name="SaveAscii", defaultValue=False,
                             doc="Write workspaces to .ascii files after computing them.")

        self.declareProperty(name="ScaleByCrossSection", defaultValue='Incoherent',
                             validator=StringListValidator(['Total', 'Incoherent', 'Coherent']),
                             doc="Scale the partial dynamical structure factors by the scattering cross section.")

        # Abins is supposed to support excitations up to fourth-order. Order 3 and 4 are currently disabled while the
        # weighting is being investigated; these intensities were unreasonably large in hydrogenous test cases
        self.declareProperty(name="QuantumOrderEventsNumber", defaultValue='1',
                             validator=StringListValidator(['1', '2']),
                             doc="Number of quantum order effects included in the calculation "
                                 "(1 -> FUNDAMENTALS, 2-> first overtone + FUNDAMENTALS + 2nd order combinations")
Exemplo n.º 17
0
    def PyInit(self):
        self.declareProperty(StringArrayProperty('InputWorkspace', direction=Direction.Input, validator=ADSValidator()),
                             doc="Input MD workspace (in Q-space) to use for peak finding")
        cell_type = StringListValidator()
        cell_type.addAllowedValue("Cubic")
        cell_type.addAllowedValue("Hexagonal")
        cell_type.addAllowedValue("Rhombohedral")
        cell_type.addAllowedValue("Tetragonal")
        cell_type.addAllowedValue("Orthorhombic")
        cell_type.addAllowedValue("Monoclinic")
        cell_type.addAllowedValue("Triclinic")
        self.declareProperty("CellType", "", cell_type, doc="Cell type to use for UB refining")

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

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

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

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

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

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

        lattice_params = ["LatticeA", "LatticeB", "LatticeC", "LatticeAlpha", "LatticeBeta", "LatticeGamma"]
        for param in lattice_params:
            self.setPropertyGroup(param, "Lattice Settings")
            self.setPropertySettings(param, EnabledWhenProperty("UseLattice", PropertyCriterion.IsNotDefault))
Exemplo n.º 18
0
 def PyInit(self):
     self.declareProperty(StringArrayProperty('InputWorkspaces', direction=Direction.Input, validator=ADSValidator()),
                          doc='List of workspaces or group workspace containing workspaces to be merged.')
     self.declareProperty(WorkspaceProperty('OutputWorkspace', '', direction=Direction.Output),
                          doc='The merged workspace.')
     self.declareProperty(FloatArrayProperty('XMin', [], direction=Direction.Input),
                          doc='Array of minimum X values for each workspace.')
     self.declareProperty(FloatArrayProperty('XMax', [], direction=Direction.Input),
                          doc='Array of maximum X values for each workspace.')
     self.declareProperty('CalculateScale', True,
                          doc='Calculate scale factor when matching spectra.')
     self.declareProperty('CalculateOffset', True,
                          doc='Calculate vertical shift when matching spectra.')
Exemplo n.º 19
0
    def PyInit(self):
        self.declareProperty(StringArrayProperty(name="WorkspaceNames",
                                                 direction=Direction.Input),
                             doc="List of Workspace names to merge.")

        self.declareProperty(
            WorkspaceProperty(name="OutputWorkspace",
                              defaultValue="MergedPoldiWorkspaces",
                              direction=Direction.Output),
            doc=
            "Workspace where all counts from the list workspaces have been added"
        )

        self.declareProperty("CheckInstruments", True, "If checked, only workspaces with equal"\
                                "instrument parameters are merged. Do not disable without a very good reason.")
Exemplo n.º 20
0
    def PyInit(self):

        self.declareProperty(
            WorkspaceProperty("Workspace",
                              "",
                              validator=InstrumentValidator(),
                              direction=Direction.InOut),
            doc="MatrixWorkspace or PeaksWorkspace with instrument.")

        # List of parameters
        self.declareProperty(
            StringArrayProperty("DetScaleList", direction=Direction.Input),
            doc=
            "Comma separated list detectorNumbers:detScales eg. 13:1.046504,14:1.259293"
        )
Exemplo n.º 21
0
    def test_dtype_function_calls(self):
        """
        Tests the dtype() function call for the data types stored in the array.
        """
        # Set up
        direc = Direction.Output
        validator = NullValidator()

        # Create float array
        float_input_values = [1.1, 2.5, 5.6, 4.6, 9.0, 6.0]
        float_arr = FloatArrayProperty("floats", float_input_values, validator, direc)

        # Create int array
        int_input_values = [1, 2, 5, 4, 9, 6]
        int_arr = IntArrayProperty("integers", int_input_values, validator, direc)

        # Create string array
        str_input_values = ["a", "b", "c", "d", "e"]
        str_arr = StringArrayProperty("letters", str_input_values, validator, direc)

        # Test
        self.assertEquals(float_arr.dtype(), "f")
        self.assertEquals(int_arr.dtype(), "i")
        self.assertEquals(str_arr.dtype(), "S1")
Exemplo n.º 22
0
    def PyInit(self):

        self.declareProperty(WorkspaceProperty("Workspace", "",
                                               validator=InstrumentValidator(),
                                               direction=Direction.InOut),
                             doc="MatrixWorkspace or PeaksWorkspace with instrument.")

        # List of parameters
        self.declareProperty(StringArrayProperty("DetScaleList",
                                                 direction=Direction.Input),
                             doc="Comma separated list detectorNumbers:detScales eg. 13:1.046504,14:1.259293")

        self.declareProperty(FileProperty(name="DetScaleFile", defaultValue="",
                                          action=FileAction.OptionalLoad,
                                          extensions=["txt"]),
                             "Optional text file with detector number and its scale on each line separated by spaces")
Exemplo n.º 23
0
 def PyInit(self):
     # Input
     self.declareProperty(
         StringArrayProperty(name="PeakWorkspaces",
                             direction=Direction.Input,
                             validator=ADSValidator()),
         doc='List of peak workspaces to use (must be more than'
         ' two peaks workspaces and each must contain at least 6 peaks.')
     positiveFloatValidator = FloatBoundedValidator(lower=0.0)
     angleValidator = FloatBoundedValidator(lower=0.0, upper=180.0)
     self.declareProperty(name="a",
                          defaultValue=-1.0,
                          direction=Direction.Input,
                          validator=positiveFloatValidator,
                          doc="Lattice parameter a")
     self.declareProperty(name="b",
                          defaultValue=-1.0,
                          direction=Direction.Input,
                          validator=positiveFloatValidator,
                          doc="Lattice parameter b")
     self.declareProperty(name="c",
                          defaultValue=-1.0,
                          direction=Direction.Input,
                          validator=positiveFloatValidator,
                          doc="Lattice parameter c")
     self.declareProperty(name="alpha",
                          defaultValue=-1.0,
                          direction=Direction.Input,
                          validator=angleValidator,
                          doc="Lattice angle alpha")
     self.declareProperty(name="beta",
                          defaultValue=-1.0,
                          direction=Direction.Input,
                          validator=angleValidator,
                          doc="Lattice angle beta")
     self.declareProperty(name="gamma",
                          defaultValue=-1.0,
                          direction=Direction.Input,
                          validator=angleValidator,
                          doc="Lattice angle gamma")
     self.declareProperty(name="Tolerance",
                          defaultValue=0.15,
                          direction=Direction.Input,
                          validator=positiveFloatValidator,
                          doc="Tolerance to index peaks in in H,K and L")
Exemplo n.º 24
0
    def PyInit(self):

        validator = StringArrayLengthValidator()
        validator.setLengthMin(1)  # group of workspaces may be given

        self.declareProperty(StringArrayProperty(name="WorkspaceNames",
                                                 direction=Direction.Input,
                                                 validator=validator),
                             doc="List of Workspace names to merge.")
        self.declareProperty(MatrixWorkspaceProperty(
            "OutputWorkspace", "", direction=Direction.Output),
                             doc="A workspace name to save the merged data.")
        H_AXIS = ["2theta", "|Q|", "d-Spacing"]
        self.declareProperty("HorizontalAxis",
                             "2theta",
                             StringListValidator(H_AXIS),
                             doc="X axis in the merged workspace")
        return
Exemplo n.º 25
0
 def PyInit(self):
     self.declareProperty(WorkspaceProperty("InputWorkspace", "",
                                            validator=InstrumentValidator(),
                                            direction=Direction.Input),
                          doc="Workspace containing the instrument to be exported")
     eulerConventions = ["ZXZ", "XYX", "YZY", "ZYZ", "XZX", "YXY",
                         "XYZ", "YZX", "ZXY", "XZY", "ZYX", "YXZ"]
     self.declareProperty(name="EulerConvention", defaultValue="YZY",
                          validator=StringListValidator(eulerConventions),
                          doc="Euler angles convention used when writing angles.")
     self.declareProperty(StringArrayProperty("Components",
                                              direction=Direction.Input),
                          doc="Comma separated list of instrument components to export")
     self.declareProperty(FileProperty(name="Filename",
                                       defaultValue="",
                                       action=FileAction.Save,
                                       extensions=[".xml"]),
                          doc="Save file")
Exemplo n.º 26
0
    def PyInit(self):
        # Input properties
        self.declareProperty(
            WorkspaceGroupProperty('InputWorkspace',
                                   '',
                                   direction=Direction.Input),
            doc='Workspace group for the workspaces to be sorted.')

        self.declareProperty('OutputGroupPrefix',
                             '',
                             doc='String to prefix the output groups.')
        self.declareProperty('OutputGroupSuffix',
                             '',
                             doc='String to suffix the output groups.')

        self.declareProperty(
            StringArrayProperty('OutputWorkspaceList', [],
                                direction=Direction.Output),
            doc='List of Workspace groups for the resulting workspaces.')
Exemplo n.º 27
0
    def PyInit(self):

        # Declare all properties
        self.declareProperty(name="AbInitioProgram",
                             direction=Direction.Input,
                             defaultValue="CASTEP",
                             validator=StringListValidator(["CASTEP", "CRYSTAL", "DMOL3", "GAUSSIAN"]),
                             doc="An ab initio program which was used for vibrational or phonon calculation.")

        self.declareProperty(FileProperty("VibrationalOrPhononFile", "",
                             action=FileAction.Load,
                             direction=Direction.Input,
                             extensions=["phonon", "out", "outmol", "log", "LOG"]),
                             doc="File with the data from a vibrational or phonon calculation.")

        self.declareProperty(FileProperty("ExperimentalFile", "",
                             action=FileAction.OptionalLoad,
                             direction=Direction.Input,
                             extensions=["raw", "dat"]),
                             doc="File with the experimental inelastic spectrum to compare.")

        self.declareProperty(name="TemperatureInKelvin",
                             direction=Direction.Input,
                             defaultValue=10.0,
                             doc="Temperature in K for which dynamical structure factor S should be calculated.")

        self.declareProperty(name="BinWidthInWavenumber",  defaultValue=1.0, doc="Width of bins used during rebining.")

        self.declareProperty(name="Scale", defaultValue=1.0,
                             doc='Scale the intensity by the given factor. Default is no scaling.')

        self.declareProperty(name="SampleForm",
                             direction=Direction.Input,
                             defaultValue="Powder",
                             validator=StringListValidator(AbinsModules.AbinsConstants.ALL_SAMPLE_FORMS),
                             # doc="Form of the sample: SingleCrystal or Powder.")
                             doc="Form of the sample: Powder.")

        self.declareProperty(name="Instrument",
                             direction=Direction.Input,
                             defaultValue="TOSCA",
                             # validator=StringListValidator(AbinsModules.AbinsConstants.ALL_INSTRUMENTS)
                             validator=StringListValidator(["TOSCA"]),
                             doc="Name of an instrument for which analysis should be performed.")

        self.declareProperty(StringArrayProperty("Atoms", Direction.Input),
                             doc="List of atoms to use to calculate partial S."
                                 "If left blank, workspaces with S for all types of atoms will be calculated.")

        self.declareProperty(name="SumContributions", defaultValue=False,
                             doc="Sum the partial dynamical structure factors into a single workspace.")

        self.declareProperty(name="ScaleByCrossSection", defaultValue='Incoherent',
                             validator=StringListValidator(['Total', 'Incoherent', 'Coherent']),
                             doc="Scale the partial dynamical structure factors by the scattering cross section.")

        self.declareProperty(name="QuantumOrderEventsNumber", defaultValue='1',
                             validator=StringListValidator(['1', '2', '3', '4']),
                             doc="Number of quantum order effects included in the calculation "
                                 "(1 -> FUNDAMENTALS, 2-> first overtone + FUNDAMENTALS + "
                                 "2nd order combinations, 3-> FUNDAMENTALS + first overtone + second overtone + 2nd "
                                 "order combinations + 3rd order combinations etc...)")

        self.declareProperty(WorkspaceProperty("OutputWorkspace", '', Direction.Output),
                             doc="Name to give the output workspace.")
Exemplo n.º 28
0
 def PyInit(self):
     self.declareProperty(
         StringArrayProperty("Input", Direction.Input),
         "string array")
Exemplo n.º 29
0
    def PyInit(self):
        self.declareProperty(ITableWorkspaceProperty(
            "CalibrationTable",
            "",
            optional=PropertyMode.Mandatory,
            direction=Direction.Input),
                             doc="Calibration table, currently only uses difc")

        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("Workspace",
                              "",
                              validator=InstrumentValidator(),
                              optional=PropertyMode.Optional,
                              direction=Direction.Input),
            doc="Workspace containing the instrument to be calibrated.")

        # Source
        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.")

        # Sample
        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.")

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

        # X position
        self.declareProperty(name="Xposition",
                             defaultValue=False,
                             doc="Refine Xposition")
        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)

        # Y position
        self.declareProperty(name="Yposition",
                             defaultValue=False,
                             doc="Refine Yposition")
        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")
        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)

        # euler angles convention
        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")
        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")
        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")
        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)

        # Translation
        self.setPropertyGroup("Xposition", "Translation")
        self.setPropertyGroup("MinXposition", "Translation")
        self.setPropertyGroup("MaxXposition", "Translation")
        self.setPropertyGroup("Yposition", "Translation")
        self.setPropertyGroup("MinYposition", "Translation")
        self.setPropertyGroup("MaxYposition", "Translation")
        self.setPropertyGroup("Zposition", "Translation")
        self.setPropertyGroup("MinZposition", "Translation")
        self.setPropertyGroup("MaxZposition", "Translation")

        # Rotation
        self.setPropertyGroup("EulerConvention", "Rotation")
        self.setPropertyGroup("AlphaRotation", "Rotation")
        self.setPropertyGroup("MinAlphaRotation", "Rotation")
        self.setPropertyGroup("MaxAlphaRotation", "Rotation")
        self.setPropertyGroup("BetaRotation", "Rotation")
        self.setPropertyGroup("MinBetaRotation", "Rotation")
        self.setPropertyGroup("MaxBetaRotation", "Rotation")
        self.setPropertyGroup("GammaRotation", "Rotation")
        self.setPropertyGroup("MinGammaRotation", "Rotation")
        self.setPropertyGroup("MaxGammaRotation", "Rotation")
    def PyInit(self):
        self.declareProperty(
            WorkspaceProperty('InputWorkspace',
                              '',
                              direction=Direction.Input,
                              validator=WorkspaceUnitValidator('TOF')),
            doc=
            'Powder event data, ideally from a highly symmetric space group',
        )
        self.declareProperty(name='OutputWorkspacesPrefix',
                             defaultValue='pdcal_',
                             direction=Direction.Input,
                             doc="Prefix to be added to output workspaces")

        # PDCalibration properties exposed, grouped
        property_names = ['TofBinning', 'PeakFunction', 'PeakPositions']
        self.copyProperties('PDCalibration', property_names)
        [
            self.setPropertyGroup(name, 'PDCalibration')
            for name in property_names
        ]

        # "Source Position" properties
        self.declareProperty(name='FixSource',
                             defaultValue=True,
                             doc="Fix source's distance from the sample")
        self.declareProperty(
            name='SourceToSampleDistance',
            defaultValue=20.004,
            doc=
            'Set this value for a fixed distance from source to sample, in meters'
        )
        self.setPropertySettings(
            'SourceToSampleDistance',
            EnabledWhenProperty("FixSource", PropertyCriterion.IsDefault))
        self.declareProperty(name='AdjustSource',
                             defaultValue=False,
                             doc='Adjust Z-coordinate of the source')
        self.declareProperty(
            name='SourceMaxTranslation',
            defaultValue=0.1,
            doc=
            'Maximum adjustment of source position along the beam (Z) axis (m)'
        )
        self.setPropertySettings(
            "SourceMaxTranslation",
            EnabledWhenProperty("AdjustSource",
                                PropertyCriterion.IsNotDefault))
        property_names = [
            'FixSource', 'SourceToSampleDistance', 'AdjustSource',
            'SourceMaxTranslation'
        ]
        [
            self.setPropertyGroup(name, 'Source Calibration')
            for name in property_names
        ]

        # AlignComponents properties
        self.declareProperty(name='FixY',
                             defaultValue=True,
                             doc="Vertical bank position is left unchanged")
        self.declareProperty(StringArrayProperty('ComponentList',
                                                 values=self._banks,
                                                 direction=Direction.Input),
                             doc='Comma separated list on banks to refine')
        self.declareProperty(
            name='ComponentMaxTranslation',
            defaultValue=0.02,
            doc=
            'Maximum translation of each component along either of the X, Y, Z axes (m)'
        )
        self.declareProperty(
            name='FixYaw',
            defaultValue=True,
            doc="Prevent rotations around the axis normal to the bank")
        self.declareProperty(
            name='ComponentMaxRotation',
            defaultValue=3.0,
            doc=
            'Maximum rotation of each component along either of the X, Y, Z axes (deg)'
        )
        property_names = [
            'FixY', 'ComponentList', 'ComponentMaxTranslation', 'FixYaw',
            'ComponentMaxRotation'
        ]
        [
            self.setPropertyGroup(name, 'Banks Calibration')
            for name in property_names
        ]

        #
        # Minimization Properties
        self.declareProperty(
            name='Minimizer',
            defaultValue='L-BFGS-B',
            direction=Direction.Input,
            validator=StringListValidator(
                ['L-BFGS-B', 'differential_evolution']),
            doc=
            'Minimizer to use, differential_evolution is more accurate and slower.'
        )
        self.declareProperty(
            name='MaxIterations',
            defaultValue=20,
            direction=Direction.Input,
            doc=
            'Maximum number of iterations for minimizer differential_evolution'
        )

        properties = ['Minimizer', 'MaxIterations']
        [self.setPropertyGroup(name, "Minimization") for name in properties]
Exemplo n.º 31
0
    def PyInit(self):
        """Initialize the algorithm's input and output properties."""
        PROPGROUP_BEAM_STOP_DIAGNOSTICS = 'Beam Stop Diagnostics'
        PROPGROUP_BKG_DIAGNOSTICS = 'Background Diagnostics'
        PROPGROUP_PEAK_DIAGNOSTICS = 'Elastic Peak Diagnostics'
        PROPGROUP_USER_MASK = 'Additional Masking'
        greaterThanUnityFloat = FloatBoundedValidator(lower=1)
        inputWorkspaceValidator = CompositeValidator()
        inputWorkspaceValidator.add(InstrumentValidator())
        inputWorkspaceValidator.add(WorkspaceUnitValidator('TOF'))
        positiveFloat = FloatBoundedValidator(lower=0)
        positiveIntArray = IntArrayBoundedValidator()
        positiveIntArray.setLower(0)
        scalingFactor = FloatBoundedValidator(lower=0, upper=1)

        # Properties.
        self.declareProperty(
            MatrixWorkspaceProperty(name=common.PROP_INPUT_WS,
                                    defaultValue='',
                                    validator=inputWorkspaceValidator,
                                    direction=Direction.Input),
            doc=
            "A 'raw' workspace from DirectILLCollectData to calculate the diagnostics from."
        )
        self.declareProperty(WorkspaceProperty(name=common.PROP_OUTPUT_WS,
                                               defaultValue='',
                                               direction=Direction.Output),
                             doc='A diagnostics mask 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(
            ITableWorkspaceProperty(name=common.PROP_EPP_WS,
                                    defaultValue='',
                                    direction=Direction.Input,
                                    optional=PropertyMode.Optional),
            doc='Table workspace containing results from the FindEPP algorithm.'
        )
        self.declareProperty(name=common.PROP_ELASTIC_PEAK_DIAGNOSTICS,
                             defaultValue=common.ELASTIC_PEAK_DIAGNOSTICS_AUTO,
                             validator=StringListValidator([
                                 common.ELASTIC_PEAK_DIAGNOSTICS_AUTO,
                                 common.ELASTIC_PEAK_DIAGNOSTICS_ON,
                                 common.ELASTIC_PEAK_DIAGNOSTICS_OFF
                             ]),
                             direction=Direction.Input,
                             doc='Enable or disable elastic peak diagnostics.')
        self.setPropertyGroup(common.PROP_ELASTIC_PEAK_DIAGNOSTICS,
                              PROPGROUP_PEAK_DIAGNOSTICS)
        self.declareProperty(
            name=common.PROP_ELASTIC_PEAK_SIGMA_MULTIPLIER,
            defaultValue=3.0,
            validator=positiveFloat,
            direction=Direction.Input,
            doc="Integration half width of the elastic peak in multiples " +
            " of 'Sigma' in the EPP table.")
        self.setPropertyGroup(common.PROP_ELASTIC_PEAK_SIGMA_MULTIPLIER,
                              PROPGROUP_PEAK_DIAGNOSTICS)
        self.declareProperty(name=common.PROP_PEAK_DIAGNOSTICS_LOW_THRESHOLD,
                             defaultValue=Property.EMPTY_DBL,
                             validator=positiveFloat,
                             direction=Direction.Input,
                             doc='Multiplier for lower acceptance limit ' +
                             'used in elastic peak diagnostics.')
        self.setPropertyGroup(common.PROP_PEAK_DIAGNOSTICS_LOW_THRESHOLD,
                              PROPGROUP_PEAK_DIAGNOSTICS)
        self.declareProperty(name=common.PROP_PEAK_DIAGNOSTICS_HIGH_THRESHOLD,
                             defaultValue=Property.EMPTY_DBL,
                             validator=greaterThanUnityFloat,
                             direction=Direction.Input,
                             doc='Multiplier for higher acceptance limit ' +
                             'used in elastic peak diagnostics.')
        self.setPropertyGroup(common.PROP_PEAK_DIAGNOSTICS_HIGH_THRESHOLD,
                              PROPGROUP_PEAK_DIAGNOSTICS)
        self.declareProperty(
            name=common.PROP_PEAK_DIAGNOSTICS_SIGNIFICANCE_TEST,
            defaultValue=Property.EMPTY_DBL,
            validator=positiveFloat,
            direction=Direction.Input,
            doc=
            'To fail the elastic peak diagnostics, the intensity must also exceed '
            +
            'this number of error bars with respect to the median intensity.')
        self.setPropertyGroup(common.PROP_PEAK_DIAGNOSTICS_SIGNIFICANCE_TEST,
                              PROPGROUP_PEAK_DIAGNOSTICS)
        self.declareProperty(name=common.PROP_BKG_DIAGNOSTICS,
                             defaultValue=common.BKG_DIAGNOSTICS_AUTO,
                             validator=StringListValidator([
                                 common.BKG_DIAGNOSTICS_AUTO,
                                 common.BKG_DIAGNOSTICS_ON,
                                 common.BKG_DIAGNOSTICS_OFF
                             ]),
                             direction=Direction.Input,
                             doc='Control the background diagnostics.')
        self.setPropertyGroup(common.PROP_BKG_DIAGNOSTICS,
                              PROPGROUP_BKG_DIAGNOSTICS)
        self.declareProperty(
            name=common.PROP_BKG_SIGMA_MULTIPLIER,
            defaultValue=10.0,
            validator=positiveFloat,
            direction=Direction.Input,
            doc=
            "Width of the range excluded from background integration around " +
            "the elastic peaks in multiplies of 'Sigma' in the EPP table")
        self.setPropertyGroup(common.PROP_BKG_SIGMA_MULTIPLIER,
                              PROPGROUP_BKG_DIAGNOSTICS)
        self.declareProperty(name=common.PROP_BKG_DIAGNOSTICS_LOW_THRESHOLD,
                             defaultValue=Property.EMPTY_DBL,
                             validator=positiveFloat,
                             direction=Direction.Input,
                             doc='Multiplier for lower acceptance limit ' +
                             'used in noisy background diagnostics.')
        self.setPropertyGroup(common.PROP_BKG_DIAGNOSTICS_LOW_THRESHOLD,
                              PROPGROUP_BKG_DIAGNOSTICS)
        self.declareProperty(name=common.PROP_BKG_DIAGNOSTICS_HIGH_THRESHOLD,
                             defaultValue=Property.EMPTY_DBL,
                             validator=greaterThanUnityFloat,
                             direction=Direction.Input,
                             doc='Multiplier for higher acceptance limit ' +
                             'used in noisy background diagnostics.')
        self.setPropertyGroup(common.PROP_BKG_DIAGNOSTICS_HIGH_THRESHOLD,
                              PROPGROUP_BKG_DIAGNOSTICS)
        self.declareProperty(
            name=common.PROP_BKG_DIAGNOSTICS_SIGNIFICANCE_TEST,
            defaultValue=Property.EMPTY_DBL,
            validator=positiveFloat,
            direction=Direction.Input,
            doc=
            'To fail the background diagnostics, the background level must also exceed '
            + 'this number of error bars with respect to the median level.')
        self.setPropertyGroup(common.PROP_BKG_DIAGNOSTICS_SIGNIFICANCE_TEST,
                              PROPGROUP_BKG_DIAGNOSTICS)
        self.declareProperty(name=common.PROP_BEAM_STOP_DIAGNOSTICS,
                             defaultValue=common.BEAM_STOP_DIAGNOSTICS_AUTO,
                             validator=StringListValidator([
                                 common.BEAM_STOP_DIAGNOSTICS_AUTO,
                                 common.BEAM_STOP_DIAGNOSTICS_ON,
                                 common.BEAM_STOP_DIAGNOSTICS_OFF
                             ]),
                             direction=Direction.Input,
                             doc='Control the beam stop diagnostics.')
        self.setPropertyGroup(common.PROP_BEAM_STOP_DIAGNOSTICS,
                              PROPGROUP_BEAM_STOP_DIAGNOSTICS)
        self.declareProperty(
            name=common.PROP_BEAM_STOP_THRESHOLD,
            defaultValue=0.67,
            validator=scalingFactor,
            direction=Direction.Input,
            doc=
            'Multiplier for the lower acceptance limit for beam stop diagnostics.'
        )
        self.setPropertyGroup(common.PROP_BEAM_STOP_THRESHOLD,
                              PROPGROUP_BEAM_STOP_DIAGNOSTICS)
        self.declareProperty(
            name=common.PROP_DEFAULT_MASK,
            defaultValue=common.DEFAULT_MASK_ON,
            validator=StringListValidator(
                [common.DEFAULT_MASK_ON, common.DEFAULT_MASK_OFF]),
            direction=Direction.Input,
            doc='Enable or disable instrument specific default mask.')
        self.declareProperty(IntArrayProperty(name=common.PROP_USER_MASK,
                                              values='',
                                              validator=positiveIntArray,
                                              direction=Direction.Input),
                             doc='List of spectra to mask.')
        self.setPropertyGroup(common.PROP_USER_MASK, PROPGROUP_USER_MASK)
        self.declareProperty(StringArrayProperty(
            name=common.PROP_USER_MASK_COMPONENTS,
            values='',
            direction=Direction.Input),
                             doc='List of instrument components to mask.')
        self.setPropertyGroup(common.PROP_USER_MASK_COMPONENTS,
                              PROPGROUP_USER_MASK)
        # Rest of the output properties
        self.declareProperty(
            ITableWorkspaceProperty(
                name=common.PROP_OUTPUT_DIAGNOSTICS_REPORT_WS,
                defaultValue='',
                direction=Direction.Output,
                optional=PropertyMode.Optional),
            doc='Output table workspace for detector diagnostics reporting.')
        self.setPropertyGroup(common.PROP_OUTPUT_DIAGNOSTICS_REPORT_WS,
                              common.PROPGROUP_OPTIONAL_OUTPUT)
        self.declareProperty(name=common.PROP_OUTPUT_DIAGNOSTICS_REPORT,
                             defaultValue='',
                             direction=Direction.Output,
                             doc='Diagnostics report as a string.')
        self.setPropertyGroup(common.PROP_OUTPUT_DIAGNOSTICS_REPORT,
                              common.PROPGROUP_OPTIONAL_OUTPUT)
Exemplo n.º 32
0
    def PyInit(self):

        mandatoryInputRuns = CompositeValidator()
        mandatoryInputRuns.add(StringArrayMandatoryValidator())
        self.declareProperty(StringArrayProperty('SampleRuns',
                                                 values=[],
                                                 validator=mandatoryInputRuns),
                             doc='Comma separated range of sample runs,\n'
                             ' eg [cycle::] 7333-7341,7345')

        self.declareProperty(
            name='EmptyRuns',
            defaultValue='',
            doc='Optional path followed by comma separated range of runs,\n'
            'looking for runs in the sample folder if path not included,\n'
            '  eg [cycle::] 6300-6308')

        self.declareProperty(name='ScaleEmptyRuns',
                             defaultValue=1.0,
                             doc='Scale the empty runs prior to subtraction')

        self.declareProperty(
            name='CalibrationRuns',
            defaultValue='',
            doc='Optional path followed by comma separated range of runs,\n'
            'looking for runs in the sample folder if path not included,\n'
            '  eg [cycle::] 6350-6365')

        self.declareProperty(
            name='EmptyCalibrationRuns',
            defaultValue='',
            doc='Optional path followed by comma separated range of runs,\n'
            'looking for runs in the sample folder if path not included,\n'
            '  eg [cycle::] 6370-6375')

        self.declareProperty(
            name='EnergyTransfer',
            defaultValue='0.0, 0.02, 3.0',
            doc='Energy transfer range in meV expressed as min, step, max')

        self.declareProperty(
            name='MomentumTransfer',
            defaultValue='',
            doc='Momentum transfer range in inverse Angstroms,\n'
            'expressed as min, step, max. Default estimates\n'
            'the max range based on energy transfer.')

        self.declareProperty(
            name='LambdaOnTwoMode',
            defaultValue=False,
            doc='Set if instrument running in lambda on two mode.')

        self.declareProperty(
            name='FrameOverlap',
            defaultValue=False,
            doc='Set if the energy transfer extends over a frame.')

        self.declareProperty(name='FixedDetector',
                             defaultValue=True,
                             doc='Fix detector positions to the first run')

        self.declareProperty(FileProperty('ScratchFolder',
                                          '',
                                          action=FileAction.OptionalDirectory,
                                          direction=Direction.Input),
                             doc='Path to save and restore merged workspaces.')

        mandatoryOutputFolder = CompositeValidator()
        mandatoryOutputFolder.add(StringArrayMandatoryValidator())
        self.declareProperty(FileProperty('OutputFolder',
                                          '',
                                          action=FileAction.Directory,
                                          direction=Direction.Input),
                             doc='Path to save the output nxspe files.')

        self.declareProperty(
            FileProperty('ConfigurationFile',
                         '',
                         action=FileAction.OptionalLoad,
                         extensions=['ini']),
            doc='Optional: INI file to override default processing values.')

        self.declareProperty(name='KeepReducedWorkspace',
                             defaultValue=False,
                             doc='Keep the last reduced workspace.')