def PyInit(self): self.declareProperty(FileProperty('CalibrationRun', '', action=FileAction.Load, extensions=['nxs']), doc='File path of calibration run. Must be a detector scan.') self.declareProperty(FileProperty('CalibrationFile', '', action=FileAction.OptionalLoad, extensions=['nxs']), doc='Optional file containing previous calibration constants.') self.declareProperty(name='CalibrationMethod', defaultValue='Median', validator=StringListValidator(['Median', 'Mean', 'MostLikelyMean']), doc='The method of how the calibration constant of a ' 'pixel relative to the neighbouring one is derived.') self.declareProperty(name='InterpolateOverlappingAngles', defaultValue=False, doc='Wheter to interpolate 2theta values for overlapping regions between neighbouring cells.') self.declareProperty(name='NormaliseTo', defaultValue='None', validator=StringListValidator(['None', 'Monitor', 'ROI']), doc='Normalise to time, monitor or ROI counts before deriving the calibration.') thetaRangeValidator = FloatArrayOrderedPairsValidator() self.declareProperty(FloatArrayProperty(name='ROI', values=[0,100.], validator=thetaRangeValidator), doc='Regions of interest for normalisation [in scattering angle in degrees].') normaliseToROI = VisibleWhenProperty('NormaliseTo', PropertyCriterion.IsEqualTo, 'ROI') self.setPropertySettings('ROI', normaliseToROI) self.declareProperty(FloatArrayProperty(name='ExcludedRange', values=[], validator=thetaRangeValidator), doc='2theta regions to exclude from the computation of relative calibration constants ' '[in scattering angle in degrees]. ') pixelRangeValidator = CompositeValidator() greaterThanOne = IntArrayBoundedValidator() greaterThanOne.setLower(1) lengthTwo = IntArrayLengthValidator() lengthTwo.setLength(2) orderedPairsValidator = IntArrayOrderedPairsValidator() pixelRangeValidator.add(greaterThanOne) pixelRangeValidator.add(lengthTwo) pixelRangeValidator.add(orderedPairsValidator) self.declareProperty(IntArrayProperty(name='PixelRange', values=[1,3072], validator=pixelRangeValidator), doc='Range of the pixel numbers to compute the calibration factors for. ' 'For the other pixels outside the range, the factor will be set to 1.') self.declareProperty(MatrixWorkspaceProperty('OutputResponseWorkspace', '', optional=PropertyMode.Optional, direction=Direction.Output), doc='Output workspace containing the summed diffraction patterns of all the pixels.') self.declareProperty(MatrixWorkspaceProperty('OutputWorkspace', '', direction=Direction.Output), doc='Output workspace containing the detector efficiencies for each pixel.')
def PyInit(self): """Initialize the input and output properties of the algorithm.""" threeNonnegativeInts = CompositeValidator() threeNonnegativeInts.add(IntArrayLengthValidator(3)) nonnegativeInts = IntArrayBoundedValidator() nonnegativeInts.setLower(0) threeNonnegativeInts.add(nonnegativeInts) self.declareProperty( MatrixWorkspaceProperty( Prop.INPUT_WS, defaultValue='', direction=Direction.Input, validator=WorkspaceUnitValidator('Wavelength')), doc='An input workspace (units wavelength) to be integrated.') self.declareProperty( MatrixWorkspaceProperty(Prop.OUTPUT_WS, defaultValue='', direction=Direction.Output), doc='The integrated foreground divided by the summed direct beam.') self.declareProperty(Prop.SUBALG_LOGGING, defaultValue=SubalgLogging.OFF, validator=StringListValidator( [SubalgLogging.OFF, SubalgLogging.ON]), doc='Enable or disable child algorithm logging.') self.declareProperty( Prop.CLEANUP, defaultValue=common.WSCleanup.ON, validator=StringListValidator( [common.WSCleanup.ON, common.WSCleanup.OFF]), doc='Enable or disable intermediate workspace cleanup.') self.declareProperty(Prop.SUM_TYPE, defaultValue=SumType.IN_LAMBDA, validator=StringListValidator( [SumType.IN_LAMBDA, SumType.IN_Q]), doc='Type of summation to perform.') self.declareProperty( MatrixWorkspaceProperty( Prop.DIRECT_FOREGROUND_WS, defaultValue='', direction=Direction.Input, optional=PropertyMode.Optional, validator=WorkspaceUnitValidator('Wavelength')), doc= 'Summed direct beam workspace if output in reflectivity is required.' ) self.declareProperty( IntArrayProperty(Prop.FOREGROUND_INDICES, values=[ Property.EMPTY_INT, Property.EMPTY_INT, Property.EMPTY_INT ], validator=threeNonnegativeInts), doc= 'A three element array of foreground start, centre and end workspace indices.' )
def PyInit(self): self.declareProperty(name='Instrument', defaultValue='IRIS', validator=StringListValidator(['IRIS', 'OSIRIS']), doc='The name of the instrument.') self.declareProperty(name='Analyser', defaultValue='', validator=StringListValidator(['graphite', 'mica', 'fmica']), doc='The analyser bank used during run.') self.declareProperty(name='Reflection', defaultValue='', validator=StringListValidator(['002', '004', '006']), doc='Reflection number for instrument setup during run.') self.declareProperty(name="FirstRun", defaultValue=-1, validator=IntBoundedValidator(lower=0), doc="First Sample run-number.") self.declareProperty(name='LastRun', defaultValue=-1, validator=IntBoundedValidator(lower=0), doc="Last Sample run-number.") self.declareProperty(name='NumberSamples', defaultValue=-1, validator=IntBoundedValidator(lower=0), doc="Increment for run-number.") self.declareProperty(IntArrayProperty(name='SpectraRange', values=[0, 1], validator=IntArrayLengthValidator(2)), doc='Comma separated range of spectra numbers to use.') self.declareProperty(FloatArrayProperty(name='ElasticRange', validator=FloatArrayLengthValidator(2)), doc='Energy range for the elastic component.') self.declareProperty(FloatArrayProperty(name='InelasticRange', validator=FloatArrayLengthValidator(2)), doc='Energy range for the inelastic component.') self.declareProperty(FloatArrayProperty(name='TotalRange', validator=FloatArrayLengthValidator(2)), doc='Energy range for the total energy component.') self.declareProperty(name='SampleEnvironmentLogName', defaultValue='Position', doc='Name of the sample environment log entry') sample_environment_log_values = ['last_value', 'average'] self.declareProperty('SampleEnvironmentLogValue', 'last_value', StringListValidator(sample_environment_log_values), doc='Value selection of the sample environment log entry') self.declareProperty(name='MSDFit', defaultValue=False, doc='Perform an MSDFit. Do not use with GroupingMethod as "All"') self.declareProperty(name='WidthFit', defaultValue=False, doc='Perform a 2 peak width Fit. Do not use with GroupingMethod as "All"') self.declareProperty(name='Plot', defaultValue=False, doc='True to plot the output data.') self.declareProperty(name='Save', defaultValue=False, doc='True to save the output data.')
def PyInit(self): """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 PyInit(self): self.declareProperty( MultipleFileProperty('CalibrationRun', action=FileAction.Load, extensions=['nxs']), doc= 'File path of calibration runs (numors). Must be detector scans.') self.declareProperty( FileProperty('CalibrationFile', '', action=FileAction.OptionalLoad, extensions=['nxs']), doc='Optional file containing previous calibration constants.') self.declareProperty( name='CalibrationMethod', defaultValue='Median', validator=StringListValidator(['Median', 'Mean', 'MostLikelyMean']), doc='The method of how the calibration constant of a pixel ' 'is derived from the distribution of ratios.') self.declareProperty( name='DerivationMethod', defaultValue='SequentialSummedReference1D', validator=StringListValidator( ['SequentialSummedReference1D', 'GlobalSummedReference2D']), doc= 'Choose sequential for D20 (1D detector), global for D2B (2D detector).' ) self.declareProperty( name='InterpolateOverlappingAngles', defaultValue=False, doc= 'Whether to interpolate scattering angle values in overlapping regions (D20 only).' ) self.declareProperty( name='NormaliseTo', defaultValue='None', validator=StringListValidator(['None', 'Monitor', 'ROI']), doc= 'Normalise to monitor or ROI counts before deriving the calibration.' ) thetaRangeValidator = FloatArrayOrderedPairsValidator() self.declareProperty( FloatArrayProperty(name='ROI', values=[0, 100.], validator=thetaRangeValidator), doc= 'Scattering angle regions of interest for normalisation [degrees].' ) normaliseToROI = VisibleWhenProperty('NormaliseTo', PropertyCriterion.IsEqualTo, 'ROI') self.setPropertySettings('ROI', normaliseToROI) self.declareProperty( FloatArrayProperty(name='ExcludedRange', values=[], validator=thetaRangeValidator), doc='Scattering angle regions to exclude from the computation of ' 'relative calibration constants; for example, the beam stop [degrees]. ' ) pixelRangeValidator = CompositeValidator() greaterThanOne = IntArrayBoundedValidator(lower=1) lengthTwo = IntArrayLengthValidator() lengthTwo.setLength(2) orderedPairsValidator = IntArrayOrderedPairsValidator() pixelRangeValidator.add(greaterThanOne) pixelRangeValidator.add(lengthTwo) pixelRangeValidator.add(orderedPairsValidator) self.declareProperty( IntArrayProperty(name='PixelRange', values=[1, 3072], validator=pixelRangeValidator), doc= 'Range of the pixel numbers to compute the calibration factors for (D20 only); ' 'for the other pixels outside the range, the factor will be set to 1.' ) self.declareProperty( MatrixWorkspaceProperty('OutputResponseWorkspace', '', optional=PropertyMode.Optional, direction=Direction.Output), doc= 'Output workspace containing the summed diffraction patterns of all the overlapping pixels.' ) self.declareProperty( MatrixWorkspaceProperty('OutputWorkspace', '', direction=Direction.Output), doc= 'Output workspace containing the calibration constants (inverse of efficiency) for each pixel.' ) self.declareProperty( name='NumberOfIterations', defaultValue=1, validator=IntBoundedValidator(lower=0, upper=10), doc= 'Number of iterations to perform (D2B only): 0 means auto; that is, the ' 'iterations will terminate after reaching some Chi2/NdoF.') maskCriterionValidator = CompositeValidator() arrayLengthTwo = FloatArrayLengthValidator() arrayLengthTwo.setLengthMax(2) orderedPairs = FloatArrayOrderedPairsValidator() maskCriterionValidator.add(arrayLengthTwo) maskCriterionValidator.add(orderedPairs) self.declareProperty( FloatArrayProperty(name='MaskCriterion', values=[], validator=maskCriterionValidator), doc='Efficiency constants outside this range will be set to zero.') self.declareProperty( name='UseCalibratedData', defaultValue=False, doc= 'Whether or not to use the calibrated data in the NeXus files (D2B only).' )
def PyInit(self): """Initialize the input and output properties of the algorithm.""" threeNonnegativeInts = CompositeValidator() threeNonnegativeInts.add(IntArrayLengthValidator(3)) nonnegativeInts = IntArrayBoundedValidator(lower=0) threeNonnegativeInts.add(nonnegativeInts) nonnegativeFloatArray = FloatArrayBoundedValidator(lower=0.) inWavelength = WorkspaceUnitValidator('Wavelength') self.declareProperty( MatrixWorkspaceProperty( Prop.INPUT_WS, defaultValue='', direction=Direction.Input, validator=inWavelength), doc='A reflected beam workspace (units wavelength).') self.declareProperty( MatrixWorkspaceProperty( Prop.OUTPUT_WS, defaultValue='', direction=Direction.Output), doc='The summed foreground workspace.') self.declareProperty( Prop.SUBALG_LOGGING, defaultValue=SubalgLogging.OFF, validator=StringListValidator([SubalgLogging.OFF, SubalgLogging.ON]), doc='Enable or disable child algorithm logging.') self.declareProperty( Prop.CLEANUP, defaultValue=utils.Cleanup.ON, validator=StringListValidator([utils.Cleanup.ON, utils.Cleanup.OFF]), doc='Enable or disable intermediate workspace cleanup.') self.declareProperty( Prop.SUM_TYPE, defaultValue=SumType.IN_LAMBDA, validator=StringListValidator([SumType.IN_LAMBDA, SumType.IN_Q]), doc='Type of summation to perform.') self.declareProperty( MatrixWorkspaceProperty( Prop.DIRECT_FOREGROUND_WS, defaultValue='', direction=Direction.Input, optional=PropertyMode.Optional, validator=inWavelength), doc='Summed direct beam workspace (units wavelength).') self.declareProperty( IntArrayProperty( Prop.FOREGROUND_INDICES, values=[Property.EMPTY_INT, Property.EMPTY_INT, Property.EMPTY_INT], validator=threeNonnegativeInts), doc='A three element array of foreground start, centre and end workspace indices.') self.declareProperty( MatrixWorkspaceProperty( Prop.DIRECT_WS, defaultValue='', direction=Direction.Input, optional=PropertyMode.Optional, validator=inWavelength), doc='The (not summed) direct beam workspace (units wavelength).') self.declareProperty( FloatArrayProperty( Prop.WAVELENGTH_RANGE, values=[0.], validator=nonnegativeFloatArray), doc='The wavelength bounds.')
def PyInit(self): """Initialize the input and output properties of the algorithm.""" nonnegativeInts = IntArrayBoundedValidator() nonnegativeInts.setLower(0) maxTwoNonnegativeInts = CompositeValidator() maxTwoNonnegativeInts.add(IntArrayLengthValidator(lenmin=0, lenmax=2)) maxTwoNonnegativeInts.add(nonnegativeInts) nonnegativeFloatArray = FloatArrayBoundedValidator() nonnegativeFloatArray.setLower(0.) stringArrayValidator = StringArrayLengthValidator() stringArrayValidator.setLengthMin(1) #======================== Main Properties ======================== self.declareProperty( PropertyNames.POLARIZATION_OPTION, 'NonPolarized', StringListValidator(['NonPolarized', 'Polarized']), 'Indicate whether measurements are polarized') is_polarized = EnabledWhenProperty(PropertyNames.POLARIZATION_OPTION, PropertyCriterion.IsEqualTo, 'Polarized') is_not_polarized = EnabledWhenProperty( PropertyNames.POLARIZATION_OPTION, PropertyCriterion.IsEqualTo, 'NonPolarized') polarized = 'Inputs for polarized measurements' self.declareProperty(MultipleFileProperty( PropertyNames.RB, action=FileAction.OptionalLoad, extensions=['nxs']), doc='A list of reflected run numbers/files.') self.setPropertySettings(PropertyNames.RB, is_not_polarized) self.declareProperty( MultipleFileProperty(PropertyNames.RB00, action=FileAction.OptionalLoad, extensions=['nxs']), doc='A list of reflected run numbers/files for 00.') self.setPropertySettings(PropertyNames.RB00, is_polarized) self.setPropertyGroup(PropertyNames.RB00, polarized) self.declareProperty( MultipleFileProperty(PropertyNames.RB01, action=FileAction.OptionalLoad, extensions=['nxs']), doc='A list of reflected run numbers/files for 01.') self.setPropertySettings(PropertyNames.RB01, is_polarized) self.setPropertyGroup(PropertyNames.RB01, polarized) self.declareProperty( MultipleFileProperty(PropertyNames.RB10, action=FileAction.OptionalLoad, extensions=['nxs']), doc='A list of reflected run numbers/files for 10.') self.setPropertySettings(PropertyNames.RB10, is_polarized) self.setPropertyGroup(PropertyNames.RB10, polarized) self.declareProperty( MultipleFileProperty(PropertyNames.RB11, action=FileAction.OptionalLoad, extensions=['nxs']), doc='A list of reflected run numbers/files for 11.') self.setPropertySettings(PropertyNames.RB11, is_polarized) self.setPropertyGroup(PropertyNames.RB11, polarized) self.declareProperty( FileProperty(PropertyNames.EFFICIENCY_FILE, defaultValue='', action=FileAction.OptionalLoad), doc='A file containing the polarization efficiency factors.') self.setPropertySettings(PropertyNames.EFFICIENCY_FILE, is_polarized) self.setPropertyGroup(PropertyNames.EFFICIENCY_FILE, polarized) self.declareProperty(MultipleFileProperty(PropertyNames.DB, action=FileAction.Load, extensions=['nxs']), doc='A list of direct run numbers/files.') self.declareProperty(WorkspaceGroupProperty( Prop.OUTPUT_WS, defaultValue='', direction=Direction.Output), doc='The output workspace group.') self.declareProperty( PropertyNames.BKG_METHOD_DIRECT, defaultValue=BkgMethod.CONSTANT, validator=StringListValidator( [BkgMethod.CONSTANT, BkgMethod.LINEAR, BkgMethod.OFF]), doc='Flat background calculation method for background subtraction.' ) self.declareProperty( PropertyNames.BKG_METHOD, defaultValue=BkgMethod.CONSTANT, validator=StringListValidator( [BkgMethod.CONSTANT, BkgMethod.LINEAR, BkgMethod.OFF]), doc='Flat background calculation method for background subtraction.' ) self.copyProperties('ReflectometryILLPreprocess', [ Prop.SUBALG_LOGGING, Prop.CLEANUP, Prop.WATER_REFERENCE, Prop.SLIT_NORM, Prop.FLUX_NORM_METHOD ]) self.declareProperty(PropertyNames.SCALE_FACTOR, defaultValue=1.0, doc='Scale factor.') self.declareProperty( PropertyNames.USE_MANUAL_SCALE_FACTORS, defaultValue=False, doc='Choose to apply manual scale factors for stitching.') self.declareProperty( FloatArrayProperty(PropertyNames.MANUAL_SCALE_FACTORS, values=[]), doc= 'A list of manual scale factors for stitching (number of anlge configurations minus 1)' ) self.setPropertySettings( PropertyNames.MANUAL_SCALE_FACTORS, EnabledWhenProperty(PropertyNames.USE_MANUAL_SCALE_FACTORS, PropertyCriterion.IsNotDefault)) self.declareProperty( PropertyNames.CACHE_DIRECT_BEAM, defaultValue=False, doc= 'Cache the processed direct beam in ADS for ready use with further reflected beams;' 'saves important execution time, however assumes that the direct beam processing ' 'configuration must be invariant for different reflected beams.') # ======================== Common Properties ======================== commonProp = 'Preprocessing common properties: provide a list or a single value' self.declareProperty(StringArrayProperty( PropertyNames.ANGLE_OPTION, values=[PropertyNames.DAN], validator=stringArrayValidator, direction=Direction.Input, ), doc='Angle option used for detector positioning') self.declareProperty(FloatArrayProperty(PropertyNames.THETA, values=[-1.]), doc='A user-defined angle theta in degree') self.declareProperty(StringArrayProperty( PropertyNames.SUM_TYPE, values=[PropertyNames.INCOHERENT], validator=stringArrayValidator, direction=Direction.Input, ), doc='Type of summation to perform') self.declareProperty(FloatArrayProperty( PropertyNames.WAVELENGTH_LOWER, values=[0.], validator=nonnegativeFloatArray), doc='The lower wavelength bound (Angstrom)') self.declareProperty(FloatArrayProperty( PropertyNames.WAVELENGTH_UPPER, values=[35.], validator=nonnegativeFloatArray), doc='The upper wavelength bound (Angstrom)') self.declareProperty( FloatArrayProperty( PropertyNames.GROUPING_FRACTION, values=[0.5], validator=nonnegativeFloatArray, ), doc= 'If set, group the output by steps of this fraction multiplied by Q resolution' ) self.setPropertyGroup(PropertyNames.ANGLE_OPTION, commonProp) self.setPropertyGroup(PropertyNames.THETA, commonProp) self.setPropertyGroup(PropertyNames.SUM_TYPE, commonProp) self.setPropertyGroup(PropertyNames.WAVELENGTH_LOWER, commonProp) self.setPropertyGroup(PropertyNames.WAVELENGTH_UPPER, commonProp) self.setPropertyGroup(PropertyNames.GROUPING_FRACTION, commonProp) # ======================== Direct Run Properties ======================== preProcessDirect = 'Preprocessing for direct runs: provide a list or a single value' self.declareProperty( IntArrayProperty(PropertyNames.LOW_FRG_HALF_WIDTH_DIRECT, values=[0], validator=nonnegativeInts), doc= 'Number of foreground pixels at lower angles from the centre pixel.' ) self.setPropertyGroup(PropertyNames.LOW_FRG_HALF_WIDTH_DIRECT, preProcessDirect) self.declareProperty( IntArrayProperty( PropertyNames.LOW_BKG_OFFSET_DIRECT, values=[7], validator=nonnegativeInts, ), doc= 'Distance of flat background region towards smaller detector angles from the ' + 'foreground centre, in pixels') self.setPropertyGroup(PropertyNames.LOW_BKG_OFFSET_DIRECT, preProcessDirect) self.declareProperty( IntArrayProperty( PropertyNames.LOW_BKG_WIDTH_DIRECT, values=[5], validator=nonnegativeInts, ), doc= 'Width of flat background region towards smaller detector angles from the ' + 'foreground centre, in pixels') self.setPropertyGroup(PropertyNames.LOW_BKG_WIDTH_DIRECT, preProcessDirect) self.declareProperty( IntArrayProperty(PropertyNames.HIGH_FRG_HALF_WIDTH_DIRECT, values=[0], validator=nonnegativeInts), doc= 'Number of foreground pixels at higher angles from the centre pixel.' ) self.setPropertyGroup(PropertyNames.HIGH_FRG_HALF_WIDTH_DIRECT, preProcessDirect) self.declareProperty( IntArrayProperty( PropertyNames.HIGH_BKG_OFFSET_DIRECT, values=[7], validator=nonnegativeInts, ), doc= 'Distance of flat background region towards larger detector angles from the ' + 'foreground centre, in pixels') self.setPropertyGroup(PropertyNames.HIGH_BKG_OFFSET_DIRECT, preProcessDirect) self.declareProperty( IntArrayProperty( PropertyNames.HIGH_BKG_WIDTH_DIRECT, values=[5], validator=nonnegativeInts, ), doc= 'Width of flat background region towards larger detector angles from the ' + 'foreground centre, in pixels') self.setPropertyGroup(PropertyNames.HIGH_BKG_WIDTH_DIRECT, preProcessDirect) self.declareProperty(IntArrayProperty( PropertyNames.START_WS_INDEX_DIRECT, values=[0], validator=nonnegativeInts, ), doc='Start histogram index used for peak fitting') self.setPropertyGroup(PropertyNames.START_WS_INDEX_DIRECT, preProcessDirect) self.declareProperty(IntArrayProperty( PropertyNames.END_WS_INDEX_DIRECT, values=[255], validator=nonnegativeInts, ), doc='Last histogram index used for peak fitting') self.setPropertyGroup(PropertyNames.END_WS_INDEX_DIRECT, preProcessDirect) self.declareProperty( PropertyNames.XMIN_DIRECT, defaultValue=-1., doc='Minimum x value (unit wavelength) used for peak fitting.') self.setPropertyGroup(PropertyNames.XMIN_DIRECT, preProcessDirect) self.declareProperty( PropertyNames.XMAX_DIRECT, defaultValue=-1., doc='Maximum x value (unit wavelength) used for peak fitting.') self.setPropertyGroup(PropertyNames.XMAX_DIRECT, preProcessDirect) # ======================== Preprocessing For Reflected Runs ======================== preProcessReflected = 'Preprocessing for reflected runs: provide a list or a single value' self.declareProperty( IntArrayProperty( PropertyNames.LOW_FRG_HALF_WIDTH, values=[0], validator=nonnegativeInts, ), doc= 'Number of foreground pixels at lower angles from the centre pixel.' ) self.setPropertyGroup(PropertyNames.LOW_FRG_HALF_WIDTH, preProcessReflected) self.declareProperty( IntArrayProperty( PropertyNames.LOW_BKG_OFFSET, values=[7], validator=nonnegativeInts, ), doc= 'Distance of flat background region towards smaller detector angles from the ' + 'foreground centre, in pixels.') self.setPropertyGroup(PropertyNames.LOW_BKG_OFFSET, preProcessReflected) self.declareProperty( IntArrayProperty( PropertyNames.LOW_BKG_WIDTH, values=[5], validator=nonnegativeInts, ), doc= 'Width of flat background region towards smaller detector angles from the ' + 'foreground centre, in pixels') self.setPropertyGroup(PropertyNames.LOW_BKG_WIDTH, preProcessReflected) self.declareProperty( IntArrayProperty( PropertyNames.HIGH_FRG_HALF_WIDTH, values=[0], validator=nonnegativeInts, ), doc= 'Number of foreground pixels at higher angles from the centre pixel.' ) self.setPropertyGroup(PropertyNames.HIGH_FRG_HALF_WIDTH, preProcessReflected) self.declareProperty( IntArrayProperty( PropertyNames.HIGH_BKG_OFFSET, values=[7], validator=nonnegativeInts, ), doc= 'Distance of flat background region towards larger detector angles from the ' + 'foreground centre, in pixels') self.setPropertyGroup(PropertyNames.HIGH_BKG_OFFSET, preProcessReflected) self.declareProperty( IntArrayProperty( PropertyNames.HIGH_BKG_WIDTH, values=[5], validator=nonnegativeInts, ), doc= 'Width of flat background region towards larger detector angles from the ' + 'foreground centre, in pixels.') self.setPropertyGroup(PropertyNames.HIGH_BKG_WIDTH, preProcessReflected) self.declareProperty(IntArrayProperty( PropertyNames.START_WS_INDEX, values=[0], validator=nonnegativeInts, ), doc='Start histogram index used for peak fitting') self.setPropertyGroup(PropertyNames.START_WS_INDEX, preProcessReflected) self.declareProperty(IntArrayProperty( PropertyNames.END_WS_INDEX, values=[255], validator=nonnegativeInts, ), doc='Last histogram index used for peak fitting') self.setPropertyGroup(PropertyNames.END_WS_INDEX, preProcessReflected) self.declareProperty( FloatArrayProperty(PropertyNames.XMIN, values=[-1.]), doc='Minimum x value (unit wavelength) used for peak fitting') self.setPropertyGroup(PropertyNames.XMIN, preProcessReflected) self.declareProperty( FloatArrayProperty(PropertyNames.XMAX, values=[-1.]), doc='Maximum x value (unit wavelength) used for peak fitting') self.setPropertyGroup(PropertyNames.XMAX, preProcessReflected)
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, extensions=['nxs']), doc='A list of input run numbers/files.') self.declareProperty(MatrixWorkspaceProperty(Prop.OUTPUT_WS, defaultValue='', direction=Direction.Output), doc='The preprocessed output workspace (unit wavelength), single histogram.') self.declareProperty('Measurement', 'DirectBeam', StringListValidator(['DirectBeam', 'ReflectedBeam']), 'Whether to process as direct or reflected beam.') self.declareProperty('AngleOption', 'SampleAngle', StringListValidator(['SampleAngle', 'DetectorAngle', 'UserAngle'])) self.setPropertySettings('AngleOption', EnabledWhenProperty('Measurement', PropertyCriterion.IsEqualTo, 'ReflectedBeam')) self.declareProperty(Prop.THETA, defaultValue=-1., doc='The bragg angle for reflected beam [Degree], used if angle option is UserAngle.') self.setPropertySettings(Prop.THETA, EnabledWhenProperty('AngleOption', PropertyCriterion.IsEqualTo, 'UserAngle')) self.declareProperty('DirectBeamDetectorAngle', -1., 'The detector angle value [Degree] for the corresponding direct beam, ' 'used if angle option is DetectorAngle') self.declareProperty('DirectBeamForegroundCentre', -1., 'Fractional pixel index for the direct beam, used if angle option is DetectorAngle.') self.setPropertySettings('DirectBeamDetectorAngle', EnabledWhenProperty('AngleOption', PropertyCriterion.IsEqualTo, 'DetectorAngle')) self.setPropertySettings('DirectBeamForegroundCentre', EnabledWhenProperty('AngleOption', PropertyCriterion.IsEqualTo, 'DetectorAngle')) 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.AUTO, validator=StringListValidator([SlitNorm.AUTO, 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.AVERAGE, validator=StringListValidator([BkgMethod.AVERAGE, 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=-1., doc='Minimum wavelength [Angstrom] used for peak fitting.') self.declareProperty(Prop.XMAX, defaultValue=-1., doc='Maximum wavelength [Angstrom] used for peak fitting.')
def PyInit(self): self.declareProperty( StringArrayProperty("InputWorkspace", direction=Direction.Input, validator=ADSValidator()), doc= "Workspace or comma-separated workspace list containing input MDHisto scan data." ) self.declareProperty("Method", direction=Direction.Input, defaultValue="Fitted", validator=StringListValidator( ["Counts", "CountsWithFitting", "Fitted"]), doc="Integration method to use") self.declareProperty( "NumBackgroundPts", direction=Direction.Input, defaultValue=3, validator=IntBoundedValidator(lower=0), doc= "Number of background points from beginning and end of scan to use for background estimation" ) self.setPropertySettings( "NumBackgroundPts", EnabledWhenProperty("Method", PropertyCriterion.IsEqualTo, "Counts")) self.declareProperty( "WidthScale", direction=Direction.Input, defaultValue=2, validator=IntBoundedValidator(lower=0, exclusive=True), doc= "Controls integration range (+/- WidthScale/2*FWHM) defined around motor positions " "for CountsWithFitting method") self.setPropertySettings( "WidthScale", EnabledWhenProperty("Method", PropertyCriterion.IsEqualTo, "CountsWithFitting")) self.declareProperty( IntArrayProperty("LowerLeft", [128, 128], IntArrayLengthValidator(2), direction=Direction.Input), doc="Region of interest lower-left corner, in detector pixels") self.declareProperty( IntArrayProperty("UpperRight", [384, 384], IntArrayLengthValidator(2), direction=Direction.Input), doc="Region of interest upper-right corner, in detector pixels") self.declareProperty( "StartX", Property.EMPTY_DBL, doc= "The start of the scan axis fitting range in degrees, either omega or chi axis." ) self.declareProperty( "EndX", Property.EMPTY_DBL, doc= "The end of the scan axis fitting range in degrees, either omega or chi axis." ) self.declareProperty( "ScaleFactor", 1.0, doc="scale the integrated intensity by this value") self.declareProperty( "ChiSqMax", 10.0, doc= "Fitting resulting in chi-sqaured higher than this won't be added to the output" ) self.declareProperty( "SignalNoiseMin", 1.0, doc= "Minimum Signal/Noice ratio (Intensity/SigmaIntensity) of peak to be added to the output" ) self.declareProperty("ApplyLorentz", True, doc="If to apply Lorentz Correction to intensity") self.declareProperty( "OutputFitResults", False, doc= "This will output the fitting result workspace and a ROI workspace" ) self.setPropertySettings( "OutputFitResults", EnabledWhenProperty("Method", PropertyCriterion.IsNotEqualTo, "Counts")) self.declareProperty( "OptimizeQVector", True, doc= "This will convert the data to q and optimize the peak location using CentroidPeaksdMD" ) self.declareProperty(IPeaksWorkspaceProperty( "OutputWorkspace", "", optional=PropertyMode.Mandatory, direction=Direction.Output), doc="Output Peaks Workspace")
def PyInit(self): """Initialize the input and output properties of the algorithm.""" nonnegativeInt = IntBoundedValidator(lower=0) nonnegativeIntArray = IntArrayBoundedValidator() nonnegativeIntArray.setLower(0) nonnegativeFloatArray = FloatArrayBoundedValidator() nonnegativeFloatArray.setLower(0.) twoNonnegativeFloats = CompositeValidator() twoNonnegativeFloats.add(FloatArrayLengthValidator(length=2)) twoNonnegativeFloats.add(nonnegativeFloatArray) maxTwoNonnegativeInts = CompositeValidator() maxTwoNonnegativeInts.add(IntArrayLengthValidator(lenmin=0, lenmax=2)) maxTwoNonnegativeInts.add(nonnegativeIntArray) self.declareProperty(MultipleFileProperty( Prop.RUN, action=FileAction.OptionalLoad, extensions=['nxs']), doc='A list of input run numbers/files.') self.declareProperty( MatrixWorkspaceProperty(Prop.INPUT_WS, defaultValue='', direction=Direction.Input, validator=WorkspaceUnitValidator('TOF'), optional=PropertyMode.Optional), doc='An input workspace (units TOF) if no Run is specified.') self.declareProperty( ITableWorkspaceProperty(Prop.BEAM_POS_WS, defaultValue='', direction=Direction.Input, optional=PropertyMode.Optional), doc='A beam position table corresponding to InputWorkspace.') self.declareProperty(Prop.BEAM_ANGLE, defaultValue=Property.EMPTY_DBL, doc='A user-defined beam angle (unit degrees).') self.declareProperty( name=Prop.BEAM_CENTRE, defaultValue=Property.EMPTY_DBL, doc='A workspace index corresponding to the beam centre.') self.declareProperty( MatrixWorkspaceProperty(Prop.OUTPUT_WS, defaultValue='', direction=Direction.Output), doc= 'The preprocessed output workspace (unit wavelength), single histogram.' ) self.declareProperty(Prop.SUBALG_LOGGING, defaultValue=SubalgLogging.OFF, validator=StringListValidator( [SubalgLogging.OFF, SubalgLogging.ON]), doc='Enable or disable child algorithm logging.') self.declareProperty( Prop.CLEANUP, defaultValue=common.WSCleanup.ON, validator=StringListValidator( [common.WSCleanup.ON, common.WSCleanup.OFF]), doc='Enable or disable intermediate workspace cleanup.') self.declareProperty( ITableWorkspaceProperty(Prop.DIRECT_BEAM_POS_WS, defaultValue='', direction=Direction.Input, optional=PropertyMode.Optional), doc='A beam position table from a direct beam measurement.') self.declareProperty(MatrixWorkspaceProperty( Prop.WATER_REFERENCE, defaultValue='', direction=Direction.Input, validator=WorkspaceUnitValidator("TOF"), optional=PropertyMode.Optional), doc='A (water) calibration workspace (unit TOF).') self.declareProperty(Prop.SLIT_NORM, defaultValue=SlitNorm.OFF, validator=StringListValidator( [SlitNorm.OFF, SlitNorm.ON]), doc='Enable or disable slit normalisation.') self.declareProperty(Prop.FLUX_NORM_METHOD, defaultValue=FluxNormMethod.TIME, validator=StringListValidator([ FluxNormMethod.TIME, FluxNormMethod.MONITOR, FluxNormMethod.OFF ]), doc='Neutron flux normalisation method.') self.declareProperty( IntArrayProperty(Prop.FOREGROUND_HALF_WIDTH, validator=maxTwoNonnegativeInts), doc= 'Number of foreground pixels at lower and higher angles from the centre pixel.' ) self.declareProperty( Prop.BKG_METHOD, defaultValue=BkgMethod.CONSTANT, validator=StringListValidator( [BkgMethod.CONSTANT, BkgMethod.LINEAR, BkgMethod.OFF]), doc='Flat background calculation method for background subtraction.' ) self.declareProperty( Prop.LOW_BKG_OFFSET, defaultValue=7, validator=nonnegativeInt, doc= 'Distance of flat background region towards smaller detector angles from the foreground centre, ' + 'in pixels.') self.declareProperty( Prop.LOW_BKG_WIDTH, defaultValue=5, validator=nonnegativeInt, doc= 'Width of flat background region towards smaller detector angles from the foreground centre, in pixels.' ) self.declareProperty( Prop.HIGH_BKG_OFFSET, defaultValue=7, validator=nonnegativeInt, doc= 'Distance of flat background region towards larger detector angles from the foreground centre, in pixels.' ) self.declareProperty( Prop.HIGH_BKG_WIDTH, defaultValue=5, validator=nonnegativeInt, doc= 'Width of flat background region towards larger detector angles from the foreground centre, in pixels.' ) self.declareProperty(ITableWorkspaceProperty( Prop.OUTPUT_BEAM_POS_WS, defaultValue='', direction=Direction.Output, optional=PropertyMode.Optional), doc='Output the beam position table.')
def PyInit(self): self.declareProperty(MultipleFileProperty('CalibrationRun', action=FileAction.Load, extensions=['nxs']), doc='File path of calibration runs (numors). Must be detector scans.') self.declareProperty(FileProperty('CalibrationFile', '', action=FileAction.OptionalLoad, extensions=['nxs']), doc='Optional file containing previous calibration constants.') self.declareProperty(name='CalibrationMethod', defaultValue='Median', validator=StringListValidator(['Median', 'Mean', 'MostLikelyMean']), doc='The method of how the calibration constant of a pixel ' 'is derived from the distribution of ratios.') self.declareProperty(name='DerivationMethod', defaultValue='SequentialSummedReference1D', validator=StringListValidator(['SequentialSummedReference1D', 'GlobalSummedReference2D']), doc='Choose sequential for D20 (1D detector), global for D2B (2D detector).') self.declareProperty(name='InterpolateOverlappingAngles', defaultValue=False, doc='Whether to interpolate scattering angle values in overlapping regions (D20 only).') self.declareProperty(name='NormaliseTo', defaultValue='None', validator=StringListValidator(['None', 'Monitor', 'ROI']), doc='Normalise to monitor or ROI counts before deriving the calibration.') thetaRangeValidator = FloatArrayOrderedPairsValidator() self.declareProperty(FloatArrayProperty(name='ROI', values=[0,100.], validator=thetaRangeValidator), doc='Scattering angle regions of interest for normalisation [degrees].') normaliseToROI = VisibleWhenProperty('NormaliseTo', PropertyCriterion.IsEqualTo, 'ROI') self.setPropertySettings('ROI', normaliseToROI) self.declareProperty(FloatArrayProperty(name='ExcludedRange', values=[], validator=thetaRangeValidator), doc='Scattering angle regions to exclude from the computation of ' 'relative calibration constants; for example, the beam stop [degrees]. ') pixelRangeValidator = CompositeValidator() greaterThanOne = IntArrayBoundedValidator() greaterThanOne.setLower(1) lengthTwo = IntArrayLengthValidator() lengthTwo.setLength(2) orderedPairsValidator = IntArrayOrderedPairsValidator() pixelRangeValidator.add(greaterThanOne) pixelRangeValidator.add(lengthTwo) pixelRangeValidator.add(orderedPairsValidator) self.declareProperty(IntArrayProperty(name='PixelRange', values=[1,3072], validator=pixelRangeValidator), doc='Range of the pixel numbers to compute the calibration factors for (D20 only); ' 'for the other pixels outside the range, the factor will be set to 1.') self.declareProperty(MatrixWorkspaceProperty('OutputResponseWorkspace', '', optional=PropertyMode.Optional, direction=Direction.Output), doc='Output workspace containing the summed diffraction patterns of all the overlapping pixels.') self.declareProperty(MatrixWorkspaceProperty('OutputWorkspace', '', direction=Direction.Output), doc='Output workspace containing the calibration constants (inverse of efficiency) for each pixel.') self.declareProperty(name='NumberOfIterations', defaultValue=1, validator=IntBoundedValidator(lower=0, upper=10), doc='Number of iterations to perform (D2B only): 0 means auto; that is, the ' 'iterations will terminate after reaching some Chi2/NdoF.') maskCriterionValidator = CompositeValidator() arrayLengthTwo = FloatArrayLengthValidator() arrayLengthTwo.setLengthMax(2) orderedPairs = FloatArrayOrderedPairsValidator() maskCriterionValidator.add(arrayLengthTwo) maskCriterionValidator.add(orderedPairs) self.declareProperty(FloatArrayProperty(name='MaskCriterion', values=[], validator=maskCriterionValidator), doc='Efficiency constants outside this range will be set to zero.') self.declareProperty(name='UseCalibratedData', defaultValue=False, doc='Whether or not to use the calibrated data in the NeXus files (D2B only).')
def PyInit(self): self.declareProperty( StringArrayProperty("InputWorkspace", direction=Direction.Input, validator=ADSValidator()), doc= "Workspace or comma-separated workspace list containing input MDHisto scan data." ) self.declareProperty( IntArrayProperty("LowerLeft", [128, 128], IntArrayLengthValidator(2), direction=Direction.Input), doc="Region of interest lower-left corner, in detector pixels") self.declareProperty( IntArrayProperty("UpperRight", [384, 384], IntArrayLengthValidator(2), direction=Direction.Input), doc="Region of interest upper-right corner, in detector pixels") self.declareProperty( "StartX", Property.EMPTY_DBL, doc= "The start of the scan axis fitting range in degrees, either omega or chi axis." ) self.declareProperty( "EndX", Property.EMPTY_DBL, doc= "The end of the scan axis fitting range in degrees, either omega or chi axis." ) self.declareProperty( "ScaleFactor", 1.0, doc="scale the integrated intensity by this value") self.declareProperty( "ChiSqMax", 10.0, doc= "Fitting resulting in chi-sqaured higher than this won't be added to the output" ) self.declareProperty( "SignalNoiseMin", 1.0, doc= "Minimum Signal/Noice ratio (Intensity/SigmaIntensity) of peak to be added to the output" ) self.declareProperty("ApplyLorentz", True, doc="If to apply Lorentz Correction to intensity") self.declareProperty( "OutputFitResults", False, doc= "This will output the fitting result workspace and a ROI workspace" ) self.declareProperty( "OptimizeQVector", True, doc= "This will convert the data to q and optimize the peak location using CentroidPeaksdMD" ) self.declareProperty(IPeaksWorkspaceProperty( "OutputWorkspace", "", optional=PropertyMode.Mandatory, direction=Direction.Output), doc="Output Peaks Workspace")