def PyInit(self):
        instruments = ['BSS', 'SNAP', 'REF_M', 'CNCS', 'EQSANS', 'VULCAN',
                       'VENUS', 'MANDI', 'TOPAZ', 'ARCS']
        self.declareProperty('Instrument', '',
                             StringListValidator(instruments),
                             'Empty uses default instrument')

        runValidator = IntBoundedValidator()
        runValidator.setLower(1)
        self.declareProperty('RunNumber', Property.EMPTY_INT, runValidator,
                             doc='Live run number to use (Optional, Default=most recent)')

        self.declareProperty(WorkspaceProperty('OutputWorkspace', '',
                                               direction=Direction.Output))

        self.declareProperty('NormalizeByCurrent', True, 'Normalize by current')

        self.declareProperty('LoadLogs', True,
                             'Attempt to load logs from an existing file')

        self.declareProperty(FileProperty('LogFilename', '',
                                          direction=Direction.Input,
                                          action=FileAction.OptionalLoad,
                                          extensions=['_event.nxs']),
                             doc='File containing logs to use (Optional)')
        self.setPropertySettings('LogFilename',
                                 EnabledWhenProperty('LoadLogs',
                                                     PropertyCriterion.IsDefault))
Beispiel #2
0
    def PyInit(self):
        self.declareProperty(
            WorkspaceProperty("InputWorkspace", "", Direction.Input),
            "The workspace containing the normalization data.")

        self.declareProperty(
            "LLSCorrection", True,
            "Whether to apply a log-log-sqrt transformation to make data more sensitive to weaker peaks."
        )

        self.declareProperty(
            "IncreasingWindow", False,
            "Use an increasing moving window when clipping."
        )

        self.declareProperty(
            name="SmoothingRange",
            defaultValue=10,
            validator=IntBoundedValidator(lower=0),
            doc="The size of the window used for smoothing data. No smoothing if set to 0."
        )

        self.declareProperty(
            name="WindowSize",
            defaultValue=10,
            validator=IntBoundedValidator(lower=0),
            doc="The size of the peak clipping window to be used."
        )

        self.declareProperty(WorkspaceProperty("OutputWorkspace", "", Direction.Output),
                             "The workspace containing the normalization data.")
Beispiel #3
0
 def PyInit(self):
     only_positive = IntBoundedValidator()
     only_positive.setLower(0)
     self.declareProperty('NumPropWithDefaultDir', -1,
                          only_positive)
     self.declareProperty('NumPropWithInOutDir', -1, only_positive,
                          "doc string", Direction.InOut)
Beispiel #4
0
 def PyInit(self):
     self.declareProperty(MultipleFileProperty('SampleRuns',
                                               extensions=['nxs']),
                          doc="File path for run(s).")
     self.declareProperty(
         MatrixWorkspaceProperty('OutputWorkspace',
                                 '',
                                 direction=Direction.Output),
         doc='The output workspace group containing reduced data.')
     self.declareProperty(
         "MaskPixelsFromStart",
         10,
         validator=IntBoundedValidator(lower=0),
         doc="Number of pixels to mask at the start of each tube")
     self.declareProperty(
         "MaskPixelsFromEnd",
         10,
         validator=IntBoundedValidator(lower=0),
         doc="Number of pixels to mask at the end of each tube")
     self.declareProperty(
         "Observable",
         "sample.temperature",
         doc=
         "If multiple files, the parameter from SampleLog to use as an index when conjoined."
     )
     self.declareProperty("Transpose", True, doc="Transpose the result.")
     self.declareProperty("Sum", False, doc="Sum along the scan")
     self.declareProperty(
         name='ComponentsToMask',
         defaultValue='',
         doc=
         'Comma separated list of component names to mask, for instance: tube_1, tube_2'
     )
Beispiel #5
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.')
Beispiel #6
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.')
Beispiel #7
0
 def PyInit(self):
     """ Declare properties
     """
     self.declareProperty(
         WorkspaceProperty("DetectorWorkspace", "", Direction.Input),
         "Workspace containing data from detectors")
     self.declareProperty(
         WorkspaceProperty("MonitorWorkspace", "", Direction.Input),
         "Workspace containing data from monitor(s)")
     self.declareProperty("EnergyGuess", -1.,
                          FloatBoundedValidator(lower=0.),
                          "Incident energy guess")
     self.declareProperty("MonitorSpectrumNumber", -1,
                          IntBoundedValidator(lower=1),
                          "Spectrum number of the monitor")
     self.declareProperty(
         "MaximumDistanceFraction", 1.02,
         FloatBoundedValidator(lower=1.0001),
         "Maximum distance for detectors to be considered, as fraction of minimum distance (default = 1.02)"
     )
     self.declareProperty("IncidentEnergy", 0.0, Direction.Output)
     self.declareProperty("FirstMonitorPeak", 0.0, Direction.Output)
     self.declareProperty("FirstMonitorIndex", 0, Direction.Output)
     self.declareProperty("Tzero", 0.0, Direction.Output)
     return
Beispiel #8
0
    def _declareSlicingProperties(self):
        """Copy properties from the child slicing algorithm and add our own custom ones"""
        self.declareProperty(Prop.SLICE,
                             False,
                             doc='If true, slice the input workspace')
        self.setPropertyGroup(Prop.SLICE, 'Slicing')
        # Convenience variables for conditional properties
        whenSliceEnabled = EnabledWhenProperty(Prop.SLICE,
                                               PropertyCriterion.IsEqualTo,
                                               "1")

        self._slice_properties = [
            'TimeInterval', 'LogName', 'LogValueInterval',
            'UseNewFilterAlgorithm'
        ]
        self.copyProperties('ReflectometrySliceEventWorkspace',
                            self._slice_properties)
        for property in self._slice_properties:
            self.setPropertySettings(property, whenSliceEnabled)
            self.setPropertyGroup(property, 'Slicing')

        self.declareProperty(
            name=Prop.NUMBER_OF_SLICES,
            defaultValue=Property.EMPTY_INT,
            validator=IntBoundedValidator(lower=1),
            direction=Direction.Input,
            doc=
            'The number of uniform-length slices to slice the input workspace into'
        )
        self.setPropertySettings(Prop.NUMBER_OF_SLICES, whenSliceEnabled)
        self.setPropertyGroup(Prop.NUMBER_OF_SLICES, 'Slicing')
Beispiel #9
0
    def PyInit(self):
        self.declareProperty(MatrixWorkspaceProperty("InputWorkspace", "", Direction.Input),
                             "Workspace with focussed spectra")

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

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

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

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

        # Output table
        self.declareProperty(
            ITableWorkspaceProperty(name='PeakProperties',
                                    defaultValue='peak_table',
                                    direction=Direction.Output),
            'Table containing the properties of the peaks')
        self.declareProperty(
            ITableWorkspaceProperty(name='RefitPeakProperties',
                                    defaultValue='refit_peak_table',
                                    direction=Direction.Output),
            'Table containing the properties of the peaks that had to be fitted twice as the first'
            'time the error was unreasonably large')
        self.declareProperty(
            ITableWorkspaceProperty(name='FitCost',
                                    defaultValue='fit_cost',
                                    direction=Direction.Output),
            'Table containing the value of both chi2 and poisson cost functions for the fit')
Beispiel #11
0
    def PyInit(self):
        self.declareProperty(
            FileProperty("Filename", "", FileAction.Load, ['.d_dat']),
            "Name of DNS experimental data file.")

        self.declareProperty(
            FileProperty("CoilCurrentsTable", "", FileAction.OptionalLoad,
                         ['.txt']),
            "Name of file containing table of coil currents and polarisations."
        )

        self.declareProperty(
            WorkspaceProperty("OutputWorkspace",
                              "",
                              direction=Direction.Output),
            doc="Name of the workspace to store the experimental data.")
        normalizations = ['duration', 'monitor', 'no']
        self.declareProperty("Normalization",
                             "duration",
                             StringListValidator(normalizations),
                             doc="Kind of data normalization.")

        self.declareProperty(
            name="ElasticChannel",
            defaultValue=0,
            validator=IntBoundedValidator(lower=0),
            doc=
            "Time channel number where elastic peak is observed. Only for TOF data."
        )
        return
Beispiel #12
0
    def PyInit(self):
        # Sample options
        self.declareProperty(MatrixWorkspaceProperty('SampleWorkspace', '', direction=Direction.Input),
                             doc='Sample workspace.')

        self.declareProperty(name='SampleChemicalFormula', defaultValue='', validator=StringMandatoryValidator(),
                             doc='Sample chemical formula')
        self.declareProperty(name='SampleDensityType', defaultValue='Mass Density',
                             validator=StringListValidator(['Mass Density', 'Number Density']),
                             doc='Use of Mass density or Number density')
        self.declareProperty(name='SampleDensity', defaultValue=0.1,
                             doc='Mass density (g/cm^3) or Number density (atoms/Angstrom^3)')
        self.declareProperty(name='SampleInnerRadius', defaultValue=0.2,
                             validator=FloatBoundedValidator(0.0),
                             doc='Sample radius')
        self.declareProperty(name='SampleOuterRadius', defaultValue=0.25,
                             validator=FloatBoundedValidator(0.0),
                             doc='Sample radius')

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

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

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

        self.declareProperty(WorkspaceGroupProperty('CorrectionsWorkspace', '', direction=Direction.Output,
                                                    optional=PropertyMode.Optional),
                             doc='The corrections workspace for scattering and absorptions in sample.')
    def PyInit(self):
        ws_validator = CompositeValidator([WorkspaceUnitValidator('Wavelength'), InstrumentValidator()])

        self.declareProperty(MatrixWorkspaceProperty('SampleWorkspace', '',
                                                     direction=Direction.Input,
                                                     validator=ws_validator),
                             doc='Name for the input sample workspace')

        self.declareProperty(name='SampleChemicalFormula', defaultValue='',
                             validator=StringMandatoryValidator(),
                             doc='Sample chemical formula')
        self.declareProperty(name='SampleNumberDensity', defaultValue=0.1,
                             validator=FloatBoundedValidator(0.0),
                             doc='Sample number density in atoms/Angstrom3')
        self.declareProperty(name='SampleThickness', defaultValue=0.0,
                             validator=FloatBoundedValidator(0.0),
                             doc='Sample thickness in cm')
        self.declareProperty(name='SampleAngle', defaultValue=0.0,
                             doc='Sample angle in degrees')

        self.declareProperty(MatrixWorkspaceProperty('CanWorkspace', '',
                                                     direction=Direction.Input,
                                                     optional=PropertyMode.Optional,
                                                     validator=ws_validator),
                             doc="Name for the input container workspace")

        self.declareProperty(name='CanChemicalFormula', defaultValue='',
                             doc='Container chemical formula')
        self.declareProperty(name='CanNumberDensity', defaultValue=0.1,
                             validator=FloatBoundedValidator(0.0),
                             doc='Container number density in atoms/Angstrom3')

        self.declareProperty(name='CanFrontThickness', defaultValue=0.0,
                             validator=FloatBoundedValidator(0.0),
                             doc='Container front thickness in cm')
        self.declareProperty(name='CanBackThickness', defaultValue=0.0,
                             validator=FloatBoundedValidator(0.0),
                             doc='Container back thickness in cm')

        self.declareProperty(name='NumberWavelengths', defaultValue=10,
                             validator=IntBoundedValidator(1),
                             doc='Number of wavelengths for calculation')
        self.declareProperty(name='Interpolate', defaultValue=True,
                             doc='Interpolate the correction workspaces to match the sample workspace')

        self.declareProperty(name='Emode', defaultValue='Elastic',
                             validator=StringListValidator(['Elastic', 'Indirect']),
                             doc='Emode: Elastic or Indirect')
        self.declareProperty(name='Efixed', defaultValue=1.0,
                             doc='Analyser energy')

        self.declareProperty(WorkspaceGroupProperty('OutputWorkspace', '',
                                                    direction=Direction.Output),
                             doc='The output corrections workspace group')
Beispiel #14
0
    def PyInit(self):
        # input
        self.declareProperty(MatrixWorkspaceProperty("Workspace", "", Direction.Input),
                             doc="input workspace")
        self.declareProperty(name="Index",defaultValue=0,validator=IntBoundedValidator(lower=0),
                             doc="workspace index - which spectrum to fit")

        # output
        self.declareProperty(name="PeakCentre",defaultValue=0.,direction=Direction.Output,
                             doc="the centre of the fitted peak")
        self.declareProperty(name="Sigma",defaultValue=0.,direction=Direction.Output,
                             doc="the sigma of the fitted peak; 0. if fitting was not successful")
Beispiel #15
0
    def PyInit(self):
        self.declareProperty('RunNumber',
                             defaultValue=0,
                             direction=Direction.Input,
                             validator=IntBoundedValidator(lower=1),
                             doc="Extracts the IPTS number for a run")

        instruments = self.getValidInstruments()
        self.declareProperty('Instrument', '',
                             StringListValidator(instruments),
                             "Empty uses default instrument")

        self.declareProperty('Directory', '', direction=Direction.Output)
Beispiel #16
0
    def PyInit(self):
        self.declareProperty(MatrixWorkspaceProperty('SampleWorkspace', '',
                                                     optional=PropertyMode.Mandatory,
                                                     direction=Direction.Input),
                             doc="Name for the sample workspace.")

        self.declareProperty(MatrixWorkspaceProperty('ResolutionWorkspace', '',
                                                     optional=PropertyMode.Mandatory,
                                                     direction=Direction.Input),
                             doc="Name for the resolution workspace.")

        self.declareProperty(name='EnergyMin', defaultValue=-0.5,
                             doc='Minimum energy for fit. Default=-0.5')
        self.declareProperty(name='EnergyMax', defaultValue=0.5,
                             doc='Maximum energy for fit. Default=0.5')
        self.declareProperty(name='BinReductionFactor', defaultValue=10.0,
                             doc='Decrease total number of spectrum points by this ratio through merging of '
                                 'intensities from neighbouring bins. Default=1')

        self.declareProperty('NumberOfIterations', DEFAULT_ITERATIONS, IntBoundedValidator(lower=1),
                             doc="Number of randomised simulations for monte-carlo error calculation.")

        self.declareProperty('SeedValue', DEFAULT_SEED, IntBoundedValidator(lower=1),
                             doc="Seed for pseudo-random number generator in monte-carlo error calculation.")

        self.declareProperty(ITableWorkspaceProperty('ParameterWorkspace', '',
                                                     direction=Direction.Output,
                                                     optional=PropertyMode.Optional),
                             doc='Table workspace for saving TransformToIqt properties')

        self.declareProperty(MatrixWorkspaceProperty('OutputWorkspace', '',
                                                     direction=Direction.Output,
                                                     optional=PropertyMode.Optional),
                             doc='Output workspace')

        self.declareProperty(name='DryRun', defaultValue=False,
                             doc='Only calculate and output the parameters')
        self.declareProperty('CalculateErrors', defaultValue=True,
                             doc="Calculate monte-carlo errors.")
Beispiel #17
0
    def PyInit(self):
        self.declareProperty(name='Run',
                             defaultValue=0,
                             validator=IntBoundedValidator(lower=0),
                             doc='Run number to load')

        self.declareProperty(
            WorkspaceGroupProperty(name='GroupWorkspace',
                                   defaultValue='',
                                   direction=Direction.Output),
            doc='Output group workspace for run')

        self.declareProperty(
            name="Directory",
            defaultValue="",
            direction=Direction.Output,
            doc="provides the directory where the run files were acquired")
Beispiel #18
0
    def PyInit(self):
        # Sample options
        self.declareProperty(MatrixWorkspaceProperty('SampleWorkspace', '', direction=Direction.Input),
                             doc='Sample workspace.')
        self.declareProperty(name='SampleChemicalFormula', defaultValue='', validator=StringMandatoryValidator(),
                             doc='Sample chemical formula')
        self.declareProperty(name='SampleNumberDensity', defaultValue=0.1,
                             validator=FloatBoundedValidator(0.0),
                             doc='Sample number density')
        self.declareProperty(name='SampleRadius', defaultValue=0.1,
                             validator=FloatBoundedValidator(0.0),
                             doc='Sample radius')

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

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

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

        self.declareProperty(WorkspaceGroupProperty('CorrectionsWorkspace', '', direction=Direction.Output,
                                                    optional=PropertyMode.Optional),
                             doc='The corrections workspace for scattering and absorptions in sample.')
 def PyInit(self):
     only_positive = IntBoundedValidator()
     only_positive.setLower(0)
     self.declareProperty('NumPropWithDefaultDir', -1, only_positive)
     self.declareProperty('NumPropWithInOutDir', -1, only_positive,"doc string", Direction.InOut)
    def PyInit(self):
        # Sample options
        self.declareProperty(WorkspaceProperty('SampleWorkspace',
                                               '',
                                               direction=Direction.Input),
                             doc='Sample Workspace')
        self.declareProperty(name='SampleChemicalFormula',
                             defaultValue='',
                             doc='Chemical formula for the sample material')
        self.declareProperty(
            name='SampleCoherentXSection',
            defaultValue=0.0,
            validator=FloatBoundedValidator(0.0),
            doc=
            'The coherent cross-section for the sample material in barns. To be used instead of '
            'Chemical Formula.')
        self.declareProperty(
            name='SampleIncoherentXSection',
            defaultValue=0.0,
            validator=FloatBoundedValidator(0.0),
            doc=
            'The incoherent cross-section for the sample material in barns. To be used instead of '
            'Chemical Formula.')
        self.declareProperty(
            name='SampleAttenuationXSection',
            defaultValue=0.0,
            validator=FloatBoundedValidator(0.0),
            doc=
            'The absorption cross-section for the sample material in barns. To be used instead of '
            'Chemical Formula.')
        self.declareProperty(
            name='SampleDensityType',
            defaultValue='Mass Density',
            validator=StringListValidator(['Mass Density', 'Number Density']),
            doc='Use of Mass density or Number density for the sample.')
        self.declareProperty(
            name='SampleNumberDensityUnit',
            defaultValue='Atoms',
            validator=StringListValidator(['Atoms', 'Formula Units']),
            doc=
            'Choose which units SampleDensity refers to. Allowed values: [Atoms, Formula Units]'
        )
        self.declareProperty(
            name='SampleDensity',
            defaultValue=0.0,
            validator=FloatBoundedValidator(0.0),
            doc=
            'The value for the sample Mass density (g/cm^3) or Number density (1/Angstrom^3).'
        )

        self.setPropertyGroup('SampleWorkspace', 'Sample Options')
        self.setPropertyGroup('SampleChemicalFormula', 'Sample Options')
        self.setPropertyGroup('SampleCoherentXSection', 'Sample Options')
        self.setPropertyGroup('SampleIncoherentXSection', 'Sample Options')
        self.setPropertyGroup('SampleAttenuationXSection', 'Sample Options')
        self.setPropertyGroup('SampleDensityType', 'Sample Options')
        self.setPropertyGroup('SampleDensity', 'Sample Options')

        # Beam Options
        self.declareProperty(name='BeamHeight',
                             defaultValue=1.0,
                             validator=FloatBoundedValidator(0.0),
                             doc='Height of the beam (cm)')
        self.declareProperty(name='BeamWidth',
                             defaultValue=1.0,
                             validator=FloatBoundedValidator(0.0),
                             doc='Width of the beam (cm)')

        self.setPropertyGroup('BeamHeight', 'Beam Options')
        self.setPropertyGroup('BeamWidth', 'Beam Options')

        # Monte Carlo options
        self.declareProperty(name='NumberOfWavelengthPoints',
                             defaultValue=10,
                             validator=IntBoundedValidator(1),
                             doc='Number of wavelengths for calculation')
        self.declareProperty(name='EventsPerPoint',
                             defaultValue=1000,
                             validator=IntBoundedValidator(0),
                             doc='Number of neutron events')
        self.declareProperty(name='Interpolation',
                             defaultValue='Linear',
                             validator=StringListValidator(
                                 ['Linear', 'CSpline']),
                             doc='Type of interpolation')
        self.declareProperty(
            name='MaxScatterPtAttempts',
            defaultValue=5000,
            validator=IntBoundedValidator(0),
            doc='Maximum number of tries made to generate a scattering point')

        self.setPropertyGroup('NumberOfWavelengthPoints',
                              'Monte Carlo Options')
        self.setPropertyGroup('EventsPerPoint', 'Monte Carlo Options')
        self.setPropertyGroup('Interpolation', 'Monte Carlo Options')
        self.setPropertyGroup('MaxScatterPtAttempts', 'Monte Carlo Options')

        # Container options
        self.declareProperty(WorkspaceProperty('ContainerWorkspace',
                                               '',
                                               direction=Direction.Input,
                                               optional=PropertyMode.Optional),
                             doc='Container Workspace')

        container_condition = VisibleWhenProperty(
            'ContainerWorkspace', PropertyCriterion.IsNotDefault)

        self.declareProperty(name='ContainerChemicalFormula',
                             defaultValue='',
                             doc='Chemical formula for the container material')
        self.declareProperty(
            name='ContainerCoherentXSection',
            defaultValue=0.0,
            validator=FloatBoundedValidator(0.0),
            doc=
            'The coherent cross-section for the can material in barns. To be used instead of '
            'Chemical Formula.')
        self.declareProperty(
            name='ContainerIncoherentXSection',
            defaultValue=0.0,
            validator=FloatBoundedValidator(0.0),
            doc=
            'The incoherent cross-section for the can material in barns. To be used instead of '
            'Chemical Formula.')
        self.declareProperty(
            name='ContainerAttenuationXSection',
            defaultValue=0.0,
            validator=FloatBoundedValidator(0.0),
            doc=
            'The absorption cross-section for the can material in barns. To be used instead of '
            'Chemical Formula.')
        self.declareProperty(
            name='ContainerDensityType',
            defaultValue='Mass Density',
            validator=StringListValidator(['Mass Density', 'Number Density']),
            doc='Use of Mass density or Number density for the container.')
        self.declareProperty(
            name='ContainerNumberDensityUnit',
            defaultValue='Atoms',
            validator=StringListValidator(['Atoms', 'Formula Units']),
            doc=
            'Choose which units ContainerDensity refers to. Allowed values: [Atoms, Formula Units]'
        )
        self.declareProperty(
            name='ContainerDensity',
            defaultValue=0.0,
            validator=FloatBoundedValidator(0.0),
            doc=
            'The value for the container Mass density (g/cm^3) or Number density (1/Angstrom^3).'
        )

        self.setPropertyGroup('ContainerWorkspace', 'Container Options')
        self.setPropertyGroup('ContainerChemicalFormula', 'Container Options')
        self.setPropertyGroup('ContainerCoherentXSection', 'Container Options')
        self.setPropertyGroup('ContainerIncoherentXSection',
                              'Container Options')
        self.setPropertyGroup('ContainerAttenuationXSection',
                              'Container Options')
        self.setPropertyGroup('ContainerDensityType', 'Container Options')
        self.setPropertyGroup('ContainerDensity', 'Container Options')

        self.setPropertySettings('ContainerChemicalFormula',
                                 container_condition)
        self.setPropertySettings('ContainerDensityType', container_condition)
        self.setPropertySettings('ContainerDensity', container_condition)

        # Shape options
        self.declareProperty(name='Shape',
                             defaultValue='FlatPlate',
                             validator=StringListValidator(
                                 ['FlatPlate', 'Cylinder', 'Annulus']),
                             doc='Geometric shape of the sample environment')

        flat_plate_condition = VisibleWhenProperty('Shape',
                                                   PropertyCriterion.IsEqualTo,
                                                   'FlatPlate')
        cylinder_condition = VisibleWhenProperty('Shape',
                                                 PropertyCriterion.IsEqualTo,
                                                 'Cylinder')
        annulus_condition = VisibleWhenProperty('Shape',
                                                PropertyCriterion.IsEqualTo,
                                                'Annulus')

        # height is common to all, and should be the same for sample and container
        self.declareProperty('Height',
                             defaultValue=0.0,
                             validator=FloatBoundedValidator(0.0),
                             doc='Height of the sample environment (cm)')

        self.setPropertyGroup('Shape', 'Shape Options')
        self.setPropertyGroup('Height', 'Shape Options')

        # ---------------------------Sample---------------------------
        # Flat Plate
        self.declareProperty(name='SampleWidth',
                             defaultValue=0.0,
                             validator=FloatBoundedValidator(0.0),
                             doc='Width of the sample environment (cm)')
        self.declareProperty(name='SampleThickness',
                             defaultValue=0.0,
                             validator=FloatBoundedValidator(0.0),
                             doc='Thickness of the sample environment (cm)')
        self.declareProperty(name='SampleCenter',
                             defaultValue=0.0,
                             doc='Center of the sample environment')
        self.declareProperty(
            name='SampleAngle',
            defaultValue=0.0,
            validator=FloatBoundedValidator(0.0),
            doc=
            'Angle of the sample environment with respect to the beam (degrees)'
        )

        self.setPropertySettings('SampleWidth', flat_plate_condition)
        self.setPropertySettings('SampleThickness', flat_plate_condition)
        self.setPropertySettings('SampleCenter', flat_plate_condition)
        self.setPropertySettings('SampleAngle', flat_plate_condition)

        self.setPropertyGroup('SampleWidth', 'Sample Shape Options')
        self.setPropertyGroup('SampleThickness', 'Sample Shape Options')
        self.setPropertyGroup('SampleCenter', 'Sample Shape Options')
        self.setPropertyGroup('SampleAngle', 'Sample Shape Options')

        # Cylinder
        self.declareProperty(name='SampleRadius',
                             defaultValue=0.0,
                             validator=FloatBoundedValidator(0.0),
                             doc='Radius of the sample environment (cm)')

        self.setPropertySettings('SampleRadius', cylinder_condition)
        self.setPropertyGroup('SampleRadius', 'Sample Shape Options')

        # Annulus
        self.declareProperty(name='SampleInnerRadius',
                             defaultValue=0.0,
                             validator=FloatBoundedValidator(0.0),
                             doc='Inner radius of the sample environment (cm)')
        self.declareProperty(name='SampleOuterRadius',
                             defaultValue=0.0,
                             validator=FloatBoundedValidator(0.0),
                             doc='Outer radius of the sample environment (cm)')

        self.setPropertySettings('SampleInnerRadius', annulus_condition)
        self.setPropertySettings('SampleOuterRadius', annulus_condition)

        self.setPropertyGroup('SampleInnerRadius', 'Sample Shape Options')
        self.setPropertyGroup('SampleOuterRadius', 'Sample Shape Options')

        # ---------------------------Container---------------------------
        # Flat Plate
        self.declareProperty(
            name='ContainerFrontThickness',
            defaultValue=0.0,
            validator=FloatBoundedValidator(0.0),
            doc='Front thickness of the container environment (cm)')
        self.declareProperty(
            name='ContainerBackThickness',
            defaultValue=0.0,
            validator=FloatBoundedValidator(0.0),
            doc='Back thickness of the container environment (cm)')

        container_flat_plate_condition = VisibleWhenProperty(
            container_condition, flat_plate_condition, LogicOperator.And)

        self.setPropertySettings('ContainerFrontThickness',
                                 container_flat_plate_condition)
        self.setPropertySettings('ContainerBackThickness',
                                 container_flat_plate_condition)

        self.setPropertyGroup('ContainerFrontThickness',
                              'Container Shape Options')
        self.setPropertyGroup('ContainerBackThickness',
                              'Container Shape Options')

        # Both cylinder and annulus have an annulus container

        not_flat_plate_condition = VisibleWhenProperty(
            'Shape', PropertyCriterion.IsNotEqualTo, 'FlatPlate')

        container_n_f_p_condition = VisibleWhenProperty(
            container_condition, not_flat_plate_condition, LogicOperator.And)

        self.declareProperty(
            name='ContainerInnerRadius',
            defaultValue=0.0,
            validator=FloatBoundedValidator(0.0),
            doc='Inner radius of the container environment (cm)')
        self.declareProperty(
            name='ContainerOuterRadius',
            defaultValue=0.0,
            validator=FloatBoundedValidator(0.0),
            doc='Outer radius of the container environment (cm)')

        self.setPropertySettings('ContainerInnerRadius',
                                 container_n_f_p_condition)
        self.setPropertySettings('ContainerOuterRadius',
                                 container_n_f_p_condition)

        self.setPropertyGroup('ContainerInnerRadius',
                              'Container Shape Options')
        self.setPropertyGroup('ContainerOuterRadius',
                              'Container Shape Options')

        # output
        self.declareProperty(
            WorkspaceGroupProperty(name='CorrectionsWorkspace',
                                   defaultValue='corrections',
                                   direction=Direction.Output,
                                   optional=PropertyMode.Optional),
            doc='Name of the workspace group to save correction factors')
        self.setPropertyGroup('CorrectionsWorkspace', 'Output Options')
Beispiel #21
0
    def PyInit(self):

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

        self.declareProperty(
            MultipleFileProperty('BackgroundRun',
                                 action=FileAction.OptionalLoad,
                                 extensions=['nxs']),
            doc='Run number(s) of background (empty can) run(s).')

        self.declareProperty(
            MultipleFileProperty('CalibrationRun',
                                 action=FileAction.OptionalLoad,
                                 extensions=['nxs']),
            doc='Run number(s) of vanadium calibration run(s).')

        self.declareProperty(
            MultipleFileProperty('CalibrationBackgroundRun',
                                 action=FileAction.OptionalLoad,
                                 extensions=['nxs']),
            doc=
            'Run number(s) of background (empty can) run(s) for vanadium run.')

        self.declareProperty(
            MultipleFileProperty('AlignmentRun',
                                 action=FileAction.OptionalLoad,
                                 extensions=['nxs']),
            doc='Run number(s) of vanadium run(s) used for '
            'peak alignment for UnmirrorOption=[5, 7]')

        self.declareProperty(name='SumRuns',
                             defaultValue=False,
                             doc='Whether to sum all the input runs.')

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

        self.declareProperty(
            name='UnmirrorOption',
            defaultValue=6,
            validator=IntBoundedValidator(lower=0, upper=7),
            doc='Unmirroring options : \n'
            '0 no unmirroring\n'
            '1 sum of left and right\n'
            '2 left\n'
            '3 right\n'
            '4 shift right according to left and sum\n'
            '5 like 4, but use alignment run for peak positions\n'
            '6 center both left and right at zero and sum\n'
            '7 like 6, but use alignment run for peak positions')

        self.declareProperty(name='BackgroundScalingFactor',
                             defaultValue=1.,
                             validator=FloatBoundedValidator(lower=0),
                             doc='Scaling factor for background subtraction')

        self.declareProperty(
            name='CalibrationBackgroundScalingFactor',
            defaultValue=1.,
            validator=FloatBoundedValidator(lower=0),
            doc=
            'Scaling factor for background subtraction for vanadium calibration'
        )

        self.declareProperty(
            name='CalibrationPeakRange',
            defaultValue=[-0.003, 0.003],
            validator=FloatArrayMandatoryValidator(),
            doc='Peak range for integration over calibration file peak (in mev)'
        )

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

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

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

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

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

        self.declareProperty(name='SpectrumAxis',
                             defaultValue='SpectrumNumber',
                             validator=StringListValidator(
                                 ['SpectrumNumber', '2Theta', 'Q', 'Q2']),
                             doc='The spectrum axis conversion target.')
Beispiel #22
0
    def PyInit(self):
        # Refinement parameters
        self.declareProperty(
            name="QTolerance",
            defaultValue=0.5,
            direction=Direction.Input,
            validator=FloatBoundedValidator(lower=0.0),
            doc="Radius of isotropic q envelope to search within.")
        self.declareProperty(
            name="QDecrement",
            defaultValue=0.95,
            validator=FloatBoundedValidator(lower=0.0, upper=1.0),
            direction=Direction.Input,
            doc="Multiplicative factor by which to decrement q envelope\
             on each iteration.")
        self.declareProperty(name="DTolerance",
                             defaultValue=0.01,
                             direction=Direction.Input,
                             validator=FloatBoundedValidator(lower=0.0),
                             doc="Observed peak is linked if\
             abs(dSpacing) < dPredicted + dTolerance.")
        self.declareProperty(
            name="NumPeaks",
            defaultValue=15,
            direction=Direction.Input,
            validator=IntBoundedValidator(lower=0),
            doc="Number of peaks, ordered from highest to lowest \
            dSpacing to consider.")
        self.declareProperty(
            name="PeakIncrement",
            defaultValue=10,
            validator=IntBoundedValidator(lower=0),
            direction=Direction.Input,
            doc="Number of peaks to add to numPeaks on each iteration.")
        self.declareProperty(name="Iterations",
                             defaultValue=10,
                             validator=IntBoundedValidator(lower=1),
                             direction=Direction.Input,
                             doc="Number of cycles of refinement.")

        # lattice
        self.declareProperty(name="a",
                             defaultValue=1.0,
                             validator=FloatBoundedValidator(lower=0.0),
                             direction=Direction.Input,
                             doc="Lattice parameter a.")
        self.declareProperty(name="b",
                             defaultValue=1.0,
                             validator=FloatBoundedValidator(lower=0.0),
                             direction=Direction.Input,
                             doc="Lattice parameter b.")
        self.declareProperty(name="c",
                             defaultValue=1.0,
                             validator=FloatBoundedValidator(lower=0.0),
                             direction=Direction.Input,
                             doc="Lattice parameter c.")
        self.declareProperty(name="alpha",
                             defaultValue=90.0,
                             validator=FloatBoundedValidator(lower=0.0),
                             direction=Direction.Input,
                             doc="Lattice parameter alpha.")
        self.declareProperty(name="beta",
                             defaultValue=90.0,
                             validator=FloatBoundedValidator(lower=0.0),
                             direction=Direction.Input,
                             doc="Lattice parameter beta.")
        self.declareProperty(name="gamma",
                             defaultValue=90.0,
                             validator=FloatBoundedValidator(lower=0.0),
                             direction=Direction.Input,
                             doc="Lattice parameter gamma.")

        # linked predicted peaks parameters
        self.declareProperty(
            name="MinWavelength",
            defaultValue=0.8,
            validator=FloatBoundedValidator(lower=0.0),
            direction=Direction.Input,
            doc="Minimum wavelength for LinkedPredictedPeaks.")
        self.declareProperty(
            name="MaxWavelength",
            defaultValue=9.3,
            validator=FloatBoundedValidator(lower=0.0),
            direction=Direction.Input,
            doc="Maximum wavelength for LinkedPredictedPeaks.")
        self.declareProperty(name="MinDSpacing",
                             defaultValue=0.6,
                             validator=FloatBoundedValidator(lower=0.0),
                             direction=Direction.Input,
                             doc="Minimum dSpacing for LinkedPredictedPeaks.")
        self.declareProperty(name="MaxDSpacing",
                             defaultValue=20.0,
                             validator=FloatBoundedValidator(lower=0.0),
                             direction=Direction.Input,
                             doc="Maximum dSpacing for LinkedPredictedPeaks.")
        self.declareProperty(name="ReflectionCondition",
                             defaultValue="Primitive",
                             direction=Direction.Input,
                             validator=StringListValidator([
                                 "Primitive", "C-face centred",
                                 "A-face centred", "B-face centred",
                                 "Body centred", "All-face centred",
                                 "Rhombohedrally centred, obverse",
                                 "Rhombohedrally centred, reverse",
                                 "Hexagonally centred, reverse"
                             ]),
                             doc="Reflection condition \
                                    for LinkedPredictedPeaks.")

        # input workspaces
        self.declareProperty(
            WorkspaceProperty(name="Workspace",
                              defaultValue="",
                              optional=PropertyMode.Mandatory,
                              direction=Direction.Input),
            doc="Instrument workspace on which observed peaks are defined.")
        self.declareProperty(
            ITableWorkspaceProperty(name="ObservedPeaks",
                                    defaultValue="",
                                    optional=PropertyMode.Mandatory,
                                    direction=Direction.Input),
            doc="FindPeaks table to which PredictedPeaks are compared.")
        self.declareProperty(
            ITableWorkspaceProperty(name="PredictedPeaks",
                                    defaultValue="",
                                    optional=PropertyMode.Mandatory,
                                    direction=Direction.Input),
            doc="PredictedPeaks table to which ObservedPeaks are compared.")

        # output workspaces
        self.declareProperty(
            ITableWorkspaceProperty(name="LinkedPeaks",
                                    defaultValue="",
                                    validator=StringMandatoryValidator(),
                                    direction=Direction.Output),
            doc="Linked peaks: UB matrix consistent with that of \
            PredictedPeaks.")
        self.declareProperty(
            ITableWorkspaceProperty(name="LinkedPredictedPeaks",
                                    defaultValue="",
                                    validator=StringMandatoryValidator(),
                                    direction=Direction.Output),
            doc="LinkedPredictedPeaks: UB matrix consistent with \
            PredictedPeaks.")
        self.declareProperty(
            "DeleteWorkspace",
            defaultValue=False,
            direction=Direction.Input,
            doc="Delete workspace after execution for memory management.")

        # groupings
        self.setPropertyGroup("QTolerance", "Refinement parameters")
        self.setPropertyGroup("QDecrement", "Refinement parameters")
        self.setPropertyGroup("DTolerance", "Refinement parameters")
        self.setPropertyGroup("NumPeaks", "Refinement parameters")
        self.setPropertyGroup("PeakIncrement", "Refinement parameters")
        self.setPropertyGroup("Iterations", "Refinement parameters")
        self.setPropertyGroup("a", "Lattice")
        self.setPropertyGroup("b", "Lattice")
        self.setPropertyGroup("c", "Lattice")
        self.setPropertyGroup("alpha", "Lattice")
        self.setPropertyGroup("beta", "Lattice")
        self.setPropertyGroup("gamma", "Lattice")
        self.setPropertyGroup("MinWavelength", "PredictPeaksParameters")
        self.setPropertyGroup("MaxWavelength", "PredictPeaksParameters")
        self.setPropertyGroup("MinDSpacing", "PredictPeaksParameters")
        self.setPropertyGroup("MaxDSpacing", "PredictPeaksParameters")
        self.setPropertyGroup("ReflectionCondition", "PredictPeaksParameters")
        self.setPropertyGroup("Workspace", "Input")
        self.setPropertyGroup("ObservedPeaks", "Input")
        self.setPropertyGroup("PredictedPeaks", "Input")
        self.setPropertyGroup("LinkedPeaks", "Output")
        self.setPropertyGroup("LinkedPredictedPeaks", "Output")
        self.setPropertyGroup("DeleteWorkspace", "Output")
Beispiel #23
0
    def PyInit(self):
        """Initialize the algorithm's input and output properties."""
        PROPGROUP_SIMULATION_INSTRUMENT = 'Simulation Instrument Settings'
        greaterThanOneInt = IntBoundedValidator(lower=2)
        greaterThanTwoInt = IntBoundedValidator(lower=3)
        inputWorkspaceValidator = CompositeValidator()
        inputWorkspaceValidator.add(InstrumentValidator())
        inputWorkspaceValidator.add(WorkspaceUnitValidator('TOF'))

        # Properties.
        self.declareProperty(
            MatrixWorkspaceProperty(name=common.PROP_INPUT_WS,
                                    defaultValue='',
                                    validator=inputWorkspaceValidator,
                                    optional=PropertyMode.Optional,
                                    direction=Direction.Input),
            doc='A workspace for which to simulate the self shielding.')
        self.declareProperty(
            MatrixWorkspaceProperty(name=common.PROP_OUTPUT_WS,
                                    defaultValue='',
                                    direction=Direction.Output),
            doc='A workspace containing the self shielding correction factors.'
        )
        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(
            name=common.PROP_SIMULATION_INSTRUMENT,
            defaultValue=common.SIMULATION_INSTRUMEN_SPARSE,
            validator=StringListValidator([
                common.SIMULATION_INSTRUMEN_SPARSE,
                common.SIMULATION_INSTRUMENT_FULL
            ]),
            direction=Direction.Input,
            doc=
            'Select if the simulation should be performed on full or approximated instrument.'
        )
        self.setPropertyGroup(common.PROP_SIMULATION_INSTRUMENT,
                              PROPGROUP_SIMULATION_INSTRUMENT)
        self.declareProperty(
            name=common.PROP_SPARSE_INSTRUMENT_ROWS,
            defaultValue=5,
            validator=greaterThanTwoInt,
            direction=Direction.Input,
            doc='Number of detector rows in sparse simulation instrument.')
        self.setPropertyGroup(common.PROP_SPARSE_INSTRUMENT_ROWS,
                              PROPGROUP_SIMULATION_INSTRUMENT)
        self.setPropertySettings(
            common.PROP_SPARSE_INSTRUMENT_ROWS,
            EnabledWhenProperty(common.PROP_SIMULATION_INSTRUMENT,
                                PropertyCriterion.IsEqualTo,
                                common.SIMULATION_INSTRUMEN_SPARSE))
        self.declareProperty(
            name=common.PROP_SPARSE_INSTRUMENT_COLUMNS,
            defaultValue=20,
            validator=greaterThanOneInt,
            direction=Direction.Input,
            doc='Number of detector columns in sparse simulation instrument.')
        self.setPropertyGroup(common.PROP_SPARSE_INSTRUMENT_COLUMNS,
                              PROPGROUP_SIMULATION_INSTRUMENT)
        self.setPropertySettings(
            common.PROP_SPARSE_INSTRUMENT_COLUMNS,
            EnabledWhenProperty(common.PROP_SIMULATION_INSTRUMENT,
                                PropertyCriterion.IsEqualTo,
                                common.SIMULATION_INSTRUMEN_SPARSE))
        self.declareProperty(
            name=common.PROP_NUMBER_OF_SIMULATION_WAVELENGTHS,
            defaultValue=Property.EMPTY_INT,
            validator=greaterThanTwoInt,
            direction=Direction.Input,
            doc=
            'Number of wavelength points where the simulation is performed (default: all).'
        )
Beispiel #24
0
    def PyInit(self):
        self.declareProperty(
            MatrixWorkspaceProperty('InputWorkspace',
                                    '',
                                    direction=Direction.Input),
            doc='The _iqt.nxs InputWorkspace used by the algorithm')

        self.declareProperty(name='Function',
                             defaultValue='',
                             doc='The function to use in fitting')

        self.declareProperty(name='FitType',
                             defaultValue='',
                             doc='The type of fit being carried out')

        self.declareProperty(name='StartX',
                             defaultValue=0.0,
                             validator=FloatBoundedValidator(0.0),
                             doc="The first value for X")

        self.declareProperty(name='EndX',
                             defaultValue=0.2,
                             validator=FloatBoundedValidator(0.0),
                             doc="The last value for X")

        self.declareProperty(name='SpecMin',
                             defaultValue=0,
                             validator=IntBoundedValidator(0),
                             doc='Minimum spectra in the worksapce to fit')

        self.declareProperty(name='SpecMax',
                             defaultValue=1,
                             validator=IntBoundedValidator(0),
                             doc='Maximum spectra in the worksapce to fit')

        self.declareProperty(name='Minimizer',
                             defaultValue='Levenberg-Marquardt',
                             doc='The minimizer to use in fitting')

        self.declareProperty(
            name="MaxIterations",
            defaultValue=500,
            validator=IntBoundedValidator(0),
            doc="The Maximum number of iterations for the fit")

        self.declareProperty(
            name='ConstrainIntensities',
            defaultValue=False,
            doc="If the Intensities should be constrained during the fit")

        self.declareProperty(
            MatrixWorkspaceProperty('OutputResultWorkspace',
                                    '',
                                    direction=Direction.Output),
            doc='The outputworkspace containing the results of the fit data')

        self.declareProperty(
            ITableWorkspaceProperty('OutputParameterWorkspace',
                                    '',
                                    direction=Direction.Output),
            doc='The outputworkspace containing the parameters for each fit')

        self.declareProperty(
            WorkspaceGroupProperty('OutputWorkspaceGroup',
                                   '',
                                   direction=Direction.Output),
            doc=
            'The OutputWorkspace group Data, Calc and Diff, values for the fit of each spectra'
        )
Beispiel #25
0
    def PyInit(self):

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        self.declareProperty(
            'OutputBinning',
            '',
            doc=
            'Output binning for each distance. : separated list of binning params.'
        )
        self.setPropertyGroup('OutputBinning', 'Integration Options')
        self.setPropertyGroup('OutputType', 'Integration Options')
        self.setPropertyGroup('CalculateResolution', 'Integration Options')
        self.declareProperty(
            'ClearCorrected2DWorkspace', True,
            'Whether to clear the fully corrected 2D workspace.')

        self.declareProperty(
            'SensitivityWithOffsets', False,
            'Whether the sensitivity data has been measured with different horizontal offsets.'
        )

        self.declareProperty(
            'StitchReferenceIndex',
            defaultValue=1,
            validator=IntBoundedValidator(lower=0),
            doc='Index of reference workspace during stitching.')

        self.copyProperties('SANSILLIntegration', ['ShapeTable'])

        self.copyProperties('SANSILLReduction', 'Wavelength')
Beispiel #26
0
    def PyInit(self):
        """Initialize the algorithm's input and output properties."""
        PROPGROUP_FLAT_BKG = 'Flat Time-Independent Background'
        PROPGROUP_INCIDENT_ENERGY_CALIBRATION = 'Indicent Energy Calibration'
        PROPGROUP_MON_NORMALISATION = 'Neutron Flux Normalisation'
        # Validators.
        mandatoryPositiveInt = CompositeValidator()
        mandatoryPositiveInt.add(IntMandatoryValidator())
        mandatoryPositiveInt.add(IntBoundedValidator(lower=0))
        positiveFloat = FloatBoundedValidator(lower=0)
        positiveInt = IntBoundedValidator(lower=0)
        inputWorkspaceValidator = CompositeValidator()
        inputWorkspaceValidator.add(InstrumentValidator())
        inputWorkspaceValidator.add(WorkspaceUnitValidator('TOF'))

        # Properties.
        self.declareProperty(MultipleFileProperty(name=common.PROP_INPUT_FILE,
                                                  action=FileAction.OptionalLoad,
                                                  extensions=['nxs']),
                             doc='An input run number (or a list thereof) or a filename.')
        self.getProperty(common.PROP_INPUT_FILE).setAutoTrim(False)
        self.declareProperty(MatrixWorkspaceProperty(
            name=common.PROP_INPUT_WS,
            defaultValue='',
            validator=inputWorkspaceValidator,
            optional=PropertyMode.Optional,
            direction=Direction.Input),
            doc='Input workspace if no run is given.')
        self.declareProperty(WorkspaceProperty(name=common.PROP_OUTPUT_WS,
                                               defaultValue='',
                                               direction=Direction.Output),
                             doc='A flux normalized and background subtracted workspace.')
        self.declareProperty(name=common.PROP_CLEANUP_MODE,
                             defaultValue=utils.Cleanup.ON,
                             validator=StringListValidator([
                                 utils.Cleanup.ON,
                                 utils.Cleanup.OFF]),
                             direction=Direction.Input,
                             doc='What to do with intermediate workspaces.')
        self.declareProperty(name=common.PROP_SUBALG_LOGGING,
                             defaultValue=common.SUBALG_LOGGING_OFF,
                             validator=StringListValidator([
                                 common.SUBALG_LOGGING_OFF,
                                 common.SUBALG_LOGGING_ON]),
                             direction=Direction.Input,
                             doc='Enable or disable subalgorithms to ' + 'print in the logs.')
        self.declareProperty(name=common.PROP_EPP_METHOD,
                             defaultValue=common.EPP_METHOD_AUTO,
                             validator=StringListValidator([
                                 common.EPP_METHOD_AUTO,
                                 common.EPP_METHOD_FIT,
                                 common.EPP_METHOD_CALCULATE]),
                             direction=Direction.Input,
                             doc='Method to create the EPP table for detectors (monitor is awlays fitted).')
        self.declareProperty(name=common.PROP_EPP_SIGMA,
                             defaultValue=Property.EMPTY_DBL,
                             validator=positiveFloat,
                             direction=Direction.Input,
                             doc='Nominal sigma for the EPP table when ' + common.PROP_EPP_METHOD
                                 + ' is set to ' + common.EPP_METHOD_CALCULATE
                                 + ' (default: 10 times the first bin width).')
        self.declareProperty(name=common.PROP_ELASTIC_CHANNEL_MODE,
                             defaultValue=common.ELASTIC_CHANNEL_AUTO,
                             validator=StringListValidator([
                                 common.ELASTIC_CHANNEL_AUTO,
                                 common.ELASTIC_CHANNEL_SAMPLE_LOG,
                                 common.ELASTIC_CHANNEL_FIT]),
                             direction=Direction.Input,
                             doc='How to acquire the nominal elastic channel.')
        self.declareProperty(MatrixWorkspaceProperty(
                             name=common.PROP_ELASTIC_CHANNEL_WS,
                             defaultValue='',
                             direction=Direction.Input,
                             optional=PropertyMode.Optional),
                             doc='A single value workspace containing the nominal elastic channel index'
                                 '(can be floating point). Overrides {}.'.format(common.PROP_ELASTIC_CHANNEL_MODE))
        self.declareProperty(name=common.PROP_MON_INDEX,
                             defaultValue=Property.EMPTY_INT,
                             validator=positiveInt,
                             direction=Direction.Input,
                             doc='Index of the incident monitor, if not specified in instrument parameters.')
        self.declareProperty(name=common.PROP_INCIDENT_ENERGY_CALIBRATION,
                             defaultValue=common.INCIDENT_ENERGY_CALIBRATION_AUTO,
                             validator=StringListValidator([
                                 common.INCIDENT_ENERGY_CALIBRATION_AUTO,
                                 common.INCIDENT_ENERGY_CALIBRATION_ON,
                                 common.INCIDENT_ENERGY_CALIBRATION_OFF]),
                             direction=Direction.Input,
                             doc='Control the incident energy calibration.')
        self.setPropertyGroup(common.PROP_INCIDENT_ENERGY_CALIBRATION, PROPGROUP_INCIDENT_ENERGY_CALIBRATION)
        self.declareProperty(MatrixWorkspaceProperty(
            name=common.PROP_INCIDENT_ENERGY_WS,
            defaultValue='',
            direction=Direction.Input,
            optional=PropertyMode.Optional),
            doc='A single-valued workspace holding a previously determined ' + 'incident energy.')
        self.setPropertyGroup(common.PROP_INCIDENT_ENERGY_WS, PROPGROUP_INCIDENT_ENERGY_CALIBRATION)
        self.declareProperty(name=common.PROP_FLAT_BKG,
                             defaultValue=common.BKG_AUTO,
                             validator=StringListValidator([
                                 common.BKG_AUTO,
                                 common.BKG_ON,
                                 common.BKG_OFF]),
                             direction=Direction.Input,
                             doc='Control flat background subtraction.')
        self.setPropertyGroup(common.PROP_FLAT_BKG, PROPGROUP_FLAT_BKG)
        self.declareProperty(name=common.PROP_FLAT_BKG_SCALING,
                             defaultValue=1.0,
                             validator=positiveFloat,
                             direction=Direction.Input,
                             doc='Flat background multiplication factor.')
        self.setPropertyGroup(common.PROP_FLAT_BKG_SCALING, PROPGROUP_FLAT_BKG)
        self.declareProperty(name=common.PROP_FLAT_BKG_WINDOW,
                             defaultValue=30,
                             validator=mandatoryPositiveInt,
                             direction=Direction.Input,
                             doc='Running average window width (in bins) for flat background.')
        self.setPropertyGroup(common.PROP_FLAT_BKG_WINDOW, PROPGROUP_FLAT_BKG)
        self.declareProperty(MatrixWorkspaceProperty(
            name=common.PROP_FLAT_BKG_WS,
            defaultValue='',
            direction=Direction.Input,
            optional=PropertyMode.Optional),
            doc='Workspace with previously determined flat background data.')
        self.setPropertyGroup(common.PROP_FLAT_BKG_WS, PROPGROUP_FLAT_BKG)
        self.declareProperty(name=common.PROP_DET_HOR_GROUPING,
                             defaultValue=1,
                             doc='Step to use when grouping detectors horizontally (between tubes) to increase'
                                 ' the statistics for flat background calculation.')
        self.setPropertyGroup(common.PROP_DET_HOR_GROUPING, PROPGROUP_FLAT_BKG)
        self.declareProperty(name=common.PROP_DET_VER_GROUPING,
                             defaultValue=1,
                             doc='Step to use when grouping detectors vertically (inside the same tube)'
                                 ' to increase the statistics for flat background calculation.')
        self.setPropertyGroup(common.PROP_DET_VER_GROUPING, PROPGROUP_FLAT_BKG)
        self.declareProperty(name=common.PROP_NORMALISATION,
                             defaultValue=common.NORM_METHOD_MON,
                             validator=StringListValidator([
                                 common.NORM_METHOD_MON,
                                 common.NORM_METHOD_TIME,
                                 common.NORM_METHOD_OFF]),
                             direction=Direction.Input,
                             doc='Normalisation method.')
        self.setPropertyGroup(common.PROP_NORMALISATION, PROPGROUP_MON_NORMALISATION)
        self.declareProperty(name=common.PROP_MON_PEAK_SIGMA_MULTIPLIER,
                             defaultValue=7.0,
                             validator=positiveFloat,
                             direction=Direction.Input,
                             doc="Width of the monitor peak in multiples " + " of 'Sigma' in monitor's EPP table.")
        self.setPropertyGroup(common.PROP_MON_PEAK_SIGMA_MULTIPLIER, PROPGROUP_MON_NORMALISATION)
        # Rest of the output properties.
        self.declareProperty(WorkspaceProperty(
            name=common.PROP_OUTPUT_RAW_WS,
            defaultValue='',
            direction=Direction.Output,
            optional=PropertyMode.Optional),
            doc='Non-normalized and non-background subtracted output workspace for DirectILLDiagnostics.')
        self.setPropertyGroup(common.PROP_OUTPUT_RAW_WS,
                              common.PROPGROUP_OPTIONAL_OUTPUT)
        self.declareProperty(WorkspaceProperty(
            name=common.PROP_OUTPUT_ELASTIC_CHANNEL_WS,
            defaultValue='',
            direction=Direction.Output,
            optional=PropertyMode.Optional),
            doc='Output workspace for elastic channel index.')
        self.setPropertyGroup(common.PROP_OUTPUT_ELASTIC_CHANNEL_WS,
                              common.PROPGROUP_OPTIONAL_OUTPUT)
        self.declareProperty(ITableWorkspaceProperty(
            name=common.PROP_OUTPUT_DET_EPP_WS,
            defaultValue='',
            direction=Direction.Output,
            optional=PropertyMode.Optional),
            doc='Output workspace for elastic peak positions.')
        self.setPropertyGroup(common.PROP_OUTPUT_DET_EPP_WS,
                              common.PROPGROUP_OPTIONAL_OUTPUT)
        self.declareProperty(WorkspaceProperty(
            name=common.PROP_OUTPUT_INCIDENT_ENERGY_WS,
            defaultValue='',
            direction=Direction.Output,
            optional=PropertyMode.Optional),
            doc='Output workspace for calibrated incident energy.')
        self.setPropertyGroup(common.PROP_OUTPUT_INCIDENT_ENERGY_WS,
                              common.PROPGROUP_OPTIONAL_OUTPUT)
        self.declareProperty(WorkspaceProperty(
            name=common.PROP_OUTPUT_FLAT_BKG_WS,
            defaultValue='',
            direction=Direction.Output,
            optional=PropertyMode.Optional),
            doc='Output workspace for flat background.')
        self.setPropertyGroup(common.PROP_OUTPUT_FLAT_BKG_WS,
                              common.PROPGROUP_OPTIONAL_OUTPUT)
Beispiel #27
0
    def PyInit(self):
        ws_validator = InstrumentValidator()

        self.declareProperty(MatrixWorkspaceProperty('SampleWorkspace', '',
                                                     direction=Direction.Input,
                                                     validator=ws_validator),
                             doc='Name for the input sample workspace')

        self.declareProperty(name='SampleChemicalFormula', defaultValue='',
                             doc='Sample chemical formula')

        self.declareProperty(name='SampleCoherentXSection', defaultValue=0.0,
                             validator=FloatBoundedValidator(0.0),
                             doc='The coherent cross-section for the sample material in barns. To be used instead of '
                                 'Chemical Formula.')

        self.declareProperty(name='SampleIncoherentXSection', defaultValue=0.0,
                             validator=FloatBoundedValidator(0.0),
                             doc='The incoherent cross-section for the sample material in barns. To be used instead of '
                                 'Chemical Formula.')

        self.declareProperty(name='SampleAttenuationXSection', defaultValue=0.0,
                             validator=FloatBoundedValidator(0.0),
                             doc='The absorption cross-section for the sample material in barns. To be used instead of '
                                 'Chemical Formula.')

        self.declareProperty(name='SampleDensityType', defaultValue='Mass Density',
                             validator=StringListValidator(['Mass Density', 'Number Density']),
                             doc='Use of Mass density or Number density for the sample.')

        self.declareProperty(name='SampleNumberDensityUnit', defaultValue='Atoms',
                             validator=StringListValidator(['Atoms', 'Formula Units']),
                             doc='Choose which units SampleDensity refers to. Allowed values: '
                                 '[Atoms, Formula Units]')

        self.declareProperty(name='SampleDensity', defaultValue=0.1,
                             doc='The value for the sample Mass density (g/cm^3) or Number density (1/Angstrom^3).')

        self.declareProperty(name='SampleThickness', defaultValue=0.0,
                             validator=FloatBoundedValidator(0.0),
                             doc='Sample thickness in cm')

        self.declareProperty(name='SampleAngle', defaultValue=0.0,
                             doc='Angle between incident beam and normal to flat plate surface')

        self.declareProperty(MatrixWorkspaceProperty('CanWorkspace', '',
                                                     direction=Direction.Input,
                                                     optional=PropertyMode.Optional,
                                                     validator=ws_validator),
                             doc="Name for the input container workspace")

        self.declareProperty(name='CanChemicalFormula', defaultValue='',
                             doc='Container chemical formula')

        self.declareProperty(name='CanCoherentXSection', defaultValue=0.0,
                             validator=FloatBoundedValidator(0.0),
                             doc='The coherent cross-section for the can material in barns. To be used instead of '
                                 'Chemical Formula.')

        self.declareProperty(name='CanIncoherentXSection', defaultValue=0.0,
                             validator=FloatBoundedValidator(0.0),
                             doc='The incoherent cross-section for the can material in barns. To be used instead of '
                                 'Chemical Formula.')

        self.declareProperty(name='CanAttenuationXSection', defaultValue=0.0,
                             validator=FloatBoundedValidator(0.0),
                             doc='The absorption cross-section for the can material in barns. To be used instead of '
                                 'Chemical Formula.')

        self.declareProperty(name='CanDensityType', defaultValue='Mass Density',
                             validator=StringListValidator(['Mass Density', 'Number Density']),
                             doc='Use of Mass density or Number density for the can.')

        self.declareProperty(name='CanNumberDensityUnit', defaultValue='Atoms',
                             validator=StringListValidator(['Atoms', 'Formula Units']),
                             doc='Choose which units CanDensity refers to. Allowed values: [Atoms, Formula Units]')

        self.declareProperty(name='CanDensity', defaultValue=0.1,
                             doc='The value for the can Mass density (g/cm^3) or Number density (1/Angstrom^3).')

        self.declareProperty(name='CanFrontThickness', defaultValue=0.0,
                             validator=FloatBoundedValidator(0.0),
                             doc='Container front thickness in cm')

        self.declareProperty(name='CanBackThickness', defaultValue=0.0,
                             validator=FloatBoundedValidator(0.0),
                             doc='Container back thickness in cm')

        self.declareProperty(name='NumberWavelengths', defaultValue=10,
                             validator=IntBoundedValidator(1),
                             doc='Number of wavelengths for calculation')

        self.declareProperty(name='Interpolate', defaultValue=True,
                             doc='Interpolate the correction workspaces to match the sample workspace')

        self.declareProperty(name='Emode', defaultValue='Elastic',
                             validator=StringListValidator(['Elastic', 'Indirect', 'Direct', 'Efixed']),
                             doc='Energy transfer mode.')

        self.declareProperty(name='Efixed', defaultValue=0.,
                             doc='Analyser energy (mev). By default will be read from the instrument parameters. '
                                 'Specify manually to override. This is used only in Efixed energy transfer mode.')

        self.declareProperty(WorkspaceGroupProperty('OutputWorkspace', '',
                                                    direction=Direction.Output),
                             doc='The output corrections workspace group')
    def PyInit(self):

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        self.declareProperty(
            name='GroupDetectors',
            defaultValue=True,
            doc=
            'Group the pixels using the range, tube-by-tube (default) or in a custom way; \n'
            'it is not recommended to group the detectors at this stage, \n'
            'in order to get absorption corrections right, \n'
            'however the default value is True for backwards compatibility.')

        self.declareProperty(
            name='DiscardSingleDetectors',
            defaultValue=False,
            doc='Whether to discard the spectra of single detectors.')
    def PyInit(self):
        # basic sample options

        self.declareProperty(MatrixWorkspaceProperty(
            'InputWorkspace', '', direction=Direction.Input),
                             doc='Input workspace')

        self.declareProperty(
            name='MaterialAlreadyDefined',
            defaultValue=False,
            doc='Select this option if the material has already been defined')

        material_defined_prop = EnabledWhenProperty(
            'MaterialAlreadyDefined', PropertyCriterion.IsDefault)

        self.declareProperty(name='ChemicalFormula',
                             defaultValue='',
                             doc='Chemical formula of sample')
        self.setPropertySettings('ChemicalFormula', material_defined_prop)

        self.declareProperty(name='DensityType',
                             defaultValue='Mass Density',
                             validator=StringListValidator(
                                 ['Mass Density', 'Number Density']),
                             doc='Use of Mass density or Number density')
        self.setPropertySettings('DensityType', material_defined_prop)

        self.declareProperty(
            name='Density',
            defaultValue=0.1,
            doc='Mass density (g/cm^3) or Number density (atoms/Angstrom^3)')
        self.setPropertySettings('Density', material_defined_prop)

        # -------------------------------------------------------------------------------------------

        # Monte Carlo options
        self.declareProperty(name='NumberOfWavelengthPoints',
                             defaultValue=10,
                             validator=IntBoundedValidator(1),
                             doc='Number of wavelengths for calculation')

        self.declareProperty(name='EventsPerPoint',
                             defaultValue=1000,
                             validator=IntBoundedValidator(0),
                             doc='Number of neutron events')

        self.declareProperty(name='Interpolation',
                             defaultValue='Linear',
                             validator=StringListValidator(
                                 ['Linear', 'CSpline']),
                             doc='Type of interpolation')

        # -------------------------------------------------------------------------------------------

        # Beam size
        self.declareProperty(name='BeamHeight',
                             defaultValue=1.0,
                             validator=FloatBoundedValidator(0.0),
                             doc='Height of the beam (cm)')

        self.declareProperty(name='BeamWidth',
                             defaultValue=1.0,
                             validator=FloatBoundedValidator(0.0),
                             doc='Width of the beam (cm)')

        # -------------------------------------------------------------------------------------------

        # set up shape options

        self.declareProperty(
            name='Shape',
            defaultValue='FlatPlate',
            validator=StringListValidator(['FlatPlate', 'Cylinder',
                                           'Annulus']),
            doc=
            'Geometry of sample environment. Options are: FlatPlate, Cylinder, Annulus'
        )

        flat_plate_condition = VisibleWhenProperty('Shape',
                                                   PropertyCriterion.IsEqualTo,
                                                   'FlatPlate')
        cylinder_condition = VisibleWhenProperty('Shape',
                                                 PropertyCriterion.IsEqualTo,
                                                 'Cylinder')
        annulus_condition = VisibleWhenProperty('Shape',
                                                PropertyCriterion.IsEqualTo,
                                                'Annulus')

        # height is common to all options

        self.declareProperty(name='Height',
                             defaultValue=0.0,
                             validator=FloatBoundedValidator(0.0),
                             doc='Height of the sample environment (cm)')

        # flat plate options

        self.declareProperty(
            name='Width',
            defaultValue=0.0,
            validator=FloatBoundedValidator(0.0),
            doc='Width of the FlatPlate sample environment (cm)')
        self.setPropertySettings('Width', flat_plate_condition)

        self.declareProperty(
            name='Thickness',
            defaultValue=0.0,
            validator=FloatBoundedValidator(),
            doc='Thickness of the FlatPlate sample environment (cm)')
        self.setPropertySettings('Thickness', flat_plate_condition)

        self.declareProperty(name='Center',
                             defaultValue=0.0,
                             doc='Center of the FlatPlate sample environment')
        self.setPropertySettings('Center', flat_plate_condition)

        self.declareProperty(
            name='Angle',
            defaultValue=0.0,
            validator=FloatBoundedValidator(0.0),
            doc=
            'Angle of the FlatPlate sample environment with respect to the beam (degrees)'
        )
        self.setPropertySettings('Angle', flat_plate_condition)

        # cylinder options

        self.declareProperty(
            name='Radius',
            defaultValue=0.0,
            validator=FloatBoundedValidator(0.0),
            doc='Radius of the Cylinder sample environment (cm)')
        self.setPropertySettings('Radius', cylinder_condition)

        # annulus options

        self.declareProperty(
            name='OuterRadius',
            defaultValue=0.0,
            validator=FloatBoundedValidator(0.0),
            doc='Outer radius of the Annulus sample environment (cm)')
        self.setPropertySettings('OuterRadius', annulus_condition)

        self.declareProperty(
            name='InnerRadius',
            defaultValue=0.0,
            validator=FloatBoundedValidator(0.0),
            doc='Inner radius of the Annulus sample environment (cm)')
        self.setPropertySettings('InnerRadius', annulus_condition)

        # -------------------------------------------------------------------------------------------

        # Output options
        self.declareProperty(MatrixWorkspaceProperty(
            'OutputWorkspace', '', direction=Direction.Output),
                             doc='The output corrected workspace.')
 def PyInit(self):
     """Initialize the input and output properties of the algorithm."""
     nonnegativeInt = IntBoundedValidator(lower=0)
     wsIndexRange = IntBoundedValidator(lower=0, upper=255)
     nonnegativeIntArray = IntArrayBoundedValidator(lower=0)
     maxTwoNonnegativeInts = CompositeValidator()
     maxTwoNonnegativeInts.add(IntArrayLengthValidator(lenmin=0, lenmax=2))
     maxTwoNonnegativeInts.add(nonnegativeIntArray)
     self.declareProperty(MultipleFileProperty(
         Prop.RUN, action=FileAction.OptionalLoad, extensions=['nxs']),
                          doc='A list of input run numbers/files.')
     self.declareProperty(
         MatrixWorkspaceProperty(Prop.INPUT_WS,
                                 defaultValue='',
                                 direction=Direction.Input,
                                 validator=WorkspaceUnitValidator('TOF'),
                                 optional=PropertyMode.Optional),
         doc='An input workspace (units TOF) if no Run is specified.')
     self.declareProperty(
         MatrixWorkspaceProperty(Prop.OUTPUT_WS,
                                 defaultValue='',
                                 direction=Direction.Output),
         doc=
         'The preprocessed output workspace (unit wavelength), single histogram.'
     )
     self.declareProperty(
         Prop.TWO_THETA,
         defaultValue=Property.EMPTY_DBL,
         doc='A user-defined scattering angle 2 theta (unit degrees).')
     self.declareProperty(
         name=Prop.LINE_POSITION,
         defaultValue=Property.EMPTY_DBL,
         doc=
         'A workspace index corresponding to the beam centre between 0.0 and 255.0.'
     )
     self.declareProperty(MatrixWorkspaceProperty(
         Prop.DIRECT_LINE_WORKSPACE,
         defaultValue='',
         direction=Direction.Input,
         optional=PropertyMode.Optional),
                          doc='A pre-processed direct beam workspace.')
     self.declareProperty(Prop.SUBALG_LOGGING,
                          defaultValue=SubalgLogging.OFF,
                          validator=StringListValidator(
                              [SubalgLogging.OFF, SubalgLogging.ON]),
                          doc='Enable or disable child algorithm logging.')
     self.declareProperty(
         Prop.CLEANUP,
         defaultValue=utils.Cleanup.ON,
         validator=StringListValidator(
             [utils.Cleanup.ON, utils.Cleanup.OFF]),
         doc='Enable or disable intermediate workspace cleanup.')
     self.declareProperty(MatrixWorkspaceProperty(
         Prop.WATER_REFERENCE,
         defaultValue='',
         direction=Direction.Input,
         validator=WorkspaceUnitValidator("TOF"),
         optional=PropertyMode.Optional),
                          doc='A (water) calibration workspace (unit TOF).')
     self.declareProperty(Prop.SLIT_NORM,
                          defaultValue=SlitNorm.OFF,
                          validator=StringListValidator(
                              [SlitNorm.OFF, SlitNorm.ON]),
                          doc='Enable or disable slit normalisation.')
     self.declareProperty(Prop.FLUX_NORM_METHOD,
                          defaultValue=FluxNormMethod.TIME,
                          validator=StringListValidator([
                              FluxNormMethod.TIME, FluxNormMethod.MONITOR,
                              FluxNormMethod.OFF
                          ]),
                          doc='Neutron flux normalisation method.')
     self.declareProperty(
         IntArrayProperty(Prop.FOREGROUND_HALF_WIDTH,
                          validator=maxTwoNonnegativeInts),
         doc=
         'Number of foreground pixels at lower and higher angles from the centre pixel.'
     )
     self.declareProperty(
         Prop.BKG_METHOD,
         defaultValue=BkgMethod.CONSTANT,
         validator=StringListValidator(
             [BkgMethod.CONSTANT, BkgMethod.LINEAR, BkgMethod.OFF]),
         doc='Flat background calculation method for background subtraction.'
     )
     self.declareProperty(
         Prop.LOW_BKG_OFFSET,
         defaultValue=7,
         validator=nonnegativeInt,
         doc=
         'Distance of flat background region towards smaller detector angles from the '
         + 'foreground centre, in pixels.')
     self.declareProperty(
         Prop.LOW_BKG_WIDTH,
         defaultValue=5,
         validator=nonnegativeInt,
         doc=
         'Width of flat background region towards smaller detector angles from the '
         + 'foreground centre, in pixels.')
     self.declareProperty(
         Prop.HIGH_BKG_OFFSET,
         defaultValue=7,
         validator=nonnegativeInt,
         doc=
         'Distance of flat background region towards larger detector angles from the '
         + 'foreground centre, in pixels.')
     self.declareProperty(
         Prop.HIGH_BKG_WIDTH,
         defaultValue=5,
         validator=nonnegativeInt,
         doc=
         'Width of flat background region towards larger detector angles from the '
         + 'foreground centre, in pixels.')
     self.declareProperty(
         Prop.START_WS_INDEX,
         validator=wsIndexRange,
         defaultValue=0,
         doc='Start workspace index used for peak fitting.')
     self.declareProperty(Prop.END_WS_INDEX,
                          validator=wsIndexRange,
                          defaultValue=255,
                          doc='Last workspace index used for peak fitting.')
     self.declareProperty(
         Prop.XMIN,
         defaultValue=Property.EMPTY_DBL,
         doc='Minimum x value (unit Angstrom) used for peak fitting.')
     self.declareProperty(
         Prop.XMAX,
         defaultValue=Property.EMPTY_DBL,
         doc='Maximum x value (unit Angstrom) used for peak fitting.')
 def loadDataRanges():
     # Data range
     self.declareProperty('TwoThetaMin',
                          50,
                          validator=IntBoundedValidator(lower=0),
                          direction=Direction.Input,
                          doc='Minimum value for 2 Theta. Everything smaller gets removed.')
     self.declareProperty('TwoThetaMax',
                          120,
                          validator=IntBoundedValidator(lower=0),
                          direction=Direction.Input,
                          doc='Maximum value for 2 Theta. Everything bigger gets removed.')
     self.declareProperty(
         'WavelengthCenter',
         0.7,
         validator=FloatBoundedValidator(lower=0.0),
         direction=Direction.Input,
         doc='Center Wavelength is used to calculate automatic values for lambdaMin and lambdaMax if they are not specified.')
     self.declareProperty(
         'LambdaMin',
         0.3,
         validator=FloatBoundedValidator(lower=0.0),
         direction=Direction.Input,
         doc='Minimum value for lambda. Everything smaller gets removed. If zero it is not used and values get calculated from '
         'center wavelength.')
     self.declareProperty(
         'LambdaMax',
         1.1,
         validator=FloatBoundedValidator(lower=0.0),
         direction=Direction.Input,
         doc='Maximum value for lambda. Everything bigger gets removed. If zero it is not used and values get calculated from '
         'center wavelength.')
     self.declareProperty(
         'DMin',
         0.11,
         validator=FloatBoundedValidator(lower=0.0),
         direction=Direction.Input,
         doc='Minimum value for d. Everything smaller gets removed. If zero it is not used and values get calculated from 2 '
         'theta and lambda.')
     self.declareProperty(
         'DMax',
         1.37,
         validator=FloatBoundedValidator(lower=0.0),
         direction=Direction.Input,
         doc='Maximum value for d. Everything bigger gets removed. If zero it is not used and values get calculated from '
         '2 theta and lambda.')
     self.declareProperty(
         'DpMin',
         0.48,
         validator=FloatBoundedValidator(lower=0.0),
         direction=Direction.Input,
         doc='Minimum value for dp. Everything smaller gets removed. If zero it is not used and values get calculated from '
         '2 theta and lambda.')
     self.declareProperty(
         'DpMax',
         1.76,
         validator=FloatBoundedValidator(lower=0.0),
         direction=Direction.Input,
         doc='Maximum value for dp. Everything bigger gets removed. If zero it is not used and values get calculated from 2 '
         'theta and lambda.')
     grp2 = 'Data Ranges'
     self.setPropertyGroup('TwoThetaMin', grp2)
     self.setPropertyGroup('TwoThetaMax', grp2)
     self.setPropertyGroup('WavelengthCenter', grp2)
     self.setPropertyGroup('LambdaMin', grp2)
     self.setPropertyGroup('LambdaMax', grp2)
     self.setPropertyGroup('DMin', grp2)
     self.setPropertyGroup('DMax', grp2)
     self.setPropertyGroup('DpMin', grp2)
     self.setPropertyGroup('DpMax', grp2)