def PyInit(self): self.declareProperty(IMDEventWorkspaceProperty("InputWorkspace", defaultValue="", optional=PropertyMode.Mandatory, direction=Direction.Input), doc="Input MDEvent workspace to convert to a MDHisto in HKL") self.declareProperty(IPeaksWorkspaceProperty("PeaksWorkspace", defaultValue="", optional=PropertyMode.Optional, direction=Direction.Input), doc="Optional peaks workspace to retrieve the UB matrix from, instead of InputWorkspace.") self.declareProperty(FloatArrayProperty("Uproj", [1, 0, 0], validator=FloatArrayLengthValidator(3), direction=Direction.Input), doc="Defines the first projection vector of the target Q coordinate system in HKL mode") self.declareProperty(FloatArrayProperty("Vproj", [0, 1, 0], validator=FloatArrayLengthValidator(3), direction=Direction.Input), doc="Defines the second projection vector of the target Q coordinate system in HKL mode") self.declareProperty(FloatArrayProperty("Wproj", [0, 0, 1], validator=FloatArrayLengthValidator(3), direction=Direction.Input), doc="Defines the third projection vector of the target Q coordinate system in HKL mode") self.declareProperty(FloatArrayProperty("Extents", [-6.02, 6.02, -6.02, 6.02, -6.02, 6.02], direction=Direction.Input), "Binning parameters for each dimension. Enter it as a" "comma-separated list of values with the" "format: 'minimum,maximum,'.") self.declareProperty(IntArrayProperty("Bins", [301, 301, 301], direction=Direction.Input), "Number of bins to use for each dimension, Enter it as a" "comma-separated list of integers.") self.declareProperty(IMDHistoWorkspaceProperty("OutputWorkspace", "", optional=PropertyMode.Mandatory, direction=Direction.Output), doc="Output MDWorkspace in Q-space, name is prefix if multiple input files were provided.")
def test_range_length_constructor_returns_hasMinMax(self): lower = 4 upper = 7 validator = FloatArrayLengthValidator(lower, upper) self.assertTrue(validator.hasMinLength()) self.assertTrue(validator.hasMaxLength()) self.assertEquals(validator.getMinLength(), lower) self.assertEquals(validator.getMaxLength(), upper)
def test_setFixedLength_alters_accepted_lenth(self): validator = FloatArrayLengthValidator() self.assertFalse(validator.hasLength()) fixed = 5 validator.setLength(fixed) self.assertTrue(validator.hasLength()) self.assertEqual(validator.getLength(), fixed) validator.clearLength() self.assertFalse(validator.hasLength())
def test_setFixedLength_alters_accepted_lenth(self): validator = FloatArrayLengthValidator() self.assertFalse(validator.hasLength()) fixed = 5 validator.setLength(fixed) self.assertTrue(validator.hasLength()) self.assertEquals(validator.getLength(), fixed) validator.clearLength() self.assertFalse(validator.hasLength())
def PyInit(self): self.declareProperty(name='Instrument', defaultValue='IRIS', validator=StringListValidator(['IRIS', 'OSIRIS']), doc='The name of the instrument.') self.declareProperty(name='Analyser', defaultValue='', validator=StringListValidator(['graphite', 'mica', 'fmica']), doc='The analyser bank used during run.') self.declareProperty(name='Reflection', defaultValue='', validator=StringListValidator(['002', '004', '006']), doc='Reflection number for instrument setup during run.') self.declareProperty(name="FirstRun", defaultValue=-1, validator=IntBoundedValidator(lower=0), doc="First Sample run-number.") self.declareProperty(name='LastRun', defaultValue=-1, validator=IntBoundedValidator(lower=0), doc="Last Sample run-number.") self.declareProperty(name='NumberSamples', defaultValue=-1, validator=IntBoundedValidator(lower=0), doc="Increment for run-number.") self.declareProperty(IntArrayProperty(name='SpectraRange', values=[0, 1], validator=IntArrayLengthValidator(2)), doc='Comma separated range of spectra numbers to use.') self.declareProperty(FloatArrayProperty(name='ElasticRange', validator=FloatArrayLengthValidator(2)), doc='Energy range for the elastic component.') self.declareProperty(FloatArrayProperty(name='InelasticRange', validator=FloatArrayLengthValidator(2)), doc='Energy range for the inelastic component.') self.declareProperty(FloatArrayProperty(name='TotalRange', validator=FloatArrayLengthValidator(2)), doc='Energy range for the total energy component.') self.declareProperty(name='SampleEnvironmentLogName', defaultValue='Position', doc='Name of the sample environment log entry') sample_environment_log_values = ['last_value', 'average'] self.declareProperty('SampleEnvironmentLogValue', 'last_value', StringListValidator(sample_environment_log_values), doc='Value selection of the sample environment log entry') self.declareProperty(name='MSDFit', defaultValue=False, doc='Perform an MSDFit. Do not use with GroupingMethod as "All"') self.declareProperty(name='WidthFit', defaultValue=False, doc='Perform a 2 peak width Fit. Do not use with GroupingMethod as "All"') self.declareProperty(name='Plot', defaultValue=False, doc='True to plot the output data.') self.declareProperty(name='Save', defaultValue=False, doc='True to save the output data.')
def PyInit(self): self.declareProperty(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.')
def PyInit(self): self.declareProperty(MultipleFileProperty('Run', extensions=['nxs']), doc='File path of run(s).') self.declareProperty( name='NormaliseTo', defaultValue='Monitor', validator=StringListValidator(['None', 'Monitor']), doc='Normalise to monitor, or skip normalisation.') self.declareProperty( name='UseCalibratedData', defaultValue=True, doc='Whether or not to use the calibrated data in the NeXus files.' ) self.declareProperty( name='Output2DTubes', defaultValue=False, doc= 'Output a 2D workspace of height along tube against tube scattering angle.' ) self.declareProperty( name='Output2D', defaultValue=False, doc= 'Output a 2D workspace of height along tube against the real scattering angle.' ) self.declareProperty( name='Output1D', defaultValue=True, doc='Output a 1D workspace with counts against scattering angle.') self.declareProperty( FloatArrayProperty(name='HeightRange', values=[], validator=CompositeValidator([ FloatArrayOrderedPairsValidator(), FloatArrayLengthValidator(0, 2) ])), doc= 'A pair of values, comma separated, to give the minimum and maximum height range (in m). If not specified ' 'the full height range is used.') self.declareProperty( WorkspaceGroupProperty('OutputWorkspace', '', direction=Direction.Output), doc='Output workspace containing the reduced data.')
def test_range_length_constructor_returns_hasMinMax(self): lower = 4 upper = 7 validator = FloatArrayLengthValidator(lower, upper) self.assertTrue(validator.hasMinLength()) self.assertTrue(validator.hasMaxLength()) self.assertEqual(validator.getMinLength(), lower) self.assertEqual(validator.getMaxLength(), upper)
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('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): # Input validators array_length_three = FloatArrayLengthValidator(3) # Properties self.declareProperty('RunNumbers', '', 'Sample run numbers') self.declareProperty(FileProperty(name='MaskFile', defaultValue=self._mask_file, action=FileAction.OptionalLoad, extensions=['.xml']), doc='See documentation for latest mask files.') self.declareProperty(FloatArrayProperty('LambdaRange', self._lambda_range, direction=Direction.Input), doc='Incoming neutron wavelength range') self.declareProperty(WorkspaceProperty('OutputWorkspace', '', optional=PropertyMode.Mandatory, direction=Direction.Output), doc='Output Workspace. If background is ' + 'subtracted, _data and _background ' + 'workspaces will also be generated') # # Background for the sample runs # background_title = 'Background runs' self.declareProperty('BackgroundRuns', '', 'Background run numbers') self.setPropertyGroup('BackgroundRuns', background_title) self.declareProperty("BackgroundScale", 1.0, doc='The background will be scaled by this ' + 'number before being subtracted.') self.setPropertyGroup('BackgroundScale', background_title) # # Vanadium # vanadium_title = 'Vanadium runs' self.declareProperty('VanadiumRuns', '', 'Vanadium run numbers') self.setPropertyGroup('VanadiumRuns', vanadium_title) # # Single Crystal Diffraction # crystal_diffraction_title = 'Single Crystal Diffraction' self.declareProperty('PsiAngleLog', 'SE50Rot', direction=Direction.Input, doc='log entry storing rotation of the sample' 'around the vertical axis') self.declareProperty('PsiOffset', 0.0, direction=Direction.Input, doc='Add this quantity to PsiAngleLog') self.declareProperty(FloatArrayProperty('LatticeSizes', [0, 0, 0], array_length_three, direction=Direction.Input), doc='three item comma-separated list "a, b, c"') self.declareProperty( FloatArrayProperty('LatticeAngles', [90.0, 90.0, 90.0], array_length_three, direction=Direction.Input), doc='three item comma-separated ' + 'list "alpha, beta, gamma"') # Reciprocal vector to be aligned with incoming beam self.declareProperty(FloatArrayProperty('VectorU', [1, 0, 0], array_length_three, direction=Direction.Input), doc='three item, comma-separated, HKL indexes' 'of the diffracting plane') # Reciprocal vector orthogonal to VectorU and in-plane with # incoming beam self.declareProperty(FloatArrayProperty('VectorV', [0, 1, 0], array_length_three, direction=Direction.Input), doc='three item, comma-separated, HKL indexes' 'of the direction perpendicular to VectorV' 'and the vertical axis') # Abscissa view self.declareProperty(FloatArrayProperty('Uproj', [1, 0, 0], array_length_three, direction=Direction.Input), doc='three item comma-separated Abscissa view' 'of the diffraction pattern') # Ordinate view self.declareProperty(FloatArrayProperty('Vproj', [0, 1, 0], array_length_three, direction=Direction.Input), doc='three item comma-separated Ordinate view' 'of the diffraction pattern') # Hidden axis self.declareProperty(FloatArrayProperty('Wproj', [0, 0, 1], array_length_three, direction=Direction.Input), doc='Hidden axis view') # Binnin in reciprocal slice self.declareProperty('NBins', 400, direction=Direction.Input, doc='number of bins in the HKL slice') for a_property in ('PsiAngleLog', 'PsiOffset', 'LatticeSizes', 'LatticeAngles', 'VectorU', 'VectorV', 'Uproj', 'Vproj', 'Wproj', 'NBins'): self.setPropertyGroup(a_property, crystal_diffraction_title)
def PyInit(self): # Input properties self.declareProperty(StringArrayProperty(name='InputFiles'), doc='A comma separated list of run numbers.') # Instrument configuration properties self.declareProperty(name='Instrument', defaultValue='', validator=StringListValidator(['IRIS', 'OSIRIS']), doc='Instrument used during run.') self.declareProperty(name='Analyser', defaultValue='', validator=StringListValidator( ['graphite', 'mica', 'fmica']), doc='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( IntArrayProperty(name='SpectraRange', values=[0, 1], validator=IntArrayMandatoryValidator()), doc='Comma separated range of spectra number 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='sample', 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.') self.declareProperty(name='WidthFit', defaultValue=False, doc='Perform a 2 peak width Fit.') self.declareProperty(name='Plot', defaultValue=False, doc='Switch Plot Off/On') self.declareProperty(name='Save', defaultValue=False, doc='Switch Save result to nxs file Off/On')
def PyInit(self): self.declareProperty( IMDHistoWorkspaceProperty("InputWorkspace", "", optional=PropertyMode.Mandatory, direction=Direction.Input), "Input Workspace") self.declareProperty( IMDHistoWorkspaceProperty("NormalisationWorkspace", "", optional=PropertyMode.Optional, direction=Direction.Input), "Workspace to use for normalisation") self.declareProperty( WorkspaceProperty("UBWorkspace", "", optional=PropertyMode.Optional, direction=Direction.Input), "Workspace containing the UB matrix to use") self.declareProperty("Wavelength", 1.488, validator=FloatBoundedValidator(0.0), doc="Wavelength to set the workspace") self.declareProperty( "S1Offset", 0., doc="Offset to apply (in degrees) to the s1 of the input workspace" ) self.declareProperty('NormaliseBy', 'Monitor', StringListValidator(['None', 'Time', 'Monitor']), "Normalise to monitor, time or None.") self.declareProperty('Frame', 'Q_sample', StringListValidator(['Q_sample', 'HKL']), "Selects Q-dimensions of the output workspace") self.declareProperty( FloatArrayProperty("Uproj", [1, 0, 0], FloatArrayLengthValidator(3), direction=Direction.Input), "Defines the first projection vector of the target Q coordinate system in HKL mode" ) self.declareProperty( FloatArrayProperty("Vproj", [0, 1, 0], FloatArrayLengthValidator(3), direction=Direction.Input), "Defines the second projection vector of the target Q coordinate system in HKL mode" ) self.declareProperty( FloatArrayProperty("Wproj", [0, 0, 1], FloatArrayLengthValidator(3), direction=Direction.Input), "Defines the third projection vector of the target Q coordinate system in HKL mode" ) self.declareProperty( FloatArrayProperty("BinningDim0", [-8.02, 8.02, 401], FloatArrayLengthValidator(3), direction=Direction.Input), "Binning parameters for the 0th dimension. Enter it as a" "comma-separated list of values with the" "format: 'minimum,maximum,number_of_bins'.") self.declareProperty( FloatArrayProperty("BinningDim1", [-0.82, 0.82, 41], FloatArrayLengthValidator(3), direction=Direction.Input), "Binning parameters for the 1st dimension. Enter it as a" "comma-separated list of values with the" "format: 'minimum,maximum,number_of_bins'.") self.declareProperty( FloatArrayProperty("BinningDim2", [-8.02, 8.02, 401], FloatArrayLengthValidator(3), direction=Direction.Input), "Binning parameters for the 2nd dimension. Enter it as a" "comma-separated list of values with the" "format: 'minimum,maximum,number_of_bins'.") self.declareProperty( 'KeepTemporaryWorkspaces', False, "If True the normalization and data workspaces in addition to the normalized data will be outputted" ) self.declareProperty( WorkspaceProperty("OutputWorkspace", "", optional=PropertyMode.Mandatory, direction=Direction.Output), "Output Workspace")
def PyInit(self): self._short_inst = 'BSS' self._long_inst = 'BASIS' self._extension = '_event.nxs' self.declareProperty('RunNumbers', '', 'Sample run numbers') self.declareProperty('DoIndividual', False, 'Do each run individually') self.declareProperty('MonitorNorm', True, 'Normalization with wavelength-dependent monitor counts') self.declareProperty('ExcludeTimeSegment', '', 'Exclude a contigous time segment; '+ 'Examples: "71546:0-60" filter run 71546 from '+ 'start to 60 seconds, "71546:300-600", '+ '"71546:120-end" from 120s to the end of the run') grouping_type = ["None", "Low-Resolution", "By-Tube"] self.declareProperty("GroupDetectors", "None", StringListValidator(grouping_type), "Switch for grouping detectors") self.declareProperty('NormalizeToFirst', False, 'Normalize spectra '+ 'to intensity of spectrum with lowest Q?') # Properties affected by the reflection selected titleReflection = 'Reflection Selector' available_reflections = sorted(REFLECTIONS_DICT.keys()) default_reflection = REFLECTIONS_DICT['silicon111'] self.declareProperty('ReflectionType', default_reflection['name'], StringListValidator(available_reflections), 'Analyzer. Documentation lists typical \ associated property values.') self.setPropertyGroup('ReflectionType', titleReflection) self.declareProperty(FloatArrayProperty('EnergyBins', default_reflection['energy_bins'], direction=Direction.Input), 'Energy transfer binning scheme (in ueV)') self.setPropertyGroup('EnergyBins', titleReflection) self.declareProperty(FloatArrayProperty('MomentumTransferBins', default_reflection['q_bins'], direction=Direction.Input), 'Momentum transfer binning scheme') self.setPropertyGroup('MomentumTransferBins', titleReflection) self.declareProperty(FileProperty(name='MaskFile', defaultValue='', action=FileAction.OptionalLoad, extensions=['.xml']), 'See documentation for latest mask files.') self.setPropertyGroup('MaskFile', titleReflection) # Properties setting the division by vanadium titleDivideByVanadium = 'Normalization by Vanadium' self.declareProperty('DivideByVanadium', False, direction=Direction.Input, doc='Do we normalize by the vanadium intensity?') self.setPropertyGroup('DivideByVanadium', titleDivideByVanadium) ifDivideByVanadium = EnabledWhenProperty('DivideByVanadium', PropertyCriterion.IsNotDefault) normalization_types = ['by Q slice', 'by detector ID'] self.declareProperty('NormalizationType', 'by Q slice', StringListValidator(normalization_types), 'Select a Vanadium normalization') self.setPropertySettings('NormalizationType', ifDivideByVanadium) self.setPropertyGroup('NormalizationType', titleDivideByVanadium) self.declareProperty('NormRunNumbers', '', 'Normalization run numbers') self.setPropertySettings('NormRunNumbers', ifDivideByVanadium) self.setPropertyGroup('NormRunNumbers', titleDivideByVanadium) arrVal = FloatArrayLengthValidator(2) self.declareProperty(FloatArrayProperty('NormWavelengthRange', DEFAULT_RANGE, arrVal, direction=Direction.Input), 'Wavelength range for normalization') self.setPropertySettings('NormWavelengthRange', ifDivideByVanadium) self.setPropertyGroup('NormWavelengthRange', titleDivideByVanadium) # Properties setting the saving of NSXPE file title_nxspe= 'Save to NXSPE' self.declareProperty('SaveNXSPE', False, direction=Direction.Input, doc='Do we save to NXSPE format?') nxspe_enabled = EnabledWhenProperty('SaveNXSPE', PropertyCriterion.IsNotDefault) self.setPropertyGroup('SaveNXSPE', title_nxspe) self.declareProperty('PsiAngleLog', 'SE50Rot', direction=Direction.Input, doc='name of entry in the logs storing the psi \ angle') self.setPropertySettings('PsiAngleLog', nxspe_enabled) self.setPropertyGroup('PsiAngleLog', title_nxspe) self.declareProperty('PsiOffset', 0.0, direction=Direction.Input, doc='add this quantity to the psi angle stored \ in the log') self.setPropertySettings('PsiOffset', nxspe_enabled) self.setPropertyGroup('PsiOffset', title_nxspe) # Aditional output properties titleAddionalOutput = 'Additional Output' self.declareProperty('OutputSusceptibility', False, direction=Direction.Input, doc='Output dynamic susceptibility (Xqw)') self.setPropertyGroup('OutputSusceptibility', titleAddionalOutput)
def test_fixed_length_constructor_return_hasLength(self): fixedlength = 9 validator = FloatArrayLengthValidator(fixedlength) self.assertTrue(validator.hasLength()) self.assertEqual(validator.getLength(), fixedlength)
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): 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 test_setMinMaxLength_alters_accepted_range(self): validator = FloatArrayLengthValidator() self.assertFalse(validator.hasMinLength()) self.assertFalse(validator.hasMaxLength()) lower = 4 upper = 7 validator.setLengthMin(lower) self.assertTrue(validator.hasMinLength()) self.assertFalse(validator.hasMaxLength()) self.assertEquals(validator.getMinLength(), lower) validator.setLengthMax(upper) self.assertTrue(validator.hasMinLength()) self.assertTrue(validator.hasMaxLength()) self.assertEquals(validator.getMaxLength(), upper) validator.clearLengthMin() self.assertFalse(validator.hasMinLength()) self.assertTrue(validator.hasMaxLength()) validator.clearLengthMax() self.assertFalse(validator.hasMinLength()) self.assertFalse(validator.hasMaxLength())
def PyInit(self): self.declareProperty(MatrixWorkspaceProperty( 'InputWorkspace', '', direction=Direction.Input), doc='The input workspace.') self.declareProperty(MatrixWorkspaceProperty( 'OutputWorkspace', '', direction=Direction.Output), doc='The output workspace.') self.declareProperty(name='OutputType', defaultValue='I(Q)', validator=StringListValidator( ['I(Q)', 'I(Qx,Qy)', 'I(Phi,Q)']), doc='Choose the output type.') self.declareProperty(name='CalculateResolution', defaultValue='None', validator=StringListValidator( ['MildnerCarpenter', 'DirectBeam', 'None']), doc='Choose to calculate the Q resolution.') output_iq = EnabledWhenProperty('OutputType', PropertyCriterion.IsEqualTo, 'I(Q)') output_iphiq = EnabledWhenProperty('OutputType', PropertyCriterion.IsEqualTo, 'I(Phi,Q)') output_iqxy = EnabledWhenProperty('OutputType', PropertyCriterion.IsEqualTo, 'I(Qx,Qy)') self.declareProperty( name='DefaultQBinning', defaultValue='PixelSizeBased', validator=StringListValidator( ['PixelSizeBased', 'ResolutionBased']), doc='Choose how to calculate the default Q binning.') self.setPropertySettings( 'DefaultQBinning', EnabledWhenProperty(output_iq, output_iphiq, LogicOperator.Or)) self.declareProperty( name='BinningFactor', defaultValue=1., validator=FloatBoundedValidator(lower=0.), doc= 'Specify a multiplicative factor for default Q binning (pixel or resolution based).' ) self.setPropertySettings( 'BinningFactor', EnabledWhenProperty(output_iq, output_iphiq, LogicOperator.Or)) self.declareProperty(FloatArrayProperty('OutputBinning'), doc='The manual Q binning of the output') self.setPropertySettings( 'OutputBinning', EnabledWhenProperty(output_iq, output_iphiq, LogicOperator.Or)) self.declareProperty('NPixelDivision', 1, IntBoundedValidator(lower=1), 'Number of subpixels to split the pixel (NxN)') self.setPropertySettings( 'NPixelDivision', EnabledWhenProperty(output_iq, output_iphiq, LogicOperator.Or)) iq_without_shapes = EnabledWhenProperty( EnabledWhenProperty("ShapeTable", PropertyCriterion.IsDefault), EnabledWhenProperty(output_iq, output_iphiq, LogicOperator.Or), LogicOperator.And) self.declareProperty(name='NumberOfWedges', defaultValue=0, validator=IntBoundedValidator(lower=0), doc='Number of wedges to integrate separately.') self.setPropertySettings('NumberOfWedges', iq_without_shapes) iq_with_wedges = EnabledWhenProperty( output_iq, EnabledWhenProperty('NumberOfWedges', PropertyCriterion.IsNotDefault), LogicOperator.And) iq_with_wedges_or_shapes = EnabledWhenProperty( iq_with_wedges, EnabledWhenProperty("ShapeTable", PropertyCriterion.IsNotDefault), LogicOperator.Or) iq_with_wedges_but_no_shapes = EnabledWhenProperty( iq_with_wedges, EnabledWhenProperty("ShapeTable", PropertyCriterion.IsDefault), LogicOperator.And) self.declareProperty( WorkspaceGroupProperty('WedgeWorkspace', '', direction=Direction.Output, optional=PropertyMode.Optional), doc='WorkspaceGroup containing I(Q) for each azimuthal wedge.') self.setPropertySettings('WedgeWorkspace', iq_with_wedges_or_shapes) self.declareProperty(name='WedgeAngle', defaultValue=30., validator=FloatBoundedValidator(lower=0.), doc='Wedge opening angle [degrees].') self.setPropertySettings('WedgeAngle', iq_with_wedges_but_no_shapes) self.declareProperty(name='WedgeOffset', defaultValue=0., validator=FloatBoundedValidator(lower=0.), doc='Wedge offset angle from x+ axis.') self.setPropertySettings('WedgeOffset', iq_with_wedges_but_no_shapes) self.declareProperty(name='AsymmetricWedges', defaultValue=False, doc='Whether to have asymmetric wedges.') self.setPropertySettings('AsymmetricWedges', iq_with_wedges_or_shapes) self.setPropertyGroup('DefaultQBinning', 'I(Q) Options') self.setPropertyGroup('BinningFactor', 'I(Q) Options') self.setPropertyGroup('OutputBinning', 'I(Q) Options') self.setPropertyGroup('NPixelDivision', 'I(Q) Options') self.setPropertyGroup('NumberOfWedges', 'I(Q) Options') self.setPropertyGroup('WedgeWorkspace', 'I(Q) Options') self.setPropertyGroup('WedgeAngle', 'I(Q) Options') self.setPropertyGroup('WedgeOffset', 'I(Q) Options') self.setPropertyGroup('AsymmetricWedges', 'I(Q) Options') self.declareProperty(name='MaxQxy', defaultValue=-1.0, validator=FloatBoundedValidator(lower=-1.0), doc='Maximum of absolute Qx and Qy.') self.setPropertySettings('MaxQxy', output_iqxy) self.declareProperty(name='DeltaQ', defaultValue=-1.0, validator=FloatBoundedValidator(lower=-1.0), doc='The dimension of a Qx-Qy cell.') self.setPropertySettings('DeltaQ', output_iqxy) self.declareProperty( name='IQxQyLogBinning', defaultValue=False, doc='I(Qx, Qy) log binning when binning is not specified.') self.setPropertySettings('IQxQyLogBinning', output_iqxy) self.setPropertyGroup('MaxQxy', 'I(Qx,Qy) Options') self.setPropertyGroup('DeltaQ', 'I(Qx,Qy) Options') self.setPropertyGroup('IQxQyLogBinning', 'I(Qx,Qy) Options') self.declareProperty( WorkspaceGroupProperty('PanelOutputWorkspaces', '', direction=Direction.Output, optional=PropertyMode.Optional), doc='The name of the output workspace group for detector panels.') self.declareProperty( ITableWorkspaceProperty('ShapeTable', '', direction=Direction.Input, optional=PropertyMode.Optional), doc= 'The name of the table workspace containing drawn shapes on which to integrate. ' 'If provided, NumberOfWedges, WedgeOffset and WedgeAngle arguments are ignored. ' ) self.setPropertyGroup('PanelOutputWorkspaces', 'I(Q) Options') self.setPropertyGroup('ShapeTable', 'I(Q) Options') lambda_range_validator = CompositeValidator() lambda_range_validator.add(FloatArrayOrderedPairsValidator()) lambda_range_validator.add(FloatArrayLengthValidator(2)) self.declareProperty( FloatArrayProperty('WavelengthRange', [1., 10.], validator=lambda_range_validator), doc= 'Wavelength range [Angstrom] to be used in integration (TOF only).' )
def PyInit(self): # files to reduce self.declareProperty( MultipleFileProperty(name="Filename", extensions=["_event.nxs", ".nxs.h5", ".nxs"]), "Files to combine in reduction") # background self.declareProperty( FileProperty(name="Background", defaultValue="", action=FileAction.OptionalLoad, extensions=["_event.nxs", ".nxs.h5", ".nxs"]), "Background run") self.declareProperty( "BackgroundScale", 1.0, doc= "The background will be scaled by this number before being subtracted." ) # Filter by TOF self.copyProperties('LoadEventNexus', ['FilterByTofMin', 'FilterByTofMax']) # Vanadium SA and flux self.declareProperty( "ReuseSAFlux", True, "If True then if a previous SolidAngle and Flux has been loaded " "it will be reused otherwise it will be loaded.") self.declareProperty( FileProperty(name="SolidAngle", defaultValue="", action=FileAction.Load, extensions=[".nxs"]), doc= "An input workspace containing momentum integrated vanadium (a measure " "of the solid angle). See :ref:`MDNormSCDPreprocessIncoherent <algm-MDNormSCDPreprocessIncoherent>` " "for details") self.declareProperty( FileProperty(name="Flux", defaultValue="", action=FileAction.Load, extensions=[".nxs"]), "An input workspace containing momentum dependent flux. See :ref:`MDnormSCD <algm-MDnormSCD>` for details" ) self.declareProperty( 'MomentumMin', Property.EMPTY_DBL, doc= "Minimum value in momentum. The max of this value and the flux momentum minimum will be used." ) self.declareProperty( 'MomentumMax', Property.EMPTY_DBL, doc= "Maximum value in momentum. The min of this value and the flux momentum maximum will be used." ) # UBMatrix self.declareProperty( MultipleFileProperty(name="UBMatrix", extensions=[".mat", ".ub", ".txt"]), doc= "Path to an ISAW-style UB matrix text file. See :ref:`LoadIsawUB <algm-LoadIsawUB>`" ) # Goniometer self.declareProperty( 'SetGoniometer', False, "Set which Goniometer to use. See :ref:`SetGoniometer <algm-SetGoniometer>`" ) condition = VisibleWhenProperty("SetGoniometer", PropertyCriterion.IsNotDefault) self.copyProperties('SetGoniometer', ['Goniometers', 'Axis0', 'Axis1', 'Axis2']) self.setPropertySettings("Goniometers", condition) self.setPropertySettings('Axis0', condition) self.setPropertySettings('Axis1', condition) self.setPropertySettings('Axis2', condition) self.declareProperty( FloatArrayProperty('OmegaOffset', [], direction=Direction.Input), doc= "Offset to apply to the omega rotation of the Goniometer. Need to provide one value for every run." ) # Corrections self.declareProperty( FileProperty(name="LoadInstrument", defaultValue="", action=FileAction.OptionalLoad, extensions=[".xml"]), "Load a different instrument IDF onto the data from a file. See :ref:`LoadInstrument <algm-LoadInstrument>`" ) self.declareProperty( ITableWorkspaceProperty("ApplyCalibration", '', optional=PropertyMode.Optional, direction=Direction.Input), doc='Calibration will be applied using this TableWorkspace using ' ':ref:`ApplyCalibration <algm-ApplyCalibration>`.') self.declareProperty( FileProperty(name="DetCal", defaultValue="", action=FileAction.OptionalLoad, extensions=[".detcal"]), "Load an ISAW DetCal calibration onto the data from a file. " "See :ref:`LoadIsawDetCal <algm-LoadIsawDetCal>`") self.declareProperty( MatrixWorkspaceProperty("CopyInstrumentParameters", '', optional=PropertyMode.Optional, direction=Direction.Input), doc= 'The input workpsace from which :ref:`CopyInstrumentParameters <algm-CopyInstrumentParameters>` ' 'will copy parameters to data') self.declareProperty( FileProperty(name="MaskFile", defaultValue="", action=FileAction.OptionalLoad, extensions=[".xml", ".msk"]), "Masking file for masking. Supported file format is XML and ISIS ASCII. See :ref:`LoadMask <algm-LoadMask>`" ) self.copyProperties('MDNorm', ['SymmetryOperations']) self.declareProperty( FloatArrayProperty('QDimension0', [1, 0, 0], FloatArrayLengthValidator(3), direction=Direction.Input), "The first Q projection axis") self.declareProperty( FloatArrayProperty('QDimension1', [0, 1, 0], FloatArrayLengthValidator(3), direction=Direction.Input), "The second Q projection axis") self.declareProperty( FloatArrayProperty('QDimension2', [0, 0, 1], FloatArrayLengthValidator(3), direction=Direction.Input), "The third Q projection axis") self.copyProperties( 'MDNorm', ['Dimension0Binning', 'Dimension1Binning', 'Dimension2Binning']) self.declareProperty( 'KeepTemporaryWorkspaces', False, "If True the normalization and data workspaces in addition to the normalized data will be outputted" ) self.declareProperty( WorkspaceProperty("OutputWorkspace", "", optional=PropertyMode.Mandatory, direction=Direction.Output), "Output Workspace. If background is subtracted _data and _background workspaces will also be made." ) # Background self.setPropertyGroup("Background", "Background") self.setPropertyGroup("BackgroundScale", "Background") # Vanadium self.setPropertyGroup("ReuseSAFlux", "Vanadium") self.setPropertyGroup("SolidAngle", "Vanadium") self.setPropertyGroup("Flux", "Vanadium") self.setPropertyGroup("MomentumMin", "Vanadium") self.setPropertyGroup("MomentumMax", "Vanadium") # Goniometer self.setPropertyGroup("SetGoniometer", "Goniometer") self.setPropertyGroup("Goniometers", "Goniometer") self.setPropertyGroup("Axis0", "Goniometer") self.setPropertyGroup("Axis1", "Goniometer") self.setPropertyGroup("Axis2", "Goniometer") self.setPropertyGroup("OmegaOffset", "Goniometer") # Corrections self.setPropertyGroup("LoadInstrument", "Corrections") self.setPropertyGroup("ApplyCalibration", "Corrections") self.setPropertyGroup("DetCal", "Corrections") self.setPropertyGroup("CopyInstrumentParameters", "Corrections") self.setPropertyGroup("MaskFile", "Corrections") # Projection and binning self.setPropertyGroup("QDimension0", "Projection and binning") self.setPropertyGroup("QDimension1", "Projection and binning") self.setPropertyGroup("QDimension2", "Projection and binning") self.setPropertyGroup("Dimension0Binning", "Projection and binning") self.setPropertyGroup("Dimension1Binning", "Projection and binning") self.setPropertyGroup("Dimension2Binning", "Projection and binning")
def PyInit(self): self._short_inst = "BSS" self._long_inst = "BASIS" self._extension = "_event.nxs" self.declareProperty("RunNumbers", "", "Sample run numbers") self.declareProperty("DoIndividual", False, "Do each run individually") self.declareProperty("NoMonitorNorm", False, "Stop monitor normalization") grouping_type = ["None", "Low-Resolution", "By-Tube"] self.declareProperty("GroupDetectors", "None", StringListValidator(grouping_type), "Switch for grouping detectors") self.declareProperty( "NormalizeToFirst", False, "Normalize spectra to intensity of spectrum with lowest Q?") # Properties affected by the reflection selected titleReflection = "Reflection Selector" available_reflections = sorted(REFLECTIONS_DICT.keys()) default_reflection = REFLECTIONS_DICT["silicon111"] self.declareProperty( "ReflectionType", default_reflection["name"], StringListValidator(available_reflections), "Analyzer. Documentation lists typical associated property values." ) self.setPropertyGroup("ReflectionType", titleReflection) self.declareProperty( FloatArrayProperty("EnergyBins", default_reflection["energy_bins"], direction=Direction.Input), "Energy transfer binning scheme (in ueV)") self.setPropertyGroup("EnergyBins", titleReflection) self.declareProperty( FloatArrayProperty("MomentumTransferBins", default_reflection["q_bins"], direction=Direction.Input), "Momentum transfer binning scheme") self.setPropertyGroup("MomentumTransferBins", titleReflection) self.declareProperty( FileProperty(name="MaskFile", defaultValue=pjoin(DEFAULT_MASK_GROUP_DIR, default_reflection["mask_file"]), action=FileAction.OptionalLoad, extensions=['.xml']), "See documentation for latest mask files.") self.setPropertyGroup("MaskFile", titleReflection) # Properties setting the division by vanadium titleDivideByVanadium = "Normalization by Vanadium" self.declareProperty("DivideByVanadium", False, direction=Direction.Input, doc="Do we normalize by the vanadium intensity?") self.setPropertyGroup("DivideByVanadium", titleDivideByVanadium) ifDivideByVanadium = EnabledWhenProperty( "DivideByVanadium", PropertyCriterion.IsNotDefault) normalization_types = ["by Q slice", "by detector ID"] self.declareProperty("NormalizationType", "by Q slice", StringListValidator(normalization_types), "Select a Vanadium normalization") self.setPropertySettings("NormalizationType", ifDivideByVanadium) self.setPropertyGroup("NormalizationType", titleDivideByVanadium) self.declareProperty("NormRunNumbers", "", "Normalization run numbers") self.setPropertySettings("NormRunNumbers", ifDivideByVanadium) self.setPropertyGroup("NormRunNumbers", titleDivideByVanadium) arrVal = FloatArrayLengthValidator(2) self.declareProperty( FloatArrayProperty("NormWavelengthRange", DEFAULT_RANGE, arrVal, direction=Direction.Input), "Wavelength range for normalization") self.setPropertySettings("NormWavelengthRange", ifDivideByVanadium) self.setPropertyGroup("NormWavelengthRange", titleDivideByVanadium)
def PyInit(self): # Input params self.declareProperty( MultipleFileProperty(name="Filename", extensions=[".nxs.h5", ".nxs"], action=FileAction.OptionalLoad), doc= "Input autoreduced detector scan data files to convert to Q-space." ) self.declareProperty(FileProperty(name="VanadiumFile", defaultValue="", extensions=[".nxs"], direction=Direction.Input, action=FileAction.OptionalLoad), doc="File with Vanadium normalization scan data") self.declareProperty('NormaliseBy', 'Time', StringListValidator(['None', 'Time', 'Monitor']), "Normalise to monitor, time or None.") # Alternative WS inputs self.declareProperty( "InputWorkspaces", defaultValue="", direction=Direction.Input, doc= "Workspace or comma-separated workspace list containing input MDHisto scan data." ) self.declareProperty( IMDHistoWorkspaceProperty("VanadiumWorkspace", defaultValue="", direction=Direction.Input, optional=PropertyMode.Optional), doc="MDHisto workspace containing vanadium normalization data") # Detector adjustment options self.declareProperty( "DetectorHeightOffset", defaultValue=0.0, direction=Direction.Input, doc= "Optional distance (in meters) to move detector height (relative to current position)" ) self.declareProperty( "DetectorDistanceOffset", defaultValue=0.0, direction=Direction.Input, doc= "Optional distance (in meters) to move detector distance (relative to current position)" ) self.declareProperty( FloatPropertyWithValue( "Wavelength", # EMPTY_DBL so it shows as blank in GUI FloatPropertyWithValue.EMPTY_DBL), doc= "Optional wavelength value to use as backup if one was not found in the sample log" ) # Which conversion algorithm to use self.declareProperty( "OutputType", "Q-sample events", StringListValidator( ['Q-sample events', 'Q-sample histogram', 'Detector']), direction=Direction.Input, doc= "Whether to use ConvertHFIRSCDtoQ for an MDEvent, or ConvertWANDSCDtoQ for an MDHisto" ) self.declareProperty( "ScaleByMotorStep", False, "If True then the intensity of the output in Q space will be scaled by the motor step size. " "This will allow directly comparing the intensity of data measure with diffrent motor step sizes." ) # MDEvent WS Specific options for ConvertHFIRSCDtoQ self.declareProperty( FloatArrayProperty("MinValues", [-10, -10, -10], FloatArrayLengthValidator(3), direction=Direction.Input), doc="3 comma separated values, one for each q_sample dimension") self.declareProperty( FloatArrayProperty("MaxValues", [10, 10, 10], FloatArrayLengthValidator(3), direction=Direction.Input), doc= "3 comma separated values, one for each q_sample dimension; must be larger than" "those specified in MinValues") self.declareProperty( "MergeInputs", defaultValue=False, direction=Direction.Input, doc= "If all inputs should be merged into one MDEvent output workspace") # MDHisto WS Specific options for ConvertWANDSCDtoQ self.declareProperty( FloatArrayProperty("BinningDim0", [-8.02, 8.02, 401], FloatArrayLengthValidator(3), direction=Direction.Input), "Binning parameters for the 0th dimension. Enter it as a" "comma-separated list of values with the" "format: 'minimum,maximum,number_of_bins'.") self.declareProperty( FloatArrayProperty("BinningDim1", [-2.52, 2.52, 126], FloatArrayLengthValidator(3), direction=Direction.Input), "Binning parameters for the 1st dimension. Enter it as a" "comma-separated list of values with the" "format: 'minimum,maximum,number_of_bins'.") self.declareProperty( FloatArrayProperty("BinningDim2", [-8.02, 8.02, 401], FloatArrayLengthValidator(3), direction=Direction.Input), "Binning parameters for the 2nd dimension. Enter it as a" "comma-separated list of values with the" "format: 'minimum,maximum,number_of_bins'.") self.setPropertySettings( "Filename", EnabledWhenProperty('InputWorkspaces', PropertyCriterion.IsDefault)) self.setPropertySettings( "VanadiumFile", EnabledWhenProperty('VanadiumWorkspace', PropertyCriterion.IsDefault)) self.setPropertySettings( "InputWorkspaces", EnabledWhenProperty('Filename', PropertyCriterion.IsDefault)) self.setPropertySettings( "VanadiumWorkspace", EnabledWhenProperty('VanadiumFile', PropertyCriterion.IsDefault)) self.setPropertySettings( "ScaleByMotorStep", EnabledWhenProperty('OutputType', PropertyCriterion.IsNotEqualTo, "Detector")) event_settings = EnabledWhenProperty('OutputType', PropertyCriterion.IsEqualTo, 'Q-sample events') self.setPropertyGroup("MinValues", "MDEvent Settings") self.setPropertyGroup("MaxValues", "MDEvent Settings") self.setPropertyGroup("MergeInputs", "MDEvent Settings") self.setPropertySettings("MinValues", event_settings) self.setPropertySettings("MaxValues", event_settings) self.setPropertySettings("MergeInputs", event_settings) histo_settings = EnabledWhenProperty('OutputType', PropertyCriterion.IsEqualTo, 'Q-sample histogram') self.setPropertyGroup("BinningDim0", "MDHisto Settings") self.setPropertyGroup("BinningDim1", "MDHisto Settings") self.setPropertyGroup("BinningDim2", "MDHisto Settings") self.setPropertySettings("BinningDim0", histo_settings) self.setPropertySettings("BinningDim1", histo_settings) self.setPropertySettings("BinningDim2", histo_settings) self.declareProperty( WorkspaceProperty("OutputWorkspace", "", optional=PropertyMode.Mandatory, direction=Direction.Output), doc= "Output MDWorkspace in Q-space, name is prefix if multiple input files were provided." )
def PyInit(self): validator = FloatArrayLengthValidator(minlength, maxlength) self.declareProperty(FloatArrayProperty("Input", validator))
def test_empty_constructor_has_no_lengths_set(self): validator = FloatArrayLengthValidator() self.assertFalse(validator.hasLength()) self.assertFalse(validator.hasMinLength()) self.assertFalse(validator.hasMaxLength())
def test_fixed_length_constructor_return_hasLength(self): fixedlength = 9 validator = FloatArrayLengthValidator(fixedlength) self.assertTrue(validator.hasLength()) self.assertEquals(validator.getLength(), fixedlength)
def PyInit(self): # files to reduce self.declareProperty( MultipleFileProperty(name="Filename", extensions=["_event.nxs", ".nxs.h5", ".nxs"]), "Files to combine in reduction") # background self.declareProperty( FileProperty(name="Background", defaultValue="", action=FileAction.OptionalLoad, extensions=["_event.nxs", ".nxs.h5", ".nxs"]), "Background run") self.declareProperty( "BackgroundScale", 1.0, doc= "The background will be scaled by this number before being subtracted." ) # Filter by TOF self.copyProperties('LoadEventNexus', ['FilterByTofMin', 'FilterByTofMax']) # Vanadium SA and flux self.declareProperty( FileProperty(name="SolidAngle", defaultValue="", action=FileAction.Load, extensions=[".nxs"]), doc= "An input workspace containing momentum integrated vanadium (a measure" "of the solid angle). See :ref:`MDnormSCD <algm-MDnormSCD>` for details" ) self.declareProperty( FileProperty(name="Flux", defaultValue="", action=FileAction.Load, extensions=[".nxs"]), "An input workspace containing momentum dependent flux. See :ref:`MDnormSCD <algm-MDnormSCD>` for details" ) # UBMatrix self.declareProperty( FileProperty(name="UBMatrix", defaultValue="", action=FileAction.Load, extensions=[".mat", ".ub", ".txt"]), doc= "Path to an ISAW-style UB matrix text file. See :ref:`LoadIsawUB <algm-LoadIsawUB>`" ) # Goniometer self.declareProperty( 'SetGoniometer', False, "Set which Goniometer to use. See :ref:`SetGoniometer <algm-SetGoniometer>`" ) condition = VisibleWhenProperty("SetGoniometer", PropertyCriterion.IsNotDefault) self.copyProperties('SetGoniometer', ['Goniometers', 'Axis0', 'Axis1', 'Axis2']) self.setPropertySettings("Goniometers", condition) self.setPropertySettings('Axis0', condition) self.setPropertySettings('Axis1', condition) self.setPropertySettings('Axis2', condition) # Corrections self.declareProperty( FileProperty(name="LoadInstrument", defaultValue="", action=FileAction.OptionalLoad, extensions=[".xml"]), "Load a different instrument IDF onto the data from a file. See :ref:`LoadInstrument <algm-LoadInstrument>`" ) self.declareProperty( FileProperty(name="DetCal", defaultValue="", action=FileAction.OptionalLoad, extensions=[".detcal"]), "Load an ISAW DetCal calibration onto the data from a file. See :ref:`LoadIsawDetCal <algm-LoadIsawDetCal>`" ) self.declareProperty( FileProperty(name="MaskFile", defaultValue="", action=FileAction.OptionalLoad, extensions=[".xml", ".msk"]), "Masking file for masking. Supported file format is XML and ISIS ASCII. See :ref:`LoadMask <algm-LoadMask>`" ) # SymmetryOps, name, group unmber or list symmetries self.declareProperty( "SymmetryOps", "", "If specified the symmetry will be applied, can be space group name or number, or list individual symmetries." ) # Binning output self.copyProperties('ConvertToMD', ['Uproj', 'Vproj', 'Wproj']) self.declareProperty( FloatArrayProperty("BinningDim0", [-5.05, 5.05, 101], FloatArrayLengthValidator(3), direction=Direction.Input), "Binning parameters for the 0th dimension. Enter it as a" "comma-separated list of values with the" "format: 'minimum,maximum,number_of_bins'.") self.declareProperty( FloatArrayProperty("BinningDim1", [-5.05, 5.05, 101], FloatArrayLengthValidator(3), direction=Direction.Input), "Binning parameters for the 1st dimension. Enter it as a" "comma-separated list of values with the" "format: 'minimum,maximum,number_of_bins'.") self.declareProperty( FloatArrayProperty("BinningDim2", [-5.05, 5.05, 101], FloatArrayLengthValidator(3), direction=Direction.Input), "Binning parameters for the 2nd dimension. Enter it as a" "comma-separated list of values with the" "format: 'minimum,maximum,number_of_bins'.") self.declareProperty( 'KeepTemporaryWorkspaces', False, "If True the normalization and data workspaces in addition to the normalized data will be outputted" ) self.declareProperty( WorkspaceProperty("OutputWorkspace", "", optional=PropertyMode.Mandatory, direction=Direction.Output), "Output Workspace. If background is subtracted _data and _background workspaces will also be made." ) # Background self.setPropertyGroup("Background", "Background") self.setPropertyGroup("BackgroundScale", "Background") # Vanadium self.setPropertyGroup("SolidAngle", "Vanadium") self.setPropertyGroup("Flux", "Vanadium") # Goniometer self.setPropertyGroup("SetGoniometer", "Goniometer") self.setPropertyGroup("Goniometers", "Goniometer") self.setPropertyGroup("Axis0", "Goniometer") self.setPropertyGroup("Axis1", "Goniometer") self.setPropertyGroup("Axis2", "Goniometer") # Corrections self.setPropertyGroup("LoadInstrument", "Corrections") self.setPropertyGroup("DetCal", "Corrections") self.setPropertyGroup("MaskFile", "Corrections") # Projection and binning self.setPropertyGroup("Uproj", "Projection and binning") self.setPropertyGroup("Vproj", "Projection and binning") self.setPropertyGroup("Wproj", "Projection and binning") self.setPropertyGroup("BinningDim0", "Projection and binning") self.setPropertyGroup("BinningDim1", "Projection and binning") self.setPropertyGroup("BinningDim2", "Projection and binning")
def test_empty_constructor_has_no_lengths_set(self): validator = FloatArrayLengthValidator() self.assertFalse(validator.hasLength()) self.assertFalse(validator.hasMinLength()) self.assertFalse(validator.hasMaxLength())
def test_setMinMaxLength_alters_accepted_range(self): validator = FloatArrayLengthValidator() self.assertFalse(validator.hasMinLength()) self.assertFalse(validator.hasMaxLength()) lower = 4 upper = 7 validator.setLengthMin(lower) self.assertTrue(validator.hasMinLength()) self.assertFalse(validator.hasMaxLength()) self.assertEqual(validator.getMinLength(), lower) validator.setLengthMax(upper) self.assertTrue(validator.hasMinLength()) self.assertTrue(validator.hasMaxLength()) self.assertEqual(validator.getMaxLength(), upper) validator.clearLengthMin() self.assertFalse(validator.hasMinLength()) self.assertTrue(validator.hasMaxLength()) validator.clearLengthMax() self.assertFalse(validator.hasMinLength()) self.assertFalse(validator.hasMaxLength())
def PyInit(self): self._short_inst = "BSS" self._long_inst = "BASIS" self._extension = "_event.nxs" self.declareProperty("RunNumbers", "", "Sample run numbers") self.declareProperty("DoIndividual", False, "Do each run individually") self.declareProperty("NoMonitorNorm", False, "Stop monitor normalization") grouping_type = ["None", "Low-Resolution", "By-Tube"] self.declareProperty("GroupDetectors", "None", StringListValidator(grouping_type), "Switch for grouping detectors") self.declareProperty( "NormalizeToFirst", False, "Normalize spectra \ to intensity of spectrum with lowest Q?") # Properties affected by the reflection selected titleReflection = "Reflection Selector" available_reflections = sorted(REFLECTIONS_DICT.keys()) default_reflection = REFLECTIONS_DICT["silicon111"] self.declareProperty( "ReflectionType", default_reflection["name"], StringListValidator(available_reflections), "Analyzer. Documentation lists typical \ associated property values.") self.setPropertyGroup("ReflectionType", titleReflection) self.declareProperty( FloatArrayProperty("EnergyBins", default_reflection["energy_bins"], direction=Direction.Input), "Energy transfer binning scheme (in ueV)") self.setPropertyGroup("EnergyBins", titleReflection) self.declareProperty( FloatArrayProperty("MomentumTransferBins", default_reflection["q_bins"], direction=Direction.Input), "Momentum transfer binning scheme") self.setPropertyGroup("MomentumTransferBins", titleReflection) self.declareProperty( FileProperty(name="MaskFile", defaultValue='', action=FileAction.OptionalLoad, extensions=['.xml']), "See documentation for latest mask files.") self.setPropertyGroup("MaskFile", titleReflection) # Properties setting the division by vanadium titleDivideByVanadium = "Normalization by Vanadium" self.declareProperty("DivideByVanadium", False, direction=Direction.Input, doc="Do we normalize by the vanadium intensity?") self.setPropertyGroup("DivideByVanadium", titleDivideByVanadium) ifDivideByVanadium = EnabledWhenProperty( "DivideByVanadium", PropertyCriterion.IsNotDefault) normalization_types = ["by Q slice", "by detector ID"] self.declareProperty("NormalizationType", "by Q slice", StringListValidator(normalization_types), "Select a Vanadium normalization") self.setPropertySettings("NormalizationType", ifDivideByVanadium) self.setPropertyGroup("NormalizationType", titleDivideByVanadium) self.declareProperty("NormRunNumbers", "", "Normalization run numbers") self.setPropertySettings("NormRunNumbers", ifDivideByVanadium) self.setPropertyGroup("NormRunNumbers", titleDivideByVanadium) arrVal = FloatArrayLengthValidator(2) self.declareProperty( FloatArrayProperty("NormWavelengthRange", DEFAULT_RANGE, arrVal, direction=Direction.Input), "Wavelength range for normalization") self.setPropertySettings("NormWavelengthRange", ifDivideByVanadium) self.setPropertyGroup("NormWavelengthRange", titleDivideByVanadium) # Properties setting the saving of NSXPE file title_nxspe = 'Save to NXSPE' self.declareProperty('SaveNXSPE', False, direction=Direction.Input, doc='Do we save to NXSPE format?') nxspe_enabled = EnabledWhenProperty('SaveNXSPE', PropertyCriterion.IsNotDefault) self.setPropertyGroup('SaveNXSPE', title_nxspe) self.declareProperty('PsiAngleLog', 'SE50Rot', direction=Direction.Input, doc='name of entry in the logs storing the psi \ angle') self.setPropertySettings('PsiAngleLog', nxspe_enabled) self.setPropertyGroup('PsiAngleLog', title_nxspe) self.declareProperty('PsiOffset', 0.0, direction=Direction.Input, doc='add this quantity to the psi angle stored \ in the log') self.setPropertySettings('PsiOffset', nxspe_enabled) self.setPropertyGroup('PsiOffset', title_nxspe) # Aditional output properties titleAddionalOutput = "Additional Output" self.declareProperty("OutputSusceptibility", False, direction=Direction.Input, doc="Output dynamic susceptibility (Xqw)") self.setPropertyGroup("OutputSusceptibility", titleAddionalOutput)