def PyInit(self): validator = StringArrayLengthValidator() validator.setLengthMin( 2) # even for workspacegroups at least 2 (SF, NSF) must be given self.declareProperty( StringArrayProperty(name="VanadiumWorkspaces", direction=Direction.Input, validator=validator), doc= "Comma separated list of Vanadium workspaces or groups of workspaces." ) self.declareProperty( StringArrayProperty(name="BackgroundWorkspaces", direction=Direction.Input, validator=validator), doc= "Comma separated list of Background workspaces or groups of workspaces." ) self.declareProperty( WorkspaceProperty("OutputWorkspace", "", direction=Direction.Output), doc= "Name of the workspace or group of workspaces that will contain computed coefficients." ) self.declareProperty( "TwoThetaTolerance", 0.05, FloatBoundedValidator(lower=0, upper=0.1), doc= "Tolerance for 2theta comparison (degrees). Number between 0 and 0.1." ) return
def _declareRunProperties(self): mandatoryInputRuns = CompositeValidator() mandatoryInputRuns.add(StringArrayMandatoryValidator()) lenValidator = StringArrayLengthValidator() lenValidator.setLengthMin(1) mandatoryInputRuns.add(lenValidator) # Add property for the input runs self.declareProperty( StringArrayProperty(Prop.RUNS, values=[], validator=mandatoryInputRuns), doc='A list of run numbers or workspace names for the input runs. ' 'Multiple runs will be summed before reduction.') # Add properties from child algorithm properties = [ 'ThetaIn', 'ThetaLogName', ] self.copyProperties('ReflectometryReductionOneAuto', properties) self._reduction_properties += properties # Add properties for settings to apply to input runs self.declareProperty( Prop.RELOAD, True, doc= 'If true, reload input workspaces if they are of the incorrect type' ) self.declareProperty(Prop.GROUP_TOF, True, doc='If true, group the TOF workspaces')
def PyInit(self): """Initialize the input and output properties of the algorithm.""" mandatoryInputRuns = CompositeValidator() mandatoryInputRuns.add(StringArrayMandatoryValidator()) lenValidator = StringArrayLengthValidator() lenValidator.setLengthMin(1) mandatoryInputRuns.add(lenValidator) self.declareProperty(StringArrayProperty(Prop.RUNS, values=[], validator=mandatoryInputRuns), doc='A list of run numbers or workspace names for the input runs. ' 'Multiple runs will be summed before reduction.') self.declareProperty(StringArrayProperty(Prop.FIRST_TRANS_RUNS, values=[]), doc='A list of run numbers or workspace names for the first transmission run. ' 'Multiple runs will be summed before reduction.') self.declareProperty(StringArrayProperty(Prop.SECOND_TRANS_RUNS, values=[]), doc='A list of run numbers or workspace names for the second transmission run. ' 'Multiple runs will be summed before reduction.') self._declareSliceAlgorithmProperties() self._declareReductionAlgorithmProperties() self.declareProperty(WorkspaceProperty(Prop.OUTPUT_WS, '', optional=PropertyMode.Optional, direction=Direction.Output), doc='The output workspace, or workspace group if sliced.') self.declareProperty(WorkspaceProperty(Prop.OUTPUT_WS_BINNED, '', optional=PropertyMode.Optional, direction=Direction.Output), doc='The binned output workspace, or workspace group if sliced.') self.declareProperty(WorkspaceProperty(Prop.OUTPUT_WS_LAM, '', optional=PropertyMode.Optional, direction=Direction.Output), doc='The output workspace in wavelength, or workspace group if sliced.')
def _get_input_runs_validator(): mandatoryInputRuns = CompositeValidator() mandatoryInputRuns.add(StringArrayMandatoryValidator()) lenValidator = StringArrayLengthValidator() lenValidator.setLengthMin(1) mandatoryInputRuns.add(lenValidator) return mandatoryInputRuns
def PyInit(self): validator = StringArrayLengthValidator() validator.setLengthMin(1) # one group may be given self.declareProperty( StringArrayProperty(name="InputWorkspaces", direction=Direction.Input, validator=validator), doc="Comma separated list of workspaces or groups of workspaces.") self.declareProperty( StringArrayProperty(name="SampleLogs", direction=Direction.Input, validator=validator), doc="Comma separated list of sample logs to compare.") self.declareProperty("Tolerance", 1e-3, validator=FloatBoundedValidator(lower=1e-7, upper=1.0), doc="Tolerance for comparison of double values.") self.declareProperty( "Result", "A string that will be empty if all the logs match, " "otherwise will contain a comma separated list of not matching logs", Direction.Output) return
def PyInit(self): """ Declare properties """ validator = StringArrayLengthValidator() validator.setLengthMin(1) self.declareProperty(StringArrayProperty(name="InputWorkspaces", direction=Direction.Input, validator=validator), doc="Comma separated list of workspaces or groups of workspaces.") self.declareProperty(WorkspaceProperty("OutputWorkspace", "", direction=Direction.Output), doc="Name of the workspace that will contain the merged workspaces.") return
def PyInit(self): """Initialize the input and output properties of the algorithm.""" mandatoryInputRuns = CompositeValidator() mandatoryInputRuns.add(StringArrayMandatoryValidator()) lenValidator = StringArrayLengthValidator() lenValidator.setLengthMin(1) mandatoryInputRuns.add(lenValidator) self.declareProperty( StringArrayProperty(Prop.RUNS, values=[], validator=mandatoryInputRuns), doc='A list of run numbers or workspace names for the input runs. ' 'Multiple runs will be summed before reduction.') self.declareProperty( StringArrayProperty(Prop.FIRST_TRANS_RUNS, values=[]), doc= 'A list of run numbers or workspace names for the first transmission run. ' 'Multiple runs will be summed before reduction.') self.declareProperty( StringArrayProperty(Prop.SECOND_TRANS_RUNS, values=[]), doc= 'A list of run numbers or workspace names for the second transmission run. ' 'Multiple runs will be summed before reduction.') self._declareSliceAlgorithmProperties() self._declareReductionAlgorithmProperties() self.declareProperty(Prop.GROUP_TOF, True, doc='If true, group the input TOF workspace') self.declareProperty( Prop.RELOAD, True, doc= 'If true, reload input workspaces if they are of the incorrect type' ) self.declareProperty( WorkspaceProperty(Prop.OUTPUT_WS, '', optional=PropertyMode.Optional, direction=Direction.Output), doc='The output workspace, or workspace group if sliced.') self.declareProperty( WorkspaceProperty(Prop.OUTPUT_WS_BINNED, '', optional=PropertyMode.Optional, direction=Direction.Output), doc='The binned output workspace, or workspace group if sliced.') self.declareProperty( WorkspaceProperty(Prop.OUTPUT_WS_LAM, '', optional=PropertyMode.Optional, direction=Direction.Output), doc= 'The output workspace in wavelength, or workspace group if sliced.' )
def PyInit(self): validator = StringArrayLengthValidator() validator.setLengthMin(1) # group of workspaces may be given self.declareProperty(StringArrayProperty(name="WorkspaceNames", direction=Direction.Input, validator=validator), doc="List of Workspace names to merge.") self.declareProperty(MatrixWorkspaceProperty("OutputWorkspace", "", direction=Direction.Output), doc="A workspace name to save the merged data.") H_AXIS = ["2theta", "|Q|", "d-Spacing"] self.declareProperty("HorizontalAxis", "2theta", StringListValidator(H_AXIS), doc="X axis in the merged workspace") return
def PyInit(self): validator = StringArrayLengthValidator() validator.setLengthMin(2) # even for workspacegroups at least 2 (SF, NSF) must be given self.declareProperty(StringArrayProperty(name="VanadiumWorkspaces", direction=Direction.Input, validator=validator), doc="Comma separated list of Vanadium workspaces or groups of workspaces.") self.declareProperty(StringArrayProperty(name="BackgroundWorkspaces", direction=Direction.Input, validator=validator), doc="Comma separated list of Background workspaces or groups of workspaces.") self.declareProperty(WorkspaceProperty("OutputWorkspace", "", direction=Direction.Output), doc="Name of the workspace or group of workspaces that will contain computed coefficients.") self.declareProperty("TwoThetaTolerance", 0.05, FloatBoundedValidator(lower=0, upper=0.1), doc="Tolerance for 2theta comparison (degrees). Number between 0 and 0.1.") return
def PyInit(self): validator = StringArrayLengthValidator() validator.setLengthMin(1) # one group may be given self.declareProperty(StringArrayProperty(name="InputWorkspaces", direction=Direction.Input, validator=validator), doc="Comma separated list of workspaces or groups of workspaces.") self.declareProperty(StringArrayProperty(name="SampleLogs", direction=Direction.Input, validator=validator), doc="Comma separated list of sample logs to compare.") self.declareProperty("Tolerance", 1e-3, validator=FloatBoundedValidator(lower=1e-7), doc="Tolerance for comparison of numeric values.") self.declareProperty("Result", "A string that will be empty if all the logs match, " "otherwise will contain a comma separated list of not matching logs", Direction.Output) return
def PyInit(self): validator = StringArrayLengthValidator() validator.setLengthMin(1) # group of workspaces may be given self.declareProperty(StringArrayProperty(name="WorkspaceNames", direction=Direction.Input, validator=validator), doc="List of Workspace names to merge.") self.declareProperty(MatrixWorkspaceProperty( "OutputWorkspace", "", direction=Direction.Output), doc="A workspace name to save the merged data.") H_AXIS = ["2theta", "|Q|", "d-Spacing"] self.declareProperty("HorizontalAxis", "2theta", StringListValidator(H_AXIS), doc="X axis in the merged workspace") return
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)