def display_plots(self, row=0):
     o_gui_utility = GuiUtility(parent = self.parent)
     is_data = o_gui_utility.is_data_tab_selected()
     
     DisplayPlots(parent = self.parent,
                  row = row,
                  is_data = is_data)
    def __init__(self, parent=None, mouse_x=0, mouse_y=0):
        QMainWindow.__init__(self, parent=parent)

        self.setWindowModality(False)
        self.ui = UiMainWindowXaxis()
        self.ui.setupUi(self)
        self.parent = parent

        o_gui_utility = GuiUtility(parent=self.parent)
        self.yaxis_type = o_gui_utility.get_reduced_yaxis_type()

        big_table_data = self.parent.big_table_data
        self._lrdata = big_table_data[0, 0]

        width = self.width()
        height = self.height()
        self.setFixedSize(width, height)

        pos_main_gui = self.parent.pos()
        plot_gui_pos = self.parent.ui.data_stitching_plot.pos()
        plot_gui_height = self.parent.ui.data_stitching_plot.frameGeometry(
        ).height()
        self.move(mouse_x + plot_gui_pos.x(),
                  plot_gui_pos.y() + plot_gui_height + mouse_y - 50)

        self.init_widgets()
Exemplo n.º 3
0
    def __init__(self, parent, data_type='data', plot_type='yi',
                 is_pan_or_zoom_activated=False,
                 is_manual_zoom_requested=False,
                 is_x_axis_manual_zoom_requested=False,
                 mouse_x=0, mouse_y=0):

        self.parent = parent
        if plot_type == 'stitching':
            if is_manual_zoom_requested:
                self.right_click_stitching_plot(is_x_axis_manual_zoom_requested,
                                                mouse_x, mouse_y)
            return

        o_gui_utility = GuiUtility(parent = self.parent)
        row = o_gui_utility.get_current_table_reduction_check_box_checked()
        if row == -1:
            return
        self.row = row
        col = o_gui_utility.get_data_norm_tab_selected()

        self.data = parent.big_table_data[row, col]

        if plot_type in ['ix', 'it']:
            return

        if plot_type == 'yi':
            self.single_yi_plot_click(data_type=data_type)

        if plot_type == 'yt':
            self.single_yt_plot_click(data_type=data_type)
Exemplo n.º 4
0
    def __init__(self, parent):

        self.parent = parent
        self.set_gui_title()
        self.set_gui_size()
        self.set_statusbar()
        self.set_main_table()
        self.set_stiching_table()
        self.set_reduced_table()
        self.set_export_stitching_settings()
        self.set_default_path()
        self.init_error_label_widgets()
        parent.allPlotAxis = AllPlotAxis()

        #enabled all widgets
        o_update_plot = UpdatePlotWidgetStatus(parent=parent)
        o_update_plot.disable_all()

        parent.ui.reductionTable.setCurrentCell(0,1)
        parent.ui.data_sequence_lineEdit.setFocus()	
        
        self.init_autopopulate_widgets()

        o_gui = GuiUtility(parent = self.parent)
        o_gui.init_widgets_value()
    def data_clocking_widgets(self, status = False):
        o_gui_utility = GuiUtility(parent = self.parent)
        if o_gui_utility.is_row_with_highest_q():
            status_clocking = True
        else:
            status_clocking = False

        if status_clocking:
            status_visible = True
            if status is False:
                status_enable = False
            else:
                status_enable = True
        else:
            status_visible = True #always visible
            status_enable = False

        self.parent.ui.dataPrimFromLabel.setVisible(status_visible)
        self.parent.ui.dataPrimFromLabel.setEnabled(status_enable)
        self.parent.ui.dataPrimFromValue.setVisible(status_visible)
        self.parent.ui.dataPrimFromValue.setEnabled(status_enable)
        
        self.parent.ui.dataPrimToLabel.setVisible(status_visible)
        self.parent.ui.dataPrimToLabel.setEnabled(status_enable)
        self.parent.ui.dataPrimToValue.setVisible(status_visible)
        self.parent.ui.dataPrimToValue.setEnabled(status_enable)
Exemplo n.º 6
0
    def calculate(self):
        o_gui_utility = GuiUtility(parent=self.parent)
        self.axis_type = o_gui_utility.get_reduced_yaxis_type()

        input_q_axis = self.input_q_axis
        input_y_axis = self.input_y_axis
        input_e_axis = self.input_e_axis

        # R vs Q selected
        if self.axis_type == 'RvsQ':
            self.output_y_axis = input_y_axis
            self.output_e_axis = input_e_axis
            return

        # RQ4 vs Q selected
        if self.axis_type == 'RQ4vsQ':
            _q_axis_4 = input_q_axis ** 4
            self.output_y_axis = input_y_axis * _q_axis_4
            self.output_e_axis = input_e_axis * _q_axis_4
            return

        # Log(R) vs Q
        # make sure there is no <= 0 values of _y_axis
        input_y_axis[input_y_axis <=0] = np.nan
        self.output_y_axis = np.log(input_y_axis)
        self.output_e_axis = input_e_axis  ## FIXME
Exemplo n.º 7
0
    def write_n_ascii(self):
        o_gui_utility = GuiUtility(parent=self.parent)
        nbr_row = o_gui_utility.reductionTable_nbr_row()

        self.is_with_4th_column_flag = self.ui.output4thColumnFlag.isChecked()
        dq_over_q = self.ui.dQoverQvalue.text()
        self.dq_over_q = float(dq_over_q)

        for _row in range(nbr_row):
            self.filename = self.format_n_filename(row=_row)
            text = self.retrieve_individual_metadata(row=_row)

            if self.is_with_4th_column_flag:
                dq0 = self.ui.dq0Value.text()
                self.dq0 = float(dq0)
                line1 = '# dQ0[1/Angstroms]= ' + dq0
                line2 = '# dQ1/Q= ' + dq_over_q
                line3 = '# Q[1/Angstroms] R delta_R Precision'
                text.append(line1)
                text.append(line2)
                text.append("#")
                text.append(line3)
            else:
                text.append('# Q[1/Angstroms] R delta_R')

            self.text_data = text
            self.produce_data_without_common_q_axis(row=_row)
            self.format_data()
            self.create_file()
    def radio_button_handler(self):
        if self.row == -1:
            return
        
        o_gui_utility = GuiUtility(parent = self.parent)        
        is_auto_tof_selected = o_gui_utility.is_auto_tof_range_radio_button_selected()

        big_table_data = self.parent.big_table_data
        for _row in self.all_rows:
            _data = big_table_data[_row, 0]
#            _data = big_table_data[_row, self.col]
        
            if _data is None:
                return
            
            if is_auto_tof_selected:
                self.new_tof_range = _data.tof_range_auto
                _data.tof_range_auto_flag = True
                #self.save_manual_tof_range()            
            else:
                self.new_tof_range = _data.tof_range_manual
                _data.tof_range_auto_flag = False
                #self.save_auto_tof_range()
            
            _data.tof_auto_flag = is_auto_tof_selected
#            big_table_data[_row, self.col] = _data
            big_table_data[_row, 0] = _data
            self.parent.big_table_data = big_table_data
            
            self.replace_tof_range_displayed()
            if _row == self.row:
                self.refresh_plot()
                self.recalculate_reduction_table_metadata()
Exemplo n.º 9
0
    def create_output_file(self):
        o_gui_utility = GuiUtility(parent=self.parent)
        nbr_row = o_gui_utility.reductionTable_nbr_row()
        _dataObject = self.parent.o_stitching_ascii_widget.loaded_ascii_array[
            0]
        _big_table_data = _dataObject.big_table_data

        #q min, q max
        [_q_min, _q_max] = self.get_q_range()
        #q bin
        _q_bin = -1. * float(self.parent.ui.qStep.text())
        _q_range = [_q_min, _q_bin, _q_max]

        # collect list of workspaces
        _list_wks = self.collect_list_wks()

        _list_wks = self.apply_sf(_list_wks)

        _text_data = self.format_metadata()

        print("Creating output file")
        print("====================")
        print("OutputBinning: %r" % _q_range)
        print("DQConstant: %r" % (float(self.ui.dq0Value.text())))
        print("DQSlope: %r" % (float(self.ui.dQoverQvalue.text())))

        LRReflectivityOutput(ReducedWorkspaces=_list_wks,
                             OutputBinning=_q_range,
                             DQConstant=float(self.ui.dq0Value.text()),
                             DQSlope=float(self.ui.dQoverQvalue.text()),
                             OutputFilename=self.filename,
                             ScaleToUnity=False,
                             Metadata=_text_data)
Exemplo n.º 10
0
	def __init__(self, parent, 
	             data_type = 'data', 
	             plot_type = 'yi', 
	             is_pan_or_zoom_activated = False):

		self.parent = parent
		o_gui_utility = GuiUtility(parent = self.parent)
		row = o_gui_utility.get_current_table_reduction_check_box_checked()
		if row == -1:
			return
		self.row = row
		col = o_gui_utility.get_data_norm_tab_selected()


		self.data = parent.big_table_data[row, col]
		
		if plot_type == 'ix':
			return
		
		if plot_type == 'it':
			return
		
		if plot_type == 'stitching':
			return
		
		if plot_type == 'yi':
			self.single_yi_plot_click(data_type = data_type)
			                          
		
		if plot_type == 'yt':
			self.single_yt_plot_click(data_type = data_type)
Exemplo n.º 11
0
 def get_data_clocking_range(self):
     big_table_data = self.big_table_data
     o_gui_utility = GuiUtility(parent=self.parent)
     _last_row = o_gui_utility.get_row_with_highest_q()
     _data = big_table_data[_last_row, 0]
     clock1 = int(_data.clocking[0])
     clock2 = int(_data.clocking[1])
     return [clock1, clock2]
 def get_data_clocking_range(self):
     big_table_data = self.big_table_data
     o_gui_utility = GuiUtility(parent = self.parent)
     _last_row = o_gui_utility.get_row_with_highest_q()
     _data = big_table_data[_last_row, 0]
     clock1 = int(_data.clocking[0])
     clock2 = int(_data.clocking[1])
     return [clock1, clock2]
Exemplo n.º 13
0
	def retrieve_lradata(self):
		o_gui_utility = GuiUtility(parent = self.parent)
		col_selected = o_gui_utility.get_current_table_reduction_column_selected()
		row_selected = o_gui_utility.get_current_table_reduction_row_selected()
		self.col = col_selected
		self.row = row_selected
		big_table_data = self.parent.big_table_data
		self.lrdata = big_table_data[row_selected, col_selected - 1]
Exemplo n.º 14
0
 def retrieve_lradata(self):
     o_gui_utility = GuiUtility(parent=self.parent)
     col_selected = o_gui_utility.get_current_table_reduction_column_selected(
     )
     row_selected = o_gui_utility.get_current_table_reduction_row_selected()
     self.col = col_selected
     self.row = row_selected
     big_table_data = self.parent.big_table_data
     self.lrdata = big_table_data[row_selected, col_selected - 1]
Exemplo n.º 15
0
 def generate_selected_sf(self, lconfig=None):
     o_gui = GuiUtility(parent=self.parent)
     stitching_type = o_gui.getStitchingType()
     if stitching_type is "absolute":
         return lconfig.sf_abs_normalization
     elif stitching_type is "auto":
         return lconfig.sf_auto
     else:
         return lconfig.sf_manual
Exemplo n.º 16
0
 def __is_row_displayed_in_range_selected(self):
     _range_selected = range(self.from_row, self.to_row + 1)
     o_gui_utility = GuiUtility(parent = self.parent)
     _row_displayed = o_gui_utility.get_current_table_reduction_check_box_checked()
     if _row_displayed == -1:
         return False
     if _row_displayed in _range_selected:
         return True
     return False
Exemplo n.º 17
0
 def retrieve_sf(self, lconfigdataset):
     o_gui = GuiUtility(parent=self.parent)
     stitching_type = o_gui.getStitchingType()
     if stitching_type == 'absolute':
         return lconfigdataset.sf_abs_normalization
     elif stitching_type == 'auto':
         return lconfigdataset.sf_auto
     else:
         return lconfigdataset.sf_manual
Exemplo n.º 18
0
    def leave_all_figure_plot(self, plot_type, row=-1, column=-1):
        parent = self.parent

        if column == -1 and row == -1:
            o_gui_utility = GuiUtility(parent=self.parent)
            row = o_gui_utility.get_current_table_reduction_check_box_checked()
            column = 0 if o_gui_utility.is_data_tab_selected() else 1

        if row == -1:
            return

        big_table_data = parent.big_table_data
        data = big_table_data[row, column]
        if data is None:
            return

        if plot_type == 'yi':
            if c == 0:
                plot_ui = parent.ui.data_yi_plot
            else:
                plot_ui = parent.ui.norm_yi_plot
        elif plot_type == 'yt':
            if c == 0:
                plot_ui = parent.ui.data_yt_plot
            else:
                plot_ui = parent.ui.norm_yt_plot
        elif plot_type == 'it':
            if c == 0:
                plot_ui = parent.ui.data_it_plot
            else:
                plot_ui = parent.ui.norm_it_plot
        elif plot_type == 'ix':
            if c == 0:
                plot_ui = parent.ui.data_ix_plot
            else:
                plot_ui = parent.ui.norm_ix_plot

        [xmin, xmax] = plot_ui.canvas.ax.xaxis.get_view_interval()
        [ymin, ymax] = plot_ui.canvas.ax.yaxis.get_view_interval()
        plot_ui.canvas.ax.xaxis.set_data_interval(xmin, xmax)
        plot_ui.canvas.ax.yaxis.set_data_interval(ymin, ymax)
        plot_ui.draw()

        if plot_type == 'yi':
            data.all_plot_axis.yi_view_interval = [xmin, xmax, ymin, ymax]
            parent.global_yi_view_interval = [xmin, xmax, ymin, ymax]
        elif plot_type == 'yt':
            data.all_plot_axis.yt_view_interval = [xmin, xmax, ymin, ymax]
            parent.global_yt_view_interval = [xmin, xmax, ymin, ymax]
        elif plot_type == 'it':
            data.all_plot_axis.it_view_interval = [xmin, xmax, ymin, ymax]
            parent.global_it_view_interval = [xmin, xmax, ymin, ymax]
        elif plot_type == 'ix':
            data.all_plot_axis.ix_view_interval = [xmin, xmax, ymin, ymax]
            parent.global_ix_view_interval = [xmin, xmax, ymin, ymax]
Exemplo n.º 19
0
	def leave_all_figure_plot(self, plot_type, row=-1, column=-1):
		parent = self.parent
		
		if column == -1 and row == -1:
			o_gui_utility = GuiUtility(parent = self.parent)
			row = o_gui_utility.get_current_table_reduction_check_box_checked()
			column = 0 if o_gui_utility.is_data_tab_selected() else 1
			
		if row == -1:
			return
		
		big_table_data = parent.big_table_data
		data = big_table_data[row, column]
		if data is None:
			return
		
		if plot_type == 'yi':
			if c==0:
				plot_ui = parent.ui.data_yi_plot
			else:
				plot_ui = parent.ui.norm_yi_plot
		elif plot_type == 'yt':
			if c==0:
				plot_ui = parent.ui.data_yt_plot
			else:
				plot_ui = parent.ui.norm_yt_plot
		elif plot_type =='it':
			if c==0:
				plot_ui = parent.ui.data_it_plot
			else:
				plot_ui = parent.ui.norm_it_plot
		elif plot_type =='ix':
			if c==0:
				plot_ui = parent.ui.data_ix_plot
			else:
				plot_ui = parent.ui.norm_ix_plot
		
		[xmin, xmax] = plot_ui.canvas.ax.xaxis.get_view_interval()
		[ymin, ymax] = plot_ui.canvas.ax.yaxis.get_view_interval()
		plot_ui.canvas.ax.xaxis.set_data_interval(xmin, xmax)
		plot_ui.canvas.ax.yaxis.set_data_interval(ymin,ymax)
		plot_ui.draw()
			
		if plot_type == 'yi':
			data.all_plot_axis.yi_view_interval = [xmin,xmax,ymin,ymax]
			parent.global_yi_view_interval = [xmin,xmax,ymin,ymax]
		elif plot_type == 'yt':
			data.all_plot_axis.yt_view_interval = [xmin,xmax,ymin,ymax]
			parent.global_yt_view_interval = [xmin,xmax,ymin,ymax]
		elif plot_type =='it':
			data.all_plot_axis.it_view_interval = [xmin,xmax,ymin,ymax]
			parent.global_it_view_interval = [xmin,xmax,ymin,ymax]
		elif plot_type =='ix':
			data.all_plot_axis.ix_view_interval = [xmin,xmax,ymin,ymax]
			parent.global_ix_view_interval = [xmin,xmax,ymin,ymax]
Exemplo n.º 20
0
    def collect_list_wks(self):
        o_gui_utility = GuiUtility(parent=self.parent)
        nbr_row = o_gui_utility.reductionTable_nbr_row()
        _dataObject = self.parent.o_stitching_ascii_widget.loaded_ascii_array[
            0]
        _big_table_data = _dataObject.big_table_data

        _list_wks = []
        for _row in range(nbr_row):
            _data = _big_table_data[_row, 2]
            _list_wks.append(_data.wks)

        return _list_wks
Exemplo n.º 21
0
    def run(self):
        '''
        main part of the program that will calculate the various SF
        '''
        o_gui = GuiUtility(parent=self.parent)
        stitching_type = o_gui.getStitchingType()

        if stitching_type is 'absolute':
            self.absolute_normalization_calculation(row_index=self.row_index)
        elif stitching_type is 'auto':
            self.auto_stitching_calculation(row_index=self.row_index)
        else:
            self.manual_stitching_calculation(row_index=self.row_index)
Exemplo n.º 22
0
    def __init__(self,
                 parent=None,
                 status='log',
                 plot_type=None,
                 is_y_log=True):

        status = str(status)
        if status == 'log':
            isLog = True
        else:
            isLog = False

        if plot_type == 'stitching':
            [row, column] = [0, 0]
        else:
            o_gui_utility = GuiUtility(parent=parent)
            row = o_gui_utility.get_current_table_reduction_check_box_checked()
            column = 0 if o_gui_utility.is_data_tab_selected() else 1

        data = parent.big_table_data[row, column]
        if data is None:
            return

        if plot_type == 'stitching':
            if is_y_log:
                data.all_plot_axis.is_reduced_plot_stitching_tab_ylog = isLog
            else:
                data.all_plot_axis.is_reduced_plot_stitching_tab_xlog = isLog
        elif plot_type == 'yi':
            if is_y_log:
                data.all_plot_axis.is_yi_ylog = isLog
            else:
                data.all_plot_axis.is_yi_xlog = isLog
        elif plot_type == 'yt':
            if is_y_log:
                data.all_plot_axis.is_yt_ylog = isLog
            else:
                data.all_plot_axis.is_yt_xlog = isLog
        elif plot_type == 'it':
            if is_y_log:
                data.all_plot_axis.is_it_ylog = isLog
            else:
                data.all_plot_axis.is_it_xlog = isLog
        elif plot_type == 'ix':
            if is_y_log:
                data.all_plot_axis.is_ix_ylog = isLog
            else:
                data.all_plot_axis.is_ix_xlog = isLog

        parent.big_table_data[row, column] = data
Exemplo n.º 23
0
	def globalize_clocking_parameters(self):
		'''
		the clocking settings of all the data should only use the 
		ones calculated for the last data file loaded
		'''
		o_gui_utility = GuiUtility(parent = self.parent)
		last_data_row = o_gui_utility.get_row_with_highest_q()
		big_table_data = self.parent.big_table_data
		_lconfig = big_table_data[last_data_row, 2]
		data_clocking = _lconfig.data_clocking
		for i in range(last_data_row):
			_lconfig = big_table_data[i, 2]
			_lconfig.data_clocking = data_clocking
			big_table_data[i, 2] = _lconfig
		self.parent.big_table_data = big_table_data
Exemplo n.º 24
0
    def apply_scaling_factor(self):
        o_gui_utility = GuiUtility(parent=self.parent)
        nbr_row = o_gui_utility.reductionTable_nbr_row()
        _dataObject = self.parent.o_stitching_ascii_widget.loaded_ascii_array[
            0]
        _big_table_data = _dataObject.big_table_data

        for _row in range(nbr_row):
            _data = _big_table_data[_row, 2]
            _wks = _data.wks
            _sf = self.retrieve_sf(_data)
            _wks_scaled = Scale(_wks, _sf, 'Multiply')
            _data.wks_scaled = _wks_scaled
            _big_table_data[_row, 2]

        _dataObject.big_table_data = _big_table_data
Exemplo n.º 25
0
	def retrieve_metadata(self):
		reduction_table = self.parent.ui.reductionTable
		text = []
		
		o_gui_utility = GuiUtility(parent = self.parent)
		_date = time.strftime("# Date: %d_%m_%Y")
		_reduction_method = '# Reduction method: manual'
		_reduction_engine = '# Reduction engine: RefRed'
		_reduction_date = '# %s' %_date
		_ipts = o_gui_utility.get_ipts(row = 0)
		for _entry in [_date, _reduction_method, _reduction_engine, _reduction_date]:
			text.append(_entry)
		text.append("#")
		
		nbr_row = o_gui_utility.reductionTable_nbr_row()
		_legend = "# DataRun\tNormRun\t2theta(degrees)\tLambdaMin(A)\tLambdaMax(A)\tQmin(1/A)\tQmax(1/A)\tScalingFactor"
		text.append(_legend)
		for _row in range(nbr_row):
			_data_run = str(reduction_table.item(_row, 1).text())
			_norm_run = str(reduction_table.item(_row, 2).text())
			_2_theta  = str(reduction_table.item(_row, 3).text())
			_lambda_min = str(reduction_table.item(_row, 4).text())
			_lambda_max = str(reduction_table.item(_row, 5).text())
			_q_min = str(reduction_table.item(_row, 6).text())
			_q_max = str(reduction_table.item(_row, 7).text())
			_scaling_factor = self.retrieve_scaling_factor(row = _row)
			_value = "# %s\t%s\t%s\t\t%s\t\t%s\t\t%s\t\t%s\t\t%s" %(_data_run,
			                                              _norm_run,
			                                              _2_theta,
			                                              _lambda_min,
			                                              _lambda_max,
			                                              _q_min,
			                                              _q_max,
			                                              _scaling_factor)
			text.append(_value)

		# clocking settings
		text.append('#')
		text.append('# Clocking Correction used')
		o_gui_utility = GuiUtility(parent = self.parent)
		last_row = o_gui_utility.get_row_with_highest_q()
		big_table_data = self.parent.big_table_data
		clocking = big_table_data[last_row, 0].clocking
		text.append('# clock1: %s' %clocking[0])
		text.append('# clock2: %s' %clocking[1])

		return text
Exemplo n.º 26
0
	def __init__(self, parent=None, status='log', plot_type=None, is_y_log=True):
		
		if status == 'log':
			isLog = True
		else:
			isLog = False
		
		if plot_type=='stitching':
			[row, column] = [0,0]
		else:
			o_gui_utility = GuiUtility(parent = parent)
			row = o_gui_utility.get_current_table_reduction_check_box_checked()
			column = 0 if o_gui_utility.is_data_tab_selected() else 1
		
		data = parent.big_table_data[row, column]
		if data is None:
			return
		   
		if plot_type=='stitching':
			if is_y_log:
				data.all_plot_axis.is_reduced_plot_stitching_tab_ylog = isLog
			else:
				data.all_plot_axis.is_reduced_plot_stitching_tab_xlog = isLog
		elif plot_type=='yi':
			if is_y_log:
				data.all_plot_axis.is_yi_ylog = isLog
			else:
				data.all_plot_axis.is_yi_xlog = isLog
		elif plot_type=='yt':
			if is_y_log:
				data.all_plot_axis.is_yt_ylog = isLog
			else:
				data.all_plot_axis.is_yt_xlog = isLog
		elif plot_type=='it':
			if is_y_log:
				data.all_plot_axis.is_it_ylog = isLog
			else:
				data.all_plot_axis.is_it_xlog = isLog
		elif plot_type=='ix':
			if is_y_log:
				data.all_plot_axis.is_ix_ylog = isLog
			else:
				data.all_plot_axis.is_ix_xlog = isLog
				
		parent.big_table_data[row, column] = data
Exemplo n.º 27
0
    def	prepare_big_table_data(self):
	'''
	all data files used last data clocking values
	'''

	big_table_data = self.parent.big_table_data
	o_gui_utility = GuiUtility(parent = self.parent)
	row_highest_q = o_gui_utility.get_row_with_highest_q()

	_ref_lrdata = big_table_data[row_highest_q, 0]
	_ref_clocking = _ref_lrdata.clocking

	for row in range(row_highest_q):
	    _lrdata = big_table_data[row, 0]
	    _lrdata.clocking = _ref_clocking
	    big_table_data[row, 0] = _lrdata
	    
	self.parent.big_table_data = big_table_data
Exemplo n.º 28
0
    def prepare_big_table_data(self):
        '''
	all data files used last data clocking values
	'''

        big_table_data = self.parent.big_table_data
        o_gui_utility = GuiUtility(parent=self.parent)
        row_highest_q = o_gui_utility.get_row_with_highest_q()

        _ref_lrdata = big_table_data[row_highest_q, 0]
        _ref_clocking = _ref_lrdata.clocking

        for row in range(row_highest_q):
            _lrdata = big_table_data[row, 0]
            _lrdata.clocking = _ref_clocking
            big_table_data[row, 0] = _lrdata

        self.parent.big_table_data = big_table_data
Exemplo n.º 29
0
    def save_xy_axis(self):
        o_gui_utility = GuiUtility(parent = self.parent)
        yaxis_type = o_gui_utility.get_reduced_yaxis_type()

        big_table_data = self.parent.big_table_data
        _data = big_table_data[0, 0]

        if yaxis_type == 'RvsQ':
            if _data.all_plot_axis.reduced_plot_RQuserView_y is None:
                self.parent.ui.data_stitching_plot.canvas.draw()
                [xmin, xmax] = self.parent.ui.data_stitching_plot.canvas.ax.xaxis.get_view_interval()
                [ymin, ymax] = self.parent.ui.data_stitching_plot.canvas.ax.yaxis.get_view_interval()

                _data.all_plot_axis.reduced_plot_RQuserView_y = [ymin, ymax]
                _data.all_plot_axis.reduced_plot_RQautoView_y = [ymin, ymax]
                _data.all_plot_axis.reduced_plot_RQQ4userView_x = [xmin, xmax]
                _data.all_plot_axis.reduced_plot_RQQ4autoView_x = [xmin, xmax]
            else:
                [xmin, xmax] = _data.all_plot_axis.reduced_plot_RQQ4userView_x
                [ymin, ymax] = _data.all_plot_axis.reduced_plot_RQuserView_y

                self.parent.ui.data_stitching_plot.canvas.ax.set_xlim([xmin, xmax])
                self.parent.ui.data_stitching_plot.canvas.ax.set_ylim([ymin, ymax])
                self.parent.ui.data_stitching_plot.canvas.draw()
        else:
            if _data.all_plot_axis.reduced_plot_RQ4QuserView_y is None:
                self.parent.ui.data_stitching_plot.canvas.draw()
                [xmin, xmax] = self.parent.ui.data_stitching_plot.canvas.ax.xaxis.get_view_interval()
                [ymin, ymax] = self.parent.ui.data_stitching_plot.canvas.ax.yaxis.get_view_interval()

                _data.all_plot_axis.reduced_plot_RQ4userView_y = [ymin, ymax]
                _data.all_plot_axis.reduced_plot_RQ4autoView_y = [ymin, ymax]
                _data.all_plot_axis.reduced_plot_RQQ4userView_x = [xmin, xmax]
                _data.all_plot.axis.reduced_plot_RQQ4autoView_x = [xmin, xmax]
            else:
                [xmin, xmax] = _data.all_plot_axis.reduced_plot_RQQ4userView_x
                [ymin, ymax] = _data.all_plot_axis.reduced_plot_RQ4userView_y

                self.parent.ui.data_stitching_plot.canvas.ax.set_xlim([xmin, xmax])
                self.parent.ui.data_stitching_plot.canvas.ax.set_ylim([ymin, ymax])
                self.parent.ui.data_stitching_plot.canvas.draw()

        big_table_data[0, 0] = _data
        self.parent.big_table_data = big_table_data
Exemplo n.º 30
0
    def closeEvent(self, event=None):
        # saving back all the settings
        nbr_row = self.ui.tableWidget.rowCount()
        _gui_metadata = {}
        for _row in range(nbr_row):
            _label = str(self.ui.tableWidget.verticalHeaderItem(_row).text())
            if _label == 'clocking_pixel':
                _value = str(self.ui.tableWidget.item(_row, 0).text())
                [_pixel1, _pixel2] = _value.split(",")
                _value = [int(_pixel1), int(_pixel2)]
            else:
                _value = float(self.ui.tableWidget.item(_row, 0).text())
            _gui_metadata[_label] = _value
        self.parent.gui_metadata = _gui_metadata
        print(self.parent.gui_metadata)

        #update GUI widgets
        o_gui = GuiUtility(parent=self.parent)
        o_gui.init_widgets_value()
    def init_widgets(self):
        o_gui_utility = GuiUtility(parent=self.parent)
        axis_type = o_gui_utility.get_reduced_yaxis_type()

        if axis_type == 'RvsQ':
            [_x_min, _x_max, _y_min,
             _y_max] = self._lrdata.all_plot_axis.get_user_reduced_RQ_view()
        else:
            [_x_min, _x_max, _y_min,
             _y_max] = self._lrdata.all_plot_axis.get_user_reduced_RQ4Q_view()

        self.y_min = _y_min
        self.y_max = _y_max

        _y_min_str = "%.8f" % _y_min
        _y_max_str = "%.8f" % _y_max

        self.ui.y_min_value.setText(_y_min_str)
        self.ui.y_max_value.setText(_y_max_str)
Exemplo n.º 32
0
    def fillRow(self, row_index=0):
        self._row_index = row_index
        self._lconfig = self.big_table_data[self._row_index, 2]
        if self._lconfig is None:
            return

        o_gui = GuiUtility(parent=self.parent)
        stitching_type = o_gui.getStitchingType()

        self.fillTableRunNumber()

        if stitching_type is 'absolute':
            self.fillTableForAbsoluteNormalization()
        elif stitching_type is 'auto':
            self.fillTableForAutoStitching()
        else:
            self.fillTableForManualStitching()

        self.fillTableForClocking()
Exemplo n.º 33
0
    def run(self):
        if self.filename == '':
            _path = self.parent.path_config
            self.filename = str(QtGui.QFileDialog.getSaveFileName(self.parent,
                                                         'Save Configuration File',
                                                         _path))
            
            if self.filename == '':
                return

            self.parent.path_config = os.path.dirname(self.filename)
            self.filename = makeSureFileHasExtension(self.filename)
            o_export = ExportXMLConfig(parent = self.parent,
                                       filename = self.filename)
            
            StatusMessageHandler(parent = self.parent, 
                                 message = 'Done!', 
                                 is_threaded = True)
            
            o_gui_utility = GuiUtility(parent = self.parent)
            o_gui_utility.gui_not_modified()
Exemplo n.º 34
0
    def run(self):
        if self.filename == '':
            _path = self.parent.path_config
            _filter = ("XML (*.xml);; All Files (*.*)")            
            self.filename = str(QtGui.QFileDialog.getSaveFileName(self.parent,
                                                         'Save Configuration File',
                                                         _path,
                                                         _filter))
            
            if self.filename == '':
                return

        self.parent.path_config = os.path.dirname(self.filename)
        self.filename = makeSureFileHasExtension(self.filename)
        o_export = ExportXMLConfig(parent = self.parent,
                                   filename = self.filename)
        
        StatusMessageHandler(parent = self.parent, 
                             message = 'Done!', 
                             is_threaded = True)
        
        o_gui_utility = GuiUtility(parent = self.parent)
        o_gui_utility.new_config_file_loaded(config_file_name = self.filename)
        o_gui_utility.gui_not_modified()

    
            
        
            
Exemplo n.º 35
0
    def norm_tab_widgets(self, status=False):
        parent = self.parent
        parent.ui.dataNormTabWidget.setEnabled(status)
        parent.ui.norm_yt_plot.setEnabled(status)
        parent.ui.normNameOfFile.setEnabled(status)
        parent.ui.norm_yi_plot.setEnabled(status)
        parent.ui.norm_it_plot.setEnabled(status)
        parent.ui.norm_ix_plot.setEnabled(status)
        parent.ui.normLowResFlag.setEnabled(status)
        parent.ui.normLowResFromLabel.setEnabled(status)
        parent.ui.normLowResFromValue.setEnabled(status)
        parent.ui.normLowResToLabel.setEnabled(status)
        parent.ui.normLowResToValue.setEnabled(status)
        parent.ui.normBackToValue.setEnabled(status)
        parent.ui.normBackFromValue.setEnabled(status)
        parent.ui.normPeakToValue.setEnabled(status)
        parent.ui.normPeakFromValue.setEnabled(status)
        parent.ui.normBackgroundFlag.setEnabled(status)
            
        self.parent.ui.dataTOFmanualLabel.setEnabled(status)
        self.parent.ui.dataTOFautoMode.setEnabled(status)
        self.parent.ui.dataTOFmanualMode.setEnabled(status)

        o_gui_utility = GuiUtility(parent = self.parent)
        if status:
            is_auto_tof_selected = o_gui_utility.is_auto_tof_range_radio_button_selected()
            o_gui_utility.set_auto_tof_range_widgets(status = is_auto_tof_selected)
        else:
            o_gui_utility.set_auto_tof_range_widgets(status = True)
            
Exemplo n.º 36
0
    def globalize_clocking_parameters(self):
        '''
        the clocking settings of all the data should only use the 
        ones calculated for the last data file loaded
        '''
        o_gui_utility = GuiUtility(parent=self.parent)
        last_data_row = o_gui_utility.get_row_with_highest_q()
        big_table_data = self.parent.big_table_data
        lrdata = big_table_data[last_data_row, 0]
        if lrdata is None:
            return
        clocking = lrdata.clocking
        for i in range(last_data_row + 1):
            if i == last_data_row:
                continue
            _lrdata = big_table_data[i, 0]
            if _lrdata is None:
                break
            _lrdata.clocking = clocking
            big_table_data[i, 0] = _lrdata

        self.parent.big_table_data = big_table_data
    def radio_button_handler(self):
        if self.row == -1:
            return

        o_gui_utility = GuiUtility(parent=self.parent)
        is_auto_tof_selected = o_gui_utility.is_auto_tof_range_radio_button_selected(
        )

        big_table_data = self.parent.big_table_data
        for _row in self.all_rows:
            _data = big_table_data[_row, 0]
            _norm = big_table_data[_row, 1]
            _lconfig = big_table_data[_row, 2]

            if _data is None:
                return

            if is_auto_tof_selected:
                self.new_tof_range = _data.tof_range_auto
                _lconfig.tof_auto_flag = True
                _data.tof_range_auto_flag = True
                if _norm is not None:
                    _norm.tof_range_auto_flag = True
            else:
                self.new_tof_range = _data.tof_range_manual
                _data.tof_range_auto_flag = False
                _lconfig.tof_auto_flag = False
                if _norm is not None:
                    _norm.tof_range_auto_flag = False

            _data.tof_auto_flag = is_auto_tof_selected
            big_table_data[_row, 1] = _norm
            big_table_data[_row, 0] = _data
            self.parent.big_table_data = big_table_data

            self.replace_tof_range_displayed()
            if _row == self.row:
                self.refresh_plot()
            self.recalculate_reduction_table_metadata(row=_row)
    def setup(self):
        o_gui_utility = GuiUtility(parent=self.parent)
        is_auto_tof_selected = o_gui_utility.is_auto_tof_range_radio_button_selected(
        )
        o_gui_utility.set_auto_tof_range_widgets(status=is_auto_tof_selected)

        self.row = o_gui_utility.get_current_table_reduction_check_box_checked(
        )
        if self.row == -1:
            return

        self.all_rows = o_gui_utility.get_other_row_with_same_run_number_as_row(
            row=self.row, auto_mode=is_auto_tof_selected)
        self.col = o_gui_utility.get_data_norm_tab_selected()
        self.is_data = True if self.col == 0 else False
    def setup(self):
        o_gui_utility = GuiUtility(parent = self.parent)
        is_auto_tof_selected = o_gui_utility.is_auto_tof_range_radio_button_selected()
        o_gui_utility.set_auto_tof_range_widgets(status = is_auto_tof_selected)
        
        self.row = o_gui_utility.get_current_table_reduction_check_box_checked()
        if self.row == -1:
            return

        self.all_rows = o_gui_utility.get_other_row_with_same_run_number_as_row(row = self.row)
        self.col = o_gui_utility.get_data_norm_tab_selected()
        self.is_data = True if self.col == 0 else False
Exemplo n.º 40
0
    def get_q_range(self):
        o_gui_utility = GuiUtility(parent=self.parent)
        nbr_row = o_gui_utility.reductionTable_nbr_row()

        _auto_qmin_flag = self.ui.auto_qmin_button.isChecked()
        if _auto_qmin_flag:
            minQ = 100
        else:
            minQ = float(self.ui.manual_qmin_value.text())

        maxQ = 0

        _dataObject = self.parent.o_stitching_ascii_widget.loaded_ascii_array[
            0]
        _big_table_data = _dataObject.big_table_data

        for i in range(nbr_row):
            _data = _big_table_data[i, 2]
            _q_axis = _data.reduce_q_axis
            if _auto_qmin_flag:
                minQ = min([_q_axis[0], minQ])
            maxQ = max([_q_axis[-1], maxQ])

        return [minQ, maxQ]
Exemplo n.º 41
0
    def retrieve_metadata(self):
        reduction_table = self.parent.ui.reductionTable
        text = []

        o_gui_utility = GuiUtility(parent=self.parent)
        _date = time.strftime("# Date: %d_%m_%Y")
        _reduction_method = '# Reduction method: manual'
        _reduction_engine = '# Reduction engine: RefRed'
        _reduction_date = '# %s' % _date
        _ipts = o_gui_utility.get_ipts(row=0)
        for _entry in [
                _date, _reduction_method, _reduction_engine, _reduction_date
        ]:
            text.append(_entry)
        text.append("#")

        nbr_row = o_gui_utility.reductionTable_nbr_row()
        _legend = "# DataRun\tNormRun\t2theta(degrees)\tLambdaMin(A)\tLambdaMax(A)\tQmin(1/A)\tQmax(1/A)\tScalingFactor\tTotal Counts\tpcCharge(mC)"
        text.append(_legend)
        for _row in range(nbr_row):
            _data_run = str(reduction_table.item(_row, 1).text())
            _norm_run = str(reduction_table.item(_row, 2).text())
            _2_theta = str(reduction_table.item(_row, 3).text())
            _lambda_min = str(reduction_table.item(_row, 4).text())
            _lambda_max = str(reduction_table.item(_row, 5).text())
            _q_min = str(reduction_table.item(_row, 6).text())
            _q_max = str(reduction_table.item(_row, 7).text())
            _scaling_factor = self.retrieve_scaling_factor(row=_row)
            _total_counts = self.retrieve_total_counts(_row)
            _pcCharge = self.retrieve_pcCharge(_row)
            _value = "# %s\t%s\t%s\t\t%s\t\t%s\t\t%s\t\t%s\t\t%s\t\t%f\t\t%f" % (
                _data_run, _norm_run, _2_theta, _lambda_min, _lambda_max,
                _q_min, _q_max, _scaling_factor, _total_counts, _pcCharge)
            text.append(_value)

        # clocking settings
        text.append('#')
        text.append('# Clocking Correction used')
        o_gui_utility = GuiUtility(parent=self.parent)
        last_row = o_gui_utility.get_row_with_highest_q()
        big_table_data = self.parent.big_table_data
        clocking = big_table_data[last_row, 0].clocking
        text.append('# clock1: %s' % clocking[0])
        text.append('# clock2: %s' % clocking[1])

        return text
Exemplo n.º 42
0
	def is_row_with_higest_q(self):
		o_gui_utility = GuiUtility(parent = self.parent)
		return o_gui_utility.is_row_with_highest_q()
Exemplo n.º 43
0
 def get_selected_reduced_output(self):
     o_gui_utility = GuiUtility(parent = self.parent)
     return o_gui_utility.get_reduced_yaxis_type()
Exemplo n.º 44
0
	def reset_gui_modified_status(self):
		o_gui_utility = GuiUtility(parent = self.parent)
		o_gui_utility.gui_not_modified()
Exemplo n.º 45
0
 def display_name_config_file(self):
     o_gui = GuiUtility(parent=self.parent)
     o_gui.new_config_file_loaded(config_file_name=self.filename)
Exemplo n.º 46
0
 def reset_gui_modified_status(self):
     o_gui_utility = GuiUtility(parent=self.parent)
     o_gui_utility.gui_not_modified()
Exemplo n.º 47
0
	def display_name_config_file(self):
		o_gui = GuiUtility(parent = self.parent)
		o_gui.new_config_file_loaded(config_file_name = self.filename)
Exemplo n.º 48
0
	def produce_data_with_common_q_axis(self):
		o_gui_utility = GuiUtility(parent = self.parent)
		nbr_row = o_gui_utility.reductionTable_nbr_row()

		_dataObject = self.parent.o_stitching_ascii_widget.loaded_ascii_array[0]
		_big_table_data = _dataObject.big_table_data
		
		minQ = 100
		maxQ = 0
		
		for i in range(nbr_row):
			_data = _big_table_data[i,2]
			
			tmp_wks_name = 'wks_' + str(i)
			
			_q_axis = _data.reduce_q_axis
			_y_axis = _data.reduce_y_axis[:-1]
			_e_axis = _data.reduce_e_axis[:-1]
			
			[_y_axis, _e_axis] = self.applySF(_data, _y_axis, _e_axis)
			
			minQ = min([_q_axis[0], minQ])
			maxQ = max([_q_axis[-1], maxQ])
			
			tmp_wks_name = CreateWorkspace(DataX = _q_axis,
					               DataY = _y_axis,
					               DataE = _e_axis,
					               Nspec = 1,
					               UnitX = "Wavelength",
					               OutputWorkspace = tmp_wks_name)
			tmp_wks_name.setDistribution(True)
			    
			# rebin everyting using the same Q binning parameters  
		binQ = self.dq_over_q
		bin_parameters = str(minQ) + ',-' + str(binQ) + ',' + str(maxQ)
		for i in range(nbr_row):  
				
			tmp_wks_name = 'wks_' + str(i)
			ConvertToHistogram(InputWorkspace = tmp_wks_name,
			                   OutputWorkspace = tmp_wks_name)
			
			Rebin(InputWorkspace = tmp_wks_name, 
			      Params = bin_parameters,
			      OutputWorkspace = tmp_wks_name)
			
		# we use the first histo as output reference
		data_y = mtd['wks_0'].dataY(0).copy()
		data_e = mtd['wks_0'].dataE(0).copy()
			
		skip_index = 0
		point_to_skip = 2
			
		for k in range(1, nbr_row):

			skip_point = True
			can_skip_last_point = False
			
			data_y_k = mtd['wks_' + str(k)].dataY(0)
			data_e_k = mtd['wks_' + str(k)].dataE(0)
			for j in range(len(data_y_k)-1):
					
				if data_y_k[j] > 0:
						
					can_skip_last_point = True
					if skip_point:
						skip_index += 1
						if skip_index == point_to_skip:
							skip_point = False
							skip_index = 0
						else:
							continue
						
				if can_skip_last_point and (data_y_k[j+1] == 0):
					break
					
				if data_y[j] > 0 and data_y_k[j] > 0:
					  
					if self.use_lowest_error_value_flag:
						if (data_e[j] > data_e_k[j]):
							data_y[j] = data_y_k[j]
							data_e[j] = data_e_k[j]
							
					else:
						[data_y[j], data_e[j]] = RefRed.utilities.weighted_mean([data_y[j], data_y_k[j]],
						                                                 [data_e[j], data_e_k[j]])
							
				elif (data_y[j] == 0) and (data_y_k[j]>0):
					data_y[j] = data_y_k[j]
					data_e[j] = data_e_k[j]
						
		data_x = mtd['wks_1'].dataX(0)
						
		self.q_axis = data_x
		self.y_axis = data_y
		self.e_axis = data_e
Exemplo n.º 49
0
 def get_selected_scale_type(self):
     o_gui_utility = GuiUtility(parent = self.parent)
     self.axis_type = o_gui_utility.get_reduced_yaxis_type()
Exemplo n.º 50
0
    def plot_live_reduced_data(self):
        self.parent.ui.data_stitching_plot.clear()
        self.parent.ui.data_stitching_plot.draw()

        big_table_data = self.big_table_data
        _data = big_table_data[0, 0]

        for index_row, _lconfig in enumerate(big_table_data[:,2]):
            if _lconfig is None:
                break

            _q_axis = _lconfig.q_axis_for_display
            _y_axis = _lconfig.y_axis_for_display
            _e_axis = _lconfig.e_axis_for_display
            sf = self.generate_selected_sf(lconfig=_lconfig)

            _y_axis = np.array(_y_axis, dtype=np.float)
            _e_axis = np.array(_e_axis, dtype=np.float)

            _y_axis = _y_axis * sf
            _e_axis = _e_axis * sf

            o_produce_output = ProducedSelectedOutputScaled(parent=self.parent,
                                                            q_axis=_q_axis,
                                                            y_axis=_y_axis,
                                                            e_axis=_e_axis)
            o_produce_output.calculate()
            y_axis = o_produce_output.output_y_axis
            e_axis = o_produce_output.output_e_axis

            self.parent.ui.data_stitching_plot.errorbar(_q_axis, y_axis, yerr = e_axis,
                                                        color = self.get_current_color_plot(index_row))

            if _data.all_plot_axis.is_reduced_plot_stitching_tab_ylog:
                self.parent.ui.data_stitching_plot.set_yscale('log')

            if _data.all_plot_axis.is_reduced_plot_stitching_tab_xlog:
                self.parent.ui.data_stitching_plot.set_xscale('log')

            self.parent.ui.data_stitching_plot.draw()

        o_gui_utility = GuiUtility(parent = self.parent)
        yaxis_type = o_gui_utility.get_reduced_yaxis_type()
        if yaxis_type == 'RvsQ':
            if _data.all_plot_axis.reduced_plot_RQuserView_y is None:
                self.parent.ui.data_stitching_plot.canvas.draw()
                [xmin,xmax] = self.parent.ui.data_stitching_plot.canvas.ax.xaxis.get_view_interval()
                [ymin,ymax] = self.parent.ui.data_stitching_plot.canvas.ax.yaxis.get_view_interval()
                _data.all_plot_axis.reduced_plot_RQQ4userView_x = [xmin, xmax]
                _data.all_plot_axis.reduced_plot_RQuserView_y = [ymin, ymax]
                _data.all_plot_axis.reduced_plot_RQQ4autoView_x = [xmin, xmax]
                _data.all_plot_axis.reduced_plot_RQautoView_y = [ymin, ymax]
            else:
                [xmin, xmax] = _data.all_plot_axis.reduced_plot_RQQ4userView_x
                [ymin, ymax] = _data.all_plot_axis.reduced_plot_RQuserView_y
                self.parent.ui.data_stitching_plot.canvas.ax.set_xlim([xmin,xmax])
                self.parent.ui.data_stitching_plot.canvas.ax.set_ylim([ymin,ymax])
                self.parent.ui.data_stitching_plot.canvas.draw()
        else:
            if _data.all_plot_axis.reduced_plot_RQ4userView_y is None:
                self.parent.ui.data_stitching_plot.canvas.draw()
                [xmin,xmax] = self.parent.ui.data_stitching_plot.canvas.ax.xaxis.get_view_interval()
                [ymin,ymax] = self.parent.ui.data_stitching_plot.canvas.ax.yaxis.get_view_interval()

                _data.all_plot_axis.reduced_plot_RQQ4userView_x = [xmin, xmax]
                _data.all_plot_axis.reduced_plot_RQ4userView_y = [ymin, ymax]
                _data.all_plot_axis.reduced_plot_RQQ4autoView_x= [xmin, xmax]
                _data.all_plot_axis.reduced_plot_RQ4autoView_y = [ymin, ymax]
            else:
                [xmin, xmax] = _data.all_plot_axis.reduced_plot_RQQ4userView_x
                [ymin, ymax] = _data.all_plot_axis.reduced_plot_RQ4userView_y

                self.parent.ui.data_stitching_plot.canvas.ax.set_xlim([xmin,xmax])
                self.parent.ui.data_stitching_plot.canvas.ax.set_ylim([ymin,ymax])
                self.parent.ui.data_stitching_plot.canvas.draw()

        big_table_data[0, 0] = _data
        self.parent.big_table_data = big_table_data
Exemplo n.º 51
0
 def clear_stiching_table(self):
     if self.row_index == 0:
         o_gui_utility = GuiUtility(parent = self.parent)
         o_gui_utility.clear_table(self.parent.ui.dataStitchingTable)
Exemplo n.º 52
0
    def __init__(self, parent=None, 
                 is_data=True, 
                 entry_type='peak', 
                 value_min=-1, 
                 value_max=-1, 
                 flag=True):

        self.parent = parent
        big_table_data = parent.big_table_data
        gui_utility = GuiUtility(self.parent)
        row = gui_utility.get_current_table_reduction_check_box_checked()
        if row == -1:
            return

        if entry_type == 'clocking':
            all_rows = gui_utility.get_all_rows()
        else:
            all_rows = gui_utility.get_other_row_with_same_run_number_as_row(row = row,
                                                                             is_data = is_data)
        for _row in all_rows:
            
            if is_data:
                index = 0
            else:
                index = 1
            data = big_table_data[_row, index]
            
            val1 = value_min
            val2 = value_max
    
            if (val1 > val2):
                val_min = val2
                val_max = val1
            else:
                val_min = val1
                val_max = val2
            
            is_plot_yt = True
            is_plot_yi = True
            is_plot_it = False
            is_plot_ix = False
            if entry_type == 'peak':
                data.peak = [str(val_min), str(val_max)]
            elif entry_type == 'back':
                data.back = [str(val_min), str(val_max)]
                data.back_flag = flag
            elif entry_type == 'low_res':
                is_plot_yt = False
                is_plot_yi = False
                is_plot_ix = True
                data.low_res = [str(val_min), str(val_max)]
                data.low_res_flag = flag
            else:
                data.clocking = [str(val_min), str(val_max)]
                
            big_table_data[_row, index] = data
            self.parent.big_table_data = big_table_data

            if row == _row:
                DisplayPlots(parent = self.parent,
                             row = row,
                             is_data = is_data,
                             plot_yt = is_plot_yt,
                             plot_yi = is_plot_yi,
                             plot_it = is_plot_it,
                             plot_ix = is_plot_ix,
                             refresh_reduction_table = False)
Exemplo n.º 53
0
    def closeEvent(self, event = None):
        [lowres1, lowres2, lowresFlag] = self.retrieveLowRes()
        [tof1, tof2, peak1, peak2, back1, back2, backFlag]= self.retrieveTofPeakBack()
        tof_auto_switch = self.ui.tof_auto_flag.isChecked()	

        big_table_data = self.parent.big_table_data

        _data = big_table_data[self.row, self.col]
        _data.peak = [str(peak1), str(peak2)]
        _data.back = [str(back1), str(back2)]
        _data.back_flag = backFlag

        _data.tof_range_auto = [self.auto_min_tof * 1000, self.auto_max_tof * 1000]
        _data.tof_range = [self.manual_min_tof * 1000, self.manual_max_tof * 1000]
        _data.tof_range_manual = _data.tof_range
        _data.tof_range_auto_flag = tof_auto_switch
        _data.tof_auto_flag = tof_auto_switch

        _data.low_res = [str(lowres1), str(lowres2)]
        _data.low_res_flag = lowresFlag

        big_table_data[self.row, self.col] = _data
        if self.is_row_with_highest_q:
            _clock1 = self.ui.clock1.value()
            _clock2 = self.ui.clock2.value()
            _clocking = [str(_clock1), str(_clock2)]
            _data = big_table_data[0, 0]
            index = 0
            while (_data is not None):
                _data.clocking = _clocking
                big_table_data[index, 0] = _data
                _data = big_table_data[index+1, 0]
                index += 1
            self.parent.ui.dataPrimFromValue.setValue(_clock1)
            self.parent.ui.dataPrimToValue.setValue(_clock2)

        self.parent.big_table_data = big_table_data
        
        # tof
        o_gui_utility = GuiUtility(parent = self.parent)
        o_gui_utility.set_auto_tof_range_radio_button(status = tof_auto_switch)
        self.parent.ui.TOFmanualFromValue.setText("%.2f" %tof1)
        self.parent.ui.TOFmanualToValue.setText("%.2f" %tof2)

        if self.data_type == 'data':
            self.parent.ui.dataPeakFromValue.setValue(peak1)
            self.parent.ui.dataPeakToValue.setValue(peak2)
            self.parent.ui.dataBackFromValue.setValue(back1)
            self.parent.ui.dataBackToValue.setValue(back2)
            self.parent.ui.dataBackgroundFlag.setChecked(backFlag)
            #self.parent.data_peak_and_back_validation(False)
            self.parent.ui.dataBackFromLabel.setEnabled(backFlag)
            self.parent.ui.dataBackFromValue.setEnabled(backFlag)
            self.parent.ui.dataBackToLabel.setEnabled(backFlag)
            self.parent.ui.dataBackToValue.setEnabled(backFlag)
            self.parent.ui.dataLowResFromValue.setValue(lowres1)
            self.parent.ui.dataLowResToValue.setValue(lowres2)
            self.parent.ui.dataLowResFromLabel.setEnabled(lowresFlag)
            self.parent.ui.dataLowResFromValue.setEnabled(lowresFlag)
            self.parent.ui.dataLowResToLabel.setEnabled(lowresFlag)
            self.parent.ui.dataLowResToValue.setEnabled(lowresFlag)
        else:
            self.parent.ui.normPeakFromValue.setValue(peak1)
            self.parent.ui.normPeakToValue.setValue(peak2)
            self.parent.ui.normBackFromValue.setValue(back1)
            self.parent.ui.normBackToValue.setValue(back2)
            self.parent.ui.normBackgroundFlag.setChecked(backFlag)
            #self.parent.norm_peak_and_back_validation(False)
            self.parent.ui.normBackFromLabel.setEnabled(backFlag)
            self.parent.ui.normBackFromValue.setEnabled(backFlag)
            self.parent.ui.normBackToLabel.setEnabled(backFlag)
            self.parent.ui.normBackToValue.setEnabled(backFlag)
            self.parent.ui.normLowResFromValue.setValue(lowres1)
            self.parent.ui.normLowResToValue.setValue(lowres2)
            self.parent.ui.normLowResFromLabel.setEnabled(lowresFlag)
            self.parent.ui.normLowResFromValue.setEnabled(lowresFlag)
            self.parent.ui.normLowResToLabel.setEnabled(lowresFlag)
            self.parent.ui.normLowResToValue.setEnabled(lowresFlag)

        DisplayPlots(parent = self.parent,
                     row = self.row,
                     is_data = self.is_data,
                     plot_yt = True,
                     plot_yi = True,
                     plot_it = True,
                     plot_ix = True,
                     refresh_reduction_table = False)
        
        if not tof_auto_switch:
            o_auto_tof_range = AutoTofRangeRadioButtonHandler(parent = self.parent)
            o_auto_tof_range.setup()
            o_auto_tof_range.line_edit_validation()
            
Exemplo n.º 54
0
 def is_row_with_higest_q(self):
     o_gui_utility = GuiUtility(parent = self.parent)
     return o_gui_utility.is_row_with_highest_q()
Exemplo n.º 55
0
 def data_norm_tab_changed(self, index):
     o_gui_utility = GuiUtility(parent = self)
     _current_table_reduction_row_selected = o_gui_utility.get_current_table_reduction_check_box_checked()
     ReductionTableCheckBox(parent = self,
                            row_selected = _current_table_reduction_row_selected)