Exemplo n.º 1
0
    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')
Exemplo n.º 2
0
    def PyInit(self):

        #
        # Reference and input data
        self.declareProperty(ITableWorkspaceProperty(
            "PeakCentersTofTable",
            "",
            optional=PropertyMode.Mandatory,
            direction=Direction.Input),
                             doc="Table of found peak centers, in TOF units")

        self.declareProperty(
            FloatArrayProperty("PeakPositions",
                               values=[],
                               direction=Direction.Input),
            doc=
            "Comma separated list of reference peak center d-spacings, sorted by increasing value."
        )

        properties = ["PeakCentersTofTable", "PeakPositions"]
        [
            self.setPropertyGroup(name, 'Reference and Input Data')
            for name in properties
        ]

        #
        # Output Tables
        self.declareProperty(
            "AdjustmentsTable",
            "",
            direction=Direction.Input,
            doc=
            "Name of output table containing optimized locations and orientations for each component"
        )

        self.declareProperty(
            "DisplacementsTable",
            "",
            direction=Direction.Input,
            doc=
            "Name of output table containing changes in position and euler angles for each bank component"
        )

        properties = ["AdjustmentsTable", "DisplacementsTable"]
        [self.setPropertyGroup(name, 'Output Tables') for name in properties]

        #
        # Selection of the instrument and mask
        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("InputWorkspace",
                              "",
                              validator=InstrumentValidator(),
                              optional=PropertyMode.Optional,
                              direction=Direction.Input),
            doc="Workspace containing the instrument to be calibrated")

        self.declareProperty(
            WorkspaceProperty("OutputWorkspace",
                              "",
                              optional=PropertyMode.Mandatory,
                              direction=Direction.Output),
            doc='Workspace containing the calibrated instrument')

        properties = [
            'MaskWorkspace', "InstrumentFilename", "InputWorkspace",
            "OutputWorkspace"
        ]
        [
            self.setPropertyGroup(name, 'Instrument Options')
            for name in properties
        ]

        #
        # Components
        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.")

        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.")

        self.declareProperty(
            StringArrayProperty("ComponentList", direction=Direction.Input),
            doc="Comma separated list on instrument components to refine.")

        properties = [
            "FitSourcePosition", "FitSamplePosition", "ComponentList"
        ]
        [
            self.setPropertyGroup(name, 'Declaration of Components')
            for name in properties
        ]

        #
        # Translation Properties
        # X position
        self.declareProperty(
            name="Xposition",
            defaultValue=False,
            doc="Refine Xposition of source and/or sample and/or components")
        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)

        self.declareProperty(
            name="Yposition",
            defaultValue=False,
            doc="Refine Yposition of source and/or sample and/or components")
        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 of source and/or sample and/or components")
        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)

        properties = [
            "Xposition", "MinXposition", "MaxXposition", "Yposition",
            "MinYposition", "MaxYposition", "Zposition", "MinZposition",
            "MaxZposition"
        ]
        [self.setPropertyGroup(name, "Translation") for name in properties]

        #
        # Rotation Properties
        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, for the components")
        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, for the components"
        )
        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, for the components")
        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)

        properties = [
            "EulerConvention", "AlphaRotation", "MinAlphaRotation",
            "MaxAlphaRotation", "BetaRotation", "MinBetaRotation",
            "MaxBetaRotation", "GammaRotation", "MinGammaRotation",
            "MaxGammaRotation"
        ]
        [self.setPropertyGroup(name, "Rotation") for name in properties]

        #
        # Minimization Properties
        self.declareProperty(name='Minimizer',
                             defaultValue='L-BFGS-B',
                             direction=Direction.Input,
                             validator=StringListValidator(
                                 ['L-BFGS-B', 'differential_evolution']),
                             doc='Minimizer to Use')
        self.declareProperty(
            name='MaxIterations',
            defaultValue=100,
            direction=Direction.Input,
            doc=
            'Maximum number of iterations for minimizer differential_evolution'
        )

        properties = ['Minimizer', 'MaxIterations']
        [self.setPropertyGroup(name, "Minimization") for name in properties]
Exemplo n.º 3
0
    def PyInit(self):
        """Initialize the algorithm's input and output properties."""
        PROPGROUP_REBINNING = 'Rebinning for SofQW'
        inputWorkspaceValidator = CompositeValidator()
        inputWorkspaceValidator.add(InstrumentValidator())
        inputWorkspaceValidator.add(WorkspaceUnitValidator('TOF'))

        # Properties.
        self.declareProperty(MatrixWorkspaceProperty(
            name=common.PROP_INPUT_WS,
            defaultValue='',
            validator=inputWorkspaceValidator,
            direction=Direction.Input),
                             doc='Input workspace.')
        self.declareProperty(WorkspaceProperty(name=common.PROP_OUTPUT_WS,
                                               defaultValue='',
                                               direction=Direction.Output),
                             doc='The output of the algorithm.')
        self.declareProperty(name=common.PROP_CLEANUP_MODE,
                             defaultValue=common.CLEANUP_ON,
                             validator=StringListValidator(
                                 [common.CLEANUP_ON, common.CLEANUP_OFF]),
                             direction=Direction.Input,
                             doc='What to do with intermediate workspaces.')
        self.declareProperty(
            name=common.PROP_SUBALG_LOGGING,
            defaultValue=common.SUBALG_LOGGING_OFF,
            validator=StringListValidator(
                [common.SUBALG_LOGGING_OFF, common.SUBALG_LOGGING_ON]),
            direction=Direction.Input,
            doc='Enable or disable subalgorithms to ' + 'print in the logs.')
        self.declareProperty(MatrixWorkspaceProperty(
            name=common.PROP_VANA_WS,
            defaultValue='',
            validator=inputWorkspaceValidator,
            direction=Direction.Input,
            optional=PropertyMode.Optional),
                             doc='Reduced vanadium workspace.')
        self.declareProperty(
            name=common.PROP_ABSOLUTE_UNITS,
            defaultValue=common.ABSOLUTE_UNITS_OFF,
            validator=StringListValidator(
                [common.ABSOLUTE_UNITS_OFF, common.ABSOLUTE_UNITS_ON]),
            direction=Direction.Input,
            doc='Enable or disable normalisation to absolute units.')
        self.declareProperty(
            MatrixWorkspaceProperty(name=common.PROP_DIAGNOSTICS_WS,
                                    defaultValue='',
                                    direction=Direction.Input,
                                    optional=PropertyMode.Optional),
            doc='Detector diagnostics workspace obtained from another ' +
            'reduction run.')
        self.declareProperty(
            FloatArrayProperty(name=common.PROP_REBINNING_PARAMS_W),
            doc='Manual energy rebinning parameters.')
        self.setPropertyGroup(common.PROP_REBINNING_PARAMS_W,
                              PROPGROUP_REBINNING)
        self.declareProperty(
            FloatArrayProperty(name=common.PROP_BINNING_PARAMS_Q),
            doc='Manual q rebinning parameters.')
        self.setPropertyGroup(common.PROP_BINNING_PARAMS_Q,
                              PROPGROUP_REBINNING)
        self.declareProperty(
            name=common.PROP_TRANSPOSE_SAMPLE_OUTPUT,
            defaultValue=common.TRANSPOSING_ON,
            validator=StringListValidator(
                [common.TRANSPOSING_ON, common.TRANSPOSING_OFF]),
            direction=Direction.Input,
            doc='Enable or disable ' + common.PROP_OUTPUT_WS + ' transposing.')
        self.declareProperty(
            WorkspaceProperty(name=common.PROP_OUTPUT_THETA_W_WS,
                              defaultValue='',
                              direction=Direction.Output,
                              optional=PropertyMode.Optional),
            doc='Output workspace for reduced S(theta, DeltaE).')
        self.setPropertyGroup(common.PROP_OUTPUT_THETA_W_WS,
                              common.PROPGROUP_OPTIONAL_OUTPUT)
Exemplo n.º 4
0
    def PyInit(self):
        self.declareProperty(
            StringArrayProperty("InputWorkspace",
                                direction=Direction.Input,
                                validator=ADSValidator()),
            doc="Input MDEvent workspace to use for integration")

        self.declareProperty(
            StringArrayProperty("PeaksWorkspace",
                                direction=Direction.Input,
                                validator=ADSValidator()),
            doc="Peaks workspace containing peaks to integrate")

        positive_val = FloatBoundedValidator(lower=0.0)
        self.declareProperty(
            "PeakRadius",
            defaultValue=1.0,
            validator=positive_val,
            doc="Fixed radius around each peak position in which to integrate"
            " (same units as input workspace) ")

        self.declareProperty(
            "BackgroundInnerRadius",
            defaultValue=0.0,
            validator=positive_val,
            doc="Inner radius used to evaluate the peak background")
        self.declareProperty(
            "BackgroundOuterRadius",
            defaultValue=0.0,
            validator=positive_val,
            doc="Outer radius used to evaluate the peak background")

        self.declareProperty(
            "ApplyLorentz",
            defaultValue=True,
            doc=
            "Whether the Lorentz correction should be applied to the integrated peaks"
        )

        self.declareProperty(
            "RemoveZeroIntensity",
            defaultValue=True,
            doc="If to remove peaks with 0 or less intensity from the output")

        formats = StringListValidator()
        formats.addAllowedValue("SHELX")
        formats.addAllowedValue("Fullprof")
        self.declareProperty(
            "OutputFormat",
            defaultValue="SHELX",
            validator=formats,
            doc="Save direction cosines in HKL, or the fullprof format")

        self.declareProperty(
            FileProperty(name="OutputFile",
                         defaultValue="",
                         direction=Direction.Input,
                         action=FileAction.OptionalSave),
            doc="Filepath to save the integrated peaks workspace in HKL format"
        )

        self.declareProperty(
            WorkspaceProperty("OutputWorkspace",
                              defaultValue="",
                              direction=Direction.Output,
                              optional=PropertyMode.Mandatory),
            doc=
            "Output peaks workspace (copy of input with updated peak intensities)"
        )
Exemplo n.º 5
0
    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."
        )

        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."
        )

        self.declareProperty(
            name="QuantumOrderEventsNumber",
            defaultValue='1',
            validator=StringListValidator(['1', '2', '3', '4']),
            doc="Number of quantum order effects included in the calculation "
            "(1 -> FUNDAMENTALS, 2-> first overtone + FUNDAMENTALS + "
            "2nd order combinations, 3-> FUNDAMENTALS + first overtone + second overtone + 2nd "
            "order combinations + 3rd order combinations etc...)")

        self.declareProperty(WorkspaceProperty("OutputWorkspace", '',
                                               Direction.Output),
                             doc="Name to give the output workspace.")
Exemplo n.º 6
0
    def PyInit(self):
        """Initialize the algorithm's input and output properties."""
        PROPGROUP_BEAM_STOP_DIAGNOSTICS = 'Beam Stop Diagnostics'
        PROPGROUP_BKG_DIAGNOSTICS = 'Background Diagnostics'
        PROPGROUP_PEAK_DIAGNOSTICS = 'Elastic Peak Diagnostics'
        PROPGROUP_USER_MASK = 'Additional Masking'
        greaterThanUnityFloat = FloatBoundedValidator(lower=1)
        inputWorkspaceValidator = CompositeValidator()
        inputWorkspaceValidator.add(InstrumentValidator())
        inputWorkspaceValidator.add(WorkspaceUnitValidator('TOF'))
        positiveFloat = FloatBoundedValidator(lower=0)
        positiveIntArray = IntArrayBoundedValidator()
        positiveIntArray.setLower(0)
        scalingFactor = FloatBoundedValidator(lower=0, upper=1)

        # Properties.
        self.declareProperty(MatrixWorkspaceProperty(
            name=common.PROP_INPUT_WS,
            defaultValue='',
            validator=inputWorkspaceValidator,
            direction=Direction.Input),
                             doc='Raw input workspace.')
        self.declareProperty(WorkspaceProperty(name=common.PROP_OUTPUT_WS,
                                               defaultValue='',
                                               direction=Direction.Output),
                             doc='A diagnostics mask workspace.')
        self.declareProperty(name=common.PROP_CLEANUP_MODE,
                             defaultValue=common.CLEANUP_ON,
                             validator=StringListValidator(
                                 [common.CLEANUP_ON, common.CLEANUP_OFF]),
                             direction=Direction.Input,
                             doc='What to do with intermediate workspaces.')
        self.declareProperty(
            name=common.PROP_SUBALG_LOGGING,
            defaultValue=common.SUBALG_LOGGING_OFF,
            validator=StringListValidator(
                [common.SUBALG_LOGGING_OFF, common.SUBALG_LOGGING_ON]),
            direction=Direction.Input,
            doc='Enable or disable subalgorithms to ' + 'print in the logs.')
        self.declareProperty(
            ITableWorkspaceProperty(name=common.PROP_EPP_WS,
                                    defaultValue='',
                                    direction=Direction.Input,
                                    optional=PropertyMode.Optional),
            doc='Table workspace containing results from the FindEPP algorithm.'
        )
        self.declareProperty(name=common.PROP_ELASTIC_PEAK_DIAGNOSTICS,
                             defaultValue=common.ELASTIC_PEAK_DIAGNOSTICS_AUTO,
                             validator=StringListValidator([
                                 common.ELASTIC_PEAK_DIAGNOSTICS_AUTO,
                                 common.ELASTIC_PEAK_DIAGNOSTICS_ON,
                                 common.ELASTIC_PEAK_DIAGNOSTICS_OFF
                             ]),
                             direction=Direction.Input,
                             doc='Enable or disable elastic peak diagnostics.')
        self.setPropertyGroup(common.PROP_ELASTIC_PEAK_DIAGNOSTICS,
                              PROPGROUP_PEAK_DIAGNOSTICS)
        self.declareProperty(
            name=common.PROP_ELASTIC_PEAK_SIGMA_MULTIPLIER,
            defaultValue=3.0,
            validator=positiveFloat,
            direction=Direction.Input,
            doc="Integration width of the elastic peak in multiples " +
            " of 'Sigma' in the EPP table.")
        self.setPropertyGroup(common.PROP_ELASTIC_PEAK_SIGMA_MULTIPLIER,
                              PROPGROUP_PEAK_DIAGNOSTICS)
        self.declareProperty(name=common.PROP_PEAK_DIAGNOSTICS_LOW_THRESHOLD,
                             defaultValue=0.1,
                             validator=scalingFactor,
                             direction=Direction.Input,
                             doc='Multiplier for lower acceptance limit ' +
                             'used in elastic peak diagnostics.')
        self.setPropertyGroup(common.PROP_PEAK_DIAGNOSTICS_LOW_THRESHOLD,
                              PROPGROUP_PEAK_DIAGNOSTICS)
        self.declareProperty(name=common.PROP_PEAK_DIAGNOSTICS_HIGH_THRESHOLD,
                             defaultValue=3.0,
                             validator=greaterThanUnityFloat,
                             direction=Direction.Input,
                             doc='Multiplier for higher acceptance limit ' +
                             'used in elastic peak diagnostics.')
        self.setPropertyGroup(common.PROP_PEAK_DIAGNOSTICS_HIGH_THRESHOLD,
                              PROPGROUP_PEAK_DIAGNOSTICS)
        self.declareProperty(
            name=common.PROP_PEAK_DIAGNOSTICS_SIGNIFICANCE_TEST,
            defaultValue=3.3,
            validator=positiveFloat,
            direction=Direction.Input,
            doc='Error bar multiplier for significance ' +
            'test in the elastic peak diagnostics.')
        self.setPropertyGroup(common.PROP_PEAK_DIAGNOSTICS_SIGNIFICANCE_TEST,
                              PROPGROUP_PEAK_DIAGNOSTICS)
        self.declareProperty(name=common.PROP_BKG_DIAGNOSTICS,
                             defaultValue=common.BKG_DIAGNOSTICS_AUTO,
                             validator=StringListValidator([
                                 common.BKG_DIAGNOSTICS_AUTO,
                                 common.BKG_DIAGNOSTICS_ON,
                                 common.BKG_DIAGNOSTICS_OFF
                             ]),
                             direction=Direction.Input,
                             doc='Control the background diagnostics.')
        self.setPropertyGroup(common.PROP_BKG_DIAGNOSTICS,
                              PROPGROUP_BKG_DIAGNOSTICS)
        self.declareProperty(
            name=common.PROP_BKG_SIGMA_MULTIPLIER,
            defaultValue=10.0,
            validator=positiveFloat,
            direction=Direction.Input,
            doc=
            "Width of the range excluded from background integration around " +
            "the elastic peaks in multiplies of 'Sigma' in the EPP table")
        self.setPropertyGroup(common.PROP_BKG_SIGMA_MULTIPLIER,
                              PROPGROUP_BKG_DIAGNOSTICS)
        self.declareProperty(name=common.PROP_BKG_DIAGNOSTICS_LOW_THRESHOLD,
                             defaultValue=0.1,
                             validator=scalingFactor,
                             direction=Direction.Input,
                             doc='Multiplier for lower acceptance limit ' +
                             'used in noisy background diagnostics.')
        self.setPropertyGroup(common.PROP_BKG_DIAGNOSTICS_LOW_THRESHOLD,
                              PROPGROUP_BKG_DIAGNOSTICS)
        self.declareProperty(name=common.PROP_BKG_DIAGNOSTICS_HIGH_THRESHOLD,
                             defaultValue=3.3,
                             validator=greaterThanUnityFloat,
                             direction=Direction.Input,
                             doc='Multiplier for higher acceptance limit ' +
                             'used in noisy background diagnostics.')
        self.setPropertyGroup(common.PROP_BKG_DIAGNOSTICS_HIGH_THRESHOLD,
                              PROPGROUP_BKG_DIAGNOSTICS)
        self.declareProperty(
            name=common.PROP_BKG_DIAGNOSTICS_SIGNIFICANCE_TEST,
            defaultValue=3.3,
            validator=positiveFloat,
            direction=Direction.Input,
            doc='Error bar multiplier for significance ' +
            'test in the noisy background diagnostics.')
        self.setPropertyGroup(common.PROP_BKG_DIAGNOSTICS_SIGNIFICANCE_TEST,
                              PROPGROUP_BKG_DIAGNOSTICS)
        self.declareProperty(name=common.PROP_BEAM_STOP_DIAGNOSTICS,
                             defaultValue=common.BEAM_STOP_DIAGNOSTICS_AUTO,
                             validator=StringListValidator([
                                 common.BEAM_STOP_DIAGNOSTICS_AUTO,
                                 common.BEAM_STOP_DIAGNOSTICS_ON,
                                 common.BEAM_STOP_DIAGNOSTICS_OFF
                             ]),
                             direction=Direction.Input,
                             doc='Control the beam stop diagnostics.')
        self.setPropertyGroup(common.PROP_BEAM_STOP_DIAGNOSTICS,
                              PROPGROUP_BEAM_STOP_DIAGNOSTICS)
        self.declareProperty(
            name=common.PROP_BEAM_STOP_THRESHOLD,
            defaultValue=0.67,
            validator=scalingFactor,
            direction=Direction.Input,
            doc=
            'Multiplier for the lower acceptance limit for beam stop diagnostics.'
        )
        self.setPropertyGroup(common.PROP_BEAM_STOP_THRESHOLD,
                              PROPGROUP_BEAM_STOP_DIAGNOSTICS)
        self.declareProperty(
            name=common.PROP_DEFAULT_MASK,
            defaultValue=common.DEFAULT_MASK_ON,
            validator=StringListValidator(
                [common.DEFAULT_MASK_ON, common.DEFAULT_MASK_OFF]),
            direction=Direction.Input,
            doc='Enable or disable instrument specific default mask.')
        self.declareProperty(IntArrayProperty(name=common.PROP_USER_MASK,
                                              values='',
                                              validator=positiveIntArray,
                                              direction=Direction.Input),
                             doc='List of spectra to mask.')
        self.setPropertyGroup(common.PROP_USER_MASK, PROPGROUP_USER_MASK)
        self.declareProperty(StringArrayProperty(
            name=common.PROP_USER_MASK_COMPONENTS,
            values='',
            direction=Direction.Input),
                             doc='List of instrument components to mask.')
        self.setPropertyGroup(common.PROP_USER_MASK_COMPONENTS,
                              PROPGROUP_USER_MASK)
        # Rest of the output properties
        self.declareProperty(
            ITableWorkspaceProperty(
                name=common.PROP_OUTPUT_DIAGNOSTICS_REPORT_WS,
                defaultValue='',
                direction=Direction.Output,
                optional=PropertyMode.Optional),
            doc='Output table workspace for detector diagnostics reporting.')
        self.setPropertyGroup(common.PROP_OUTPUT_DIAGNOSTICS_REPORT_WS,
                              common.PROPGROUP_OPTIONAL_OUTPUT)
        self.declareProperty(name=common.PROP_OUTPUT_DIAGNOSTICS_REPORT,
                             defaultValue='',
                             direction=Direction.Output,
                             doc='Diagnostics report as a string.')
        self.setPropertyGroup(common.PROP_OUTPUT_DIAGNOSTICS_REPORT,
                              common.PROPGROUP_OPTIONAL_OUTPUT)
Exemplo n.º 7
0
 def PyInit(self):
     self.declareProperty(
         IMDHistoWorkspaceProperty("InputWorkspace",
                                   "",
                                   optional=PropertyMode.Mandatory,
                                   direction=Direction.Input),
         "Input Workspace")
     self.declareProperty(
         IMDHistoWorkspaceProperty("NormalisationWorkspace",
                                   "",
                                   optional=PropertyMode.Optional,
                                   direction=Direction.Input),
         "Workspace to use for normalisation")
     self.declareProperty(
         WorkspaceProperty("UBWorkspace",
                           "",
                           optional=PropertyMode.Optional,
                           direction=Direction.Input),
         "Workspace containing the UB matrix to use")
     self.declareProperty("Wavelength",
                          1.488,
                          validator=FloatBoundedValidator(0.0),
                          doc="Wavelength to set the workspace")
     self.declareProperty(
         "S1Offset",
         0.,
         doc="Offset to apply (in degrees) to the s1 of the input workspace"
     )
     self.declareProperty('NormaliseBy', 'Monitor',
                          StringListValidator(['None', 'Time', 'Monitor']),
                          "Normalise to monitor, time or None.")
     self.declareProperty('Frame', 'Q_sample',
                          StringListValidator(['Q_sample', 'HKL']),
                          "Selects Q-dimensions of the output workspace")
     self.declareProperty(
         FloatArrayProperty("Uproj", [1, 0, 0],
                            FloatArrayLengthValidator(3),
                            direction=Direction.Input),
         "Defines the first projection vector of the target Q coordinate system in HKL mode"
     )
     self.declareProperty(
         FloatArrayProperty("Vproj", [0, 1, 0],
                            FloatArrayLengthValidator(3),
                            direction=Direction.Input),
         "Defines the second projection vector of the target Q coordinate system in HKL mode"
     )
     self.declareProperty(
         FloatArrayProperty("Wproj", [0, 0, 1],
                            FloatArrayLengthValidator(3),
                            direction=Direction.Input),
         "Defines the third projection vector of the target Q coordinate system in HKL mode"
     )
     self.declareProperty(
         FloatArrayProperty("BinningDim0", [-8.02, 8.02, 401],
                            FloatArrayLengthValidator(3),
                            direction=Direction.Input),
         "Binning parameters for the 0th dimension. Enter it as a"
         "comma-separated list of values with the"
         "format: 'minimum,maximum,number_of_bins'.")
     self.declareProperty(
         FloatArrayProperty("BinningDim1", [-0.82, 0.82, 41],
                            FloatArrayLengthValidator(3),
                            direction=Direction.Input),
         "Binning parameters for the 1st dimension. Enter it as a"
         "comma-separated list of values with the"
         "format: 'minimum,maximum,number_of_bins'.")
     self.declareProperty(
         FloatArrayProperty("BinningDim2", [-8.02, 8.02, 401],
                            FloatArrayLengthValidator(3),
                            direction=Direction.Input),
         "Binning parameters for the 2nd dimension. Enter it as a"
         "comma-separated list of values with the"
         "format: 'minimum,maximum,number_of_bins'.")
     self.declareProperty(
         'KeepTemporaryWorkspaces', False,
         "If True the normalization and data workspaces in addition to the normalized data will be outputted"
     )
     self.declareProperty(
         "ObliquityParallaxCoefficient",
         1.0,
         validator=FloatBoundedValidator(0.0),
         doc=
         "Geometrical correction for shift in vertical beam position due to wide beam."
     )
     self.declareProperty(
         WorkspaceProperty("OutputWorkspace",
                           "",
                           optional=PropertyMode.Mandatory,
                           direction=Direction.Output), "Output Workspace")
Exemplo n.º 8
0
    def PyInit(self):
        """Initialize the algorithm's input and output properties."""
        PROPGROUP_FLAT_BKG = 'Flat Time-Independent Background'
        PROPGROUP_INCIDENT_ENERGY_CALIBRATION = 'Indicent Energy Calibration'
        PROPGROUP_MON_NORMALISATION = 'Neutron Flux Normalisation'
        # Validators.
        mandatoryPositiveInt = CompositeValidator()
        mandatoryPositiveInt.add(IntMandatoryValidator())
        mandatoryPositiveInt.add(IntBoundedValidator(lower=0))
        positiveFloat = FloatBoundedValidator(lower=0)
        positiveInt = IntBoundedValidator(lower=0)
        inputWorkspaceValidator = CompositeValidator()
        inputWorkspaceValidator.add(InstrumentValidator())
        inputWorkspaceValidator.add(WorkspaceUnitValidator('TOF'))

        # Properties.
        self.declareProperty(
            MultipleFileProperty(name=common.PROP_INPUT_FILE,
                                 action=FileAction.OptionalLoad,
                                 extensions=['nxs']),
            doc='An input run number (or a list thereof) or a filename.')
        self.declareProperty(MatrixWorkspaceProperty(
            name=common.PROP_INPUT_WS,
            defaultValue='',
            validator=inputWorkspaceValidator,
            optional=PropertyMode.Optional,
            direction=Direction.Input),
                             doc='Input workspace if no run is given.')
        self.declareProperty(
            WorkspaceProperty(name=common.PROP_OUTPUT_WS,
                              defaultValue='',
                              direction=Direction.Output),
            doc='A flux normalized and background subtracted workspace.')
        self.declareProperty(name=common.PROP_CLEANUP_MODE,
                             defaultValue=utils.Cleanup.ON,
                             validator=StringListValidator(
                                 [utils.Cleanup.ON, utils.Cleanup.OFF]),
                             direction=Direction.Input,
                             doc='What to do with intermediate workspaces.')
        self.declareProperty(
            name=common.PROP_SUBALG_LOGGING,
            defaultValue=common.SUBALG_LOGGING_OFF,
            validator=StringListValidator(
                [common.SUBALG_LOGGING_OFF, common.SUBALG_LOGGING_ON]),
            direction=Direction.Input,
            doc='Enable or disable subalgorithms to ' + 'print in the logs.')
        self.declareProperty(
            name=common.PROP_EPP_METHOD,
            defaultValue=common.EPP_METHOD_AUTO,
            validator=StringListValidator([
                common.EPP_METHOD_AUTO, common.EPP_METHOD_FIT,
                common.EPP_METHOD_CALCULATE
            ]),
            direction=Direction.Input,
            doc=
            'Method to create the EPP table for detectors (monitor is awlays fitted).'
        )
        self.declareProperty(name=common.PROP_EPP_SIGMA,
                             defaultValue=Property.EMPTY_DBL,
                             validator=positiveFloat,
                             direction=Direction.Input,
                             doc='Nominal sigma for the EPP table when ' +
                             common.PROP_EPP_METHOD + ' is set to ' +
                             common.EPP_METHOD_CALCULATE +
                             ' (default: 10 times the first bin width).')
        self.declareProperty(name=common.PROP_ELASTIC_CHANNEL_MODE,
                             defaultValue=common.ELASTIC_CHANNEL_AUTO,
                             validator=StringListValidator([
                                 common.ELASTIC_CHANNEL_AUTO,
                                 common.ELASTIC_CHANNEL_SAMPLE_LOG,
                                 common.ELASTIC_CHANNEL_FIT
                             ]),
                             direction=Direction.Input,
                             doc='How to acquire the nominal elastic channel.')
        self.declareProperty(
            MatrixWorkspaceProperty(name=common.PROP_ELASTIC_CHANNEL_WS,
                                    defaultValue='',
                                    direction=Direction.Input,
                                    optional=PropertyMode.Optional),
            doc=
            'A single value workspace containing the nominal elastic channel index. Overrides '
            + common.PROP_ELASTIC_CHANNEL_MODE + '.')
        self.declareProperty(
            name=common.PROP_MON_INDEX,
            defaultValue=Property.EMPTY_INT,
            validator=positiveInt,
            direction=Direction.Input,
            doc=
            'Index of the incident monitor, if not specified in instrument parameters.'
        )
        self.declareProperty(
            name=common.PROP_INCIDENT_ENERGY_CALIBRATION,
            defaultValue=common.INCIDENT_ENERGY_CALIBRATION_AUTO,
            validator=StringListValidator([
                common.INCIDENT_ENERGY_CALIBRATION_AUTO,
                common.INCIDENT_ENERGY_CALIBRATION_ON,
                common.INCIDENT_ENERGY_CALIBRATION_OFF
            ]),
            direction=Direction.Input,
            doc='Control the incident energy calibration.')
        self.setPropertyGroup(common.PROP_INCIDENT_ENERGY_CALIBRATION,
                              PROPGROUP_INCIDENT_ENERGY_CALIBRATION)
        self.declareProperty(
            MatrixWorkspaceProperty(name=common.PROP_INCIDENT_ENERGY_WS,
                                    defaultValue='',
                                    direction=Direction.Input,
                                    optional=PropertyMode.Optional),
            doc='A single-valued workspace holding a previously determined ' +
            'incident energy.')
        self.setPropertyGroup(common.PROP_INCIDENT_ENERGY_WS,
                              PROPGROUP_INCIDENT_ENERGY_CALIBRATION)
        self.declareProperty(name=common.PROP_FLAT_BKG,
                             defaultValue=common.BKG_AUTO,
                             validator=StringListValidator([
                                 common.BKG_AUTO, common.BKG_ON, common.BKG_OFF
                             ]),
                             direction=Direction.Input,
                             doc='Control flat background subtraction.')
        self.setPropertyGroup(common.PROP_FLAT_BKG, PROPGROUP_FLAT_BKG)
        self.declareProperty(name=common.PROP_FLAT_BKG_SCALING,
                             defaultValue=1.0,
                             validator=positiveFloat,
                             direction=Direction.Input,
                             doc='Flat background multiplication factor.')
        self.setPropertyGroup(common.PROP_FLAT_BKG_SCALING, PROPGROUP_FLAT_BKG)
        self.declareProperty(
            name=common.PROP_FLAT_BKG_WINDOW,
            defaultValue=30,
            validator=mandatoryPositiveInt,
            direction=Direction.Input,
            doc='Running average window width (in bins) for flat background.')
        self.setPropertyGroup(common.PROP_FLAT_BKG_WINDOW, PROPGROUP_FLAT_BKG)
        self.declareProperty(
            MatrixWorkspaceProperty(name=common.PROP_FLAT_BKG_WS,
                                    defaultValue='',
                                    direction=Direction.Input,
                                    optional=PropertyMode.Optional),
            doc='Workspace with previously determined flat background data.')
        self.setPropertyGroup(common.PROP_FLAT_BKG_WS, PROPGROUP_FLAT_BKG)
        self.declareProperty(name=common.PROP_NORMALISATION,
                             defaultValue=common.NORM_METHOD_MON,
                             validator=StringListValidator([
                                 common.NORM_METHOD_MON,
                                 common.NORM_METHOD_TIME,
                                 common.NORM_METHOD_OFF
                             ]),
                             direction=Direction.Input,
                             doc='Normalisation method.')
        self.setPropertyGroup(common.PROP_NORMALISATION,
                              PROPGROUP_MON_NORMALISATION)
        self.declareProperty(name=common.PROP_MON_PEAK_SIGMA_MULTIPLIER,
                             defaultValue=3.0,
                             validator=positiveFloat,
                             direction=Direction.Input,
                             doc="Width of the monitor peak in multiples " +
                             " of 'Sigma' in monitor's EPP table.")
        self.setPropertyGroup(common.PROP_MON_PEAK_SIGMA_MULTIPLIER,
                              PROPGROUP_MON_NORMALISATION)
        # Rest of the output properties.
        self.declareProperty(
            WorkspaceProperty(name=common.PROP_OUTPUT_RAW_WS,
                              defaultValue='',
                              direction=Direction.Output,
                              optional=PropertyMode.Optional),
            doc=
            'Non-normalized and non-background subtracted output workspace for DirectILLDiagnostics.'
        )
        self.setPropertyGroup(common.PROP_OUTPUT_RAW_WS,
                              common.PROPGROUP_OPTIONAL_OUTPUT)
        self.declareProperty(WorkspaceProperty(
            name=common.PROP_OUTPUT_ELASTIC_CHANNEL_WS,
            defaultValue='',
            direction=Direction.Output,
            optional=PropertyMode.Optional),
                             doc='Output workspace for elastic channel index.')
        self.setPropertyGroup(common.PROP_OUTPUT_ELASTIC_CHANNEL_WS,
                              common.PROPGROUP_OPTIONAL_OUTPUT)
        self.declareProperty(
            ITableWorkspaceProperty(name=common.PROP_OUTPUT_DET_EPP_WS,
                                    defaultValue='',
                                    direction=Direction.Output,
                                    optional=PropertyMode.Optional),
            doc='Output workspace for elastic peak positions.')
        self.setPropertyGroup(common.PROP_OUTPUT_DET_EPP_WS,
                              common.PROPGROUP_OPTIONAL_OUTPUT)
        self.declareProperty(
            WorkspaceProperty(name=common.PROP_OUTPUT_INCIDENT_ENERGY_WS,
                              defaultValue='',
                              direction=Direction.Output,
                              optional=PropertyMode.Optional),
            doc='Output workspace for calibrated incident energy.')
        self.setPropertyGroup(common.PROP_OUTPUT_INCIDENT_ENERGY_WS,
                              common.PROPGROUP_OPTIONAL_OUTPUT)
        self.declareProperty(WorkspaceProperty(
            name=common.PROP_OUTPUT_FLAT_BKG_WS,
            defaultValue='',
            direction=Direction.Output,
            optional=PropertyMode.Optional),
                             doc='Output workspace for flat background.')
        self.setPropertyGroup(common.PROP_OUTPUT_FLAT_BKG_WS,
                              common.PROPGROUP_OPTIONAL_OUTPUT)
Exemplo n.º 9
0
    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):
        # 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')
Exemplo n.º 11
0
    def PyInit(self):
        # ----------
        # INPUT
        # ----------
        self.declareProperty(
            PropertyManagerProperty('SANSState'),
            doc='A property manager which fulfills the SANSState contract.')

        self.declareProperty(
            "PublishToCache",
            True,
            direction=Direction.Input,
            doc=
            "Publish the calibration workspace to a cache, in order to avoid reloading "
            "for subsequent runs.")

        self.declareProperty(
            "UseCached",
            True,
            direction=Direction.Input,
            doc=
            "Checks if there are loaded files available. If they are, those files are used."
        )

        self.declareProperty(
            "MoveWorkspace",
            defaultValue=False,
            direction=Direction.Input,
            doc=
            "Move the workspace according to the SANSState setting. This might be useful"
            "for manual inspection.")

        # Beam coordinates if an initial move of the workspace is requested
        enabled_condition = EnabledWhenProperty("MoveWorkspace",
                                                PropertyCriterion.IsNotDefault)
        self.declareProperty(
            FloatArrayProperty(name='BeamCoordinates', values=[]),
            doc=
            'The coordinates which is used to position the instrument component(s). '
            'If the workspaces should be loaded with an initial move, then this '
            'needs to be specified.')
        # Components which are to be moved
        self.declareProperty(
            'Component',
            '',
            direction=Direction.Input,
            doc='Component that should be moved. '
            'If the workspaces should be loaded with an initial move, then this '
            'needs to be specified.')
        self.setPropertySettings("BeamCoordinates", enabled_condition)
        self.setPropertySettings("Component", enabled_condition)

        # ------------
        #  OUTPUT
        # ------------
        default_number_of_workspaces = 0

        # Sample Scatter Workspaces
        self.declareProperty(
            WorkspaceProperty('SampleScatterWorkspace',
                              '',
                              optional=PropertyMode.Optional,
                              direction=Direction.Output),
            doc=
            'The sample scatter workspace. This workspace does not contain monitors.'
        )
        self.declareProperty(
            WorkspaceProperty('SampleScatterMonitorWorkspace',
                              '',
                              optional=PropertyMode.Optional,
                              direction=Direction.Output),
            doc=
            'The sample scatter monitor workspace. This workspace only contains monitors.'
        )
        self.declareProperty(MatrixWorkspaceProperty(
            'SampleTransmissionWorkspace',
            '',
            optional=PropertyMode.Optional,
            direction=Direction.Output),
                             doc='The sample transmission workspace.')
        self.declareProperty(MatrixWorkspaceProperty(
            'SampleDirectWorkspace',
            '',
            optional=PropertyMode.Optional,
            direction=Direction.Output),
                             doc='The sample scatter direct workspace.')

        self.setPropertyGroup("SampleScatterWorkspace", 'Sample')
        self.setPropertyGroup("SampleScatterMonitorWorkspace", 'Sample')
        self.setPropertyGroup("SampleTransmissionWorkspace", 'Sample')
        self.setPropertyGroup("SampleDirectWorkspace", 'Sample')

        # Number of sample workspaces
        self.declareProperty('NumberOfSampleScatterWorkspaces',
                             defaultValue=default_number_of_workspaces,
                             direction=Direction.Output,
                             doc='The number of workspace for sample scatter.')
        self.declareProperty(
            'NumberOfSampleTransmissionWorkspaces',
            defaultValue=default_number_of_workspaces,
            direction=Direction.Output,
            doc='The number of workspace for sample transmission.')
        self.declareProperty('NumberOfSampleDirectWorkspaces',
                             defaultValue=default_number_of_workspaces,
                             direction=Direction.Output,
                             doc='The number of workspace for sample direct.')

        self.declareProperty(
            MatrixWorkspaceProperty('CanScatterWorkspace',
                                    '',
                                    optional=PropertyMode.Optional,
                                    direction=Direction.Output),
            doc=
            'The can scatter workspace. This workspace does not contain monitors.'
        )
        self.declareProperty(
            MatrixWorkspaceProperty('CanScatterMonitorWorkspace',
                                    '',
                                    optional=PropertyMode.Optional,
                                    direction=Direction.Output),
            doc=
            'The can scatter monitor workspace. This workspace only contains monitors.'
        )
        self.declareProperty(MatrixWorkspaceProperty(
            'CanTransmissionWorkspace',
            '',
            optional=PropertyMode.Optional,
            direction=Direction.Output),
                             doc='The can transmission workspace.')
        self.declareProperty(MatrixWorkspaceProperty(
            'CanDirectWorkspace',
            '',
            optional=PropertyMode.Optional,
            direction=Direction.Output),
                             doc='The sample scatter direct workspace.')
        self.setPropertyGroup("CanScatterWorkspace", 'Can')
        self.setPropertyGroup("CanScatterMonitorWorkspace", 'Can')
        self.setPropertyGroup("CanTransmissionWorkspace", 'Can')
        self.setPropertyGroup("CanDirectWorkspace", 'Can')

        self.declareProperty('NumberOfCanScatterWorkspaces',
                             defaultValue=default_number_of_workspaces,
                             direction=Direction.Output,
                             doc='The number of workspace for can scatter.')
        self.declareProperty(
            'NumberOfCanTransmissionWorkspaces',
            defaultValue=default_number_of_workspaces,
            direction=Direction.Output,
            doc='The number of workspace for can transmission.')
        self.declareProperty('NumberOfCanDirectWorkspaces',
                             defaultValue=default_number_of_workspaces,
                             direction=Direction.Output,
                             doc='The number of workspace for can direct.')
Exemplo n.º 12
0
    def PyInit(self):
        # Sample options
        self.declareProperty(WorkspaceProperty('SampleWorkspace',
                                               '',
                                               direction=Direction.Input),
                             doc='Sample Workspace')
        self.declareProperty(name='SampleChemicalFormula',
                             defaultValue='',
                             doc='Chemical formula for the sample material')
        self.declareProperty(name='SampleDensityType',
                             defaultValue='Mass Density',
                             validator=StringListValidator(
                                 ['Mass Density', 'Number Density']),
                             doc='Sample density type')
        self.declareProperty(name='SampleDensity',
                             defaultValue=0.0,
                             validator=FloatBoundedValidator(0.0),
                             doc='Sample density')

        self.setPropertyGroup('SampleWorkspace', 'Sample Options')
        self.setPropertyGroup('SampleChemicalFormula', 'Sample Options')
        self.setPropertyGroup('SampleDensityType', 'Sample Options')
        self.setPropertyGroup('SampleDensity', 'Sample Options')

        # Beam Options
        self.declareProperty(name='BeamHeight',
                             defaultValue=1.0,
                             validator=FloatBoundedValidator(0.0),
                             doc='Height of the beam (cm)')
        self.declareProperty(name='BeamWidth',
                             defaultValue=1.0,
                             validator=FloatBoundedValidator(0.0),
                             doc='Width of the beam (cm)')

        self.setPropertyGroup('BeamHeight', 'Beam Options')
        self.setPropertyGroup('BeamWidth', 'Beam Options')

        # Monte Carlo options
        self.declareProperty(name='NumberOfWavelengthPoints',
                             defaultValue=10,
                             validator=IntBoundedValidator(1),
                             doc='Number of wavelengths for calculation')
        self.declareProperty(name='EventsPerPoint',
                             defaultValue=1000,
                             validator=IntBoundedValidator(0),
                             doc='Number of neutron events')
        self.declareProperty(name='Interpolation',
                             defaultValue='Linear',
                             validator=StringListValidator(
                                 ['Linear', 'CSpline']),
                             doc='Type of interpolation')
        self.declareProperty(
            name='MaxScatterPtAttempts',
            defaultValue=5000,
            validator=IntBoundedValidator(0),
            doc='Maximum number of tries made to generate a scattering point')

        self.setPropertyGroup('NumberOfWavelengthPoints',
                              'Monte Carlo Options')
        self.setPropertyGroup('EventsPerPoint', 'Monte Carlo Options')
        self.setPropertyGroup('Interpolation', 'Monte Carlo Options')
        self.setPropertyGroup('MaxScatterPtAttempts', 'Monte Carlo Options')

        # Container options
        self.declareProperty(WorkspaceProperty('ContainerWorkspace',
                                               '',
                                               direction=Direction.Input,
                                               optional=PropertyMode.Optional),
                             doc='Container Workspace')

        container_condition = VisibleWhenProperty(
            'ContainerWorkspace', PropertyCriterion.IsNotDefault)

        self.declareProperty(name='ContainerChemicalFormula',
                             defaultValue='',
                             doc='Chemical formula for the container material')
        self.declareProperty(name='ContainerDensityType',
                             defaultValue='Mass Density',
                             validator=StringListValidator(
                                 ['Mass Density', 'Number Density']),
                             doc='Container density type')
        self.declareProperty(name='ContainerDensity',
                             defaultValue=0.0,
                             validator=FloatBoundedValidator(0.0),
                             doc='Container density')

        self.setPropertyGroup('ContainerWorkspace', 'Container Options')
        self.setPropertyGroup('ContainerChemicalFormula', 'Container Options')
        self.setPropertyGroup('ContainerDensityType', 'Container Options')
        self.setPropertyGroup('ContainerDensity', 'Container Options')

        self.setPropertySettings('ContainerChemicalFormula',
                                 container_condition)
        self.setPropertySettings('ContainerDensityType', container_condition)
        self.setPropertySettings('ContainerDensity', container_condition)

        # Shape options
        self.declareProperty(name='Shape',
                             defaultValue='FlatPlate',
                             validator=StringListValidator(
                                 ['FlatPlate', 'Cylinder', 'Annulus']),
                             doc='Geometric shape of the sample environment')

        flat_plate_condition = VisibleWhenProperty('Shape',
                                                   PropertyCriterion.IsEqualTo,
                                                   'FlatPlate')
        cylinder_condition = VisibleWhenProperty('Shape',
                                                 PropertyCriterion.IsEqualTo,
                                                 'Cylinder')
        annulus_condition = VisibleWhenProperty('Shape',
                                                PropertyCriterion.IsEqualTo,
                                                'Annulus')

        # height is common to all, and should be the same for sample and container
        self.declareProperty('Height',
                             defaultValue=0.0,
                             validator=FloatBoundedValidator(0.0),
                             doc='Height of the sample environment (cm)')

        self.setPropertyGroup('Shape', 'Shape Options')
        self.setPropertyGroup('Height', 'Shape Options')

        # ---------------------------Sample---------------------------
        # Flat Plate
        self.declareProperty(name='SampleWidth',
                             defaultValue=0.0,
                             validator=FloatBoundedValidator(0.0),
                             doc='Width of the sample environment (cm)')
        self.declareProperty(name='SampleThickness',
                             defaultValue=0.0,
                             validator=FloatBoundedValidator(0.0),
                             doc='Thickness of the sample environment (cm)')
        self.declareProperty(name='SampleCenter',
                             defaultValue=0.0,
                             doc='Center of the sample environment')
        self.declareProperty(
            name='SampleAngle',
            defaultValue=0.0,
            validator=FloatBoundedValidator(0.0),
            doc=
            'Angle of the sample environment with respect to the beam (degrees)'
        )

        self.setPropertySettings('SampleWidth', flat_plate_condition)
        self.setPropertySettings('SampleThickness', flat_plate_condition)
        self.setPropertySettings('SampleCenter', flat_plate_condition)
        self.setPropertySettings('SampleAngle', flat_plate_condition)

        self.setPropertyGroup('SampleWidth', 'Sample Shape Options')
        self.setPropertyGroup('SampleThickness', 'Sample Shape Options')
        self.setPropertyGroup('SampleCenter', 'Sample Shape Options')
        self.setPropertyGroup('SampleAngle', 'Sample Shape Options')

        # Cylinder
        self.declareProperty(name='SampleRadius',
                             defaultValue=0.0,
                             validator=FloatBoundedValidator(0.0),
                             doc='Radius of the sample environment (cm)')

        self.setPropertySettings('SampleRadius', cylinder_condition)
        self.setPropertyGroup('SampleRadius', 'Sample Shape Options')

        # Annulus
        self.declareProperty(name='SampleInnerRadius',
                             defaultValue=0.0,
                             validator=FloatBoundedValidator(0.0),
                             doc='Inner radius of the sample environment (cm)')
        self.declareProperty(name='SampleOuterRadius',
                             defaultValue=0.0,
                             validator=FloatBoundedValidator(0.0),
                             doc='Outer radius of the sample environment (cm)')

        self.setPropertySettings('SampleInnerRadius', annulus_condition)
        self.setPropertySettings('SampleOuterRadius', annulus_condition)

        self.setPropertyGroup('SampleInnerRadius', 'Sample Shape Options')
        self.setPropertyGroup('SampleOuterRadius', 'Sample Shape Options')

        # ---------------------------Container---------------------------
        # Flat Plate
        self.declareProperty(
            name='ContainerFrontThickness',
            defaultValue=0.0,
            validator=FloatBoundedValidator(0.0),
            doc='Front thickness of the container environment (cm)')
        self.declareProperty(
            name='ContainerBackThickness',
            defaultValue=0.0,
            validator=FloatBoundedValidator(0.0),
            doc='Back thickness of the container environment (cm)')

        container_flat_plate_condition = VisibleWhenProperty(
            container_condition, flat_plate_condition, LogicOperator.And)

        self.setPropertySettings('ContainerFrontThickness',
                                 container_flat_plate_condition)
        self.setPropertySettings('ContainerBackThickness',
                                 container_flat_plate_condition)

        self.setPropertyGroup('ContainerFrontThickness',
                              'Container Shape Options')
        self.setPropertyGroup('ContainerBackThickness',
                              'Container Shape Options')

        # Both cylinder and annulus have an annulus container

        not_flat_plate_condition = VisibleWhenProperty(
            'Shape', PropertyCriterion.IsNotEqualTo, 'FlatPlate')

        container_n_f_p_condition = VisibleWhenProperty(
            container_condition, not_flat_plate_condition, LogicOperator.And)

        self.declareProperty(
            name='ContainerInnerRadius',
            defaultValue=0.0,
            validator=FloatBoundedValidator(0.0),
            doc='Inner radius of the container environment (cm)')
        self.declareProperty(
            name='ContainerOuterRadius',
            defaultValue=0.0,
            validator=FloatBoundedValidator(0.0),
            doc='Outer radius of the container environment (cm)')

        self.setPropertySettings('ContainerInnerRadius',
                                 container_n_f_p_condition)
        self.setPropertySettings('ContainerOuterRadius',
                                 container_n_f_p_condition)

        self.setPropertyGroup('ContainerInnerRadius',
                              'Container Shape Options')
        self.setPropertyGroup('ContainerOuterRadius',
                              'Container Shape Options')

        # output
        self.declareProperty(
            WorkspaceGroupProperty(name='CorrectionsWorkspace',
                                   defaultValue='corrections',
                                   direction=Direction.Output,
                                   optional=PropertyMode.Optional),
            doc='Name of the workspace group to save correction factors')
        self.setPropertyGroup('CorrectionsWorkspace', 'Output Options')
Exemplo n.º 13
0
    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")
Exemplo n.º 14
0
    def PyInit(self):
        # Declare all properties
        from abins.constants import AB_INITIO_FILE_EXTENSIONS, ALL_INSTRUMENTS, ALL_SAMPLE_FORMS

        self.declareProperty(
            name="AbInitioProgram",
            direction=Direction.Input,
            defaultValue="CASTEP",
            validator=StringListValidator(
                ["CASTEP", "CRYSTAL", "DMOL3", "GAUSSIAN", "VASP"]),
            doc=
            "An ab initio program which was used for vibrational or phonon calculation."
        )

        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(
            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(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(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.")
Exemplo n.º 15
0
    def PyInit(self):
        """Initialize the algorithm's input and output properties."""
        PROPGROUP_REBINNING = 'Rebinning for SofQW'
        inputWorkspaceValidator = CompositeValidator()
        inputWorkspaceValidator.add(InstrumentValidator())
        inputWorkspaceValidator.add(WorkspaceUnitValidator('TOF'))
        positiveFloat = FloatBoundedValidator(0., exclusive=True)
        validRebinParams = RebinParamsValidator(AllowEmpty=True)

        # Properties.
        self.declareProperty(MatrixWorkspaceProperty(
            name=common.PROP_INPUT_WS,
            defaultValue='',
            validator=inputWorkspaceValidator,
            direction=Direction.Input),
            doc='A workspace to reduce.')
        self.declareProperty(WorkspaceProperty(name=common.PROP_OUTPUT_WS,
                                               defaultValue='',
                                               direction=Direction.Output),
                             doc='The reduced S(Q, DeltaE) workspace.')
        self.declareProperty(name=common.PROP_CLEANUP_MODE,
                             defaultValue=utils.Cleanup.ON,
                             validator=StringListValidator([
                                 utils.Cleanup.ON,
                                 utils.Cleanup.OFF]),
                             direction=Direction.Input,
                             doc='What to do with intermediate workspaces.')
        self.declareProperty(name=common.PROP_SUBALG_LOGGING,
                             defaultValue=common.SUBALG_LOGGING_OFF,
                             validator=StringListValidator([
                                 common.SUBALG_LOGGING_OFF,
                                 common.SUBALG_LOGGING_ON]),
                             direction=Direction.Input,
                             doc='Enable or disable subalgorithms to print in the logs.')
        self.declareProperty(MatrixWorkspaceProperty(
            name=common.PROP_VANA_WS,
            defaultValue='',
            validator=inputWorkspaceValidator,
            direction=Direction.Input,
            optional=PropertyMode.Optional),
            doc='An integrated vanadium workspace.')
        self.declareProperty(name=common.PROP_ABSOLUTE_UNITS,
                             defaultValue=common.ABSOLUTE_UNITS_OFF,
                             validator=StringListValidator([
                                 common.ABSOLUTE_UNITS_OFF,
                                 common.ABSOLUTE_UNITS_ON]),
                             direction=Direction.Input,
                             doc='Enable or disable normalisation to absolute units.')
        self.declareProperty(MatrixWorkspaceProperty(
            name=common.PROP_DIAGNOSTICS_WS,
            defaultValue='',
            direction=Direction.Input,
            optional=PropertyMode.Optional),
            doc='Detector diagnostics workspace for masking.')
        self.declareProperty(name=common.PROP_GROUPING_ANGLE_STEP,
                             defaultValue=Property.EMPTY_DBL,
                             validator=positiveFloat,
                             doc='A scattering angle step to which to group detectors, in degrees.')
        self.declareProperty(FloatArrayProperty(name=common.PROP_REBINNING_PARAMS_W, validator=validRebinParams),
                             doc='Manual energy rebinning parameters.')
        self.setPropertyGroup(common.PROP_REBINNING_PARAMS_W, PROPGROUP_REBINNING)
        self.declareProperty(name=common.PROP_REBINNING_W,
                             defaultValue='',
                             doc='Energy rebinning when mixing manual and automatic binning parameters.')
        self.declareProperty(FloatArrayProperty(name=common.PROP_BINNING_PARAMS_Q, validator=validRebinParams),
                             doc='Manual q rebinning parameters.')
        self.setPropertyGroup(common.PROP_BINNING_PARAMS_Q, PROPGROUP_REBINNING)
        self.declareProperty(name=common.PROP_TRANSPOSE_SAMPLE_OUTPUT,
                             defaultValue=common.TRANSPOSING_ON,
                             validator=StringListValidator([
                                 common.TRANSPOSING_ON,
                                 common.TRANSPOSING_OFF]),
                             direction=Direction.Input,
                             doc='Enable or disable ' + common.PROP_OUTPUT_WS + ' transposing.')
        self.declareProperty(WorkspaceProperty(
            name=common.PROP_OUTPUT_THETA_W_WS,
            defaultValue='',
            direction=Direction.Output,
            optional=PropertyMode.Optional),
            doc='Output workspace for reduced S(theta, DeltaE).')
        self.setPropertyGroup(common.PROP_OUTPUT_THETA_W_WS,
                              common.PROPGROUP_OPTIONAL_OUTPUT)
Exemplo n.º 16
0
    def PyExec(self):
        # Retrieve all relevant notice

        in_Runs = self.getProperty("RunNumbers").value

        maskWSname = self._getMaskWSname()

        progress = Progress(self, 0., .25, 3)

        # either type of file-based calibration is stored in the same variable
        calib = self.getProperty("Calibration").value
        if calib == "Calibration File":
            cal_File = self.getProperty("CalibrationFilename").value
            progress.report('loaded calibration')
        elif calib == 'DetCal File':
            cal_File = self.getProperty('DetCalFilename').value
            cal_File = ','.join(cal_File)
            progress.report('loaded detcal')
        else:
            cal_File = None
            progress.report('')

        params = self.getProperty("Binning").value
        norm = self.getProperty("Normalization").value

        if norm == "From Processed Nexus":
            norm_File = self.getProperty("NormalizationFilename").value
            LoadNexusProcessed(Filename=norm_File, OutputWorkspace='normWS')
            normWS = 'normWS'
            progress.report('loaded normalization')
        elif norm == "From Workspace":
            normWS = str(self.getProperty("NormalizationWorkspace").value)
            progress.report('')
        else:
            normWS = None
            progress.report('')

        group_to_real = {
            'Banks': 'Group',
            'Modules': 'bank',
            '2_4 Grouping': '2_4Grouping'
        }
        group = self.getProperty('GroupDetectorsBy').value
        real_name = group_to_real.get(group, group)

        if not mtd.doesExist(group):
            if group == '2_4 Grouping':
                group = '2_4_Grouping'
            CreateGroupingWorkspace(InstrumentName='SNAP',
                                    GroupDetectorsBy=real_name,
                                    OutputWorkspace=group)
            progress.report('create grouping')

        Process_Mode = self.getProperty("ProcessingMode").value

        prefix = self.getProperty("OptionalPrefix").value

        # --------------------------- REDUCE DATA -----------------------------

        Tag = 'SNAP'

        progStart = .25
        progDelta = (1. - progStart) / len(in_Runs)
        for r in in_Runs:
            progress = Progress(self, progStart, progStart + progDelta, 7)

            self.log().notice("processing run %s" % r)
            self.log().information(str(self.get_IPTS_Local(r)))
            if self.getProperty("LiveData").value:
                Tag = 'Live'
                raise RuntimeError('Live data is not currently supported')
            else:
                Load(Filename='SNAP' + str(r), OutputWorkspace='WS')
                NormaliseByCurrent(InputWorkspace='WS', OutputWorkspace='WS')
            progress.report('loaded data')

            CompressEvents(InputWorkspace='WS', OutputWorkspace='WS')
            progress.report('compressed')
            CropWorkspace(InputWorkspace='WS',
                          OutputWorkspace='WS',
                          XMax=50000)
            progress.report('cropped in tof')
            RemovePromptPulse(InputWorkspace='WS',
                              OutputWorkspace='WS',
                              Width='1600',
                              Frequency='60.4')  # TODO don't declare frequency
            progress.report('remove prompt pulse')

            if maskWSname is not None:
                MaskDetectors(Workspace='WS', MaskedWorkspace=maskWSname)
                progress.report('masked detectors')
            else:
                progress.report('')

            self._alignAndFocus(params, calib, cal_File, group)
            progress.report('align and focus')

            normWS = self._generateNormalization('WS_red', norm, normWS)
            WS_nor = None
            if normWS is not None:
                WS_nor = 'WS_nor'
                Divide(LHSWorkspace='WS_red',
                       RHSWorkspace=normWS,
                       OutputWorkspace='WS_nor')
                ReplaceSpecialValues(Inputworkspace='WS_nor',
                                     OutputWorkspace='WS_nor',
                                     NaNValue='0',
                                     NaNError='0',
                                     InfinityValue='0',
                                     InfinityError='0')
                progress.report('normalized')
            else:
                progress.report()

            new_Tag = Tag
            if len(prefix) > 0:
                new_Tag += '_' + prefix

            # Edit instrument geomety to make final workspace smaller on disk
            det_table = PreprocessDetectorsToMD(
                Inputworkspace='WS_red', OutputWorkspace='__SNAP_det_table')
            polar = np.degrees(det_table.column('TwoTheta'))
            azi = np.degrees(det_table.column('Azimuthal'))
            EditInstrumentGeometry(Workspace='WS_red',
                                   L2=det_table.column('L2'),
                                   Polar=polar,
                                   Azimuthal=azi)
            if WS_nor is not None:
                EditInstrumentGeometry(Workspace='WS_nor',
                                       L2=det_table.column('L2'),
                                       Polar=polar,
                                       Azimuthal=azi)
            mtd.remove('__SNAP_det_table')
            progress.report('simplify geometry')

            # Save requested formats
            basename = '%s_%s_%s' % (new_Tag, r, group)
            self._save(r, basename, norm)

            # temporary workspace no longer needed
            DeleteWorkspace(Workspace='WS')

            # rename everything as appropriate and determine output workspace name
            RenameWorkspace(Inputworkspace='WS_d',
                            OutputWorkspace='%s_%s_d' % (new_Tag, r))
            RenameWorkspace(Inputworkspace='WS_red',
                            OutputWorkspace=basename + '_red')
            if norm == 'None':
                outputWksp = basename + '_red'
            else:
                outputWksp = basename + '_nor'
                RenameWorkspace(Inputworkspace='WS_nor',
                                OutputWorkspace=basename + '_nor')
            if norm == "Extracted from Data":
                RenameWorkspace(Inputworkspace='peak_clip_WS',
                                OutputWorkspace='%s_%s_normalizer' %
                                (new_Tag, r))

            # set workspace as an output so it gets history
            propertyName = 'OutputWorkspace_' + str(outputWksp)
            self.declareProperty(
                WorkspaceProperty(propertyName, outputWksp, Direction.Output))
            self.setProperty(propertyName, outputWksp)

            # delte some things in production
            if Process_Mode == "Production":
                DeleteWorkspace(Workspace='%s_%s_d' %
                                (new_Tag, r))  # was 'WS_d'

                if norm != "None":
                    DeleteWorkspace(Workspace=basename +
                                    '_red')  # was 'WS_red'
                elif norm == "Extracted from Data":
                    DeleteWorkspace(Workspace='%s_%s_normalizer' %
                                    (new_Tag, r))  # was 'peak_clip_WS'
            else:  # TODO set them as workspace properties
                propNames = [
                    'OuputWorkspace_' + str(it)
                    for it in ['d', 'norm', 'normalizer']
                ]
                wkspNames = [
                    '%s_%s_d' % (new_Tag, r), basename + '_red',
                    '%s_%s_normalizer' % (new_Tag, r)
                ]
                for (propName, wkspName) in zip(propNames, wkspNames):
                    self.declareProperty(
                        WorkspaceProperty(propName, wkspName,
                                          Direction.Output))
                    self.setProperty(propName, wkspName)
    def PyInit(self):
        # files to reduce
        self.declareProperty(
            MultipleFileProperty(name="Filename",
                                 extensions=["_event.nxs", ".nxs.h5", ".nxs"]),
            "Files to combine in reduction")

        # background
        self.declareProperty(
            FileProperty(name="Background",
                         defaultValue="",
                         action=FileAction.OptionalLoad,
                         extensions=["_event.nxs", ".nxs.h5", ".nxs"]),
            "Background run")
        self.declareProperty(
            "BackgroundScale",
            1.0,
            doc=
            "The background will be scaled by this number before being subtracted."
        )

        # Filter by TOF
        self.copyProperties('LoadEventNexus',
                            ['FilterByTofMin', 'FilterByTofMax'])

        # Vanadium SA and flux
        self.declareProperty(
            FileProperty(name="SolidAngle",
                         defaultValue="",
                         action=FileAction.Load,
                         extensions=[".nxs"]),
            doc=
            "An input workspace containing momentum integrated vanadium (a measure"
            "of the solid angle). See :ref:`MDnormSCD <algm-MDnormSCD>` for details"
        )
        self.declareProperty(
            FileProperty(name="Flux",
                         defaultValue="",
                         action=FileAction.Load,
                         extensions=[".nxs"]),
            "An input workspace containing momentum dependent flux. See :ref:`MDnormSCD <algm-MDnormSCD>` for details"
        )
        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(
            FileProperty(name="UBMatrix",
                         defaultValue="",
                         action=FileAction.Load,
                         extensions=[".mat", ".ub", ".txt"]),
            doc=
            "Path to an ISAW-style UB matrix text file. See :ref:`LoadIsawUB <algm-LoadIsawUB>`"
        )
        # Goniometer
        self.declareProperty(
            'SetGoniometer', False,
            "Set which Goniometer to use. See :ref:`SetGoniometer <algm-SetGoniometer>`"
        )
        condition = VisibleWhenProperty("SetGoniometer",
                                        PropertyCriterion.IsNotDefault)
        self.copyProperties('SetGoniometer',
                            ['Goniometers', 'Axis0', 'Axis1', 'Axis2'])
        self.setPropertySettings("Goniometers", condition)
        self.setPropertySettings('Axis0', condition)
        self.setPropertySettings('Axis1', condition)
        self.setPropertySettings('Axis2', condition)

        # Corrections
        self.declareProperty(
            FileProperty(name="LoadInstrument",
                         defaultValue="",
                         action=FileAction.OptionalLoad,
                         extensions=[".xml"]),
            "Load a different instrument IDF onto the data from a file. See :ref:`LoadInstrument <algm-LoadInstrument>`"
        )
        self.declareProperty(
            FileProperty(name="DetCal",
                         defaultValue="",
                         action=FileAction.OptionalLoad,
                         extensions=[".detcal"]),
            "Load an ISAW DetCal calibration onto the data from a file. See :ref:`LoadIsawDetCal <algm-LoadIsawDetCal>`"
        )
        self.declareProperty(
            FileProperty(name="MaskFile",
                         defaultValue="",
                         action=FileAction.OptionalLoad,
                         extensions=[".xml", ".msk"]),
            "Masking file for masking. Supported file format is XML and ISIS ASCII. See :ref:`LoadMask <algm-LoadMask>`"
        )

        # SymmetryOps, name, group unmber or list symmetries
        self.declareProperty(
            "SymmetryOps", "",
            "If specified the symmetry will be applied, can be space group name or number, or list individual symmetries."
        )

        # Binning output
        self.copyProperties('ConvertToMD', ['Uproj', 'Vproj', 'Wproj'])
        self.declareProperty(
            FloatArrayProperty("BinningDim0", [-5.05, 5.05, 101],
                               FloatArrayLengthValidator(3),
                               direction=Direction.Input),
            "Binning parameters for the 0th dimension. Enter it as a"
            "comma-separated list of values with the"
            "format: 'minimum,maximum,number_of_bins'.")
        self.declareProperty(
            FloatArrayProperty("BinningDim1", [-5.05, 5.05, 101],
                               FloatArrayLengthValidator(3),
                               direction=Direction.Input),
            "Binning parameters for the 1st dimension. Enter it as a"
            "comma-separated list of values with the"
            "format: 'minimum,maximum,number_of_bins'.")
        self.declareProperty(
            FloatArrayProperty("BinningDim2", [-5.05, 5.05, 101],
                               FloatArrayLengthValidator(3),
                               direction=Direction.Input),
            "Binning parameters for the 2nd dimension. Enter it as a"
            "comma-separated list of values with the"
            "format: 'minimum,maximum,number_of_bins'.")

        self.declareProperty(
            'KeepTemporaryWorkspaces', False,
            "If True the normalization and data workspaces in addition to the normalized data will be outputted"
        )

        self.declareProperty(
            WorkspaceProperty("OutputWorkspace",
                              "",
                              optional=PropertyMode.Mandatory,
                              direction=Direction.Output),
            "Output Workspace. If background is subtracted _data and _background workspaces will also be made."
        )

        # Background
        self.setPropertyGroup("Background", "Background")
        self.setPropertyGroup("BackgroundScale", "Background")

        # Vanadium
        self.setPropertyGroup("SolidAngle", "Vanadium")
        self.setPropertyGroup("Flux", "Vanadium")
        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")

        # Corrections
        self.setPropertyGroup("LoadInstrument", "Corrections")
        self.setPropertyGroup("DetCal", "Corrections")
        self.setPropertyGroup("MaskFile", "Corrections")

        # Projection and binning
        self.setPropertyGroup("Uproj", "Projection and binning")
        self.setPropertyGroup("Vproj", "Projection and binning")
        self.setPropertyGroup("Wproj", "Projection and binning")
        self.setPropertyGroup("BinningDim0", "Projection and binning")
        self.setPropertyGroup("BinningDim1", "Projection and binning")
        self.setPropertyGroup("BinningDim2", "Projection and binning")
Exemplo n.º 18
0
    def PyInit(self):
        # Input workspace
        self.declareProperty(
            WorkspaceProperty(name='InputWorkspace', defaultValue='', direction=Direction.Input),
            'Workspace with peaks to be identified')

        # Input parameters
        self.declareProperty('SpectrumNumber',1, doc = 'Spectrum number to use',
                             validator=IntBoundedValidator(lower=0))
        self.declareProperty('StartXValue', 0.0, doc='Value of X to start the search from')
        self.declareProperty('EndXValue', np.Inf, doc='Value of X to stop the search to')
        self.declareProperty(
            'AcceptanceThreshold',
            0.01,
            doc=
            'Threshold for considering a peak significant, the exact meaning of the value depends '
            'on the cost function used and the data to be fitted. '
            'Good values might be about 1-10 for poisson cost and 0.0001-0.01 for chi2',
            validator=FloatBoundedValidator(lower=0.0))
        self.declareProperty(
            'SmoothWindow',
            5,
            doc='Half size of the window used to find the background values to subtract',
            validator=IntBoundedValidator(lower=0))
        self.declareProperty(
            'BadPeaksToConsider',
            20,
            doc='Number of peaks that do not exceed the acceptance threshold to be searched before '
            'terminating. This is useful because sometimes good peaks can be found after '
            'some bad ones. However setting this value too high will make the search much slower.',
            validator=IntBoundedValidator(lower=0))
        self.declareProperty(
            'UsePoissonCost',
            False,
            doc='Use a probabilistic approach to find the cost of a fit instead of using chi2.')
        self.declareProperty(
            'FitToBaseline',
            False,
            doc='Use a probabilistic approach to find the cost of a fit instead of using chi2.')
        self.declareProperty(
            'EstimatePeakSigma',
            3.0,
            doc='A rough estimate of the standard deviation of the gaussian used to fit the peaks',
            validator=FloatBoundedValidator(lower=0.0))
        self.declareProperty('MinPeakSigma',
                             0.5,
                             doc='Minimum value for the standard deviation of a peak',
                             validator=FloatBoundedValidator(lower=0.0))
        self.declareProperty('MaxPeakSigma',
                             30.0,
                             doc='Maximum value for the standard deviation of a peak',
                             validator=FloatBoundedValidator(lower=0.0))
        self.declareProperty('PlotPeaks', False,
                             'Plot the position of the peaks found by the algorithm')
        self.declareProperty('PlotBaseline', False,
                             'Plot the baseline as calculated by the algorithm')

        # Output table
        self.declareProperty(
            ITableWorkspaceProperty(name='PeakPropertiesTableName',
                                    defaultValue='peak_table',
                                    direction=Direction.Output),
            doc='Name of the table containing the properties of the peaks')
        self.declareProperty(
            ITableWorkspaceProperty(
                name='RefitPeakPropertiesTableName',
                defaultValue='refit_peak_table',
                direction=Direction.Output),
            doc='Name of the table containing the properties of the peaks that had to be fitted twice '
                'as the first time the error was unreasonably large')
        self.declareProperty(
            WorkspaceProperty(name='OutputWorkspace', defaultValue='workspace_with_errors', direction=Direction.Output),
            'Workspace containing the same data as the input one, with errors added if not present from the beginning')
Exemplo n.º 19
0
    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):
        # Sample Input
        self.declareProperty(WorkspaceProperty('InputWorkspace', '', direction=Direction.Input),
                             doc='Workspace with the measurement of the sample [in a container].')

        # Monte Carlo Options
        self.declareProperty(name='EventsPerPoint', defaultValue=1000,
                             validator=IntBoundedValidator(0),
                             doc='Number of neutron events')
        self.declareProperty(name='Interpolation', defaultValue='Linear',
                             validator=StringListValidator(
                                 ['Linear', 'CSpline']),
                             doc='Type of interpolation')
        self.declareProperty(name='MaxScatterPtAttempts', defaultValue=5000,
                             validator=IntBoundedValidator(0),
                             doc='Maximum number of tries made to generate a scattering point')
        self.declareProperty(name='SparseInstrument', defaultValue=False,
                             doc='Whether to spatially approximate the instrument for faster calculation.')
        self.declareProperty(name='NumberOfDetectorRows', defaultValue=3,
                             validator=IntBoundedValidator(lower=3),
                             doc='Number of detector rows in the detector grid of the sparse instrument.')
        self.declareProperty(name='NumberOfDetectorColumns', defaultValue=2,
                             validator=IntBoundedValidator(lower=2),
                             doc='Number of detector columns in the detector grid of the sparse instrument.')

        sparse_condition = EnabledWhenProperty('SparseInstrument', PropertyCriterion.IsNotDefault)
        self.setPropertySettings('NumberOfDetectorRows', sparse_condition)
        self.setPropertySettings('NumberOfDetectorColumns', sparse_condition)

        self.setPropertyGroup('SparseInstrument', 'Monte Carlo Options')
        self.setPropertyGroup('NumberOfDetectorRows', 'Monte Carlo Options')
        self.setPropertyGroup('NumberOfDetectorColumns', 'Monte Carlo Options')
        self.setPropertyGroup('EventsPerPoint', 'Monte Carlo Options')
        self.setPropertyGroup('Interpolation', 'Monte Carlo Options')
        self.setPropertyGroup('MaxScatterPtAttempts', 'Monte Carlo Options')

        # Beam Options
        self.declareProperty(name='BeamHeight', defaultValue=1.0,
                             validator=FloatBoundedValidator(0.0),
                             doc='Height of the beam (cm)')
        self.declareProperty(name='BeamWidth', defaultValue=1.0,
                             validator=FloatBoundedValidator(0.0),
                             doc='Width of the beam (cm)')

        self.setPropertyGroup('BeamHeight', 'Beam Options')
        self.setPropertyGroup('BeamWidth', 'Beam Options')

        # Shape Options
        self.declareProperty(name='Shape', defaultValue='Preset',
                             validator=StringListValidator(['Preset', 'FlatPlate', 'Cylinder', 'Annulus']),
                             doc='Geometric shape of the sample environment')

        not_preset_condition = EnabledWhenProperty('Shape', PropertyCriterion.IsNotEqualTo, 'Preset')
        flat_plate_condition = VisibleWhenProperty('Shape', PropertyCriterion.IsEqualTo, 'FlatPlate')
        cylinder_condition = VisibleWhenProperty('Shape', PropertyCriterion.IsEqualTo, 'Cylinder')
        annulus_condition = VisibleWhenProperty('Shape', PropertyCriterion.IsEqualTo, 'Annulus')

        # show flat plate as visible but disabled if preset shape chosen, to avoid empty group on alg dialogue
        preset_condition = VisibleWhenProperty('Shape', PropertyCriterion.IsEqualTo, 'Preset')
        flat_plate_visible = VisibleWhenProperty(preset_condition, flat_plate_condition, LogicOperator.Or)

        # height is common to all shapes, and should be the same for sample and container
        self.declareProperty('Height', defaultValue=0.0, validator=FloatBoundedValidator(0.0),
                             doc='Height of the sample environment (cm)')
        self.setPropertySettings('Height', not_preset_condition)

        self.setPropertyGroup('Shape', 'Shape Options')
        self.setPropertyGroup('Height', 'Shape Options')

        # Sample Shape
        # Flat Plate
        self.declareProperty(name='SampleWidth', defaultValue=0.0,
                             validator=FloatBoundedValidator(0.0),
                             doc='Width of the sample environment (cm)')
        self.declareProperty(name='SampleThickness', defaultValue=0.0,
                             validator=FloatBoundedValidator(0.0),
                             doc='Thickness of the sample environment (cm)')
        self.declareProperty(name='SampleCenter', defaultValue=0.0,
                             doc='Center of the sample environment')
        self.declareProperty(name='SampleAngle', defaultValue=0.0,
                             validator=FloatBoundedValidator(-180.0, 180.0),
                             doc='Angle of the sample environment with respect to the beam (degrees)')

        self.setPropertySettings('SampleWidth', flat_plate_visible)
        self.setPropertySettings('SampleThickness', flat_plate_visible)
        self.setPropertySettings('SampleCenter', flat_plate_visible)
        self.setPropertySettings('SampleAngle', flat_plate_visible)
        self.setPropertySettings('SampleWidth', not_preset_condition)
        self.setPropertySettings('SampleThickness', not_preset_condition)
        self.setPropertySettings('SampleCenter', not_preset_condition)
        self.setPropertySettings('SampleAngle', not_preset_condition)

        self.setPropertyGroup('SampleWidth', 'Sample Shape')
        self.setPropertyGroup('SampleThickness', 'Sample Shape')
        self.setPropertyGroup('SampleCenter', 'Sample Shape')
        self.setPropertyGroup('SampleAngle', 'Sample Shape')

        # Cylinder
        self.declareProperty(name='SampleRadius', defaultValue=0.0,
                             validator=FloatBoundedValidator(0.0),
                             doc='Radius of the sample environment (cm)')

        self.setPropertySettings('SampleRadius', cylinder_condition)
        self.setPropertyGroup('SampleRadius', 'Sample Shape')

        # Annulus
        self.declareProperty(name='SampleInnerRadius', defaultValue=0.0,
                             validator=FloatBoundedValidator(0.0),
                             doc='Inner radius of the sample environment (cm)')
        self.declareProperty(name='SampleOuterRadius', defaultValue=0.0,
                             validator=FloatBoundedValidator(0.0),
                             doc='Outer radius of the sample environment (cm)')

        self.setPropertySettings('SampleInnerRadius', annulus_condition)
        self.setPropertySettings('SampleOuterRadius', annulus_condition)

        self.setPropertyGroup('SampleInnerRadius', 'Sample Shape')
        self.setPropertyGroup('SampleOuterRadius', 'Sample Shape')

        # Sample Material
        self.declareProperty(name='SampleChemicalFormula', defaultValue='',
                             doc='Chemical formula for the sample material')
        self.declareProperty(name='SampleCoherentXSection', defaultValue=0.0,
                             validator=FloatBoundedValidator(0.0),
                             doc='The coherent cross-section for the sample material in barns. To be used instead of '
                                 'Chemical Formula.')
        self.declareProperty(name='SampleIncoherentXSection', defaultValue=0.0,
                             validator=FloatBoundedValidator(0.0),
                             doc='The incoherent cross-section for the sample material in barns. To be used instead of '
                                 'Chemical Formula.')
        self.declareProperty(name='SampleAttenuationXSection', defaultValue=0.0,
                             validator=FloatBoundedValidator(0.0),
                             doc='The absorption cross-section for the sample material in barns. To be used instead of '
                                 'Chemical Formula.')
        self.declareProperty(name='SampleDensityType', defaultValue='Mass Density',
                             validator=StringListValidator(['Mass Density', 'Number Density']),
                             doc='Use of Mass density or Number density for the sample.')
        self.declareProperty(name='SampleNumberDensityUnit', defaultValue='Atoms',
                             validator=StringListValidator(['Atoms', 'Formula Units']),
                             doc='Choose which units SampleDensity refers to. Allowed values: [Atoms, Formula Units]')
        self.declareProperty(name='SampleDensity', defaultValue=0.0,
                             validator=FloatBoundedValidator(0.0),
                             doc='The value for the sample Mass density (g/cm^3) or Number density (1/Angstrom^3).')

        self.setPropertyGroup('SampleChemicalFormula', 'Sample Material')
        self.setPropertyGroup('SampleCoherentXSection', 'Sample Material')
        self.setPropertyGroup('SampleIncoherentXSection', 'Sample Material')
        self.setPropertyGroup('SampleAttenuationXSection', 'Sample Material')
        self.setPropertyGroup('SampleDensityType', 'Sample Material')
        self.setPropertyGroup('SampleNumberDensityUnit', 'Sample Material')
        self.setPropertyGroup('SampleDensity', 'Sample Material')

        # Flat Plate
        self.declareProperty(name='ContainerFrontThickness', defaultValue=0.0,
                             validator=FloatBoundedValidator(0.0),
                             doc='Front thickness of the container environment (cm)')
        self.declareProperty(name='ContainerBackThickness', defaultValue=0.0,
                             validator=FloatBoundedValidator(0.0),
                             doc='Back thickness of the container environment (cm)')

        self.setPropertySettings('ContainerFrontThickness', flat_plate_condition)
        self.setPropertySettings('ContainerBackThickness', flat_plate_condition)
        self.setPropertySettings('ContainerFrontThickness', not_preset_condition)
        self.setPropertySettings('ContainerBackThickness', not_preset_condition)
        self.setPropertyGroup('ContainerFrontThickness', 'Container Shape')
        self.setPropertyGroup('ContainerBackThickness', 'Container Shape')

        # Cylinder
        self.declareProperty(name='ContainerRadius', defaultValue=0.0,
                             validator=FloatBoundedValidator(0.0),
                             doc='Outer radius of the sample environment (cm)')

        self.setPropertySettings('ContainerRadius', cylinder_condition)
        self.setPropertyGroup('ContainerRadius', 'Container Shape')

        # Annulus
        self.declareProperty(name='ContainerInnerRadius', defaultValue=0.0,
                             validator=FloatBoundedValidator(0.0),
                             doc='Inner radius of the container environment (cm)')
        self.declareProperty(name='ContainerOuterRadius', defaultValue=0.0,
                             validator=FloatBoundedValidator(0.0),
                             doc='Outer radius of the container environment (cm)')

        self.setPropertySettings('ContainerInnerRadius', annulus_condition)
        self.setPropertySettings('ContainerOuterRadius', annulus_condition)

        self.setPropertyGroup('ContainerInnerRadius', 'Container Shape')
        self.setPropertyGroup('ContainerOuterRadius', 'Container Shape')

        # Container Material
        self.declareProperty(name='ContainerChemicalFormula', defaultValue='',
                             doc='Chemical formula for the container material')
        self.declareProperty(name='ContainerCoherentXSection', defaultValue=0.0,
                             validator=FloatBoundedValidator(0.0),
                             doc='The coherent cross-section for the can material in barns. To be used instead of '
                                 'Chemical Formula.')
        self.declareProperty(name='ContainerIncoherentXSection', defaultValue=0.0,
                             validator=FloatBoundedValidator(0.0),
                             doc='The incoherent cross-section for the can material in barns. To be used instead of '
                                 'Chemical Formula.')
        self.declareProperty(name='ContainerAttenuationXSection', defaultValue=0.0,
                             validator=FloatBoundedValidator(0.0),
                             doc='The absorption cross-section for the can material in barns. To be used instead of '
                                 'Chemical Formula.')
        self.declareProperty(name='ContainerDensityType', defaultValue='Mass Density',
                             validator=StringListValidator(['Mass Density', 'Number Density']),
                             doc='Use of Mass density or Number density for the container.')
        self.declareProperty(name='ContainerNumberDensityUnit', defaultValue='Atoms',
                             validator=StringListValidator(['Atoms', 'Formula Units']),
                             doc='Choose which units ContainerDensity refers to. Allowed values: [Atoms, Formula Units]')
        self.declareProperty(name='ContainerDensity', defaultValue=0.0,
                             validator=FloatBoundedValidator(0.0),
                             doc='The value for the container Mass density (g/cm^3) or Number density (1/Angstrom^3).')

        self.setPropertyGroup('ContainerChemicalFormula', 'Container Material')
        self.setPropertyGroup('ContainerCoherentXSection', 'Container Material')
        self.setPropertyGroup('ContainerIncoherentXSection', 'Container Material')
        self.setPropertyGroup('ContainerAttenuationXSection', 'Container Material')
        self.setPropertyGroup('ContainerDensityType', 'Container Material')
        self.setPropertyGroup('ContainerNumberDensityUnit', 'Container Material')
        self.setPropertyGroup('ContainerDensity', 'Container Material')
        self.setPropertySettings('ContainerChemicalFormula', not_preset_condition)
        self.setPropertySettings('ContainerCoherentXSection', not_preset_condition)
        self.setPropertySettings('ContainerIncoherentXSection', not_preset_condition)
        self.setPropertySettings('ContainerAttenuationXSection', not_preset_condition)
        self.setPropertySettings('ContainerDensityType', not_preset_condition)
        self.setPropertySettings('ContainerNumberDensityUnit', not_preset_condition)
        self.setPropertySettings('ContainerDensity', not_preset_condition)

        # Output Workspace Group
        self.declareProperty(WorkspaceGroupProperty(name='CorrectionsWorkspace',
                                                    defaultValue='corrections',
                                                    direction=Direction.Output,
                                                    optional=PropertyMode.Optional),
                             doc='Name of the workspace group to save correction factors')
Exemplo n.º 21
0
    def PyInit(self):
        self.declareProperty(
            IMDHistoWorkspaceProperty("InputWorkspace",
                                      "",
                                      optional=PropertyMode.Mandatory,
                                      direction=Direction.Input),
            "Input Workspace with HKL dimensions centered on zero.")
        self.declareProperty(
            WorkspaceProperty("IntermediateWorkspace",
                              "",
                              optional=PropertyMode.Optional,
                              direction=Direction.Output),
            "The resulting workspace after reflection removal and filters applied. What is the input of the FFT."
        )
        self.declareProperty(
            WorkspaceProperty("OutputWorkspace",
                              "",
                              optional=PropertyMode.Mandatory,
                              direction=Direction.Output), "Output Workspace")

        self.declareProperty(
            "Method", 'KAREN',
            StringListValidator(['None', 'Punch and fill', 'KAREN']),
            "Bragg peak removal method")
        self.declareProperty(
            "WindowFunction", 'Blackman',
            StringListValidator(
                ['None', 'Gaussian', 'Blackman', 'Tukey', 'Kaiser']),
            "Apply a window function to the data")
        self.declareProperty(
            "WindowParameter",
            defaultValue=0.5,
            validator=FloatBoundedValidator(0.),
            doc=
            "Parameter for window function, depends on window type, see algorithm docs"
        )

        # Punch and fill
        condition = EnabledWhenProperty("Method", PropertyCriterion.IsEqualTo,
                                        'Punch and fill')
        self.declareProperty("Shape",
                             "sphere",
                             doc="Shape to punch out reflections",
                             validator=StringListValidator(['sphere', 'cube']))
        self.setPropertySettings("Shape", condition)
        val_min_zero = FloatArrayBoundedValidator(lower=0.)
        self.declareProperty(
            FloatArrayProperty("Size", [0.2], validator=val_min_zero),
            "Width of cube/diameter of sphere used to remove reflections, in (HKL) (one or three values)"
        )
        self.setPropertySettings("Size", condition)
        self.declareProperty(
            "SpaceGroup",
            "",
            doc=
            "Space group for reflection removal, either full name or number. If empty all HKL's will be removed."
        )
        self.setPropertySettings("SpaceGroup", condition)
        self.declareProperty(
            "Convolution", True,
            "Apply convolution to fill in removed reflections")
        self.setPropertySettings("Convolution", condition)
        self.declareProperty("ConvolutionWidth",
                             2.0,
                             validator=FloatBoundedValidator(0.),
                             doc="Width of gaussian convolution in pixels")
        self.setPropertySettings("ConvolutionWidth", condition)

        self.declareProperty(
            "CropSphere", False,
            "Limit min/max q values. Can help with edge effects.")
        condition = EnabledWhenProperty("CropSphere",
                                        PropertyCriterion.IsNotDefault)
        self.declareProperty(
            FloatArrayProperty("SphereMin", [Property.EMPTY_DBL],
                               validator=val_min_zero),
            "HKL values below which will be removed (one or three values)")
        self.setPropertySettings("SphereMin", condition)
        self.declareProperty(
            FloatArrayProperty("SphereMax", [Property.EMPTY_DBL],
                               validator=val_min_zero),
            "HKL values above which will be removed (one or three values)")
        self.setPropertySettings("SphereMax", condition)
        self.declareProperty("FillValue", Property.EMPTY_DBL,
                             "Value to replace with outside sphere")
        self.setPropertySettings("FillValue", condition)

        # KAREN
        self.declareProperty("KARENWidth", 7, "Size of filter window")

        # Reflections
        self.setPropertyGroup("Shape", "Punch and fill")
        self.setPropertyGroup("Size", "Punch and fill")
        self.setPropertyGroup("SpaceGroup", "Punch and fill")

        # Sphere
        self.setPropertyGroup("CropSphere", "Cropping to a sphere")
        self.setPropertyGroup("SphereMin", "Cropping to a sphere")
        self.setPropertyGroup("SphereMax", "Cropping to a sphere")
        self.setPropertyGroup("FillValue", "Cropping to a sphere")

        # Convolution
        self.setPropertyGroup("Convolution", "Convolution")
        self.setPropertyGroup("ConvolutionWidth", "Convolution")
Exemplo n.º 22
0
 def PyInit(self):
     # Input file
     self.declareProperty(WorkspaceProperty('Workspace',
                                            '',
                                            direction=Direction.Input),
                          doc='Workspace that should be used.')
     # Output File
     self.declareProperty(FileProperty('OutputFile',
                                       '',
                                       action=FileAction.Save,
                                       direction=Direction.Input),
                          doc='Output File for ".p2d" Data.')
     # Manipulating Data ranges
     self.declareProperty(
         'RemoveNaN',
         True,
         direction=Direction.Input,
         doc='Remove DataPoints with NaN as intensity value')
     self.declareProperty(
         'RemoveNegatives',
         True,
         direction=Direction.Input,
         doc='Remove data points with negative intensity values')
     self.declareProperty(
         'CutData',
         False,
         direction=Direction.Input,
         doc=
         'Use the following inputs to limit data in Theta, lambda, d and dp'
     )
     self.declareProperty('TthMin',
                          50,
                          direction=Direction.Input,
                          doc='Minimum for tth values')
     self.declareProperty('TthMax',
                          120,
                          direction=Direction.Input,
                          doc='Maximum  for tth values')
     self.declareProperty('LambdaMin',
                          0.3,
                          direction=Direction.Input,
                          doc='Minimum  for lambda values')
     self.declareProperty('LambdaMax',
                          1.1,
                          direction=Direction.Input,
                          doc='Maximum  for lambda values')
     self.declareProperty('DMin',
                          0.11,
                          direction=Direction.Input,
                          doc='Minimum  for d values')
     self.declareProperty('DMax',
                          1.37,
                          direction=Direction.Input,
                          doc='Maximum  for d values')
     self.declareProperty('DpMin',
                          0.48,
                          direction=Direction.Input,
                          doc='Minimum  for dp values')
     self.declareProperty('DpMax',
                          1.76,
                          direction=Direction.Input,
                          doc='Maximum  for dp values')
Exemplo n.º 23
0
    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")

        # 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("OutputAsMDEventWorkspace", defaultValue=True, direction=Direction.Input,
                             doc="Whether to use ConvertHFIRSCDtoQ for an MDEvent, or ConvertWANDSCDtoQ for an MDHisto")

        # 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))

        event_settings = EnabledWhenProperty('OutputAsMDEventWorkspace', PropertyCriterion.IsDefault)
        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('OutputAsMDEventWorkspace', PropertyCriterion.IsNotDefault)
        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.")
Exemplo n.º 24
0
    def PyInit(self):
        #
        # Properties
        #
        self.declareProperty('RunNumbers', '', 'Sample run numbers')

        #
        #  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)
        flux_normalization_types = ['Monitor', 'Proton Charge', 'Duration']
        default_flux_normalization = flux_normalization_types[0]
        self.declareProperty('FluxNormalizationType',
                             default_flux_normalization,
                             StringListValidator(flux_normalization_types),
                             'Flux Normalization Type')
        self.setPropertySettings('FluxNormalizationType',
                                 if_flux_normalization)
        self.setPropertyGroup('FluxNormalizationType',
                              title_flux_normalization)

        self.declareProperty(FloatArrayProperty('MomentumTransferBins',
                                                [0.1, 0.0025, 2.5],  # invers A
                                                direction=Direction.Input),
                             'Momentum transfer binning scheme')

        self.declareProperty(WorkspaceProperty('OutputWorkspace', '',
                                               optional=PropertyMode.Mandatory,
                                               direction=Direction.Output),
                             doc='Output reduced workspace')

        self.declareProperty(FileProperty(name='MaskFile',
                                          defaultValue=self._mask_file,
                                          action=FileAction.OptionalLoad,
                                          extensions=['.xml']),
                             doc='See documentation for latest mask files.')
        #
        # 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)
        self.declareProperty(WorkspaceProperty('OutputBackground', '',
                                               optional=PropertyMode.Optional,
                                               direction=Direction.Output),
                             doc='Reduced workspace for background runs')
        self.setPropertyGroup('OutputBackground', background_title)
        #
        # Vanadium
        #
        vanadium_title = 'Vanadium runs'
        self.declareProperty('VanadiumRuns', '', 'Vanadium run numbers')
        self.setPropertyGroup('VanadiumRuns', vanadium_title)