Skip to content

Commit 395caa5

Browse files
Caleb DuffCaleb Duff
authored andcommitted
Added Rotation parameters to dialog window
1 parent 23a7d90 commit 395caa5

File tree

2 files changed

+72
-18
lines changed

2 files changed

+72
-18
lines changed

xpdView/azimuthal.py

Lines changed: 29 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,24 @@ class Azimuthal(object):
2727
2828
Attributes
2929
----------
30+
x_lists : list of 1d numpy arrays
31+
list of x data for the integration patterns to be stored in
32+
y_lists : list of 1d numpy arrays
33+
see above, but for y data
34+
file_names : list of strings
35+
list of strings unique to each integration pattern
36+
wl : float
37+
wavelength in angstroms
38+
poni1 : float
39+
required by pyFAI something to do with beam placement
40+
poni2 : float
41+
same as above
42+
dist : float
43+
distance from sample to detector
44+
rot1 : float
45+
rotation of the detector, required by pyFAI
46+
rot2 : float
47+
rotation of the detector, required by pyFAI
3048
"""
3149

3250
def __init__(self):
@@ -48,8 +66,10 @@ def __init__(self):
4866
self.poni1 = None
4967
self.poni2 = None
5068
self.dist = None
69+
self.rot1 = None
70+
self.rot2 = None
5171

52-
def set_integration_parameters(self, wl=0.184320, poni1=.1006793, poni2=.1000774, dist=0.2418217):
72+
def set_integration_parameters(self, wl=0.184320, poni1=.1006793, poni2=.1000774, dist=0.2418217, rot1=0, rot2=0):
5373
"""
5474
This method sets the integration parameters
5575
Parameters
@@ -62,6 +82,10 @@ def set_integration_parameters(self, wl=0.184320, poni1=.1006793, poni2=.1000774
6282
this value is required by the pyFAI integrator
6383
dist : float
6484
This is distance to the detector
85+
rot1 : float
86+
This is the rotation one parameter
87+
rot2 : float
88+
This is the rotation two parameter
6589
6690
Returns
6791
-------
@@ -72,6 +96,8 @@ def set_integration_parameters(self, wl=0.184320, poni1=.1006793, poni2=.1000774
7296
self.poni1 = 2*poni1
7397
self.poni2 = 2*poni2
7498
self.dist = dist
99+
self.rot1 = rot1
100+
self.rot2 = rot2
75101

76102
def get_right_names(self, file_names, data_list):
77103
"""
@@ -117,7 +143,8 @@ def integration_time(self, data_list):
117143
ni = pyFAI.calibrant.ALL_CALIBRANTS("Ni")
118144
ni.set_wavelength(self.wl)
119145
ai = pyFAI.AzimuthalIntegrator(dist=self.dist, poni1=self.poni1,
120-
poni2=self.poni2, rot1=0, rot2=0, detector=det)
146+
poni2=self.poni2, rot1=self.rot1,
147+
rot2=self.rot2, detector=det)
121148
ai.set_wavelength(self.wl)
122149

123150
for data in data_list:

xpdView/xpd_view.py

Lines changed: 43 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -62,10 +62,10 @@ def data_gen(length):
6262
for x in range(x_length):
6363
for y in range(y_length):
6464
height = idx + 1
65-
if x == int(x_length/2) and y == int(y_length/2):
65+
if x == int(x_length / 2) and y == int(y_length / 2):
6666
array_style[x][y] = 0
6767
else:
68-
array_style[x][y] = height/np.sqrt((x-int(x_length/2))**2+(y-int(y_length/2))**2)
68+
array_style[x][y] = height / np.sqrt((x - int(x_length / 2)) ** 2 + (y - int(y_length / 2)) ** 2)
6969
data.append(array_style)
7070
return data, keys
7171

@@ -623,7 +623,7 @@ def set_x_offset(self, value):
623623
self.water.generate_waterfall()
624624

625625
def set_y_offset(self, value):
626-
self.water.y_offset = (value/10.0)
626+
self.water.y_offset = (value / 10.0)
627627
self.water.generate_waterfall()
628628

629629
def set_analysis_type(self, i):
@@ -879,6 +879,8 @@ def set_integration_parameters(self):
879879
poni1 = .1006793
880880
poni2 = .1000774
881881
dist = 0.2418217
882+
rot1 = 0
883+
rot2 = 0
882884
vbox = QtGui.QVBoxLayout()
883885
popup.setLayout(vbox)
884886

@@ -888,7 +890,7 @@ def set_integration_parameters(self):
888890
wave_label = QtGui.QLabel()
889891
wave_label.setText('Wavelength (in Angstroms): ')
890892
wave_number = QtGui.QDoubleSpinBox()
891-
wave_number.setDecimals(12)
893+
wave_number.setDecimals(8)
892894
wave_number.setValue(wavelength)
893895
hbox1.addWidget(wave_label)
894896
hbox1.addWidget(wave_number)
@@ -899,7 +901,7 @@ def set_integration_parameters(self):
899901
poni1_label = QtGui.QLabel()
900902
poni1_label.setText('Poni1: ')
901903
poni1_number = QtGui.QDoubleSpinBox()
902-
poni1_number.setDecimals(12)
904+
poni1_number.setDecimals(8)
903905
poni1_number.setValue(poni1)
904906
hbox2.addWidget(poni1_label)
905907
hbox2.addWidget(poni1_number)
@@ -910,7 +912,7 @@ def set_integration_parameters(self):
910912
poni2_label = QtGui.QLabel()
911913
poni2_label.setText('Poni2: ')
912914
poni2_number = QtGui.QDoubleSpinBox()
913-
poni2_number.setDecimals(12)
915+
poni2_number.setDecimals(8)
914916
poni2_number.setValue(poni2)
915917
hbox3.addWidget(poni2_label)
916918
hbox3.addWidget(poni2_number)
@@ -922,21 +924,45 @@ def set_integration_parameters(self):
922924
dist_label.setText('Distance (m): ')
923925
dist_number = QtGui.QDoubleSpinBox()
924926
dist_number.setValue(dist)
925-
dist_number.setDecimals(12)
927+
dist_number.setDecimals(8)
926928
hbox4.addWidget(dist_label)
927929
hbox4.addWidget(dist_number)
928930

929-
# This sets up the button to accept the values and close the window
931+
# This sets up the line for setting the rot1 value
930932
hbox5 = QtGui.QHBoxLayout()
931933
vbox.addLayout(hbox5)
934+
rot1_label = QtGui.QLabel()
935+
rot1_label.setText('Rotation 1 (Radians): ')
936+
rot1_number = QtGui.QDoubleSpinBox()
937+
rot1_number.setValue(rot1)
938+
rot1_number.setDecimals(8)
939+
hbox5.addWidget(rot1_label)
940+
hbox5.addWidget(rot1_number)
941+
942+
# This sets up the line for setting the rot2 value
943+
hbox6 = QtGui.QHBoxLayout()
944+
vbox.addLayout(hbox6)
945+
rot2_label = QtGui.QLabel()
946+
rot2_label.setText('Rotation 2 (Radians): ')
947+
rot2_number = QtGui.QDoubleSpinBox()
948+
rot2_number.setValue(rot2)
949+
rot2_number.setDecimals(8)
950+
hbox6.addWidget(rot2_label)
951+
hbox6.addWidget(rot2_number)
952+
953+
# This sets up the button to accept the values and close the window
954+
hbox6 = QtGui.QHBoxLayout()
955+
vbox.addLayout(hbox6)
932956
accept_btn = QtGui.QPushButton()
933957
accept_btn.setText('Accept')
934-
hbox5.addWidget(accept_btn)
958+
hbox6.addWidget(accept_btn)
935959
accept_btn.clicked.connect(popup.close)
936960
accept_btn.clicked.connect(lambda: self.Azi.set_integration_parameters(wl=wave_number.value(),
937961
poni1=poni1_number.value(),
938962
poni2=poni2_number.value(),
939-
dist=dist_number.value()))
963+
dist=dist_number.value(),
964+
rot1=rot1_number.value(),
965+
rot2=rot2_number.value()))
940966

941967
popup.show()
942968
popup.exec_()
@@ -1058,7 +1084,7 @@ def update_int_data(self, file_list, data_x, data_y):
10581084
for file in file_list:
10591085
self.int_key_list.append(file)
10601086
for i in range(old_length, len(self.int_key_list)):
1061-
self.int_data_dict[self.int_key_list[i]] = [data_x[i-old_length], data_y[i-old_length]]
1087+
self.int_data_dict[self.int_key_list[i]] = [data_x[i - old_length], data_y[i - old_length]]
10621088
if len(self.int_key_list) != 0:
10631089
self.water.normalize_data()
10641090
self.water.generate_waterfall()
@@ -1114,7 +1140,7 @@ def add_func(self, func):
11141140
self.func_dict[func.__name__] = func
11151141

11161142
def remove_func(self, func_name):
1117-
"""This function will remove a function from the function dictionary
1143+
"""This function will remove a function from the function dictionary
11181144
11191145
To delete the name of the function must match the name of a function currently in the dictionary
11201146
@@ -1126,10 +1152,10 @@ def remove_func(self, func_name):
11261152
11271153
"""
11281154

1129-
try:
1130-
self.data_dict.__delitem__(func_name)
1131-
except KeyError:
1132-
print("There is no function matching " + func_name + " in the function dictionary")
1155+
try:
1156+
self.data_dict.__delitem__(func_name)
1157+
except KeyError:
1158+
print("There is no function matching " + func_name + " in the function dictionary")
11331159

11341160

11351161
def main():
@@ -1146,5 +1172,6 @@ def main():
11461172
viewer.show()
11471173
sys.exit(app.exec_())
11481174

1175+
11491176
if __name__ == "__main__":
11501177
main()

0 commit comments

Comments
 (0)