Exemple #1
0
    def __init__(self,
                 parent=None,
                 state=None,
                 settings=None,
                 data_type=None,
                 data_proxy=None):
        super(SampleDataWidget, self).__init__(parent,
                                               state,
                                               settings,
                                               data_type,
                                               data_proxy=data_proxy)

        class DataFrame(QtGui.QFrame, ui.sans.ui_hfir_sample_data.Ui_Frame):
            def __init__(self, parent=None):
                QtGui.QFrame.__init__(self, parent)
                self.setupUi(self)

        self._content = DataFrame(self)
        self._layout.addWidget(self._content)
        self.initialize_content()

        if state is not None:
            self.set_state(state)
        else:
            m = SampleData()
            self.set_state(m)

        self._last_direct_state = None
        self._last_spreader_state = None
Exemple #2
0
    def __init__(self,
                 parent=None,
                 state=None,
                 settings=None,
                 data_type=None,
                 data_proxy=None):
        super(DirectBeam, self).__init__(parent,
                                         state,
                                         settings,
                                         data_type,
                                         data_proxy=data_proxy)

        class DirectBeamFrame(QtGui.QGroupBox,
                              ui.sans.ui_trans_direct_beam.Ui_GroupBox):
            def __init__(self, parent=None):
                QtGui.QGroupBox.__init__(self, parent)
                self.setupUi(self)

        self._content = DirectBeamFrame(self)
        self._layout.addWidget(self._content)
        self.initialize_content()

        if state is not None:
            self.set_state(state)
        else:
            self.set_state(SampleData.DirectBeam())
Exemple #3
0
    def __init__(self,
                 parent=None,
                 state=None,
                 settings=None,
                 data_type=None,
                 data_proxy=None):
        super(DirectBeam, self).__init__(parent,
                                         state,
                                         settings,
                                         data_type,
                                         data_proxy=data_proxy)

        class DirectBeamFrame(QGroupBox):
            def __init__(self, parent=None):
                QGroupBox.__init__(self, parent)
                self.ui = load_ui(__file__,
                                  '../../../ui/sans/trans_direct_beam.ui',
                                  baseinstance=self)

        self._content = DirectBeamFrame(self)
        self._layout.addWidget(self._content)
        self.initialize_content()

        if state is not None:
            self.set_state(state)
        else:
            self.set_state(SampleData.DirectBeam())
Exemple #4
0
    def __init__(self,
                 parent=None,
                 state=None,
                 settings=None,
                 data_type=None,
                 data_proxy=None):
        super(SampleDataWidget, self).__init__(parent,
                                               state,
                                               settings,
                                               data_type,
                                               data_proxy=data_proxy)

        class DataFrame(QFrame):
            def __init__(self, parent=None):
                QFrame.__init__(self, parent)
                self.ui = load_ui(__file__,
                                  '../../../ui/sans/hfir_sample_data.ui',
                                  baseinstance=self)

        self._content = DataFrame(self)
        self._layout.addWidget(self._content)
        self.initialize_content()

        if state is not None:
            self.set_state(state)
        else:
            m = SampleData()
            self.set_state(m)

        self._last_direct_state = None
        self._last_spreader_state = None
 def get_state(self):
     """
         Returns an object with the state of the interface
     """
     m = SampleData.DirectBeam()
     m.beam_radius = util._check_and_get_float_line_edit(self._content.beam_radius_edit)
     m.sample_file = unicode(self._content.sample_edit.text())
     m.direct_beam = unicode(self._content.direct_edit.text())
     self._settings.emit_key_value("TRANS_SAMPLE", str(self._content.sample_edit.text()))
     self._settings.emit_key_value("TRANS_DIRECT", str(self._content.direct_edit.text()))
     return m
    def get_state(self):
        """
            Returns an object with the state of the interface
        """
        m = SampleData()

        m.transmission = util._check_and_get_float_line_edit(self._content.transmission_edit)
        m.transmission_spread = util._check_and_get_float_line_edit(self._content.dtransmission_edit)
        m.sample_thickness = util._check_and_get_float_line_edit(self._content.thickness_edit)

        m.calculate_transmission = self._content.calculate_chk.isChecked()
        m.theta_dependent = self._content.theta_dep_chk.isChecked()
        m.dark_current = self._content.dark_current_edit.text()

        m.calculation_method=self._method_box.get_state()

        # Data file
        m.data_files = self._get_data_files()

        return m
 def get_state(self):
     """
         Returns an object with the state of the interface
     """
     m = SampleData.BeamSpreader()
     m.spreader_trans = util._check_and_get_float_line_edit(self._content.spreader_trans_edit)
     m.spreader_trans_spread = util._check_and_get_float_line_edit(self._content.spreader_trans_spread_edit)
     m.sample_scatt = unicode(self._content.sample_scatt_edit.text())
     m.direct_scatt = unicode(self._content.direct_scatt_edit.text())
     m.sample_spreader = unicode(self._content.sample_spread_edit.text())
     m.direct_spreader = unicode(self._content.direct_spread_edit.text())
     return m
Exemple #8
0
    def get_state(self):
        """
            Returns an object with the state of the interface
        """
        m = SampleData()
        if self._settings.api2: m.PYTHON_API=2

        m.transmission = util._check_and_get_float_line_edit(self._content.transmission_edit)
        m.transmission_spread = util._check_and_get_float_line_edit(self._content.dtransmission_edit)
        m.sample_thickness = util._check_and_get_float_line_edit(self._content.thickness_edit)
        
        m.calculate_transmission = self._content.calculate_chk.isChecked()
        m.theta_dependent = self._content.theta_dep_chk.isChecked()
        m.dark_current = self._content.dark_current_edit.text()
        
        m.calculation_method=self._method_box.get_state()    
        
        # Data file
        m.data_files = self._get_data_files()

        return m
Exemple #9
0
    def __init__(self, parent=None, state=None, settings=None, data_type=None, data_proxy=None):
        super(SampleDataWidget, self).__init__(parent, state, settings, data_type, data_proxy=data_proxy) 

        class DataFrame(QtGui.QFrame, ui.sans.ui_hfir_sample_data.Ui_Frame): 
            def __init__(self, parent=None):
                QtGui.QFrame.__init__(self, parent)
                self.setupUi(self)
                
        self._content = DataFrame(self)
        self._layout.addWidget(self._content)
        self.initialize_content()
        
        if state is not None:
            self.set_state(state)
        else:
            m = SampleData()
            if self._settings.api2: m.PYTHON_API=2
            self.set_state(m)
            
        self._last_direct_state = None
        self._last_spreader_state = None
class SampleData(BaseSampleData):

    calculation_method = BaseSampleData.DirectBeam()
    # Option list
    option_list = [BaseSampleData.DirectBeam]
    # Option to fit the two frame separately when in frame-skipping mode
    combine_transmission_frames = False
    calculate_transmission = True

    def __init__(self):
        super(SampleData, self).__init__()
        self.reset()

    def reset(self):
        """
            Reset state
        """
        super(SampleData, self).reset()
        self.calculation_method.reset()
        self.combine_transmission_frames = SampleData.combine_transmission_frames
        self.calculate_transmission = SampleData.calculate_transmission

    def to_script(self, data_file=None):
        """
            Generate reduction script
            @param execute: if true, the script will be executed
        """
        script = super(SampleData, self).to_script(data_file)
        if self.calculate_transmission:
            script += "CombineTransmissionFits(%s)\n" % self.combine_transmission_frames
        return script

    def to_xml(self):
        """
            Create XML from the current data.
        """
        xml_str = super(SampleData, self).to_xml()
        return BaseScriptElement.addElementToSection(xml_str, "Transmission", "combine_transmission_frames",
                                                     str(self.combine_transmission_frames))

    def from_xml(self, xml_str):
        """
            Read in data from XML
            @param xml_str: text to read the data from
        """
        self.reset()
        super(SampleData, self).from_xml(xml_str)

        dom = xml.dom.minidom.parseString(xml_str)
        element_list = dom.getElementsByTagName("Transmission")
        if len(element_list)>0:
            instrument_dom = element_list[0]
            self.combine_transmission_frames = BaseScriptElement.getBoolElement(instrument_dom, "combine_transmission_frames",
                                                                                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()
        super(SampleData, self).from_setup_info(xml_str)

        (alg, _) = BaseScriptElement.getAlgorithmFromXML(xml_str)
        self.combine_transmission_frames = BaseScriptElement.getPropertyValue(alg, "FitFramesTogether",
                                                                              default=SampleData.combine_transmission_frames)