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 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( 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).')