Пример #1
0
    def PyInit(self):
        self.declareProperty(IMDEventWorkspaceProperty("InputWorkspace", defaultValue="",
                                                       optional=PropertyMode.Mandatory,
                                                       direction=Direction.Input),
                             doc="Input MDEvent workspace to convert to a MDHisto in HKL")

        self.declareProperty(IPeaksWorkspaceProperty("PeaksWorkspace", defaultValue="", optional=PropertyMode.Optional,
                                                     direction=Direction.Input),
                             doc="Optional peaks workspace to retrieve the UB matrix from, instead of InputWorkspace.")

        self.declareProperty(FloatArrayProperty("Uproj", [1, 0, 0], validator=FloatArrayLengthValidator(3),
                                                direction=Direction.Input),
                             doc="Defines the first projection vector of the target Q coordinate system in HKL mode")
        self.declareProperty(FloatArrayProperty("Vproj", [0, 1, 0], validator=FloatArrayLengthValidator(3),
                                                direction=Direction.Input),
                             doc="Defines the second projection vector of the target Q coordinate system in HKL mode")
        self.declareProperty(FloatArrayProperty("Wproj", [0, 0, 1], validator=FloatArrayLengthValidator(3),
                                                direction=Direction.Input),
                             doc="Defines the third projection vector of the target Q coordinate system in HKL mode")

        self.declareProperty(FloatArrayProperty("Extents", [-6.02, 6.02, -6.02, 6.02, -6.02, 6.02],
                                                direction=Direction.Input),
                             "Binning parameters for each dimension. Enter it as a"
                             "comma-separated list of values with the"
                             "format: 'minimum,maximum,'.")

        self.declareProperty(IntArrayProperty("Bins", [301, 301, 301],
                                              direction=Direction.Input),
                             "Number of bins to use for each dimension, Enter it as a"
                             "comma-separated list of integers.")

        self.declareProperty(IMDHistoWorkspaceProperty("OutputWorkspace", "",
                                                       optional=PropertyMode.Mandatory,
                                                       direction=Direction.Output),
                             doc="Output MDWorkspace in Q-space, name is prefix if multiple input files were provided.")
Пример #2
0
    def PyInit(self):
        # Input workspace/data info (filename or IPTS+RunNumber)
        # Priority: Filename > IPTS + RunNumber
        self.declareProperty(
            MultipleFileProperty(name="Filename",
                                 action=FileAction.OptionalLoad,
                                 extensions=[".nxs.h5"]), "Files to load")
        self.declareProperty('IPTS', Property.EMPTY_INT,
                             "IPTS number to load from")
        self.declareProperty(IntArrayProperty("RunNumbers", []),
                             'Run numbers to load')

        # Normalization info (optional, skip normalization if not specified)
        # Priority: IPTS + RunNumber > Filename >  NormalizationFile
        # NOTE:
        #   The current convention for loading Vanadium data is by IPTS+RunNumber, so this is the default\
        # -- default
        self.declareProperty('VanadiumIPTS', Property.EMPTY_INT,
                             "IPTS number to load Vanadium normalization")
        self.declareProperty('VanadiumRunNumber', Property.EMPTY_INT,
                             "Run number to load Vanadium normalization")
        # -- alternative
        self.declareProperty(FileProperty(name="VanadiumFile",
                                          defaultValue="",
                                          extensions=[".nxs"],
                                          direction=Direction.Input,
                                          action=FileAction.OptionalLoad),
                             doc="File with Vanadium normalization scan data")
        # alternative
        self.declareProperty(
            IMDHistoWorkspaceProperty("VanadiumWorkspace",
                                      defaultValue="",
                                      direction=Direction.Input,
                                      optional=PropertyMode.Optional),
            doc="MDHisto workspace containing vanadium normalization data")
        # normalization method
        self.declareProperty(
            "NormalizedBy", 'None',
            StringListValidator(['None', 'Counts', 'Monitor', 'Time']),
            "Normalize to Counts, Monitor, Time.")
        # group normalization properties
        self.setPropertyGroup('VanadiumIPTS', 'Normalization')
        self.setPropertyGroup('VanadiumRunNumber', 'Normalization')
        self.setPropertyGroup('VanadiumFile', 'Normalization')
        self.setPropertyGroup('VanadiumWorkspace', 'Normalization')
        self.setPropertyGroup('NormalizedBy', 'Normalization')

        # Grouping info
        self.declareProperty(
            "Grouping", 'None', StringListValidator(['None', '2x2', '4x4']),
            "Group pixels (shared by input and normalization)")

        # Output workspace/data info
        self.declareProperty(
            WorkspaceProperty("OutputWorkspace",
                              "",
                              optional=PropertyMode.Mandatory,
                              direction=Direction.Output), "Output Workspace")
Пример #3
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")
Пример #4
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(
         WorkspaceProperty("OutputWorkspace",
                           "",
                           optional=PropertyMode.Mandatory,
                           direction=Direction.Output), "Output Workspace")
Пример #5
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("RemoveReflections", True,
                             "Remove HKL reflections")
        condition = EnabledWhenProperty("RemoveReflections",
                                        PropertyCriterion.IsDefault)
        self.declareProperty("Shape",
                             "sphere",
                             doc="Shape to cut out reflections",
                             validator=StringListValidator(['sphere', 'cube']))
        self.setPropertySettings("Shape", condition)
        val_min_zero = FloatArrayBoundedValidator()
        val_min_zero.setLower(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(
            "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)

        self.declareProperty(
            "Convolution", True,
            "Apply convolution to fill in removed reflections")
        condition = EnabledWhenProperty("Convolution",
                                        PropertyCriterion.IsDefault)
        self.declareProperty("ConvolutionWidth",
                             2.0,
                             validator=FloatBoundedValidator(0.),
                             doc="Width of gaussian convolution in pixels")
        self.setPropertySettings("ConvolutionWidth", condition)
        self.declareProperty("Deconvolution", False,
                             "Apply deconvolution after fourier transform")
        self.setPropertySettings("Deconvolution", condition)

        # Reflections
        self.setPropertyGroup("RemoveReflections", "Reflection Removal")
        self.setPropertyGroup("Shape", "Reflection Removal")
        self.setPropertyGroup("Size", "Reflection Removal")
        self.setPropertyGroup("SpaceGroup", "Reflection Removal")

        # 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")
        self.setPropertyGroup("Deconvolution", "Convolution")
Пример #6
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")

        self.declareProperty('NormaliseBy', 'Time',
                             StringListValidator(['None', 'Time', 'Monitor']),
                             "Normalise to monitor, time or None.")

        # Alternative WS inputs
        self.declareProperty(
            "InputWorkspaces",
            defaultValue="",
            direction=Direction.Input,
            doc=
            "Workspace or comma-separated workspace list containing input MDHisto scan data."
        )
        self.declareProperty(
            IMDHistoWorkspaceProperty("VanadiumWorkspace",
                                      defaultValue="",
                                      direction=Direction.Input,
                                      optional=PropertyMode.Optional),
            doc="MDHisto workspace containing vanadium normalization data")

        # Detector adjustment options
        self.declareProperty(
            "DetectorHeightOffset",
            defaultValue=0.0,
            direction=Direction.Input,
            doc=
            "Optional distance (in meters) to move detector height (relative to current position)"
        )
        self.declareProperty(
            "DetectorDistanceOffset",
            defaultValue=0.0,
            direction=Direction.Input,
            doc=
            "Optional distance (in meters) to move detector distance (relative to current position)"
        )

        self.declareProperty(
            FloatPropertyWithValue(
                "Wavelength",  # EMPTY_DBL so it shows as blank in GUI
                FloatPropertyWithValue.EMPTY_DBL),
            doc=
            "Optional wavelength value to use as backup if one was not found in the sample log"
        )

        # Which conversion algorithm to use
        self.declareProperty(
            "OutputType",
            "Q-sample events",
            StringListValidator(
                ['Q-sample events', 'Q-sample histogram', 'Detector']),
            direction=Direction.Input,
            doc=
            "Whether to use ConvertHFIRSCDtoQ for an MDEvent, or ConvertWANDSCDtoQ for an MDHisto"
        )

        self.declareProperty(
            "ScaleByMotorStep", False,
            "If True then the intensity of the output in Q space will be scaled by the motor step size. "
            "This will allow directly comparing the intensity of data measure with diffrent motor step sizes."
        )

        # MDEvent WS Specific options for ConvertHFIRSCDtoQ
        self.declareProperty(
            FloatArrayProperty("MinValues", [-10, -10, -10],
                               FloatArrayLengthValidator(3),
                               direction=Direction.Input),
            doc="3 comma separated values, one for each q_sample dimension")
        self.declareProperty(
            FloatArrayProperty("MaxValues", [10, 10, 10],
                               FloatArrayLengthValidator(3),
                               direction=Direction.Input),
            doc=
            "3 comma separated values, one for each q_sample dimension; must be larger than"
            "those specified in MinValues")
        self.declareProperty(
            "MergeInputs",
            defaultValue=False,
            direction=Direction.Input,
            doc=
            "If all inputs should be merged into one MDEvent output workspace")

        # MDHisto WS Specific options for ConvertWANDSCDtoQ
        self.declareProperty(
            FloatArrayProperty("BinningDim0", [-8.02, 8.02, 401],
                               FloatArrayLengthValidator(3),
                               direction=Direction.Input),
            "Binning parameters for the 0th dimension. Enter it as a"
            "comma-separated list of values with the"
            "format: 'minimum,maximum,number_of_bins'.")
        self.declareProperty(
            FloatArrayProperty("BinningDim1", [-2.52, 2.52, 126],
                               FloatArrayLengthValidator(3),
                               direction=Direction.Input),
            "Binning parameters for the 1st dimension. Enter it as a"
            "comma-separated list of values with the"
            "format: 'minimum,maximum,number_of_bins'.")
        self.declareProperty(
            FloatArrayProperty("BinningDim2", [-8.02, 8.02, 401],
                               FloatArrayLengthValidator(3),
                               direction=Direction.Input),
            "Binning parameters for the 2nd dimension. Enter it as a"
            "comma-separated list of values with the"
            "format: 'minimum,maximum,number_of_bins'.")

        self.setPropertySettings(
            "Filename",
            EnabledWhenProperty('InputWorkspaces',
                                PropertyCriterion.IsDefault))
        self.setPropertySettings(
            "VanadiumFile",
            EnabledWhenProperty('VanadiumWorkspace',
                                PropertyCriterion.IsDefault))
        self.setPropertySettings(
            "InputWorkspaces",
            EnabledWhenProperty('Filename', PropertyCriterion.IsDefault))
        self.setPropertySettings(
            "VanadiumWorkspace",
            EnabledWhenProperty('VanadiumFile', PropertyCriterion.IsDefault))

        self.setPropertySettings(
            "ScaleByMotorStep",
            EnabledWhenProperty('OutputType', PropertyCriterion.IsNotEqualTo,
                                "Detector"))

        event_settings = EnabledWhenProperty('OutputType',
                                             PropertyCriterion.IsEqualTo,
                                             'Q-sample events')
        self.setPropertyGroup("MinValues", "MDEvent Settings")
        self.setPropertyGroup("MaxValues", "MDEvent Settings")
        self.setPropertyGroup("MergeInputs", "MDEvent Settings")
        self.setPropertySettings("MinValues", event_settings)
        self.setPropertySettings("MaxValues", event_settings)
        self.setPropertySettings("MergeInputs", event_settings)

        histo_settings = EnabledWhenProperty('OutputType',
                                             PropertyCriterion.IsEqualTo,
                                             'Q-sample histogram')
        self.setPropertyGroup("BinningDim0", "MDHisto Settings")
        self.setPropertyGroup("BinningDim1", "MDHisto Settings")
        self.setPropertyGroup("BinningDim2", "MDHisto Settings")
        self.setPropertySettings("BinningDim0", histo_settings)
        self.setPropertySettings("BinningDim1", histo_settings)
        self.setPropertySettings("BinningDim2", histo_settings)

        self.declareProperty(
            WorkspaceProperty("OutputWorkspace",
                              "",
                              optional=PropertyMode.Mandatory,
                              direction=Direction.Output),
            doc=
            "Output MDWorkspace in Q-space, name is prefix if multiple input files were provided."
        )