def test_constructor_with_name_and_default_and_action_and_exts_list(self): prop = FileProperty("LoadProperty", "", FileAction.Load, ['.nxs', '.raw']) self.assertNotEquals("", prop.isValid()) self.assertEquals(Direction.Input, prop.direction) allowed = prop.allowedValues self.assertTrue('.nxs' in allowed) self.assertTrue('.raw' in allowed)
def PyInit(self): self.declareProperty(MultipleFileProperty('Run', extensions=['nxs']), doc='Run number(s) of sample run(s).') self.declareProperty( MultipleFileProperty('BackgroundRun', action=FileAction.OptionalLoad, extensions=['nxs']), doc='Run number(s) of background (empty can) run(s).') self.declareProperty( MultipleFileProperty('CalibrationRun', action=FileAction.OptionalLoad, extensions=['nxs']), doc='Run number(s) of vanadium calibration run(s).') self.declareProperty( MultipleFileProperty('CalibrationBackgroundRun', action=FileAction.OptionalLoad, extensions=['nxs']), doc= 'Run number(s) of background (empty can) run(s) for vanadium run.') self.declareProperty( MultipleFileProperty('AlignmentRun', action=FileAction.OptionalLoad, extensions=['nxs']), doc='Run number(s) of vanadium run(s) used for ' 'peak alignment for UnmirrorOption=[5, 7]') self.declareProperty(name='SumRuns', defaultValue=False, doc='Whether to sum all the input runs.') self.declareProperty( name='CropDeadMonitorChannels', defaultValue=False, doc='Whether or not to exclude the first and last few channels ' 'with 0 monitor count in the energy transfer formula.') self.declareProperty( name='UnmirrorOption', defaultValue=6, validator=IntBoundedValidator(lower=0, upper=7), doc='Unmirroring options : \n' '0 no unmirroring\n' '1 sum of left and right\n' '2 left\n' '3 right\n' '4 shift right according to left and sum\n' '5 like 4, but use alignment run for peak positions\n' '6 center both left and right at zero and sum\n' '7 like 6, but use alignment run for peak positions') self.declareProperty(name='BackgroundScalingFactor', defaultValue=1., validator=FloatBoundedValidator(lower=0), doc='Scaling factor for background subtraction') self.declareProperty( name='CalibrationBackgroundScalingFactor', defaultValue=1., validator=FloatBoundedValidator(lower=0), doc= 'Scaling factor for background subtraction for vanadium calibration' ) self.declareProperty( name='CalibrationPeakRange', defaultValue=[-0.003, 0.003], validator=FloatArrayMandatoryValidator(), doc='Peak range for integration over calibration file peak (in mev)' ) self.declareProperty( FileProperty('MapFile', '', action=FileAction.OptionalLoad, extensions=['map', 'xml']), doc='Filename of the detector grouping map file to use. \n' 'By default all the pixels will be summed per each tube. \n' 'Use .map or .xml file (see GroupDetectors documentation) ' 'only if different range is needed for each tube.') self.declareProperty( name='ManualPSDIntegrationRange', defaultValue=[1, 128], doc='Integration range of vertical pixels in each PSD tube. \n' 'By default all the pixels will be summed per each tube. \n' 'Use this option if the same range (other than default) ' 'is needed for all the tubes.') self.declareProperty(name='Analyser', defaultValue='silicon', validator=StringListValidator(['silicon']), doc='Analyser crystal.') self.declareProperty(name='Reflection', defaultValue='111', validator=StringListValidator(['111', '311']), doc='Analyser reflection.') self.declareProperty(WorkspaceGroupProperty( 'OutputWorkspace', '', direction=Direction.Output), doc='Group name for the reduced workspace(s).') self.declareProperty(name='SpectrumAxis', defaultValue='SpectrumNumber', validator=StringListValidator( ['SpectrumNumber', '2Theta', 'Q', 'Q2']), doc='The spectrum axis conversion target.') self.declareProperty( name='DiscardSingleDetectors', defaultValue=False, doc='Whether to discard the spectra of single detectors.')
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( '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') help_doc = """Only retain events occurring within a time segment. Examples: 71546:0-3600 only retains events from the first hour of run 71546. 71546:3600-7200 retain only the second hour. 71546:7200-end retain events after the first two hours""" self.declareProperty('RetainTimeSegment', '', help_doc) grouping_type = ['None', 'Low-Resolution', 'By-Tube'] self.declareProperty('GroupDetectors', 'None', StringListValidator(grouping_type), 'Switch for grouping detectors') # # Normalization selector # title_flux_normalization = 'Flux Normalization' self.declareProperty('DoFluxNormalization', True, direction=Direction.Input, doc='Do we normalize data by incoming flux?') self.setPropertyGroup('DoFluxNormalization', title_flux_normalization) if_flux_normalization = EnabledWhenProperty( 'DoFluxNormalization', PropertyCriterion.IsDefault) default_flux_normalization = self._flux_normalization_types[0] self.declareProperty( 'FluxNormalizationType', default_flux_normalization, StringListValidator(self._flux_normalization_types), 'Flux Normalization Type') self.setPropertySettings('FluxNormalizationType', if_flux_normalization) self.setPropertyGroup('FluxNormalizationType', title_flux_normalization) 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['silicon_111'] 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) # 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) self.declareProperty('OutputPowderSpectrum', False, direction=Direction.Input, doc='Output S(Q) and S(theta) powder diffraction') self.setPropertyGroup('OutputPowderSpectrum', titleAddionalOutput) self.declareProperty('RemoveTemporaryWorkspaces', True, direction=Direction.Input, doc='Remove temporary workspaces and files') self.setPropertyGroup('RemoveTemporaryWorkspaces', titleAddionalOutput)
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): # 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('SingleCrystalDiffraction', False, direction=Direction.Input, doc='Calculate diffraction pattern?') crystal_diffraction_enabled =\ EnabledWhenProperty('SingleCrystalDiffraction', PropertyCriterion.IsNotDefault) 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') self.setPropertyGroup('SingleCrystalDiffraction', crystal_diffraction_title) for a_property in ('PsiAngleLog', 'PsiOffset', 'LatticeSizes', 'LatticeAngles', 'VectorU', 'VectorV', 'Uproj', 'Vproj', 'Wproj', 'NBins'): self.setPropertyGroup(a_property, crystal_diffraction_title) self.setPropertySettings(a_property, crystal_diffraction_enabled)
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_constructor_with_name_and_default_and_action_and_single_ext(self): prop = FileProperty("LoadProperty", "", FileAction.Load, '.nxs') self.assertNotEquals("", prop.isValid) self.assertEquals(Direction.Input, prop.direction) allowed = prop.allowedValues self.assertTrue('.nxs' in allowed)
def PyInit(self): """Initialize the input and output properties of the algorithm.""" nonnegativeInts = IntArrayBoundedValidator() nonnegativeInts.setLower(0) maxTwoNonnegativeInts = CompositeValidator() maxTwoNonnegativeInts.add(IntArrayLengthValidator(lenmin=0, lenmax=2)) maxTwoNonnegativeInts.add(nonnegativeInts) nonnegativeFloatArray = FloatArrayBoundedValidator() nonnegativeFloatArray.setLower(0.) stringArrayValidator = StringArrayLengthValidator() stringArrayValidator.setLengthMin(1) #======================== Main Properties ======================== self.declareProperty( PropertyNames.POLARIZATION_OPTION, 'NonPolarized', StringListValidator(['NonPolarized', 'Polarized']), 'Indicate whether measurements are polarized') is_polarized = EnabledWhenProperty(PropertyNames.POLARIZATION_OPTION, PropertyCriterion.IsEqualTo, 'Polarized') is_not_polarized = EnabledWhenProperty( PropertyNames.POLARIZATION_OPTION, PropertyCriterion.IsEqualTo, 'NonPolarized') polarized = 'Inputs for polarized measurements' self.declareProperty(MultipleFileProperty( PropertyNames.RB, action=FileAction.OptionalLoad, extensions=['nxs']), doc='A list of reflected run numbers/files.') self.setPropertySettings(PropertyNames.RB, is_not_polarized) self.declareProperty( MultipleFileProperty(PropertyNames.RB00, action=FileAction.OptionalLoad, extensions=['nxs']), doc='A list of reflected run numbers/files for 00.') self.setPropertySettings(PropertyNames.RB00, is_polarized) self.setPropertyGroup(PropertyNames.RB00, polarized) self.declareProperty( MultipleFileProperty(PropertyNames.RB01, action=FileAction.OptionalLoad, extensions=['nxs']), doc='A list of reflected run numbers/files for 01.') self.setPropertySettings(PropertyNames.RB01, is_polarized) self.setPropertyGroup(PropertyNames.RB01, polarized) self.declareProperty( MultipleFileProperty(PropertyNames.RB10, action=FileAction.OptionalLoad, extensions=['nxs']), doc='A list of reflected run numbers/files for 10.') self.setPropertySettings(PropertyNames.RB10, is_polarized) self.setPropertyGroup(PropertyNames.RB10, polarized) self.declareProperty( MultipleFileProperty(PropertyNames.RB11, action=FileAction.OptionalLoad, extensions=['nxs']), doc='A list of reflected run numbers/files for 11.') self.setPropertySettings(PropertyNames.RB11, is_polarized) self.setPropertyGroup(PropertyNames.RB11, polarized) self.declareProperty( FileProperty(PropertyNames.EFFICIENCY_FILE, defaultValue='', action=FileAction.OptionalLoad), doc='A file containing the polarization efficiency factors.') self.setPropertySettings(PropertyNames.EFFICIENCY_FILE, is_polarized) self.setPropertyGroup(PropertyNames.EFFICIENCY_FILE, polarized) self.declareProperty(MultipleFileProperty(PropertyNames.DB, action=FileAction.Load, extensions=['nxs']), doc='A list of direct run numbers/files.') self.declareProperty(WorkspaceGroupProperty( Prop.OUTPUT_WS, defaultValue='', direction=Direction.Output), doc='The output workspace group.') self.declareProperty( PropertyNames.BKG_METHOD_DIRECT, defaultValue=BkgMethod.CONSTANT, validator=StringListValidator( [BkgMethod.CONSTANT, BkgMethod.LINEAR, BkgMethod.OFF]), doc='Flat background calculation method for background subtraction.' ) self.declareProperty( PropertyNames.BKG_METHOD, defaultValue=BkgMethod.CONSTANT, validator=StringListValidator( [BkgMethod.CONSTANT, BkgMethod.LINEAR, BkgMethod.OFF]), doc='Flat background calculation method for background subtraction.' ) self.copyProperties('ReflectometryILLPreprocess', [ Prop.SUBALG_LOGGING, Prop.CLEANUP, Prop.WATER_REFERENCE, Prop.SLIT_NORM, Prop.FLUX_NORM_METHOD ]) self.declareProperty(PropertyNames.SCALE_FACTOR, defaultValue=1.0, doc='Scale factor.') self.declareProperty( PropertyNames.USE_MANUAL_SCALE_FACTORS, defaultValue=False, doc='Choose to apply manual scale factors for stitching.') self.declareProperty( FloatArrayProperty(PropertyNames.MANUAL_SCALE_FACTORS, values=[]), doc= 'A list of manual scale factors for stitching (number of anlge configurations minus 1)' ) self.setPropertySettings( PropertyNames.MANUAL_SCALE_FACTORS, EnabledWhenProperty(PropertyNames.USE_MANUAL_SCALE_FACTORS, PropertyCriterion.IsNotDefault)) self.declareProperty( PropertyNames.CACHE_DIRECT_BEAM, defaultValue=False, doc= 'Cache the processed direct beam in ADS for ready use with further reflected beams;' 'saves important execution time, however assumes that the direct beam processing ' 'configuration must be invariant for different reflected beams.') # ======================== Common Properties ======================== commonProp = 'Preprocessing common properties: provide a list or a single value' self.declareProperty(StringArrayProperty( PropertyNames.ANGLE_OPTION, values=[PropertyNames.DAN], validator=stringArrayValidator, direction=Direction.Input, ), doc='Angle option used for detector positioning') self.declareProperty(FloatArrayProperty(PropertyNames.THETA, values=[-1.]), doc='A user-defined angle theta in degree') self.declareProperty(StringArrayProperty( PropertyNames.SUM_TYPE, values=[PropertyNames.INCOHERENT], validator=stringArrayValidator, direction=Direction.Input, ), doc='Type of summation to perform') self.declareProperty(FloatArrayProperty( PropertyNames.WAVELENGTH_LOWER, values=[0.], validator=nonnegativeFloatArray), doc='The lower wavelength bound (Angstrom)') self.declareProperty(FloatArrayProperty( PropertyNames.WAVELENGTH_UPPER, values=[35.], validator=nonnegativeFloatArray), doc='The upper wavelength bound (Angstrom)') self.declareProperty( FloatArrayProperty( PropertyNames.GROUPING_FRACTION, values=[0.5], validator=nonnegativeFloatArray, ), doc= 'If set, group the output by steps of this fraction multiplied by Q resolution' ) self.setPropertyGroup(PropertyNames.ANGLE_OPTION, commonProp) self.setPropertyGroup(PropertyNames.THETA, commonProp) self.setPropertyGroup(PropertyNames.SUM_TYPE, commonProp) self.setPropertyGroup(PropertyNames.WAVELENGTH_LOWER, commonProp) self.setPropertyGroup(PropertyNames.WAVELENGTH_UPPER, commonProp) self.setPropertyGroup(PropertyNames.GROUPING_FRACTION, commonProp) # ======================== Direct Run Properties ======================== preProcessDirect = 'Preprocessing for direct runs: provide a list or a single value' self.declareProperty( IntArrayProperty(PropertyNames.LOW_FRG_HALF_WIDTH_DIRECT, values=[0], validator=nonnegativeInts), doc= 'Number of foreground pixels at lower angles from the centre pixel.' ) self.setPropertyGroup(PropertyNames.LOW_FRG_HALF_WIDTH_DIRECT, preProcessDirect) self.declareProperty( IntArrayProperty( PropertyNames.LOW_BKG_OFFSET_DIRECT, values=[7], validator=nonnegativeInts, ), doc= 'Distance of flat background region towards smaller detector angles from the ' + 'foreground centre, in pixels') self.setPropertyGroup(PropertyNames.LOW_BKG_OFFSET_DIRECT, preProcessDirect) self.declareProperty( IntArrayProperty( PropertyNames.LOW_BKG_WIDTH_DIRECT, values=[5], validator=nonnegativeInts, ), doc= 'Width of flat background region towards smaller detector angles from the ' + 'foreground centre, in pixels') self.setPropertyGroup(PropertyNames.LOW_BKG_WIDTH_DIRECT, preProcessDirect) self.declareProperty( IntArrayProperty(PropertyNames.HIGH_FRG_HALF_WIDTH_DIRECT, values=[0], validator=nonnegativeInts), doc= 'Number of foreground pixels at higher angles from the centre pixel.' ) self.setPropertyGroup(PropertyNames.HIGH_FRG_HALF_WIDTH_DIRECT, preProcessDirect) self.declareProperty( IntArrayProperty( PropertyNames.HIGH_BKG_OFFSET_DIRECT, values=[7], validator=nonnegativeInts, ), doc= 'Distance of flat background region towards larger detector angles from the ' + 'foreground centre, in pixels') self.setPropertyGroup(PropertyNames.HIGH_BKG_OFFSET_DIRECT, preProcessDirect) self.declareProperty( IntArrayProperty( PropertyNames.HIGH_BKG_WIDTH_DIRECT, values=[5], validator=nonnegativeInts, ), doc= 'Width of flat background region towards larger detector angles from the ' + 'foreground centre, in pixels') self.setPropertyGroup(PropertyNames.HIGH_BKG_WIDTH_DIRECT, preProcessDirect) self.declareProperty(IntArrayProperty( PropertyNames.START_WS_INDEX_DIRECT, values=[0], validator=nonnegativeInts, ), doc='Start histogram index used for peak fitting') self.setPropertyGroup(PropertyNames.START_WS_INDEX_DIRECT, preProcessDirect) self.declareProperty(IntArrayProperty( PropertyNames.END_WS_INDEX_DIRECT, values=[255], validator=nonnegativeInts, ), doc='Last histogram index used for peak fitting') self.setPropertyGroup(PropertyNames.END_WS_INDEX_DIRECT, preProcessDirect) self.declareProperty( PropertyNames.XMIN_DIRECT, defaultValue=-1., doc='Minimum x value (unit wavelength) used for peak fitting.') self.setPropertyGroup(PropertyNames.XMIN_DIRECT, preProcessDirect) self.declareProperty( PropertyNames.XMAX_DIRECT, defaultValue=-1., doc='Maximum x value (unit wavelength) used for peak fitting.') self.setPropertyGroup(PropertyNames.XMAX_DIRECT, preProcessDirect) # ======================== Preprocessing For Reflected Runs ======================== preProcessReflected = 'Preprocessing for reflected runs: provide a list or a single value' self.declareProperty( IntArrayProperty( PropertyNames.LOW_FRG_HALF_WIDTH, values=[0], validator=nonnegativeInts, ), doc= 'Number of foreground pixels at lower angles from the centre pixel.' ) self.setPropertyGroup(PropertyNames.LOW_FRG_HALF_WIDTH, preProcessReflected) self.declareProperty( IntArrayProperty( PropertyNames.LOW_BKG_OFFSET, values=[7], validator=nonnegativeInts, ), doc= 'Distance of flat background region towards smaller detector angles from the ' + 'foreground centre, in pixels.') self.setPropertyGroup(PropertyNames.LOW_BKG_OFFSET, preProcessReflected) self.declareProperty( IntArrayProperty( PropertyNames.LOW_BKG_WIDTH, values=[5], validator=nonnegativeInts, ), doc= 'Width of flat background region towards smaller detector angles from the ' + 'foreground centre, in pixels') self.setPropertyGroup(PropertyNames.LOW_BKG_WIDTH, preProcessReflected) self.declareProperty( IntArrayProperty( PropertyNames.HIGH_FRG_HALF_WIDTH, values=[0], validator=nonnegativeInts, ), doc= 'Number of foreground pixels at higher angles from the centre pixel.' ) self.setPropertyGroup(PropertyNames.HIGH_FRG_HALF_WIDTH, preProcessReflected) self.declareProperty( IntArrayProperty( PropertyNames.HIGH_BKG_OFFSET, values=[7], validator=nonnegativeInts, ), doc= 'Distance of flat background region towards larger detector angles from the ' + 'foreground centre, in pixels') self.setPropertyGroup(PropertyNames.HIGH_BKG_OFFSET, preProcessReflected) self.declareProperty( IntArrayProperty( PropertyNames.HIGH_BKG_WIDTH, values=[5], validator=nonnegativeInts, ), doc= 'Width of flat background region towards larger detector angles from the ' + 'foreground centre, in pixels.') self.setPropertyGroup(PropertyNames.HIGH_BKG_WIDTH, preProcessReflected) self.declareProperty(IntArrayProperty( PropertyNames.START_WS_INDEX, values=[0], validator=nonnegativeInts, ), doc='Start histogram index used for peak fitting') self.setPropertyGroup(PropertyNames.START_WS_INDEX, preProcessReflected) self.declareProperty(IntArrayProperty( PropertyNames.END_WS_INDEX, values=[255], validator=nonnegativeInts, ), doc='Last histogram index used for peak fitting') self.setPropertyGroup(PropertyNames.END_WS_INDEX, preProcessReflected) self.declareProperty( FloatArrayProperty(PropertyNames.XMIN, values=[-1.]), doc='Minimum x value (unit wavelength) used for peak fitting') self.setPropertyGroup(PropertyNames.XMIN, preProcessReflected) self.declareProperty( FloatArrayProperty(PropertyNames.XMAX, values=[-1.]), doc='Maximum x value (unit wavelength) used for peak fitting') self.setPropertyGroup(PropertyNames.XMAX, preProcessReflected)
def PyInit(self): validator = IntArrayBoundedValidator() validator.setLower(0) self.declareProperty( IntArrayProperty("RunNumbers", values=[0], direction=Direction.Input, validator=validator), "Run numbers to process, comma separated") self.declareProperty( "LiveData", False, "Read live data - requires a saved run in the current IPTS " + "with the same Instrument configuration as the live run") mask = [ "None", "Horizontal", "Vertical", "Masking Workspace", "Custom - xml masking file" ] self.declareProperty("Masking", "None", StringListValidator(mask), "Mask to be applied to the data") self.declareProperty( WorkspaceProperty("MaskingWorkspace", "", Direction.Input, PropertyMode.Optional), "The workspace containing the mask.") self.declareProperty(FileProperty(name="MaskingFilename", defaultValue="", direction=Direction.Input, action=FileAction.OptionalLoad), doc="The file containing the xml mask.") self.declareProperty( name="Calibration", defaultValue="Convert Units", validator=StringListValidator( ['Convert Units', 'Calibration File', 'DetCal File']), direction=Direction.Input, doc="The type of conversion to d_spacing to be used.") self.declareProperty( FileProperty(name="CalibrationFilename", defaultValue="", extensions=['.h5', '.cal'], direction=Direction.Input, action=FileAction.OptionalLoad), doc="The calibration file to convert to d_spacing.") self.declareProperty( MultipleFileProperty(name='DetCalFilename', extensions=['.detcal'], action=FileAction.OptionalLoad), 'ISAW DetCal file') self.declareProperty( FloatArrayProperty("Binning", [0.5, -0.004, 7.0]), "Min, Step, and Max of d-space bins. Logarithmic binning is used if Step is negative." ) nor_corr = [ "None", "From Workspace", "From Processed Nexus", "Extracted from Data" ] self.declareProperty( "Normalization", "None", StringListValidator(nor_corr), "If needed what type of input to use as normalization, Extracted from " + "Data uses a background determination that is peak independent.This " + "implemantation can be tested in algorithm SNAP Peak Clipping Background" ) self.declareProperty( FileProperty(name="NormalizationFilename", defaultValue="", direction=Direction.Input, action=FileAction.OptionalLoad), doc="The file containing the processed nexus for normalization.") self.declareProperty( WorkspaceProperty("NormalizationWorkspace", "", Direction.Input, PropertyMode.Optional), "The workspace containing the normalization data.") self.declareProperty( "PeakClippingWindowSize", 10, "Read live data - requires a saved run in the current " + "IPTS with the same Instrumnet configuration") self.declareProperty( "SmoothingRange", 10, "Read live data - requires a saved run in the " + "current IPTS with the same Instrumnet configuration") grouping = ["All", "Column", "Banks", "Modules", "2_4 Grouping"] self.declareProperty( "GroupDetectorsBy", "All", StringListValidator(grouping), "Detector groups to use for future focussing: " + "All detectors as one group, Groups (East,West for " + "SNAP), Columns for SNAP, detector banks") mode = ["Set-Up", "Production"] self.declareProperty( "ProcessingMode", "Production", StringListValidator(mode), "Set-Up Mode is used for establishing correct parameters. Production " + "Mode only Normalized workspace is kept for each run.") self.declareProperty( name="OptionalPrefix", defaultValue="", direction=Direction.Input, doc="Optional Prefix to be added to workspaces and output filenames" ) self.declareProperty( "SaveData", False, "Save data in the following formats: Ascii- " + "d-spacing ,Nexus Processed,GSAS and Fullprof") self.declareProperty(FileProperty(name="OutputDirectory", defaultValue="", action=FileAction.OptionalDirectory), doc='Default value is proposal shared directory')
def PyInit(self): self.declareProperty( MatrixWorkspaceProperty("InputWorkspace", '', optional=PropertyMode.Mandatory, direction=Direction.Input), doc='The workspace which is to be saved.' ' This workspace needs to be the result of a SANS reduction,' ' i.e. it can only be 1D or 2D if the second axis is numeric.') self.declareProperty( FileProperty("Filename", '', action=FileAction.Save, extensions=[]), doc="The name of the file which needs to be stored. Note that " "the actual file type is selected below.") self.declareProperty( MatrixWorkspaceProperty("Transmission", defaultValue='', optional=PropertyMode.Optional, direction=Direction.Input), doc='The sample transmission workspace. Optional.') self.declareProperty(MatrixWorkspaceProperty( "TransmissionCan", defaultValue='', optional=PropertyMode.Optional, direction=Direction.Input), doc='The can transmission workspace. Optional.') self.declareProperty( "Nexus", False, direction=Direction.Input, doc="Save as nexus format. " "Note that if file formats of the same type, e.g. .xml are chosen, then the " "file format is appended to the file name.") self.declareProperty( "CanSAS", False, direction=Direction.Input, doc="Save as CanSAS xml format." "Note that if file formats of the same type, e.g. .xml are chosen, then the " "file format is appended to the file name.") self.declareProperty( "NXcanSAS", False, direction=Direction.Input, doc="Save as NXcanSAS format." "Note that if file formats of the same type, e.g. .xml are chosen, then the " "file format is appended to the file name.") self.declareProperty( "NistQxy", False, direction=Direction.Input, doc="Save as Nist Qxy format." "Note that if file formats of the same type, e.g. .xml are chosen, then the " "file format is appended to the file name.") self.declareProperty( "RKH", False, direction=Direction.Input, doc="Save as RKH format." "Note that if file formats of the same type, e.g. .xml are chosen, then the " "file format is appended to the file name.") self.declareProperty( "CSV", False, direction=Direction.Input, doc="Save as CSV format." "Note that if file formats of the same type, e.g. .xml are chosen, then the " "file format is appended to the file name.") self.setPropertyGroup("Nexus", 'FileFormats') self.setPropertyGroup("CanSAS", 'FileFormats') self.setPropertyGroup("NXCanSAS", 'FileFormats') self.setPropertyGroup("NistQxy", 'FileFormats') self.setPropertyGroup("RKH", 'FileFormats') self.setPropertyGroup("CSV", 'FileFormats') self.declareProperty( "UseZeroErrorFree", True, direction=Direction.Input, doc= "This allows the user to artificially inflate zero error values.") self.declareProperty( "SampleTransmissionRunNumber", "", direction=Direction.Input, doc="The run number for the Sample Transmission workspace used in " "the reduction. Can be blank.") self.declareProperty( "SampleDirectRunNumber", "", direction=Direction.Input, doc="The run number for the Sample Direct workspace used in " "the reduction. Can be blank.") self.declareProperty( "CanScatterRunNumber", "", direction=Direction.Input, doc= "The run number for the Can Scatter workspace used in the reduction. Can be blank." ) self.declareProperty( "CanDirectRunNumber", "", direction=Direction.Input, doc= "The run number for the Can Direct workspace used in the reduction. Can be blank." )
def PyInit(self): self.declareProperty( MultipleFileProperty(name="Filename", action=FileAction.OptionalLoad, extensions=[".dat"]), "Data files to load") condition = EnabledWhenProperty("Filename", PropertyCriterion.IsDefault) self.declareProperty('IPTS', Property.EMPTY_INT, "IPTS number to load from") self.setPropertySettings("IPTS", condition) self.declareProperty('Exp', Property.EMPTY_INT, "Experiment number to load from") self.setPropertySettings("Exp", condition) self.declareProperty(IntArrayProperty("ScanNumbers", []), 'Scan numbers to load') self.setPropertySettings("ScanNumbers", condition) self.declareProperty( FileProperty(name="Vanadium", defaultValue="", action=FileAction.OptionalLoad, extensions=[".dat", ".txt"]), doc= "Vanadium file, can be either the vanadium scan file or the reduced vcorr file. " "If not provided the vcorr file adjacent to the data file will be used" ) self.declareProperty( 'Normalise', True, "If False vanadium normalisation will not be performed") self.declareProperty( IntArrayProperty("ExcludeDetectors", []), doc= "Detectors to exclude. If not provided the HB2A_exp???__exclude_detectors.txt adjacent " "to the data file will be used if it exist") self.declareProperty( 'DefX', '', "By default the def_x (x-axis) from the file will be used, it can be overridden by setting it here" ) self.declareProperty( 'IndividualDetectors', False, "If True the workspace will include each anode as a separate spectrum, useful for debugging issues" ) condition = EnabledWhenProperty("IndividualDetectors", PropertyCriterion.IsDefault) self.declareProperty( 'BinData', True, "Data will be binned using BinWidth. If False then all data will be unbinned" ) self.setPropertySettings("BinData", condition) positiveFloat = FloatBoundedValidator(lower=0., exclusive=True) self.declareProperty('BinWidth', 0.05, positiveFloat, "Bin size of the output workspace") self.setPropertySettings("BinWidth", condition) self.declareProperty('Scale', 1.0, positiveFloat, "The output will be scaled by this value") self.declareProperty( WorkspaceProperty("OutputWorkspace", "", optional=PropertyMode.Mandatory, direction=Direction.Output), "Output Workspace") # extend functionality requested by HB2A users self.declareProperty( name='SaveData', defaultValue=True, doc="By default saving the reduced data to either GSAS or XYE") condition = EnabledWhenProperty('SaveData', PropertyCriterion.IsDefault) self.declareProperty( name='OutputFormat', defaultValue="GSAS", validator=StringListValidator(['XYE', 'GSAS']), doc="Supportted output format: XYE (.dat), GSAS (.gss)") self.setPropertySettings('OutputFormat', condition) self.declareProperty(FileProperty(name="OutputDirectory", defaultValue="", action=FileAction.OptionalDirectory), doc="Saving directory for output file") self.setPropertySettings('OutputDirectory', condition) # group the GUI groupname = "Save Reduction Results" self.setPropertyGroup('SaveData', groupname) self.setPropertyGroup('OutputFormat', groupname) self.setPropertyGroup('OutputDirectory', groupname)
def PyInit(self): # files to reduce self.declareProperty( MultipleFileProperty(name="Filename", extensions=["_event.nxs", ".nxs.h5", ".nxs"]), "Files to combine in reduction") # Filter by time self.copyProperties( 'LoadEventNexus', ['FilterByTofMin', 'FilterByTofMax', 'FilterByTimeStop']) # Filter momentum self.declareProperty( 'MomentumMin', Property.EMPTY_DBL, doc= "Minimum value in momentum. This should match the Flux momentum if " "the output is to be used with :ref:`MDNorm <algm-MDNorm>`") self.declareProperty( 'MomentumMax', Property.EMPTY_DBL, doc= "Maximum value in momentum. This should match the Fluxmomentum if " "the output is to be used with :ref:`MDNorm <algm-MDNorm>`") # UBMatrix self.declareProperty( FileProperty(name="UBMatrix", defaultValue="", action=FileAction.OptionalLoad, 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( 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.declareProperty( WorkspaceProperty("OutputWorkspace", "", optional=PropertyMode.Mandatory, direction=Direction.Output), "Output Workspace") # Convert Settings self.declareProperty( 'QFrame', 'Q_sample', validator=StringListValidator(['Q_sample', 'HKL']), doc= "Selects Q-dimensions of the output workspace. Q (sample frame): " "Wave-vector converted into the frame of the sample (taking out the " "goniometer rotation). HKL: Use the sample's UB matrix to convert " "Wave-vector to crystal's HKL indices.") self.copyProperties('ConvertToMD', [ 'Uproj', 'Vproj', 'Wproj', 'MinValues', 'MaxValues', 'SplitInto', 'SplitThreshold', 'MaxRecursionDepth', 'OverwriteExisting' ]) self.setPropertyGroup('FilterByTofMin', 'Loading') self.setPropertyGroup('FilterByTofMax', 'Loading') self.setPropertyGroup('FilterByTimeStop', 'Loading') self.setPropertyGroup('MomentumMin', 'Loading') self.setPropertyGroup('MomentumMax', 'Loading') # 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") # ConvertToMD self.setPropertyGroup('QFrame', 'ConvertToMD') self.setPropertyGroup('Uproj', 'ConvertToMD') self.setPropertyGroup('Vproj', 'ConvertToMD') self.setPropertyGroup('Wproj', 'ConvertToMD') self.setPropertyGroup('MinValues', 'ConvertToMD') self.setPropertyGroup('MaxValues', 'ConvertToMD') self.setPropertyGroup('SplitInto', 'ConvertToMD') self.setPropertyGroup('SplitThreshold', 'ConvertToMD') self.setPropertyGroup('MaxRecursionDepth', 'ConvertToMD')
def PyInit(self): # Input properties self.declareProperty(StringArrayProperty(name='InputFiles'), doc='Comma separated list of input files') self.declareProperty( name='SumFiles', defaultValue=False, doc='Toggle input file summing or sequential processing') self.declareProperty(name='LoadLogFiles', defaultValue=True, doc='Load log files when loading runs') self.declareProperty(WorkspaceProperty('CalibrationWorkspace', '', direction=Direction.Input, optional=PropertyMode.Optional), doc='Workspace containing calibration data') # Instrument configuration properties self.declareProperty(name='Instrument', defaultValue='', validator=StringListValidator( ['IRIS', 'OSIRIS', 'TOSCA', 'TFXA']), 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( name='Efixed', defaultValue=Property.EMPTY_DBL, validator=FloatBoundedValidator(0.0), doc= 'Overrides the default Efixed value for the analyser/reflection selection.' ) self.declareProperty( IntArrayProperty(name='SpectraRange', values=[0, 1], validator=IntArrayMandatoryValidator()), doc='Comma separated range of spectra number to use.') self.declareProperty( FloatArrayProperty(name='BackgroundRange'), doc= 'Range of background to subtract from raw data in time of flight.') self.declareProperty(name='RebinString', defaultValue='', doc='Rebin string parameters.') self.declareProperty(name='DetailedBalance', defaultValue=Property.EMPTY_DBL, doc='') self.declareProperty(name='ScaleFactor', defaultValue=1.0, doc='Factor by which to scale result.') self.declareProperty( name='FoldMultipleFrames', defaultValue=True, doc='Folds multiple framed data sets into a single workspace.') # Spectra grouping options self.declareProperty(name='GroupingMethod', defaultValue='IPF', validator=StringListValidator([ 'Individual', 'All', 'File', 'Workspace', 'IPF', 'Custom' ]), doc='Method used to group spectra.') self.declareProperty(WorkspaceProperty('GroupingWorkspace', '', direction=Direction.Input, optional=PropertyMode.Optional), doc='Workspace containing spectra grouping.') self.declareProperty(name='GroupingString', defaultValue='', direction=Direction.Input, doc='Spectra to group as string') self.declareProperty(FileProperty('MapFile', '', action=FileAction.OptionalLoad, extensions=['.map']), doc='Workspace containing spectra grouping.') # Output properties self.declareProperty(name='UnitX', defaultValue='DeltaE', validator=StringListValidator( ['DeltaE', 'DeltaE_inWavenumber']), doc='X axis units for the result workspace.') self.declareProperty( WorkspaceGroupProperty('OutputWorkspace', '', direction=Direction.Output), doc='Workspace group for the resulting workspaces.')
def loadInputOutputFiles(): # Input files self.declareProperty(FileProperty('SampleData', '', action=FileAction.OptionalLoad, direction=Direction.Input), doc='Datafile that should be used.') self.declareProperty( 'DoIntensityCorrection', False, direction=Direction.Input, doc= 'If set to True you have to declare a vanadium measurement for intensity correction.' ) self.declareProperty( FileProperty('VanaData', '', action=FileAction.OptionalLoad, direction=Direction.Input), doc='Vanadium measurement for intensity correction.') self.declareProperty( 'DoBackgroundCorrection', False, direction=Direction.Input, doc= 'If set to True you have to declare an empty can measurement for background correction.' ) self.declareProperty( FileProperty('EmptyData', '', action=FileAction.OptionalLoad, direction=Direction.Input), doc='Empty measurement of the can for background correction.') self.declareProperty(FileProperty('CalFile', '', action=FileAction.OptionalLoad, direction=Direction.Input), doc='Calibration file.') self.declareProperty( 'DoEdgebinning', False, direction=Direction.Input, doc='If set to True you have to declare a BinEdges file.') self.declareProperty(FileProperty('BinEdgesFile', '', action=FileAction.OptionalLoad, direction=Direction.Input), doc='BinEdges file used for edgebinning.') grp1 = 'Input and Output Files' self.setPropertyGroup('SampleData', grp1) self.setPropertyGroup('DoIntensityCorrection', grp1) self.setPropertyGroup('VanaData', grp1) self.setPropertyGroup('DoBackgroundCorrection', grp1) self.setPropertyGroup('EmptyData', grp1) self.setPropertyGroup('CalFile', grp1) self.setPropertyGroup('DoEdgebinning', grp1) self.setPropertyGroup('BinEdgesFile', grp1) # OutputFile self.declareProperty(FileProperty('OutputFile', '', action=FileAction.Save, direction=Direction.Input), doc='Output File for p2d Data.') self.setPropertyGroup('OutputFile', grp1)
def test_constructor_with_name_and_default_and_action_and_single_ext_and_direction(self): prop = FileProperty("LoadProperty", "", FileAction.Load, ['.nxs'], Direction.InOut) self.assertNotEquals("", prop.isValid()) self.assertEquals(Direction.InOut, prop.direction)
def PyInit(self): self.declareProperty(MultipleFileProperty('Run', extensions=['nxs']), doc='Run number(s) of sample run(s).') self.declareProperty( MultipleFileProperty('BackgroundRun', action=FileAction.OptionalLoad, extensions=['nxs']), doc='Run number(s) of background (empty can) run(s).') self.declareProperty( MultipleFileProperty('CalibrationRun', action=FileAction.OptionalLoad, extensions=['nxs']), doc='Run number(s) of vanadium calibration run(s).') self.declareProperty( MultipleFileProperty('CalibrationBackgroundRun', action=FileAction.OptionalLoad, extensions=['nxs']), doc= 'Run number(s) of background (empty can) run(s) for vanadium run.') self.declareProperty(name='Observable', defaultValue='sample.temperature', doc='Scanning observable, a Sample Log entry\n') self.declareProperty(name='SortXAxis', defaultValue=False, doc='Whether or not to sort the x-axis\n') self.declareProperty(name='BackgroundScalingFactor', defaultValue=1., validator=FloatBoundedValidator(lower=0), doc='Scaling factor for background subtraction') self.declareProperty( name='CalibrationBackgroundScalingFactor', defaultValue=1., validator=FloatBoundedValidator(lower=0), doc= 'Scaling factor for background subtraction for vanadium calibration' ) self.declareProperty( name='BackgroundOption', defaultValue='Sum', validator=StringListValidator(['Sum', 'Interpolate']), doc='Whether to sum or interpolate the background runs.') self.declareProperty( name='CalibrationOption', defaultValue='Sum', validator=StringListValidator(['Sum', 'Interpolate']), doc='Whether to sum or interpolate the calibration runs.') self.declareProperty( name='CalibrationBackgroundOption', defaultValue='Sum', validator=StringListValidator(['Sum', 'Interpolate']), doc= 'Whether to sum or interpolate the background run for calibration runs.' ) self.declareProperty( FileProperty('MapFile', '', action=FileAction.OptionalLoad, extensions=['map', 'xml']), doc='Filename of the detector grouping map file to use. \n' 'By default all the pixels will be summed per each tube. \n' 'Use .map or .xml file (see GroupDetectors documentation) ' 'only if different range is needed for each tube.') self.declareProperty( name='ManualPSDIntegrationRange', defaultValue=[1, 128], doc='Integration range of vertical pixels in each PSD tube. \n' 'By default all the pixels will be summed per each tube. \n' 'Use this option if the same range (other than default) ' 'is needed for all the tubes.') self.declareProperty(name='Analyser', defaultValue='silicon', validator=StringListValidator(['silicon']), doc='Analyser crystal.') self.declareProperty(name='Reflection', defaultValue='111', validator=StringListValidator(['111', '311']), doc='Analyser reflection.') self.declareProperty(WorkspaceGroupProperty( 'OutputWorkspace', '', direction=Direction.Output), doc='Output workspace group') self.declareProperty(name='SpectrumAxis', defaultValue='SpectrumNumber', validator=StringListValidator( ['SpectrumNumber', '2Theta', 'Q', 'Q2']), doc='The spectrum axis conversion target.') self.declareProperty( name='DiscardSingleDetectors', defaultValue=False, doc='Whether to discard the spectra of single detectors.') self.declareProperty( name='ManualInelasticPeakChannels', defaultValue=[-1, -1], doc= 'The channel indices for the inelastic peak positions in the beginning ' 'and in the end of the spectra; by default the maxima of the monitor ' 'spectrum will be used for this. The intensities will be integrated symmetrically ' 'around each peak.') 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.')
def PyInit(self): self.declareProperty( FileProperty("NoDocString", "", FileAction.Load)) self.declareProperty( FileProperty("WithDocString", "", FileAction.Load), self._testdocstring)
def test_constructor_with_name_and_default_and_action(self): prop = FileProperty("LoadProperty", "", FileAction.Load) self.assertNotEquals("", prop.isValid) self.assertEquals(Direction.Input, prop.direction)
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_constructor_with_name_and_default_and_action_and_single_ext_and_direction( self): prop = FileProperty("LoadProperty", "", FileAction.Load, ['.nxs'], Direction.InOut) self.assertNotEquals("", prop.isValid) self.assertEquals(Direction.InOut, prop.direction)
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.') self.declareProperty(name='DeleteMonitorWorkspace', defaultValue=True, doc='Whether to delete the monitor spectrum.') self.setPropertyGroup('DeleteMonitorWorkspace', bats_options)
def declare_common_properties(self) -> None: """Declare properties common to Abins 1D and 2D versions""" self.declareProperty( FileProperty("VibrationalOrPhononFile", "", action=FileAction.Load, direction=Direction.Input, extensions=AB_INITIO_FILE_EXTENSIONS), doc="File with the data from a vibrational or phonon calculation.") self.declareProperty( name="AbInitioProgram", direction=Direction.Input, defaultValue="CASTEP", validator=StringListValidator([ "CASTEP", "CRYSTAL", "DMOL3", "FORCECONSTANTS", "GAUSSIAN", "VASP" ]), doc= "An ab initio program which was used for vibrational or phonon calculation." ) self.declareProperty(WorkspaceProperty("OutputWorkspace", '', Direction.Output), doc="Name to give the output workspace.") self.declareProperty( name="TemperatureInKelvin", direction=Direction.Input, defaultValue=10.0, doc= "Temperature in K for which dynamical structure factor S should be calculated." ) self.declareProperty(name="BinWidthInWavenumber", defaultValue=1.0, doc="Width of bins used during rebining.") self.declareProperty(name="SampleForm", direction=Direction.Input, defaultValue="Powder", validator=StringListValidator(ALL_SAMPLE_FORMS), doc="Form of the sample: Powder.") self.declareProperty( StringArrayProperty("Atoms", Direction.Input), doc="List of atoms to use to calculate partial S." "If left blank, workspaces with S for all types of atoms will be calculated. " "Element symbols will be interpreted as a sum of all atoms of that element in the " "cell. 'atomN' or 'atom_N' (where N is a positive integer) will be interpreted as " "individual atoms, indexing from 1 following the order of the input data." ) self.declareProperty( name="SumContributions", defaultValue=False, doc= "Sum the partial dynamical structure factors into a single workspace." ) self.declareProperty( name="SaveAscii", defaultValue=False, doc="Write workspaces to .ascii files after computing them.") self.declareProperty( name="ScaleByCrossSection", defaultValue='Incoherent', validator=StringListValidator(['Total', 'Incoherent', 'Coherent']), doc= "Scale the partial dynamical structure factors by the scattering cross section." ) # Abins is supposed to support excitations up to fourth-order. Order 3 and 4 are currently disabled while the # weighting is being investigated; these intensities were unreasonably large in hydrogenous test cases self.declareProperty( name="QuantumOrderEventsNumber", defaultValue='1', validator=StringListValidator(['1', '2']), doc="Number of quantum order effects included in the calculation " "(1 -> FUNDAMENTALS, 2-> first overtone + FUNDAMENTALS + 2nd order combinations" )
def PyInit(self): # Declare all properties self.declareProperty( name="AbInitioProgram", direction=Direction.Input, defaultValue="CASTEP", validator=StringListValidator( ["CASTEP", "CRYSTAL", "DMOL3", "GAUSSIAN"]), doc= "An ab initio program which was used for vibrational or phonon calculation." ) self.declareProperty( FileProperty("VibrationalOrPhononFile", "", action=FileAction.Load, direction=Direction.Input, extensions=["phonon", "out", "outmol", "log", "LOG"]), doc="File with the data from a vibrational or phonon calculation.") self.declareProperty( FileProperty("ExperimentalFile", "", action=FileAction.OptionalLoad, direction=Direction.Input, extensions=["raw", "dat"]), doc="File with the experimental inelastic spectrum to compare.") self.declareProperty( name="TemperatureInKelvin", direction=Direction.Input, defaultValue=10.0, doc= "Temperature in K for which dynamical structure factor S should be calculated." ) self.declareProperty(name="BinWidthInWavenumber", defaultValue=1.0, doc="Width of bins used during rebining.") self.declareProperty( name="Scale", defaultValue=1.0, doc= 'Scale the intensity by the given factor. Default is no scaling.') self.declareProperty( name="SampleForm", direction=Direction.Input, defaultValue="Powder", validator=StringListValidator( AbinsModules.AbinsConstants.ALL_SAMPLE_FORMS), # doc="Form of the sample: SingleCrystal or Powder.") doc="Form of the sample: Powder.") self.declareProperty( name="Instrument", direction=Direction.Input, defaultValue="TOSCA", validator=StringListValidator( AbinsModules.AbinsConstants.ALL_INSTRUMENTS), doc="Name of an instrument for which analysis should be performed." ) self.declareProperty( StringArrayProperty("Atoms", Direction.Input), doc="List of atoms to use to calculate partial S." "If left blank, workspaces with S for all types of atoms will be calculated. " "Element symbols will be interpreted as a sum of all atoms of that element in the " "cell. 'atomN' or 'atom_N' (where N is a positive integer) will be interpreted as " "individual atoms, indexing from 1 following the order of the input data." ) self.declareProperty( name="SumContributions", defaultValue=False, doc= "Sum the partial dynamical structure factors into a single workspace." ) self.declareProperty( name="ScaleByCrossSection", defaultValue='Incoherent', validator=StringListValidator(['Total', 'Incoherent', 'Coherent']), doc= "Scale the partial dynamical structure factors by the scattering cross section." ) # Abins is supposed to support excitations up to fourth-order. Order 3 and 4 are currently disabled while the # weighting is being investigated; these intensities were unreasonably large in hydrogenous test cases self.declareProperty( name="QuantumOrderEventsNumber", defaultValue='1', validator=StringListValidator(['1', '2']), doc="Number of quantum order effects included in the calculation " "(1 -> FUNDAMENTALS, 2-> first overtone + FUNDAMENTALS + 2nd order combinations" ) self.declareProperty(WorkspaceProperty("OutputWorkspace", '', Direction.Output), doc="Name to give the 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("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): self.declareProperty(ITableWorkspaceProperty( "CalibrationTable", "", optional=PropertyMode.Mandatory, direction=Direction.Input), doc="Calibration table, currently only uses difc") self.declareProperty(MatrixWorkspaceProperty( "MaskWorkspace", "", optional=PropertyMode.Optional, direction=Direction.Input), doc="Mask workspace") self.declareProperty(FileProperty(name="InstrumentFilename", defaultValue="", action=FileAction.OptionalLoad, extensions=[".xml"]), doc="Instrument filename") self.declareProperty( WorkspaceProperty("Workspace", "", validator=InstrumentValidator(), optional=PropertyMode.Optional, direction=Direction.Input), doc="Workspace containing the instrument to be calibrated.") # Source self.declareProperty( name="FitSourcePosition", defaultValue=False, doc= "Fit the source position, changes L1 (source to sample) distance." "Uses entire instrument. Occurs before Components are Aligned.") # Sample self.declareProperty( name="FitSamplePosition", defaultValue=False, doc= "Fit the sample position, changes L1 (source to sample) and L2 (sample to detector) distance." "Uses entire instrument. Occurs before Components are Aligned.") # List of components self.declareProperty( StringArrayProperty("ComponentList", direction=Direction.Input), doc="Comma separated list on instrument components to refine.") # X position self.declareProperty(name="Xposition", defaultValue=False, doc="Refine Xposition") condition = EnabledWhenProperty("Xposition", PropertyCriterion.IsNotDefault) self.declareProperty(name="MinXposition", defaultValue=-0.1, validator=FloatBoundedValidator(-10.0, 10.0), doc="Minimum relative X bound (m)") self.setPropertySettings("MinXposition", condition) self.declareProperty(name="MaxXposition", defaultValue=0.1, validator=FloatBoundedValidator(-10.0, 10.0), doc="Maximum relative X bound (m)") self.setPropertySettings("MaxXposition", condition) # Y position self.declareProperty(name="Yposition", defaultValue=False, doc="Refine Yposition") condition = EnabledWhenProperty("Yposition", PropertyCriterion.IsNotDefault) self.declareProperty(name="MinYposition", defaultValue=-0.1, validator=FloatBoundedValidator(-10.0, 10.0), doc="Minimum relative Y bound (m)") self.setPropertySettings("MinYposition", condition) self.declareProperty(name="MaxYposition", defaultValue=0.1, validator=FloatBoundedValidator(-10.0, 10.0), doc="Maximum relative Y bound (m)") self.setPropertySettings("MaxYposition", condition) # Z position self.declareProperty(name="Zposition", defaultValue=False, doc="Refine Zposition") condition = EnabledWhenProperty("Zposition", PropertyCriterion.IsNotDefault) self.declareProperty(name="MinZposition", defaultValue=-0.1, validator=FloatBoundedValidator(-10.0, 10.0), doc="Minimum relative Z bound (m)") self.setPropertySettings("MinZposition", condition) self.declareProperty(name="MaxZposition", defaultValue=0.1, validator=FloatBoundedValidator(-10.0, 10.0), doc="Maximum relative Z bound (m)") self.setPropertySettings("MaxZposition", condition) # euler angles convention eulerConventions = [ "ZXZ", "XYX", "YZY", "ZYZ", "XZX", "YXY", "XYZ", "YZX", "ZXY", "XZY", "ZYX", "YXZ" ] self.declareProperty( name="EulerConvention", defaultValue="YZX", validator=StringListValidator(eulerConventions), doc= "Euler angles convention used when calculating and displaying angles," "eg XYZ corresponding to alpha beta gamma.") # alpha rotation self.declareProperty(name="AlphaRotation", defaultValue=False, doc="Refine rotation around first axis, alpha") condition = EnabledWhenProperty("AlphaRotation", PropertyCriterion.IsNotDefault) self.declareProperty(name="MinAlphaRotation", defaultValue=-10.0, validator=FloatBoundedValidator(-90, 90), doc="Minimum relative alpha rotation (deg)") self.setPropertySettings("MinAlphaRotation", condition) self.declareProperty(name="MaxAlphaRotation", defaultValue=10.0, validator=FloatBoundedValidator(-90, 90), doc="Maximum relative alpha rotation (deg)") self.setPropertySettings("MaxAlphaRotation", condition) # beta rotation self.declareProperty(name="BetaRotation", defaultValue=False, doc="Refine rotation around seconds axis, beta") condition = EnabledWhenProperty("BetaRotation", PropertyCriterion.IsNotDefault) self.declareProperty(name="MinBetaRotation", defaultValue=-10.0, validator=FloatBoundedValidator(-90, 90), doc="Minimum relative beta rotation (deg)") self.setPropertySettings("MinBetaRotation", condition) self.declareProperty(name="MaxBetaRotation", defaultValue=10.0, validator=FloatBoundedValidator(-90, 90), doc="Maximum relative beta rotation (deg)") self.setPropertySettings("MaxBetaRotation", condition) # gamma rotation self.declareProperty(name="GammaRotation", defaultValue=False, doc="Refine rotation around third axis, gamma") condition = EnabledWhenProperty("GammaRotation", PropertyCriterion.IsNotDefault) self.declareProperty(name="MinGammaRotation", defaultValue=-10.0, validator=FloatBoundedValidator(-90, 90), doc="Minimum relative gamma rotation (deg)") self.setPropertySettings("MinGammaRotation", condition) self.declareProperty(name="MaxGammaRotation", defaultValue=10.0, validator=FloatBoundedValidator(-90, 90), doc="Maximum relative gamma rotation (deg)") self.setPropertySettings("MaxGammaRotation", condition) # Translation self.setPropertyGroup("Xposition", "Translation") self.setPropertyGroup("MinXposition", "Translation") self.setPropertyGroup("MaxXposition", "Translation") self.setPropertyGroup("Yposition", "Translation") self.setPropertyGroup("MinYposition", "Translation") self.setPropertyGroup("MaxYposition", "Translation") self.setPropertyGroup("Zposition", "Translation") self.setPropertyGroup("MinZposition", "Translation") self.setPropertyGroup("MaxZposition", "Translation") # Rotation self.setPropertyGroup("EulerConvention", "Rotation") self.setPropertyGroup("AlphaRotation", "Rotation") self.setPropertyGroup("MinAlphaRotation", "Rotation") self.setPropertyGroup("MaxAlphaRotation", "Rotation") self.setPropertyGroup("BetaRotation", "Rotation") self.setPropertyGroup("MinBetaRotation", "Rotation") self.setPropertyGroup("MaxBetaRotation", "Rotation") self.setPropertyGroup("GammaRotation", "Rotation") self.setPropertyGroup("MinGammaRotation", "Rotation") self.setPropertyGroup("MaxGammaRotation", "Rotation")
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']) # Cropping self.declareProperty('MomentumMin', Property.EMPTY_DBL, doc="Minimum value in momentum.", validator=FloatMandatoryValidator()) self.declareProperty('MomentumMax', Property.EMPTY_DBL, doc="Maximum value in momentum.", validator=FloatMandatoryValidator()) # Grouping self.declareProperty(FileProperty(name="GroupingFile",defaultValue="",action=FileAction.OptionalLoad, extensions=[".xml",".map"]), "A file that consists of lists of spectra numbers to group. See :ref:`GroupDetectors <algm-GroupDetectors>`") # Corrections self.declareProperty('NormaliseByCurrent', True, "Normalise the Solid Angle workspace by the proton charge.") 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>`") # Anvred self.declareProperty('SphericalAbsorptionCorrection', False, "Apply Spherical Absorption correction using :ref:`AnvredCorrection <algm-AnvredCorrection>`") condition = VisibleWhenProperty("SphericalAbsorptionCorrection", PropertyCriterion.IsNotDefault) self.copyProperties('AnvredCorrection', ['LinearScatteringCoef','LinearAbsorptionCoef','Radius']) self.setPropertySettings("LinearScatteringCoef", condition) self.setPropertySettings("LinearAbsorptionCoef", condition) self.setPropertySettings("Radius", condition) # Output self.declareProperty(WorkspaceProperty("SolidAngleOutputWorkspace", "", optional=PropertyMode.Mandatory, direction=Direction.Output), "Output Workspace for Solid Angle") self.declareProperty(WorkspaceProperty("FluxOutputWorkspace", "", optional=PropertyMode.Mandatory, direction=Direction.Output), "Output Workspace for Flux") # Background self.setPropertyGroup("Background","Background") self.setPropertyGroup("BackgroundScale","Background") # Corrections self.setPropertyGroup("NormaliseByCurrent","Corrections") self.setPropertyGroup("LoadInstrument","Corrections") self.setPropertyGroup("DetCal","Corrections") self.setPropertyGroup("MaskFile","Corrections") self.setPropertyGroup("SphericalAbsorptionCorrection","Corrections") self.setPropertyGroup("LinearScatteringCoef","Corrections") self.setPropertyGroup("LinearAbsorptionCoef","Corrections") self.setPropertyGroup("Radius","Corrections")
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): self.declareProperty(MultipleFileProperty("Filenames", action=FileAction.OptionalLoad), doc="The file names with a single YIG scan.") self.declareProperty(MatrixWorkspaceProperty('InputWorkspace', '', direction=Direction.Input, optional=PropertyMode.Optional), doc='The name of the workspace containing the entire YIG scan.') default_d7_yig_file = os.path.join(config.getInstrumentDirectory(), 'D7_YIG_peaks.xml') self.declareProperty(FileProperty('YIGPeaksFile', default_d7_yig_file, action=FileAction.Load, extensions=['.xml']), doc='The file name with all YIG peaks in d-spacing.') self.declareProperty(name="ApproximateWavelength", defaultValue=3.1, validator=FloatBoundedValidator(lower=0), direction=Direction.Input, doc="The initial guess for the neutrons' wavelength") self.declareProperty(name="MinimalDistanceBetweenPeaks", defaultValue=3.0, validator=FloatBoundedValidator(lower=0), direction=Direction.Input, doc="The minimal allowable distance between two YIG peaks (in degrees 2theta).") self.declareProperty(name="BankOffsets", defaultValue=[3.0, 3.0, 0.0], direction=Direction.Input, doc="List of values of offset for each bank (in degrees).") self.declareProperty(name="BraggPeakWidth", defaultValue=2.0, validator=FloatBoundedValidator(lower=0), direction=Direction.Input, doc="An initial guess for the width of YIG Bragg peaks used for fitting (in degrees).") self.declareProperty(name="MaskedBinsRange", defaultValue=[-35.0, 15.0], direction=Direction.Input, doc="The lower and upper bound for the masked region around the direct beam (in degrees).") self.declareProperty(FileProperty(name='CalibrationOutputFile', action=FileAction.OptionalSave, extensions=['xml'], defaultValue=''), doc="The output YIG calibration Instrument Parameter File.") self.declareProperty(name="ClearCache", defaultValue=True, direction=Direction.Input, doc="Whether to clear the intermediate fitting results.") self.declareProperty(ITableWorkspaceProperty(name='FitOutputWorkspace', defaultValue='', direction=Direction.Output, optional=PropertyMode.Optional), doc="The table workspace name that will be used to store all of the calibration parameters.") self.declareProperty(name="FittingMethod", defaultValue="None", validator=StringListValidator(["None", "Individual", "Global"]), direction=Direction.Input, doc="Option to provide the initial guesses or perform fits for Bragg peaks either individually or globally.")
def PyInit(self): self.declareProperty(MultipleFileProperty('Run', extensions=['nxs']), doc='Run number(s) of sample run(s).') self.declareProperty( MultipleFileProperty('BackgroundRun', action=FileAction.OptionalLoad, extensions=['nxs']), doc='Run number(s) of background (empty can) run(s).') self.declareProperty( MultipleFileProperty('CalibrationRun', action=FileAction.OptionalLoad, extensions=['nxs']), doc='Run number(s) of vanadium calibration run(s).') self.declareProperty( MultipleFileProperty('CalibrationBackgroundRun', action=FileAction.OptionalLoad, extensions=['nxs']), doc= 'Run number(s) of background (empty can) run(s) for vanadium run.') self.declareProperty(name='Observable', defaultValue='sample.temperature', doc='Scanning observable, a Sample Log entry\n') self.declareProperty(name='SortXAxis', defaultValue=False, doc='Whether or not to sort the x-axis\n') self.declareProperty(name='BackgroundScalingFactor', defaultValue=1., validator=FloatBoundedValidator(lower=0), doc='Scaling factor for background subtraction') self.declareProperty( name='CalibrationBackgroundScalingFactor', defaultValue=1., validator=FloatBoundedValidator(lower=0), doc= 'Scaling factor for background subtraction for vanadium calibration' ) self.declareProperty( name='BackgroundOption', defaultValue='Sum', validator=StringListValidator(['Sum', 'Interpolate']), doc='Whether to sum or interpolate the background runs.') self.declareProperty( name='CalibrationOption', defaultValue='Sum', validator=StringListValidator(['Sum', 'Interpolate']), doc='Whether to sum or interpolate the calibration runs.') self.declareProperty( name='CalibrationBackgroundOption', defaultValue='Sum', validator=StringListValidator(['Sum', 'Interpolate']), doc= 'Whether to sum or interpolate the background run for calibration runs.' ) self.declareProperty( FileProperty('MapFile', '', action=FileAction.OptionalLoad, extensions=['map', 'xml']), doc='Filename of the detector grouping map file to use. \n' 'By default all the pixels will be summed per each tube. \n' 'Use .map or .xml file (see GroupDetectors documentation) ' 'only if different range is needed for each tube.') self.declareProperty( name='ManualPSDIntegrationRange', defaultValue=[1, 128], doc='Integration range of vertical pixels in each PSD tube. \n' 'By default all the pixels will be summed per each tube. \n' 'Use this option if the same range (other than default) ' 'is needed for all the tubes.') self.declareProperty(name='Analyser', defaultValue='silicon', validator=StringListValidator(['silicon']), doc='Analyser crystal.') self.declareProperty(name='Reflection', defaultValue='111', validator=StringListValidator(['111', '311']), doc='Analyser reflection.') self.declareProperty(WorkspaceGroupProperty( 'OutputWorkspace', '', direction=Direction.Output), doc='Output workspace group') self.declareProperty(name='SpectrumAxis', defaultValue='SpectrumNumber', validator=StringListValidator( ['SpectrumNumber', '2Theta', 'Q', 'Q2']), doc='The spectrum axis conversion target.')
def PyInit(self): group = "Input" self.declareProperty( FileProperty(name="Filename", defaultValue="", action=FileAction.OptionalLoad, extensions=["_event.nxs", ".nxs.h5"]), "Event file") self.copyProperties('AlignAndFocusPowderFromFiles', 'MaxChunkSize') self.declareProperty("FilterBadPulses", 95., doc="Filter out events measured while proton " + "charge is more than 5% below average") self.declareProperty(MatrixWorkspaceProperty( "InputWorkspace", "", direction=Direction.Input, optional=PropertyMode.Optional), doc="Handle to reduced workspace") self.setPropertyGroup("Filename", group) self.setPropertyGroup("MaxChunkSize", group) self.setPropertyGroup("FilterBadPulses", group) self.setPropertyGroup("InputWorkspace", group) group = "Output" self.declareProperty(MatrixWorkspaceProperty( "OutputWorkspace", "", direction=Direction.Output), doc="Handle to reduced workspace") self.copyProperties('AlignAndFocusPowderFromFiles', 'CacheDir') self.declareProperty( FileProperty(name="PDFgetNFile", defaultValue="", action=FileAction.Save, extensions=[".getn"]), "Output filename") self.setPropertyGroup("OutputWorkspace", group) self.setPropertyGroup("PDFgetNFile", group) self.declareProperty( FileProperty(name="CalibrationFile", defaultValue="", action=FileAction.OptionalLoad, extensions=[".h5", ".hd5", ".hdf", ".cal"])) self.declareProperty( FileProperty(name="CharacterizationRunsFile", defaultValue="", action=FileAction.OptionalLoad, extensions=["txt"]), "File with characterization runs denoted") self.copyProperties('AlignAndFocusPowderFromFiles', [ 'FrequencyLogNames', 'WaveLengthLogNames', 'RemovePromptPulseWidth', 'CropWavelengthMin', 'CropWavelengthMax' ]) self.declareProperty( FloatArrayProperty("Binning", values=[0., 0., 0.], direction=Direction.Input), "Positive is linear bins, negative is logorithmic") self.declareProperty( "ResampleX", 0, "Number of bins in x-axis. Non-zero value overrides \"Params\" property. " + "Negative value means logorithmic binning.")
def PyInit(self): # files to reduce self.declareProperty( MultipleFileProperty(name="Filename", extensions=["_event.nxs", ".nxs.h5", ".nxs"]), "Files to combine in reduction") # Filter by time self.copyProperties( 'LoadEventNexus', ['FilterByTofMin', 'FilterByTofMax', 'FilterByTimeStop']) # UBMatrix self.declareProperty( FileProperty(name="UBMatrix", defaultValue="", action=FileAction.OptionalLoad, 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>`" ) self.declareProperty( WorkspaceProperty("OutputWorkspace", "", optional=PropertyMode.Mandatory, direction=Direction.Output), "Output Workspace") # Convert Settings self.copyProperties('ConvertToMD', [ 'Uproj', 'Vproj', 'Wproj', 'MinValues', 'MaxValues', 'SplitInto', 'SplitThreshold', 'MaxRecursionDepth', 'OverwriteExisting' ]) self.setPropertyGroup('FilterByTofMin', 'Loading') self.setPropertyGroup('FilterByTofMax', 'Loading') self.setPropertyGroup('FilterByTimeStop', 'Loading') # 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") # ConvertToMD self.setPropertyGroup('Uproj', 'ConvertToMD') self.setPropertyGroup('Vproj', 'ConvertToMD') self.setPropertyGroup('Wproj', 'ConvertToMD') self.setPropertyGroup('MinValues', 'ConvertToMD') self.setPropertyGroup('MaxValues', 'ConvertToMD') self.setPropertyGroup('SplitInto', 'ConvertToMD') self.setPropertyGroup('SplitThreshold', 'ConvertToMD') self.setPropertyGroup('MaxRecursionDepth', 'ConvertToMD')
def test_constructor_with_name_and_default_and_action(self): prop = FileProperty("LoadProperty", "", FileAction.Load) self.assertNotEquals("", prop.isValid()) self.assertEquals(Direction.Input, prop.direction)
def PyInit(self): self.declareProperty(FileProperty(name="InputFile", defaultValue="", action=FileAction.Load, extensions=["hdf"])) self.declareProperty(WorkspaceProperty(name="OutputWorkspace", defaultValue="", direction=Direction.Output))