Skip to content

Commit

Permalink
able to project the bkg subtraction result to master cv figures
Browse files Browse the repository at this point in the history
  • Loading branch information
jackey-qiu committed Jan 30, 2022
1 parent 2789620 commit dd78ab8
Show file tree
Hide file tree
Showing 12 changed files with 134 additions and 45 deletions.
Binary file modified .DS_Store
Binary file not shown.
Binary file modified Doc/.DS_Store
Binary file not shown.
Binary file modified Doc/xrv/xrv.eddx
Binary file not shown.
2 changes: 1 addition & 1 deletion FilterPool/DataFilterPool.py
Original file line number Diff line number Diff line change
Expand Up @@ -408,7 +408,7 @@ def create_mask_new(self,img, img_q_par, img_q_ver, mon):
remove_q_range = {'par':remove_q_par,'ver':remove_q_ver}
remove_partial_range = {'point_couple':line_strike_segments, 'pixel_width':line_strike_width}

def _find_pixel_index_from_q(grid_q_par, grid_q_ver, point):
def _find_pixel_index_from_q(grid_q_ver, grid_q_par, point):
q_par_one_row = grid_q_par[0,:]
q_ver_one_col = grid_q_ver[:,0]
qx,qy = point
Expand Down
Binary file modified dump_files/temp_data_xrv.xlsx
Binary file not shown.
23 changes: 21 additions & 2 deletions projects/viewer/Data_Viewer_XRV_GUI.py
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,7 @@ def __init__(self, parent = None):
self.init_pandas_model_cv_setting()
self.pushButton_bkg_fit.clicked.connect(self.perform_bkg_fitting)
self.pushButton_extract_cv.clicked.connect(self.extract_cv_data)
self.pushButton_project.clicked.connect(self.project_to_master)

def perform_bkg_fitting(self):
order = 0
Expand All @@ -153,7 +154,18 @@ def perform_bkg_fitting(self):
scan_rate = float(self.lineEdit_scan_rate.text())
charge = self.widget.perform_bkg_fitting(order, s, fct, scan_rate)
self.lineEdit_charge.setText(f'{charge} mC/cm2')


def project_to_master(self):
scan_no = int(self.comboBox_scans_3.currentText())
index_lf, index_rg = list(map(int,list(self.widget.region.getRegion())))
pot = self.widget.p3_handle.getData()[1][index_lf:index_rg]
current_bkg = self.widget.p1_bkg_handle.getData()[1][index_lf:index_rg]
cv_scale_factor= self.plot_lib[scan_no][2]
getattr(self,'plot_axis_scan{}'.format(scan_no))[0].plot(pot, current_bkg * cv_scale_factor, '--k')
self.mplwidget.fig.tight_layout()
self.mplwidget.fig.subplots_adjust(wspace=0.04,hspace=0.04)
self.mplwidget.canvas.draw()

def init_pandas_model_ax_format(self):
data_ = {}
data_['use'] = [True]*6
Expand Down Expand Up @@ -1594,6 +1606,11 @@ def _cal_pseudcap_charge(self, scan):
print('Fail to cal charge info. Check!')

def _do_text_label(self, scan, count_pH13, x_min_value, y_max_values):
#overwrite max_y using the format setting
if 'master' in self.tick_label_settings:
if 'current' in self.tick_label_settings['master']:
y_max_values[0] = self.tick_label_settings['master']['current']['locator'][-1] + float(self.tick_label_settings['master']['current']['padding'])

#extract color
try:#from cv settings
_,_,_,_,_,color, _, _ = self.plot_lib[scan]
Expand Down Expand Up @@ -1624,10 +1641,12 @@ def _do_text_label(self, scan, count_pH13, x_min_value, y_max_values):
else:
text = ''
#set label here
getattr(self,'plot_axis_scan{}'.format(scan))[0].text(x_min_value, y_max_values[0]*0.8,text,color = color,fontsize=11)
text_obj = getattr(self,'plot_axis_scan{}'.format(scan))[0].text(x_min_value, y_max_values[0]*0.8,text,color = color,fontsize=11)
setattr(self, f'text_obj_{scan}', text_obj)
return count_pH13

def _decorate_axis_tick_labels(self, scan, channel, channel_index, x_min_value, x_max_value, y_min_values, y_max_values):

if self.plot_label_x[self.scans.index(scan)] == 'potential':
if 'master' in self.tick_label_settings:
if 'potential' in self.tick_label_settings['master']:
Expand Down
62 changes: 26 additions & 36 deletions projects/viewer/data_viewer_xrv_gui.ui
Original file line number Diff line number Diff line change
Expand Up @@ -1501,7 +1501,7 @@
<attribute name="title">
<string>FitCVPeak</string>
</attribute>
<layout class="QVBoxLayout" name="verticalLayout_11">
<layout class="QVBoxLayout" name="verticalLayout_13">
<item>
<widget class="bkg_win" name="widget" native="true"/>
</item>
Expand Down Expand Up @@ -1698,58 +1698,35 @@
</layout>
</item>
<item>
<layout class="QVBoxLayout" name="verticalLayout_10">
<layout class="QVBoxLayout" name="verticalLayout_11">
<item>
<widget class="QLabel" name="label_48">
<widget class="QPushButton" name="pushButton_bkg_fit">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Preferred">
<sizepolicy hsizetype="Minimum" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string>Peak_width</string>
<string>Remove bkg</string>
</property>
</widget>
</item>
<item>
<widget class="QSpinBox" name="spinBox_peak_width">
<property name="minimum">
<number>1</number>
<widget class="QPushButton" name="pushButton_project">
<property name="sizePolicy">
<sizepolicy hsizetype="Minimum" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="value">
<number>15</number>
<property name="text">
<string>Project to Master</string>
</property>
</widget>
</item>
</layout>
</item>
<item>
<widget class="QPushButton" name="pushButton_bkg_fit">
<property name="sizePolicy">
<sizepolicy hsizetype="Minimum" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string>perform bkg subtraction</string>
</property>
</widget>
</item>
<item>
<spacer name="horizontalSpacer_6">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item>
<layout class="QVBoxLayout" name="verticalLayout_12">
<item>
Expand All @@ -1768,6 +1745,19 @@
</item>
</layout>
</item>
<item>
<spacer name="horizontalSpacer_6">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
</layout>
</item>
</layout>
Expand Down
5 changes: 2 additions & 3 deletions projects/xrv/XRV_GUI.py
Original file line number Diff line number Diff line change
Expand Up @@ -564,9 +564,8 @@ def launch_file(self):

def save_file_as(self):
path, _ = QFileDialog.getSaveFileName(self, "Save file", "", "Text documents (*.txt);All files (*.*)")
text = self.textEdit.toPlainText()
with open(path, 'w') as f:
f.write(text)
# text = self.textEdit.toPlainText()
self.widget_config.save_parameter(path)
self.statusbar.showMessage('Config file is saved as {}!'.format(path))

def save_file(self):
Expand Down
81 changes: 81 additions & 0 deletions projects/xrv/config_file_XRV_default.ini
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
[Global]
beamline = P23_PETRA3
beamtime_id = I20190574
scan_nos = [82]
phs = [10]
data_keys = phs,scan_no,image_no,potential,potential_cal,current,peak_intensity,peak_intensity_error,bkg,pcov_ip,strain_ip,grain_size_ip,cen_ip,FWHM_ip,amp_ip,lfrac_ip,bg_slope_ip,bg_offset_ip,pcov_oop,strain_oop,grain_size_oop,cen_oop,FWHM_oop,amp_oop,lfrac_oop,bg_slope_oop,bg_offset_oop,H,K,L,phi,chi,mu,delta,gamma,omega_t,mon,transm,mask_cv_xrd,mask_ctr
cen = 637,328
clip_width = {'hor':200,'ver':300}
dim_detector = [1556,516]

[Data_Storage]
ids_file_head = ids
ids_files = ['048_S221_CV','054_S229_CV','057_S231_CV','060_S236_CV','064_S243_CV','065_S244_CV']

[Film_Lattice]
film_material_cif = Co3O4.cif
film_hkl_bragg_peak = [[-1,1,3]]
film_hkl_normal = [1,1,1]
film_hkl_x = [1,1,-2]

[Reciprocal_Mapping]
ub = [-0.388904, -2.34687, 0.00424869, 0.000210428, -0.0104566, -0.889455, 2.48543, 0.905918, 0.00074013]
sdd = 750
e_kev = 22.5
pixelsize = [0.055,0.055]
boost_mapping = False

[Peak_Fit]
pot_step_scan = False
use_first_fit_for_pos = True
fit_bounds = {'hor':[[1.0, 0.0050, 0, 0, -100000, -1e6],[1.3, 0.42, 1e9, 1, 100000, 1e6]], 'ver':[[1.2, 0.0050, 0, 0, -100000, -1e6],[1.6, 0.42, 1e9, 1, 100000, 1e6]]}
fit_p0 = {'hor':[1.2, 0.21, 0.1, 0.5, 0, 0],'ver':[1.35, 0.21, 0.1, 0.5, 0, 0]}
fit_p0_2 = {'hor':[1.2, 0.21, 0.1, 0.5, 0, 0],'ver':[1.35, 0.21, 0.1, 0.5, 0, 0]}
cut_offset = {'hor':[50,20],'ver':[50,20]}
data_range_offset = {'hor':[70,70],'ver':[70,70]}

[Image_Loader]
check_abnormality = False
transpose = True
flip = True
left_offset = 10
right_offset = 100
frame_prefix = i20180678_2
nexus_path = F://P23_I20180678/raw
constant_motors = {'omega_t':0.5, 'phi':0, 'chi':0, 'mu':0,'gamma':0,'delta':13.7}

[Visulization]
vmax = 200
vmin = 0
cmap = jet
pot_step = True

[Mask]
threshold = 50000
compare_method = larger
remove_columns = 10
remove_rows = 10
remove_pix = [231,206]
remove_q_par = []
remove_q_ver = []
line_strike_segments = []
line_strike_width = []

[Background_Subtraction]
rod_scan = 0
check_level = 0.00000000001
peak_shift = 0
peak_width = 70
update_width = False
row_width = 80
col_width = 80
bkg_row_width = 10
bkg_col_width = 5
bkg_win_cen_offset_lr = 10
bkg_win_cen_offset_ud = 10
int_direct = x
ord_cus_s = [1]
ss = [1]
ss_factor = 0.1
fct = atq

6 changes: 3 additions & 3 deletions projects/xrv/config_file_XRV_standard_new.ini
Original file line number Diff line number Diff line change
Expand Up @@ -58,14 +58,14 @@ remove_rows = []
remove_pix = []
remove_q_par = []
remove_q_ver = []
line_strike_segments = [{'p1': [2.4, 3.2], 'p2': [2.5, 3.0]}, {'p1': [2.4, 3.0], 'p2': [2.55, 3.3]}]
line_strike_segments = [{'p1': [2.16, 1.35], 'p2': [2.18, 1.38]}]
line_strike_width = []

[Background_Subtraction]
rod_scan = 0
check_level = 1e-10
check_level = 1e-10cc
peak_shift = 0
peak_width = 80
peak_width = 30
update_width = False
row_width = 80
col_width = 80
Expand Down
Binary file modified util/.DS_Store
Binary file not shown.
Binary file modified util/accessory_functions/.DS_Store
Binary file not shown.

0 comments on commit dd78ab8

Please sign in to comment.