Skip to content

Commit 38356f7

Browse files
author
Joel Bernier
committed
many small changes from beamtime
1 parent 65bfd6a commit 38356f7

File tree

10 files changed

+75
-30
lines changed

10 files changed

+75
-30
lines changed

hexrd/config/findorientations.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ def seed_search(self):
4545

4646
@property
4747
def threshold(self):
48-
return self._cfg.get('find_orientations:threshold', 0)
48+
return self._cfg.get('find_orientations:threshold', 1)
4949

5050

5151
@property

hexrd/config/imageseries.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,7 @@ def flip(self):
110110
if temp is None:
111111
return
112112
temp = temp.lower()
113-
if temp not in ['h', 'v', 'hv', 'vh', 'cw', 'ccw']:
113+
if temp not in ['h', 'v', 'hv', 'vh', 'cw90', 'ccw90']:
114114
raise RuntimeError(
115115
'image_series:flip setting "%s" is not valid' % temp
116116
)

hexrd/config/tests/test_find_orientations.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -85,15 +85,15 @@ def test_threshold(self):
8585
def test_threshold(self):
8686
self.assertEqual(
8787
self.cfgs[0].find_orientations.threshold,
88-
0
88+
1
8989
)
9090
self.assertEqual(
9191
self.cfgs[1].find_orientations.threshold,
9292
5
9393
)
9494
self.assertEqual(
9595
self.cfgs[2].find_orientations.threshold,
96-
0
96+
1
9797
)
9898

9999

hexrd/findorientations.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -173,7 +173,7 @@ def quat_distance(x, y):
173173
qfib_r = qfib[:, np.array(compl) > min_compl]
174174
num_ors = qfib_r.shape[1]
175175

176-
if num_ors > 12000:
176+
if num_ors > 25000:
177177
if algorithm == 'sph-dbscan' or algorithm == 'fclusterdata':
178178
logger.info("defaulting to orthographic DBSCAN")
179179
algorithm = 'ort-dbscan'

hexrd/fitgrains.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -487,6 +487,11 @@ def loop(self):
487487
refit_tol=self._p['refit_tol'])
488488
if compl == 0:
489489
break
490+
pass
491+
492+
# final pull spots if enabled
493+
if not self._p['fit_only']:
494+
self.pull_spots(id, grain_params, -1)
490495

491496
eMat = self.get_e_mat(grain_params)
492497
resd = self.get_residuals(grain_params)

hexrd/wx/cakingcanvas.py

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -455,7 +455,7 @@ def update(self, **kwargs):
455455
p.axes.set_aspect('auto')
456456
else:
457457
p.axes.imshow(intensity, origin='upper',
458-
interpolation='nearest',
458+
interpolation='none',
459459
aspect='auto',
460460
cmap=self.cmPanel.cmap,
461461
vmin=self.cmPanel.cmin_val,
@@ -646,9 +646,14 @@ def update(self, **kwargs):
646646
p.axes.hold(True)
647647
p.axes.images = []
648648

649+
if self.cmPanel.apply_filter:
650+
img = -ndimage.filters.gaussian_laplace(hkldata, self.cmPanel.filter_val)
651+
else:
652+
img = hkldata
653+
649654
# show new image
650-
p.axes.imshow(hkldata, origin='upper',
651-
interpolation='nearest',
655+
p.axes.imshow(img, origin='upper',
656+
interpolation='none',
652657
aspect='auto',
653658
cmap=self.cmPanel.cmap,
654659
vmin=self.cmPanel.cmin_val,

hexrd/wx/canvasutil.py

Lines changed: 47 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,7 @@ def __makeObjects(self):
9999
'Colormap: ',
100100
style=wx.ALIGN_RIGHT)
101101

102-
self.cmap_nameList = ['autumn', 'bone', 'bone_r', 'cool', 'copper',
102+
self.cmap_nameList = ['autumn', 'bone', 'bone_r', 'bwr', 'cool', 'copper',
103103
'flag', 'gray', 'gray_r', 'hot', 'hot_r',
104104
'hsv', 'jet', 'pink', 'prism', 'spring',
105105
'summer', 'winter', 'spectral']
@@ -111,22 +111,31 @@ def __makeObjects(self):
111111

112112
self.cmin_val = 0
113113
self.cmin_lab = wx.StaticText(self, wx.NewId(),
114-
'Minimum: ',
115-
style=wx.ALIGN_RIGHT)
114+
'Minimum: ',
115+
style=wx.ALIGN_RIGHT)
116116
self.cmin_txt = wx.TextCtrl(self, wx.NewId(),
117-
value=str(self.cmin_val),
118-
style=wx.RAISED_BORDER | wx.TE_PROCESS_ENTER)
117+
value=str(self.cmin_val),
118+
style=wx.RAISED_BORDER | wx.TE_PROCESS_ENTER)
119119
self.cmUnder_box = wx.CheckBox(self, wx.NewId(), 'show under')
120120

121121
self.cmax_val = 2000
122122
self.cmax_lab = wx.StaticText(self, wx.NewId(),
123-
'Maximum: ',
124-
style=wx.ALIGN_RIGHT)
123+
'Maximum: ',
124+
style=wx.ALIGN_RIGHT)
125125
self.cmax_txt = wx.TextCtrl(self, wx.NewId(),
126-
value=str(self.cmax_val),
127-
style=wx.RAISED_BORDER | wx.TE_PROCESS_ENTER)
126+
value=str(self.cmax_val),
127+
style=wx.RAISED_BORDER | wx.TE_PROCESS_ENTER)
128128
self.cmOver_box = wx.CheckBox(self, wx.NewId(), 'show over')
129129

130+
self.apply_filter = False
131+
self.filter_val = 0.8
132+
self.applyFilter_txt = wx.TextCtrl(self, wx.NewId(),
133+
value=str(self.filter_val),
134+
style=wx.RAISED_BORDER | wx.TE_PROCESS_ENTER)
135+
self.applyFilter_lab = wx.StaticText(self, wx.NewId(),
136+
'Apply filter: ',
137+
style=wx.ALIGN_RIGHT)
138+
self.applyFilter_box = wx.CheckBox(self, wx.NewId(), 'apply filter')
130139

131140
return
132141

@@ -140,14 +149,16 @@ def __makeBindings(self):
140149
self.Bind(wx.EVT_CHECKBOX, self.OnSetUnder, self.cmUnder_box)
141150
self.Bind(wx.EVT_CHECKBOX, self.OnSetOver, self.cmOver_box)
142151

152+
self.Bind(wx.EVT_TEXT_ENTER, self.OnSetFilterVal, self.applyFilter_txt)
153+
self.Bind(wx.EVT_CHECKBOX, self.OnApplyFilter, self.applyFilter_box)
143154
return
144155

145156
def __makeSizers(self):
146157
"""Lay out the interactors"""
147158
#
148159
# colormap sizer
149160
#
150-
nrow = 3; ncol = 3; padx = 5; pady = 5
161+
nrow = 4; ncol = 3; padx = 5; pady = 5
151162
self.cmSizer = wx.FlexGridSizer(nrow, ncol, padx, pady)
152163

153164
self.cmSizer.Add(self.cmap_lab, 0, wx.EXPAND | wx.ALIGN_RIGHT)
@@ -162,6 +173,11 @@ def __makeSizers(self):
162173
self.cmSizer.Add(self.cmax_txt, 0, wx.EXPAND | wx.ALIGN_RIGHT)
163174
self.cmSizer.Add(self.cmOver_box, 0, wx.EXPAND | wx.ALIGN_RIGHT)
164175

176+
self.cmSizer.Add(self.applyFilter_lab, 0, wx.EXPAND | wx.ALIGN_RIGHT)
177+
self.cmSizer.Add(self.applyFilter_txt, 0, wx.EXPAND | wx.ALIGN_RIGHT)
178+
self.cmSizer.Add(self.applyFilter_box, 0, wx.EXPAND | wx.ALIGN_RIGHT)
179+
180+
165181
self.sizer = wx.BoxSizer(wx.VERTICAL)
166182
self.sizer.Add(self.tbarSizer, 0, wx.EXPAND|wx.ALIGN_CENTER)
167183
self.sizer.Add(self.cmSizer, 0, wx.EXPAND|wx.ALIGN_RIGHT)
@@ -219,6 +235,27 @@ def OnSetOver(self, e):
219235

220236
return
221237

238+
def OnSetFilterVal(self, e):
239+
"""set std dev for filter"""
240+
241+
self.filter_val = float(self.applyFilter_txt.GetValue())
242+
self.update(updateImage=True)
243+
244+
return
245+
246+
def OnApplyFilter(self, e):
247+
"""toggle application of gauss-laplace filter in display"""
248+
249+
if e.IsChecked():
250+
self.apply_filter = True
251+
else:
252+
self.apply_filter = False
253+
pass
254+
255+
self.update(updateImage=True)
256+
257+
return
258+
222259
pass # end class
223260
#
224261
# -----------------------------------------------END CLASS: cmapPanel

hexrd/xrd/crystallography.py

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1349,16 +1349,16 @@ def getFriedelPair(tth0, eta0, *ome0, **kwargs):
13491349

13501350
nchi = num.c_[0., cchi, schi].T
13511351

1352-
gHat0_l = num.vstack([ceta * ctht,
1353-
seta * ctht,
1354-
stht])
1352+
gHat0_l = -num.vstack([ceta * ctht,
1353+
seta * ctht,
1354+
stht])
13551355

1356-
a = cchi*ceta*ctht
1357-
b = cchi*schi*seta*ctht + schi*schi*stht - stht
1358-
c = stht + cchi*schi*seta*ctht + schi*schi*stht
1356+
a = cchi*ceta*ctht
1357+
b = -cchi*stht
1358+
c = stht + schi*seta*ctht
13591359

13601360
# form solution
1361-
abMag = num.sqrt(a*a + b*b); assert num.all(abMag > 0), "Beam vector specification is infealible!"
1361+
abMag = num.sqrt(a*a + b*b); assert num.all(abMag > 0), "Beam vector specification is infeasible!"
13621362
phaseAng = num.arctan2(b, a)
13631363
rhs = c / abMag; rhs[abs(rhs) > 1.] = num.nan
13641364
rhsAng = num.arcsin(rhs)

hexrd/xrd/material.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,7 @@ def __init__(self, name=DFLT_NAME, cfgP=None):
9898
#
9999
self.sgnum = Material.DFLT_SGNUM
100100
#
101-
self._atominfo = Material.DFLT_ATOMINFO
101+
self._atominfo = Material.DFLT_ATOMINFO
102102
#
103103
pass
104104
return

hexrd/xrd/xrdutil.py

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3591,7 +3591,7 @@ def simulateLauePattern(hkls, bMat,
35913591
pass
35923592

35933593
# index for valid reflections
3594-
keepers = num.logical_and(onDetector, validEnergy)
3594+
keepers = num.where(num.logical_and(onDetector, validEnergy))[0]
35953595

35963596
# assign output arrays
35973597
xy_det[iG][keepers, :] = dpts[:, keepers].T
@@ -3905,7 +3905,6 @@ def pullSpots(pd, detector_params, grain_params, reader,
39053905
tVec_s = num.ascontiguousarray(detector_params[7:10])
39063906
rMat_c = xfcapi.makeRotMatOfExpMap(grain_params[:3])
39073907
tVec_c = num.ascontiguousarray(grain_params[3:6])
3908-
vInv_s = num.ascontiguousarray(grain_params[6:12])
39093908

39103909
reader_as_list = False
39113910
if hasattr(reader, '__len__'):
@@ -3964,7 +3963,6 @@ def pullSpots(pd, detector_params, grain_params, reader,
39643963
else:
39653964
labelStructure = ndimage.generate_binary_structure(3,3)
39663965

3967-
pixel_area = pixel_pitch[0]*pixel_pitch[1] # mm^2
39683966
pdim_buffered = [(panel_dims[0][0] + panel_buff[0], panel_dims[0][1] + panel_buff[1]),
39693967
(panel_dims[1][0] - panel_buff[0], panel_dims[1][1] - panel_buff[1])]
39703968
# results: hkl, ang, xy, pix
@@ -4104,7 +4102,7 @@ def pullSpots(pd, detector_params, grain_params, reader,
41044102
f1 = rdr.read(nframes=len(oidx1), nskip=oidx1[0])
41054103
r2 = rdr.makeNew()
41064104
f2 = r2.read(nframes=len(oidx2), nskip=oidx2[0])
4107-
frames = num.zeros(sdim, dtype=f1.dtype)
4105+
frames = num.zeros(sdims, dtype=f1.dtype)
41084106
frames[:len(oidx1), :, :] = f1
41094107
frames[len(oidx1):, :, :] = f2
41104108
else:

0 commit comments

Comments
 (0)