def from_setup_info(self, xml_str):
        """
            Read in data from XML using the string representation of the setup algorithm used
            to prepare the reduction properties.
            @param xml_str: text to read the data from
        """
        self.reset()
        from mantid.api import Algorithm
        dom = xml.dom.minidom.parseString(xml_str)

        process_dom = dom.getElementsByTagName("SASProcess")[0]
        setup_alg_str = BaseScriptElement.getStringElement(process_dom, 'SetupInfo')
        alg=Algorithm.fromString(str(setup_alg_str))

        self.background_file = BaseScriptElement.getPropertyValue(alg, "BackgroundFiles", default='')
        self.background_corr = len(self.background_file)>0
        self.bck_transmission_enabled = True
        trans_method = BaseScriptElement.getPropertyValue(alg, "BckTransmissionMethod", default='Value')

        # Transmission
        self.bck_transmission = BaseScriptElement.getPropertyValue(alg, "BckTransmissionValue", default=SampleData.transmission)
        self.bck_transmission_spread = BaseScriptElement.getPropertyValue(alg, "BckTransmissionError", default=SampleData.transmission_spread)

        self.trans_dark_current = BaseScriptElement.getPropertyValue(alg, "BckTransmissionDarkCurrentFile", default='')
        self.theta_dependent = BaseScriptElement.getPropertyValue(alg, "BckThetaDependentTransmission",
                                                                  default = SampleData.theta_dependent)

        self.calculate_transmission = trans_method in ['DirectBeam', 'BeamSpreader']
        if trans_method=='DirectBeam':
            self.trans_calculation_method = Background.DirectBeam()
            self.trans_calculation_method.from_setup_info(xml_str)
        elif trans_method=='BeamSpreader':
            self.trans_calculation_method = Background.BeamSpreader()
            self.trans_calculation_method.from_setup_info(xml_str)
Example #2
0
    def from_setup_info(self, xml_str):
        """
            Read in data from XML using the string representation of the setup algorithm used
            to prepare the reduction properties.
            @param xml_str: text to read the data from
        """
        self.reset()
        from mantid.api import Algorithm
        dom = xml.dom.minidom.parseString(xml_str)

        process_dom = dom.getElementsByTagName("SASProcess")[0]
        setup_alg_str = BaseScriptElement.getStringElement(process_dom, 'SetupInfo')
        alg=Algorithm.fromString(str(setup_alg_str))

        # Transmission
        self.transmission = BaseScriptElement.getPropertyValue(alg, "TransmissionValue", default=SampleData.transmission)
        self.transmission_spread = BaseScriptElement.getPropertyValue(alg, "TransmissionError", default=SampleData.transmission_spread)
        self.dark_current = BaseScriptElement.getPropertyValue(alg, "TransmissionDarkCurrentFile", default='')
        self.theta_dependent = BaseScriptElement.getPropertyValue(alg, "ThetaDependentTransmission",
                                                                  default = SampleData.theta_dependent)
        self.sample_thickness = BaseScriptElement.getPropertyValue(alg, "SampleThickness",
                                                                   default = SampleData.sample_thickness)

        trans_method = BaseScriptElement.getPropertyValue(alg, "TransmissionMethod", default='Value')

        self.calculate_transmission = trans_method in ['DirectBeam', 'BeamSpreader']
        if trans_method=='DirectBeam':
            self.calculation_method = SampleData.DirectBeam()
            self.calculation_method.from_setup_info(xml_str)
        elif trans_method=='BeamSpreader':
            self.calculation_method = SampleData.BeamSpreader()
            self.calculation_method.from_setup_info(xml_str)

        # Data file section
        self.data_files = [BaseScriptElement.getStringElement(process_dom, 'Filename', '')]
Example #3
0
    def from_setup_info(self, xml_str):
        """
            Read in data from XML using the string representation of the setup algorithm used
            to prepare the reduction properties.
            @param xml_str: text to read the data from
        """
        self.reset()
        super(ReductionOptions, self).from_setup_info(xml_str)

        from mantid.api import Algorithm
        dom = xml.dom.minidom.parseString(xml_str)

        process_dom = dom.getElementsByTagName("SASProcess")[0]
        setup_alg_str = BaseScriptElement.getStringElement(process_dom, 'SetupInfo')
        alg=Algorithm.fromString(str(setup_alg_str))
        self.use_config_cutoff = BaseScriptElement.getPropertyValue(alg, "UseConfigTOFCuts",
                                                                    default=ReductionOptions.use_config_cutoff)
        self.correct_for_flight_path = BaseScriptElement.getPropertyValue(alg, "CorrectForFlightPath",
                                                                          default=ReductionOptions.correct_for_flight_path)
        self.low_TOF_cut = BaseScriptElement.getPropertyValue(alg, "LowTOFCut",
                                                              default=ReductionOptions.low_TOF_cut)
        self.high_TOF_cut = BaseScriptElement.getPropertyValue(alg, "HighTOFCut",
                                                               default=ReductionOptions.high_TOF_cut)
        self.use_config_mask = BaseScriptElement.getPropertyValue(alg, "UseConfigMask",
                                                                  default=ReductionOptions.use_config_mask)
        self.compute_resolution = BaseScriptElement.getPropertyValue(alg, "ComputeResolution",
                                                                     default=ReductionOptions.compute_resolution)
        self.sample_aperture_diameter = BaseScriptElement.getPropertyValue(alg, "SampleApertureDiameter",
                                                                           default=ReductionOptions.sample_aperture_diameter)
        self.perform_TOF_correction = not BaseScriptElement.getPropertyValue(alg, "SkipTOFCorrection",
                                                                             default=False)
        norm_option = BaseScriptElement.getPropertyValue(alg, "Normalisation", default = 'Monitor')
        self.use_beam_monitor = norm_option=='Monitor'
        self.beam_monitor_reference = BaseScriptElement.getPropertyValue(alg, "MonitorReferenceFile",
                                                                         default=ReductionOptions.beam_monitor_reference)
        def from_setup_info(self, xml_str):
            """
                Read in data from XML using the string representation of the setup algorithm used
                to prepare the reduction properties.
                @param xml_str: text to read the data from
            """
            self.reset()
            from mantid.api import Algorithm
            dom = xml.dom.minidom.parseString(xml_str)

            process_dom = dom.getElementsByTagName("SASProcess")[0]
            setup_alg_str = BaseScriptElement.getStringElement(
                process_dom, 'SetupInfo')
            alg = Algorithm.fromString(str(setup_alg_str))

            self.sample_scatt = BaseScriptElement.getPropertyValue(
                alg, "BckTransSampleScatteringFilename", default='')
            self.sample_spreader = BaseScriptElement.getPropertyValue(
                alg, "BckTransSampleSpreaderFilename", default='')
            self.direct_scatt = BaseScriptElement.getPropertyValue(
                alg, "BckTransDirectScatteringFilename", default='')
            self.direct_spreader = BaseScriptElement.getPropertyValue(
                alg, "BckTransDirectSpreaderFilename", default='')
            self.spreader_trans = BaseScriptElement.getPropertyValue(
                alg,
                "BckSpreaderTransmissionValue",
                default=SampleData.BeamSpreader.spreader_trans)
            self.spreader_trans_spread = BaseScriptElement.getPropertyValue(
                alg,
                "BckSpreaderTransmissionError",
                default=SampleData.BeamSpreader.spreader_trans_spread)
    def from_setup_info(self, xml_str):
        """
            Read in data from XML using the string representation of the setup algorithm used
            to prepare the reduction properties.
            @param xml_str: text to read the data from
        """
        self.reset()
        from mantid.api import Algorithm
        dom = xml.dom.minidom.parseString(xml_str)

        process_dom = dom.getElementsByTagName("SASProcess")[0]
        setup_alg_str = BaseScriptElement.getStringElement(
            process_dom, 'SetupInfo')
        alg = Algorithm.fromString(str(setup_alg_str))

        # Sensitivity correction
        self.sensitivity_data = BaseScriptElement.getPropertyValue(
            alg, "SensitivityFile", default='')
        self.sensitivity_corr = len(self.sensitivity_data) > 0
        self.sensitivity_dark = BaseScriptElement.getPropertyValue(
            alg, "SensitivityDarkCurrentFile", default='')
        self.use_sample_dark = BaseScriptElement.getPropertyValue(
            alg, "UseDefaultDC", default=Detector.use_sample_dark)
        self.min_sensitivity = BaseScriptElement.getPropertyValue(
            alg, "MinEfficiency", default=Detector.min_sensitivity)
        self.max_sensitivity = BaseScriptElement.getPropertyValue(
            alg, "MaxEfficiency", default=Detector.max_sensitivity)

        sensitivity_center_method = BaseScriptElement.getPropertyValue(
            alg, "SensitivityBeamCenterMethod", default='None')
        self.flood_use_finder = sensitivity_center_method in [
            'DirectBeam', 'Scattering'
        ]
        self.flood_use_direct_beam = sensitivity_center_method == 'DirectBeam'
        self.use_sample_beam_center = sensitivity_center_method == 'None'
        self.flood_x_position = BaseScriptElement.getPropertyValue(
            alg, "SensitivityBeamCenterX", default=Detector.flood_x_position)
        self.flood_y_position = BaseScriptElement.getPropertyValue(
            alg, "SensitivityBeamCenterY", default=Detector.flood_y_position)
        self.flood_beam_file = BaseScriptElement.getPropertyValue(
            alg, "SensitivityBeamCenterFile", default='')
        self.flood_beam_radius = BaseScriptElement.getPropertyValue(alg, "SensitivityBeamCenterRadius",\
                                                                   default=Detector.flood_beam_radius)

        # Beam center
        center_method = BaseScriptElement.getPropertyValue(alg,
                                                           "BeamCenterMethod",
                                                           default='None')
        self.use_finder = center_method in ['DirectBeam', 'Scattering']
        self.use_direct_beam = center_method == 'DirectBeam'
        self.x_position = BaseScriptElement.getPropertyValue(alg, "BeamCenterX",\
                                                                   default=Detector.x_position)
        self.y_position = BaseScriptElement.getPropertyValue(alg, "BeamCenterY",\
                                                                   default=Detector.y_position)
        self.beam_file = BaseScriptElement.getPropertyValue(alg,
                                                            "BeamCenterFile",
                                                            default='')
        self.beam_radius = BaseScriptElement.getPropertyValue(alg, "BeamRadius",\
                                                                    default=Detector.beam_radius)
Example #6
0
 def _process_setup_info(process_dom_):
     setup_alg_str = BaseScriptElement.getStringElement(
         process_dom_, 'SetupInfo', '')
     if len(setup_alg_str) == 0:
         return None
     filename = BaseScriptElement.getStringElement(
         process_dom_, 'Filename', '')
     return (Algorithm.fromString(str(setup_alg_str)), filename)
Example #7
0
    def from_setup_info(self, xml_str):
        """
            Read in data from XML using the string representation of the setup algorithm used
            to prepare the reduction properties.
            @param xml_str: text to read the data from
        """
        self.reset()
        from mantid.api import Algorithm
        dom = xml.dom.minidom.parseString(xml_str)

        process_dom = dom.getElementsByTagName("SASProcess")[0]
        setup_alg_str = BaseScriptElement.getStringElement(process_dom, 'SetupInfo')
        alg=Algorithm.fromString(str(setup_alg_str))

        # Sensitivity correction
        self.sensitivity_data = BaseScriptElement.getPropertyValue(alg, "SensitivityFile", default='')
        self.sensitivity_corr = len(self.sensitivity_data)>0
        self.sensitivity_dark = BaseScriptElement.getPropertyValue(alg, "SensitivityDarkCurrentFile", default='')
        self.use_sample_dark = BaseScriptElement.getPropertyValue(alg, "UseDefaultDC",
                                                                  default = Detector.use_sample_dark)
        self.min_sensitivity = BaseScriptElement.getPropertyValue(alg, "MinEfficiency",
                                                                  default=Detector.min_sensitivity)
        self.max_sensitivity = BaseScriptElement.getPropertyValue(alg, "MaxEfficiency",
                                                                  default=Detector.max_sensitivity)

        sensitivity_center_method = BaseScriptElement.getPropertyValue(alg, "SensitivityBeamCenterMethod",
                                                                       default='None')
        self.flood_use_finder = sensitivity_center_method in ['DirectBeam', 'Scattering']
        self.flood_use_direct_beam = sensitivity_center_method=='DirectBeam'
        self.use_sample_beam_center =  sensitivity_center_method=='None'
        self.flood_x_position = BaseScriptElement.getPropertyValue(alg, "SensitivityBeamCenterX",
                                                                   default=Detector.flood_x_position)
        self.flood_y_position = BaseScriptElement.getPropertyValue(alg, "SensitivityBeamCenterY",
                                                                   default=Detector.flood_y_position)
        self.flood_beam_file = BaseScriptElement.getPropertyValue(alg, "SensitivityBeamCenterFile", default='')
        self.flood_beam_radius = BaseScriptElement.getPropertyValue(alg, "SensitivityBeamCenterRadius",\
                                                                   default=Detector.flood_beam_radius)

        # Beam center
        center_method = BaseScriptElement.getPropertyValue(alg, "BeamCenterMethod", default='None')
        self.use_finder = center_method in ['DirectBeam', 'Scattering']
        self.use_direct_beam = center_method=='DirectBeam'
        self.x_position = BaseScriptElement.getPropertyValue(alg, "BeamCenterX",\
                                                                   default=Detector.x_position)
        self.y_position = BaseScriptElement.getPropertyValue(alg, "BeamCenterY",\
                                                                   default=Detector.y_position)
        self.beam_file = BaseScriptElement.getPropertyValue(alg, "BeamCenterFile", default='')
        self.beam_radius = BaseScriptElement.getPropertyValue(alg, "BeamRadius",\
                                                                    default=Detector.beam_radius)
    def from_setup_info(self, xml_str):
        """
            Read in data from XML using the string representation of the setup algorithm used
            to prepare the reduction properties.
            @param xml_str: text to read the data from
        """
        self.reset()
        super(ReductionOptions, self).from_setup_info(xml_str)

        from mantid.api import Algorithm
        dom = xml.dom.minidom.parseString(xml_str)

        process_dom = dom.getElementsByTagName("SASProcess")[0]
        setup_alg_str = BaseScriptElement.getStringElement(
            process_dom, 'SetupInfo')
        alg = Algorithm.fromString(str(setup_alg_str))
        self.use_config_cutoff = BaseScriptElement.getPropertyValue(
            alg,
            "UseConfigTOFCuts",
            default=ReductionOptions.use_config_cutoff)
        self.correct_for_flight_path = BaseScriptElement.getPropertyValue(
            alg,
            "CorrectForFlightPath",
            default=ReductionOptions.correct_for_flight_path)
        self.low_TOF_cut = BaseScriptElement.getPropertyValue(
            alg, "LowTOFCut", default=ReductionOptions.low_TOF_cut)
        self.high_TOF_cut = BaseScriptElement.getPropertyValue(
            alg, "HighTOFCut", default=ReductionOptions.high_TOF_cut)
        self.use_config_mask = BaseScriptElement.getPropertyValue(
            alg, "UseConfigMask", default=ReductionOptions.use_config_mask)
        self.compute_resolution = BaseScriptElement.getPropertyValue(
            alg,
            "ComputeResolution",
            default=ReductionOptions.compute_resolution)
        self.sample_aperture_diameter = BaseScriptElement.getPropertyValue(
            alg,
            "SampleApertureDiameter",
            default=ReductionOptions.sample_aperture_diameter)
        self.perform_TOF_correction = not BaseScriptElement.getPropertyValue(
            alg, "SkipTOFCorrection", default=False)
        norm_option = BaseScriptElement.getPropertyValue(alg,
                                                         "Normalisation",
                                                         default='Monitor')
        self.use_beam_monitor = norm_option == 'Monitor'
        self.beam_monitor_reference = BaseScriptElement.getPropertyValue(
            alg,
            "MonitorReferenceFile",
            default=ReductionOptions.beam_monitor_reference)
    def from_setup_info(self, xml_str):
        """
            Read in data from XML using the string representation of the setup algorithm used
            to prepare the reduction properties.
            @param xml_str: text to read the data from
        """
        self.reset()
        super(SampleData, self).from_setup_info(xml_str)

        from mantid.api import Algorithm
        dom = xml.dom.minidom.parseString(xml_str)

        process_dom = dom.getElementsByTagName("SASProcess")[0]
        setup_alg_str = BaseScriptElement.getStringElement(process_dom, 'SetupInfo')
        alg=Algorithm.fromString(str(setup_alg_str))
        self.combine_transmission_frames = BaseScriptElement.getPropertyValue(alg, "FitFramesTogether",
                                                                              default=SampleData.combine_transmission_frames)
        def from_setup_info(self, xml_str):
            """
                Read in data from XML using the string representation of the setup algorithm used
                to prepare the reduction properties.
                @param xml_str: text to read the data from
            """
            self.reset()
            from mantid.api import Algorithm
            dom = xml.dom.minidom.parseString(xml_str)

            process_dom = dom.getElementsByTagName("SASProcess")[0]
            setup_alg_str = BaseScriptElement.getStringElement(process_dom, 'SetupInfo')
            alg=Algorithm.fromString(str(setup_alg_str))

            self.sample_file = BaseScriptElement.getPropertyValue(alg, "BckTransmissionSampleDataFile", default='')
            self.direct_beam = BaseScriptElement.getPropertyValue(alg, "BckTransmissionEmptyDataFile", default='')
            self.beam_radius = BaseScriptElement.getPropertyValue(alg, "BckTransmissionBeamRadius",
                                                                  default=SampleData.DirectBeam.beam_radius)
Example #11
0
        def from_setup_info(self, xml_str):
            """
                Read in data from XML using the string representation of the setup algorithm used
                to prepare the reduction properties.
                @param xml_str: text to read the data from
            """
            self.reset()
            from mantid.api import Algorithm
            dom = xml.dom.minidom.parseString(xml_str)

            process_dom = dom.getElementsByTagName("SASProcess")[0]
            setup_alg_str = BaseScriptElement.getStringElement(process_dom, 'SetupInfo')
            alg=Algorithm.fromString(str(setup_alg_str))

            self.sample_file = BaseScriptElement.getPropertyValue(alg, "TransmissionSampleDataFile", default='')
            self.direct_beam = BaseScriptElement.getPropertyValue(alg, "TransmissionEmptyDataFile", default='')
            self.beam_radius = BaseScriptElement.getPropertyValue(alg, "TransmissionBeamRadius",
                                                                  default=SampleData.DirectBeam.beam_radius)
Example #12
0
    def from_setup_info(self, xml_str):
        """
            Read in data from XML using the string representation of the setup algorithm used
            to prepare the reduction properties.
            @param xml_str: text to read the data from
        """
        self.reset()
        super(Background, self).from_setup_info(xml_str)

        from mantid.api import Algorithm
        dom = xml.dom.minidom.parseString(xml_str)

        process_dom = dom.getElementsByTagName("SASProcess")[0]
        setup_alg_str = BaseScriptElement.getStringElement(
            process_dom, 'SetupInfo')
        alg = Algorithm.fromString(str(setup_alg_str))
        self.combine_transmission_frames = BaseScriptElement.getPropertyValue(
            alg,
            "BckFitFramesTogether",
            default=SampleData.combine_transmission_frames)
        def from_setup_info(self, xml_str):
            """
                Read in data from XML using the string representation of the setup algorithm used
                to prepare the reduction properties.
                @param xml_str: text to read the data from
            """
            self.reset()
            from mantid.api import Algorithm
            dom = xml.dom.minidom.parseString(xml_str)

            process_dom = dom.getElementsByTagName("SASProcess")[0]
            setup_alg_str = BaseScriptElement.getStringElement(process_dom, 'SetupInfo')
            alg=Algorithm.fromString(str(setup_alg_str))

            self.sample_scatt = BaseScriptElement.getPropertyValue(alg, "BckTransSampleScatteringFilename", default='')
            self.sample_spreader = BaseScriptElement.getPropertyValue(alg, "BckTransSampleSpreaderFilename", default='')
            self.direct_scatt = BaseScriptElement.getPropertyValue(alg, "BckTransDirectScatteringFilename", default='')
            self.direct_spreader = BaseScriptElement.getPropertyValue(alg, "BckTransDirectSpreaderFilename", default='')
            self.spreader_trans = BaseScriptElement.getPropertyValue(alg, "BckSpreaderTransmissionValue",
                                                                     default=SampleData.BeamSpreader.spreader_trans)
            self.spreader_trans_spread = BaseScriptElement.getPropertyValue(alg, "BckSpreaderTransmissionError",
                                                                            default=SampleData.BeamSpreader.spreader_trans_spread)
Example #14
0
 def _process_setup_info(process_dom_):
     setup_alg_str = BaseScriptElement.getStringElement(process_dom_, 'SetupInfo', '')
     if len(setup_alg_str) == 0:
         return None
     filename = BaseScriptElement.getStringElement(process_dom_, 'Filename', '')
     return (Algorithm.fromString(str(setup_alg_str)), filename)
    def from_setup_info(self, xml_str):
        """
            Read in data from XML using the string representation of the setup algorithm used
            to prepare the reduction properties.
            @param xml_str: text to read the data from
        """
        self.reset()
        from mantid.api import Algorithm

        dom = xml.dom.minidom.parseString(xml_str)
        process_dom = dom.getElementsByTagName("SASProcess")[0]
        setup_alg_str = BaseScriptElement.getStringElement(
            process_dom, 'SetupInfo')
        alg = Algorithm.fromString(str(setup_alg_str))

        self.sample_detector_distance = BaseScriptElement.getPropertyValue(
            alg, "SampleDetectorDistance", default=ReductionOptions.sample_detector_distance)
        self.detector_offset = BaseScriptElement.getPropertyValue(
            alg, "SampleDetectorDistanceOffset", default=ReductionOptions.detector_offset)
        self.wavelength = BaseScriptElement.getPropertyValue(
            alg, "Wavelength", default=ReductionOptions.wavelength)
        self.wavelength_spread = BaseScriptElement.getPropertyValue(
            alg, "WavelengthSpread", default=ReductionOptions.wavelength_spread)

        self.solid_angle_corr = BaseScriptElement.getPropertyValue(
            alg, "SolidAngleCorrection", default=ReductionOptions.solid_angle_corr)
        self.output_directory = BaseScriptElement.getPropertyValue(
            alg, "OutputDirectory", default=ReductionOptions.output_directory)
        self.use_data_directory = not len(self.output_directory) > 0

        # Dark current
        self.dark_current_data = BaseScriptElement.getPropertyValue(
            alg, "DarkCurrentFile", default='')
        self.dark_current_corr = len(self.dark_current_data) > 0

        self.n_q_bins = BaseScriptElement.getPropertyValue(
            alg, "IQNumberOfBins", default=ReductionOptions.n_q_bins)
        self.n_sub_pix = BaseScriptElement.getPropertyValue(
            alg, "NumberOfSubpixels", default=ReductionOptions.n_sub_pix)
        self.log_binning = BaseScriptElement.getPropertyValue(
            alg, "IQLogBinning", default=ReductionOptions.log_binning)
        self.align_log_with_decades = BaseScriptElement.getPropertyValue(
            alg, "IQAlignLogWithDecades", default=ReductionOptions.align_log_with_decades)
        self.error_weighting = BaseScriptElement.getPropertyValue(
            alg, "ErrorWeighting", default=ReductionOptions.error_weighting)

        self.n_wedges = BaseScriptElement.getPropertyValue(
            alg, "NumberOfWedges", default=ReductionOptions.n_wedges)
        self.wedge_angle = BaseScriptElement.getPropertyValue(
            alg, "WedgeAngle", default=ReductionOptions.wedge_angle)
        self.wedge_offset = BaseScriptElement.getPropertyValue(
            alg, "WedgeOffset", default=ReductionOptions.wedge_offset)

        # Normalization
        norm_option = BaseScriptElement.getPropertyValue(
            alg, "Normalisation", default='Monitor')
        self.normalization = ReductionOptions.normalization
        if norm_option == 'Timer':
            self.normalization = ReductionOptions.NORMALIZATION_TIME
        elif norm_option == 'Monitor' or norm_option == 'BeamProfileAndCharge':
            self.normalization = ReductionOptions.NORMALIZATION_MONITOR
        elif norm_option == 'None':
            self.normalization = ReductionOptions.NORMALIZATION_NONE

        # Mask
        mask = BaseScriptElement.getPropertyValue(
            alg, "MaskedEdges", default=[])
        if type(mask).__name__ == 'ndarray':
            mask = mask.tolist()
        if len(mask) == 4:
            self.top = mask[3]
            self.bottom = mask[2]
            self.right = mask[1]
            self.left = mask[0]
        self.detector_ids = BaseScriptElement.getPropertyValue(
            alg, "MaskedDetectorList", default=[])
        if type(self.detector_ids).__name__ == 'ndarray':
            self.detector_ids = self.detector_ids.tolist()
        self.use_mask_file = len(self.detector_ids) > 0

        # Absolute scaling
        scale_option = BaseScriptElement.getPropertyValue(
            alg, "AbsoluteScaleMethod", default='None')
        self.calculate_scale = False
        self.scaling_factor = 1.0
        if scale_option == 'Value':
            self.scaling_factor = BaseScriptElement.getPropertyValue(
                alg, "AbsoluteScalingFactor", default=ReductionOptions.scaling_factor)
        elif scale_option == 'ReferenceData':
            self.calculate_scale = True
            self.scaling_direct_file = BaseScriptElement.getPropertyValue(
                alg, "AbsoluteScalingReferenceFilename")
            self.scaling_att_trans = BaseScriptElement.getPropertyValue(
                alg, "AbsoluteScalingAttenuatorTrans", default=ReductionOptions.scaling_att_trans)
            self.manual_beam_diam = False
            if alg.existsProperty("AbsoluteScalingBeamDiameter"):
                if not alg.getProperty("AbsoluteScalingBeamDiameter").isDefault:
                    self.scaling_beam_diam = BaseScriptElement.getPropertyValue(
                        alg, "AbsoluteScalingBeamDiameter", default=ReductionOptions.scaling_beam_diam)
                    self.manual_beam_diam = True
    def from_setup_info(self, xml_str):
        """
            Read in data from XML using the string representation of the setup algorithm used
            to prepare the reduction properties.
            @param xml_str: text to read the data from
        """
        self.reset()
        from mantid.api import Algorithm

        dom = xml.dom.minidom.parseString(xml_str)
        process_dom = dom.getElementsByTagName("SASProcess")[0]
        setup_alg_str = BaseScriptElement.getStringElement(
            process_dom, 'SetupInfo')
        alg = Algorithm.fromString(str(setup_alg_str))

        self.sample_detector_distance = BaseScriptElement.getPropertyValue(
            alg,
            "SampleDetectorDistance",
            default=ReductionOptions.sample_detector_distance)
        self.detector_offset = BaseScriptElement.getPropertyValue(
            alg,
            "SampleDetectorDistanceOffset",
            default=ReductionOptions.detector_offset)
        self.wavelength = BaseScriptElement.getPropertyValue(
            alg, "Wavelength", default=ReductionOptions.wavelength)
        self.wavelength_spread = BaseScriptElement.getPropertyValue(
            alg,
            "WavelengthSpread",
            default=ReductionOptions.wavelength_spread)

        self.solid_angle_corr = BaseScriptElement.getPropertyValue(
            alg,
            "SolidAngleCorrection",
            default=ReductionOptions.solid_angle_corr)
        self.output_directory = BaseScriptElement.getPropertyValue(
            alg, "OutputDirectory", default=ReductionOptions.output_directory)
        self.use_data_directory = not len(self.output_directory) > 0

        # Dark current
        self.dark_current_data = BaseScriptElement.getPropertyValue(
            alg, "DarkCurrentFile", default='')
        self.dark_current_corr = len(self.dark_current_data) > 0

        self.n_q_bins = BaseScriptElement.getPropertyValue(
            alg, "IQNumberOfBins", default=ReductionOptions.n_q_bins)
        self.n_sub_pix = BaseScriptElement.getPropertyValue(
            alg, "NumberOfSubpixels", default=ReductionOptions.n_sub_pix)
        self.log_binning = BaseScriptElement.getPropertyValue(
            alg, "IQLogBinning", default=ReductionOptions.log_binning)
        self.align_log_with_decades = BaseScriptElement.getPropertyValue(
            alg,
            "IQAlignLogWithDecades",
            default=ReductionOptions.align_log_with_decades)
        self.error_weighting = BaseScriptElement.getPropertyValue(
            alg, "ErrorWeighting", default=ReductionOptions.error_weighting)

        self.n_wedges = BaseScriptElement.getPropertyValue(
            alg, "NumberOfWedges", default=ReductionOptions.n_wedges)
        self.wedge_angle = BaseScriptElement.getPropertyValue(
            alg, "WedgeAngle", default=ReductionOptions.wedge_angle)
        self.wedge_offset = BaseScriptElement.getPropertyValue(
            alg, "WedgeOffset", default=ReductionOptions.wedge_offset)

        # Normalization
        norm_option = BaseScriptElement.getPropertyValue(alg,
                                                         "Normalisation",
                                                         default='Monitor')
        self.normalization = ReductionOptions.normalization
        if norm_option == 'Timer':
            self.normalization = ReductionOptions.NORMALIZATION_TIME
        elif norm_option == 'Monitor' or norm_option == 'BeamProfileAndCharge':
            self.normalization = ReductionOptions.NORMALIZATION_MONITOR
        elif norm_option == 'None':
            self.normalization = ReductionOptions.NORMALIZATION_NONE

        # Mask
        mask = BaseScriptElement.getPropertyValue(alg,
                                                  "MaskedEdges",
                                                  default=[])
        if type(mask).__name__ == 'ndarray':
            mask = mask.tolist()
        if len(mask) == 4:
            self.top = mask[3]
            self.bottom = mask[2]
            self.right = mask[1]
            self.left = mask[0]
        self.detector_ids = BaseScriptElement.getPropertyValue(
            alg, "MaskedDetectorList", default=[])
        if type(self.detector_ids).__name__ == 'ndarray':
            self.detector_ids = self.detector_ids.tolist()
        self.use_mask_file = len(self.detector_ids) > 0

        # Absolute scaling
        scale_option = BaseScriptElement.getPropertyValue(
            alg, "AbsoluteScaleMethod", default='None')
        self.calculate_scale = False
        self.scaling_factor = 1.0
        if scale_option == 'Value':
            self.scaling_factor = BaseScriptElement.getPropertyValue(
                alg,
                "AbsoluteScalingFactor",
                default=ReductionOptions.scaling_factor)
        elif scale_option == 'ReferenceData':
            self.calculate_scale = True
            self.scaling_direct_file = BaseScriptElement.getPropertyValue(
                alg, "AbsoluteScalingReferenceFilename")
            self.scaling_att_trans = BaseScriptElement.getPropertyValue(
                alg,
                "AbsoluteScalingAttenuatorTrans",
                default=ReductionOptions.scaling_att_trans)
            self.manual_beam_diam = False
            if alg.existsProperty("AbsoluteScalingBeamDiameter"):
                if not alg.getProperty(
                        "AbsoluteScalingBeamDiameter").isDefault:
                    self.scaling_beam_diam = BaseScriptElement.getPropertyValue(
                        alg,
                        "AbsoluteScalingBeamDiameter",
                        default=ReductionOptions.scaling_beam_diam)
                    self.manual_beam_diam = True