Пример #1
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
Пример #2
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")
Пример #3
0
    def PyInit(self):
        self.declareProperty(IMDEventWorkspaceProperty("InputWorkspace", defaultValue="",
                                                       optional=PropertyMode.Mandatory,
                                                       direction=Direction.Input),
                             doc="Input MDEvent workspace to convert to a MDHisto in HKL")

        self.declareProperty(IPeaksWorkspaceProperty("PeaksWorkspace", defaultValue="", optional=PropertyMode.Optional,
                                                     direction=Direction.Input),
                             doc="Optional peaks workspace to retrieve the UB matrix from, instead of InputWorkspace.")

        self.declareProperty(FloatArrayProperty("Uproj", [1, 0, 0], validator=FloatArrayLengthValidator(3),
                                                direction=Direction.Input),
                             doc="Defines the first projection vector of the target Q coordinate system in HKL mode")
        self.declareProperty(FloatArrayProperty("Vproj", [0, 1, 0], validator=FloatArrayLengthValidator(3),
                                                direction=Direction.Input),
                             doc="Defines the second projection vector of the target Q coordinate system in HKL mode")
        self.declareProperty(FloatArrayProperty("Wproj", [0, 0, 1], validator=FloatArrayLengthValidator(3),
                                                direction=Direction.Input),
                             doc="Defines the third projection vector of the target Q coordinate system in HKL mode")

        self.declareProperty(FloatArrayProperty("Extents", [-6.02, 6.02, -6.02, 6.02, -6.02, 6.02],
                                                direction=Direction.Input),
                             "Binning parameters for each dimension. Enter it as a"
                             "comma-separated list of values with the"
                             "format: 'minimum,maximum,'.")

        self.declareProperty(IntArrayProperty("Bins", [301, 301, 301],
                                              direction=Direction.Input),
                             "Number of bins to use for each dimension, Enter it as a"
                             "comma-separated list of integers.")

        self.declareProperty(IMDHistoWorkspaceProperty("OutputWorkspace", "",
                                                       optional=PropertyMode.Mandatory,
                                                       direction=Direction.Output),
                             doc="Output MDWorkspace in Q-space, name is prefix if multiple input files were provided.")
Пример #4
0
    def PyInit(self):
        self.declareProperty(FloatArrayProperty("Masses", direction=Direction.Input),
                             doc="The masses that make up the sample")

        self.declareProperty(FloatArrayProperty("Amplitudes", direction=Direction.Input),
                             doc="The amplitudes of the peaks")

        self.declareProperty("TransmissionGuess", 1.0,
                             doc="Initial guess for the transmission")

        self.declareProperty("Thickness", 5.0,
                             doc="The thickness of the sample in centimetres (cm)")

        self.declareProperty("NumberDensity", 1.0,
                             doc="The Number Density of the sample material")

        self.declareProperty(ITableWorkspaceProperty("DensityWorkspace", "",
                                                     direction=Direction.Output),
                             doc="Output Workspace containing the iterative "
                             +"approximations for Sample Density. The final "
                             +"Y value in the first spectrum will be the last iteration")

        self.declareProperty(ITableWorkspaceProperty("TransmissionWorkspace", "",
                                                     direction=Direction.Output),
                             doc="Output Workspace containing the iterative "
                             +"approximation for Transmission.")
Пример #5
0
    def PyInit(self):
        self.declareProperty(MatrixWorkspaceProperty('InputWorkspace', '',
                                                     Direction.Input),
                             doc='Workspace to match the spectra between')
        self.declareProperty(MatrixWorkspaceProperty('OutputWorkspace', '',
                                                     Direction.Output),
                             doc='Workspace with the spectra matched')
        self.declareProperty('ReferenceSpectrum',
                             1,
                             doc='Spectrum to match other spectra to')
        self.declareProperty('CalculateOffset',
                             True,
                             doc='Calculate vertical shift')
        self.declareProperty('CalculateScale',
                             True,
                             doc='Calculate scale factor')

        self.declareProperty(
            FloatArrayProperty('Offset', values=[],
                               direction=Direction.Output),
            'Additive factor from matching')
        self.declareProperty(
            FloatArrayProperty('Scale', values=[], direction=Direction.Output),
            'Multiplicitive factor from matching')
        self.declareProperty(
            FloatArrayProperty('ChiSq', values=[], direction=Direction.Output),
            'Unweighted ChiSq between the spectrum and the reference. '
            'NaN means that the spectrum was not matched')
Пример #6
0
 def test_name_validator_direction_constructor_gives_correct_object(self):
     """
         Test the constructor that takes a name, validator & direction
     """
     name = "numbers"
     direc = Direction.Output
     validator = NullValidator()
     arr = FloatArrayProperty(name, validator, direc)
     self._check_object_attributes(arr, name, direc)
     self.assertEquals(arr.isValid(), "")
Пример #7
0
    def PyInit(self):
        """ Declare properties
        """
        self.declareProperty(mantid.api.WorkspaceProperty(  "Workspace", "",
                                                            direction=mantid.kernel.Direction.Input,
                                                            validator=mantid.api.InstrumentValidator()),
                             "Input workspace")

        self.declareProperty(IntArrayProperty("UpstreamSpectra", Direction.Output))
        self.declareProperty(FloatArrayProperty("UpstreamDetectorDistances", Direction.Output))
        self.declareProperty(IntArrayProperty("DownstreamSpectra", Direction.Output))
        self.declareProperty(FloatArrayProperty("DownstreamDetectorDistances", Direction.Output))
Пример #8
0
    def PyInit(self):
        self.declareProperty(name='Instrument', defaultValue='IRIS',
                             validator=StringListValidator(['IRIS', 'OSIRIS']),
                             doc='The name of the instrument.')
        self.declareProperty(name='Analyser', defaultValue='',
                             validator=StringListValidator(['graphite', 'mica', 'fmica']),
                             doc='The 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="FirstRun", defaultValue=-1,
                             validator=IntBoundedValidator(lower=0),
                             doc="First Sample run-number.")
        self.declareProperty(name='LastRun', defaultValue=-1,
                             validator=IntBoundedValidator(lower=0),
                             doc="Last Sample run-number.")
        self.declareProperty(name='NumberSamples', defaultValue=-1,
                             validator=IntBoundedValidator(lower=0),
                             doc="Increment for run-number.")

        self.declareProperty(IntArrayProperty(name='SpectraRange', values=[0, 1],
                                              validator=IntArrayLengthValidator(2)),
                             doc='Comma separated range of spectra numbers 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='Position',
                             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. Do not use with GroupingMethod as "All"')

        self.declareProperty(name='WidthFit', defaultValue=False,
                             doc='Perform a 2 peak width Fit. Do not use with GroupingMethod as "All"')

        self.declareProperty(name='Plot', defaultValue=False,
                             doc='True to plot the output data.')
        self.declareProperty(name='Save', defaultValue=False,
                             doc='True to save the output data.')
 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.')
Пример #10
0
 def test_name_string_values_validator_direction_constructor_gives_correct_object(self):
     """
         Test the constructor that takes a name, values as string, validator & direction
     """
     name = "numbers"
     direc = Direction.Output
     validator = NullValidator()
     values_str = "1.345,34.2,5345.3,4,5.3948"
     arr = FloatArrayProperty(name, values_str, validator, direc)
     self._check_object_attributes(arr, name, direc, length = 5)
     self.assertEquals(arr.isValid(), "")
     values = arr.value
     self.assertTrue(isinstance(values, np.ndarray))
Пример #11
0
    def test_construct_numpy_array_with_given_dtype_float(self):
        # 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)

        # Use the returned dtype() to check it works with numpy arrays
        x = np.arange(1, 10, dtype=float_arr.dtype())
        self.assertIsInstance(x, np.ndarray)
        self.assertEquals(x.dtype, float_arr.dtype())
Пример #12
0
    def test_construct_numpy_array_with_given_dtype_float(self):
        # 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)

        # Use the returned dtype() to check it works with numpy arrays
        x = np.arange(1, 10, dtype=float_arr.dtype())
        self.assertIsInstance(x, np.ndarray)
        self.assertEquals(x.dtype, float_arr.dtype())
Пример #13
0
    def PyInit(self):
        self.declareProperty(MatrixWorkspaceProperty(
            'InputWorkspace',
            '',
            direction=Direction.Input,
        ),
                             doc='Incident spectrum to be fit.')

        self.declareProperty(
            MatrixWorkspaceProperty('OutputWorkspace',
                                    '',
                                    direction=Direction.Output),
            doc=
            'Output workspace containing the fit and it\'s first derivative.')

        self.declareProperty(
            name='WorkspaceIndex',
            defaultValue=0,
            doc=
            'Workspace index of the spectra to be fitted (Defaults to the first index.)'
        )

        self.declareProperty(
            FloatArrayProperty(name="BinningForCalc",
                               validator=RebinParamsValidator(AllowEmpty=True),
                               direction=Direction.Input),
            doc=
            'Bin range for calculation given as an array of floats in the same format as `Rebin`: '
            '[Start],[Increment],[End]. If empty use default binning. The calculated '
            'spectrum will use this binning')

        self.declareProperty(
            FloatArrayProperty(name="BinningForFit",
                               validator=RebinParamsValidator(AllowEmpty=True),
                               direction=Direction.Input),
            doc=
            'Bin range for fitting given as an array of floats in the same format as `Rebin`: '
            '[Start],[Increment],[End]. If empty use BinningForCalc. The '
            'incident spectrum will be rebined to this range before being fit.'
        )

        self.declareProperty(
            name='FitSpectrumWith',
            defaultValue='GaussConvCubicSpline',
            validator=StringListValidator([
                'GaussConvCubicSpline', 'CubicSpline', 'CubicSplineViaMantid'
            ]),
            doc='The method for fitting the incident spectrum.')
Пример #14
0
 def PyInit(self):
     int_validator = IntArrayOrderedPairsValidator()
     self.declareProperty(
         IntArrayProperty("IntInput", int_validator))
     float_validator = FloatArrayOrderedPairsValidator()
     self.declareProperty(
         FloatArrayProperty("FloatInput", float_validator))
Пример #15
0
    def PyInit(self):

        self.declareProperty(MatrixWorkspaceProperty(
            'InputWorkspace',
            '',
            direction=Direction.Input,
            validator=WorkspaceUnitValidator("Wavelength")),
                             doc='Flood weighting measurement')
        self.declareProperty(MatrixWorkspaceProperty(
            'TransmissionWorkspace',
            '',
            direction=Direction.Input,
            optional=PropertyMode.Optional,
            validator=WorkspaceUnitValidator("Wavelength")),
                             doc='Flood weighting measurement')

        validator = FloatArrayBoundedValidator(lower=0.)
        self.declareProperty(
            FloatArrayProperty('Bands', [],
                               direction=Direction.Input,
                               validator=validator),
            doc='Wavelength bands to use. Single pair min to max.')

        self.declareProperty(MatrixWorkspaceProperty(
            'OutputWorkspace', '', direction=Direction.Output),
                             doc='Normalized flood weighting measurement')

        self.declareProperty("SolidAngleCorrection",
                             True,
                             direction=Direction.Input,
                             doc="Perform final solid angle correction")
Пример #16
0
    def PyInit(self):
        # State
        self.declareProperty(PropertyManagerProperty('SANSState'),
                             doc='A property manager which fulfills the SANSState contract.')

        # Workspace which is to be moved
        self.declareProperty(MatrixWorkspaceProperty("Workspace", '',
                                                     optional=PropertyMode.Mandatory, direction=Direction.InOut),
                             doc='The sample scatter workspace. This workspace does not contain monitors.')

        # Move Type
        move_types = StringListValidator(list(self._make_move_type_map().keys()))
        self.declareProperty('MoveType', 'ElementaryDisplacement', validator=move_types, direction=Direction.Input,
                             doc='The type of movement. This can be: '
                                 '1) InitialMove for freshly workspaces, '
                                 '2) ElementaryDisplacement of the instrument component, '
                                 '3) SetToZero resets a component to the initial position.')

        # Coordinates of the beam
        self.declareProperty(FloatArrayProperty(name='BeamCoordinates', values=[]),
                             doc='The coordinates which are used to position the instrument component(s). If nothing '
                                 'is specified, then the coordinates from SANSState are used')

        # Components which are to be moved
        self.declareProperty('Component', '', direction=Direction.Input, doc='Component that should be moved.')

        # If is a transmission workspace
        self.declareProperty('IsTransmissionWorkspace', False, direction=Direction.Input,
                             doc='If the input workspace is a transmission or direct workspace')
Пример #17
0
def test_attrs_with_dims():
    from mantid.kernel import FloatArrayProperty
    import mantid.simpleapi as sapi
    dataX = [1, 2, 3]
    dataY = [1, 2, 3]
    ws = sapi.CreateWorkspace(DataX=dataX,
                              DataY=dataY,
                              NSpec=1,
                              UnitX="Wavelength")
    # Time series property
    sapi.AddSampleLog(ws, 'attr0', LogText='1', LogType='Number Series')
    # Single value property
    sapi.AddSampleLog(ws, 'attr1', LogText='1', LogType='Number')
    # Array property (not time series)
    p = FloatArrayProperty('attr2', np.arange(10))
    run = ws.mutableRun()
    run.addProperty('attr2', p, replace=True)

    ds = scn.from_mantid(ws)
    # Variable (single value) wrapped DataArray
    assert isinstance(ds.attrs['attr0'].value, sc.DataArray)
    assert 'time' in ds.attrs['attr0'].value.coords
    # Variable (single value)
    assert isinstance(ds.attrs['attr1'].value, int)
    # Variable (single value) wrapped Variable
    assert isinstance(ds.attrs['attr2'].value, sc.Variable)
    assert ds.attrs['attr2'].shape == []  # outer wrapper
    assert ds.attrs['attr2'].value.shape == [10]  # inner held
Пример #18
0
 def PyInit(self):
     self.declareProperty(
         FloatArrayProperty("FloatInput", FloatArrayMandatoryValidator()))
     self.declareProperty(
         IntArrayProperty("IntInput", IntArrayMandatoryValidator()))
     self.declareProperty(
         StringArrayProperty("StringInput",
                             StringArrayMandatoryValidator()))
Пример #19
0
    def PyInit(self):
        #
        # Properties
        #
        self.declareProperty('RunNumbers', '', 'Sample run numbers')

        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')
        #
        # Common Properties
        #
        required_title = 'Required Properties'

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

        self.declareProperty(
            'MonitorNormalization', True,
            'Normalization with wavelength-dependent '
            'monitor counts')
        for a_property in ('MaskFile', 'MonitorNormalization'):
            self.setPropertyGroup(a_property, required_title)
        #
        # 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)
Пример #20
0
 def PyInit(self):
     self.declareProperty(MatrixWorkspaceProperty('InputWorkspace', "", direction=Direction.Input))
     self.declareProperty('Axis1', "", StringMandatoryValidator())
     self.declareProperty('Axis2', "", StringMandatoryValidator())
     self.declareProperty('Units', "", StringMandatoryValidator())
     self.declareProperty(FloatArrayProperty('Limits', direction=Direction.Input))
     self.declareProperty('EMode', "Direct", StringMandatoryValidator())
     self.declareProperty('ProjectionType', "QE", StringMandatoryValidator(), doc='Q or Theta projection')
     self.declareProperty(IMDEventWorkspaceProperty('OutputWorkspace', "", direction=Direction.Output))
Пример #21
0
 def test_name_direction_constructor_gives_correct_object(self):
     """
         Tests the constructor that takes
         only a name & direction
     """
     name = "numbers"
     direc = Direction.Output
     arr = FloatArrayProperty(name, direc)
     self._check_object_attributes(arr, name, direc)
Пример #22
0
 def test_name_only_constructor_gives_correct_object(self):
     """
         Tests the simplest constructor that takes
         only a name
     """
     name = "numbers"
     arr = FloatArrayProperty(name)
     self.assertTrue(isinstance(arr, FloatArrayProperty))
     self._check_object_attributes(arr, name, Direction.Input)
Пример #23
0
    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.')
Пример #24
0
 def PyInit(self):
     if not allow_empty:
         if not allow_ranges:
             validator = RebinParamsValidator()
     else:
         if not allow_ranges:
             validator = RebinParamsValidator(allow_empty)
         else:
             validator = RebinParamsValidator(allow_empty, allow_ranges)
     self.declareProperty(FloatArrayProperty("Input", validator))
Пример #25
0
 def test_name_validator_direction_constructor_gives_correct_object(self):
     """
         Test the constructor that takes a name, validator & direction
     """
     name = "numbers"
     direc = Direction.Output
     validator = NullValidator()
     arr = FloatArrayProperty(name, validator, direc)
     self._check_object_attributes(arr, name, direc)
     self.assertEquals(arr.isValid, "")
Пример #26
0
 def test_name_values_from_array_validator_direction_constructor_gives_correct_object(
         self):
     """
         Test the constructor that takes a name, values from python object,
         validator & direction
     """
     name = "numbers"
     direc = Direction.Output
     validator = NullValidator()
     input_values = np.array([1.1, 2.5, 5.6, 4.6, 9.0, 6.0])
     arr = FloatArrayProperty(name, input_values, validator, direc)
     self._check_object_attributes(arr, name, direc, length=6)
Пример #27
0
    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(
            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(
            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.')
    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.')
Пример #29
0
 def PyInit(self):
     """ Algorithm properties
     """
     self.declareProperty(MatrixWorkspaceProperty("InputWorkspace", "",
                                                  Direction.Input),
                          doc="Input QENS data as MatrixWorkspace")
     self.declareProperty(
         "RaiseMode",
         False,
         doc=
         "Set to True if an Exception, instead of an empty list of Q values, is desired."
     )
     self.declareProperty(FloatArrayProperty("Qvalues", Direction.Output))
Пример #30
0
    def PyInit(self):
        group = "Input"
        self.declareProperty(FileProperty(name="Filename",
                                          defaultValue="", action=FileAction.OptionalLoad,
                                          extensions=["_event.nxs", ".nxs.h5"]),
                             "Event file")
        self.declareProperty("MaxChunkSize", 0.0,
                             "Specify maximum Gbytes of file to read in one chunk.  Default is whole file.")
        self.declareProperty("FilterBadPulses", 95.,
                             doc="Filter out events measured while proton " +
                             "charge is more than 5% below average")

        self.declareProperty(MatrixWorkspaceProperty("InputWorkspace", "",
                                                     direction=Direction.Input,
                                                     optional=PropertyMode.Optional),
                             doc="Handle to reduced workspace")
        self.setPropertyGroup("Filename", group)
        self.setPropertyGroup("MaxChunkSize", group)
        self.setPropertyGroup("FilterBadPulses", group)
        self.setPropertyGroup("InputWorkspace", group)

        group = "Output"
        self.declareProperty(MatrixWorkspaceProperty("OutputWorkspace", "",
                                                     direction=Direction.Output),
                             doc="Handle to reduced workspace")
        self.declareProperty(FileProperty(name="PDFgetNFile", defaultValue="", action=FileAction.Save,
                                          extensions=[".getn"]), "Output filename")
        self.setPropertyGroup("OutputWorkspace", group)
        self.setPropertyGroup("PDFgetNFile", group)

        self.declareProperty(FileProperty(name="CalibrationFile",
                                          defaultValue="", action=FileAction.OptionalLoad,
                                          extensions=[".h5", ".hd5", ".hdf", ".cal"]))
        self.declareProperty(FileProperty(name="CharacterizationRunsFile", defaultValue="",
                                          action=FileAction.OptionalLoad,
                                          extensions=["txt"]),
                             "File with characterization runs denoted")

        self.declareProperty("RemovePromptPulseWidth", 0.0,
                             "Width of events (in microseconds) near the prompt pulse to remove. 0 disables")
        self.declareProperty("CropWavelengthMin", 0.,
                             "Crop the data at this minimum wavelength.")
        self.declareProperty("CropWavelengthMax", 0.,
                             "Crop the data at this maximum wavelength.")

        self.declareProperty(FloatArrayProperty("Binning", values=[0., 0., 0.],
                                                direction=Direction.Input),
                             "Positive is linear bins, negative is logorithmic")
        self.declareProperty("ResampleX", 0,
                             "Number of bins in x-axis. Non-zero value overrides \"Params\" property. " +
                             "Negative value means logorithmic binning.")
Пример #31
0
 def test_name_string_values_validator_direction_constructor_gives_correct_object(
         self):
     """
         Test the constructor that takes a name, values as string, validator & direction
     """
     name = "numbers"
     direc = Direction.Output
     validator = NullValidator()
     values_str = "1.345,34.2,5345.3,4,5.3948"
     arr = FloatArrayProperty(name, values_str, validator, direc)
     self._check_object_attributes(arr, name, direc, length=5)
     self.assertEquals(arr.isValid, "")
     values = arr.value
     self.assertTrue(isinstance(values, np.ndarray))
Пример #32
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")
Пример #33
0
    def PyInit(self):
        group = "Input"
        self.declareProperty(FileProperty(name="Filename",
                                          defaultValue="", action=FileAction.OptionalLoad,
                                          extensions=["_event.nxs", ".nxs.h5"]),
                             "Event file")
        self.copyProperties('AlignAndFocusPowderFromFiles', 'MaxChunkSize')
        self.declareProperty("FilterBadPulses", 95.,
                             doc="Filter out events measured while proton " +
                             "charge is more than 5% below average")

        self.declareProperty(MatrixWorkspaceProperty("InputWorkspace", "",
                                                     direction=Direction.Input,
                                                     optional=PropertyMode.Optional),
                             doc="Handle to reduced workspace")
        self.setPropertyGroup("Filename", group)
        self.setPropertyGroup("MaxChunkSize", group)
        self.setPropertyGroup("FilterBadPulses", group)
        self.setPropertyGroup("InputWorkspace", group)

        group = "Output"
        self.declareProperty(MatrixWorkspaceProperty("OutputWorkspace", "",
                                                     direction=Direction.Output),
                             doc="Handle to reduced workspace")
        self.copyProperties('AlignAndFocusPowderFromFiles', 'CacheDir')
        self.declareProperty(FileProperty(name="PDFgetNFile", defaultValue="", action=FileAction.Save,
                                          extensions=[".getn"]), "Output filename")
        self.setPropertyGroup("OutputWorkspace", group)
        self.setPropertyGroup("PDFgetNFile", group)

        self.declareProperty(FileProperty(name="CalibrationFile",
                                          defaultValue="", action=FileAction.OptionalLoad,
                                          extensions=[".h5", ".hd5", ".hdf", ".cal"]))
        self.declareProperty(FileProperty(name="CharacterizationRunsFile", defaultValue="",
                                          action=FileAction.OptionalLoad,
                                          extensions=["txt"]),
                             "File with characterization runs denoted")
        self.copyProperties('AlignAndFocusPowderFromFiles',
                            ['FrequencyLogNames', 'WaveLengthLogNames', 'RemovePromptPulseWidth',
                             'CropWavelengthMin', 'CropWavelengthMax'])

        self.declareProperty(FloatArrayProperty("Binning", values=[0., 0., 0.],
                                                direction=Direction.Input),
                             "Positive is linear bins, negative is logorithmic")
        self.declareProperty("ResampleX", 0,
                             "Number of bins in x-axis. Non-zero value overrides \"Params\" property. " +
                             "Negative value means logorithmic binning.")
Пример #34
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")