Skip to content

Commit 943fb17

Browse files
committed
updates for wxpython 4 compatability
2 parents 0fcf1ee + ecaeeea commit 943fb17

File tree

14 files changed

+219
-71
lines changed

14 files changed

+219
-71
lines changed

conda.recipe/meta.yaml

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ package:
44

55
source:
66
#git_url: https://github.com/joelvbernier/hexrd.git
7-
#git_tag: v0.3.x
7+
#git_tag: v0.6.x
88
git_url: ../
99

1010
build:
@@ -22,15 +22,15 @@ requirements:
2222
build:
2323
- numba
2424
- numpy
25-
- python ==2
25+
- python
2626
- setuptools
2727
run:
2828
- h5py
2929
- matplotlib
3030
- numba
3131
- numpy
3232
- progressbar
33-
- python ==2
33+
- python
3434
- python.app # [osx]
3535
- pyyaml
3636
- scikit-image
@@ -41,17 +41,17 @@ requirements:
4141
test:
4242
imports:
4343
- hexrd
44-
#commands:
45-
# - hexrd -V
46-
# - hexrd -h
47-
# - hexrd help
48-
# - hexrd find-orientations -h
49-
# - hexrd help find-orientations
50-
# - hexrd fit-grains -h
51-
# - hexrd help fit-grains
52-
# - hexrd gui -h
53-
# - hexrd help gui
54-
# - hexrd test
44+
# commands:
45+
# - hexrd -V
46+
# - hexrd -h
47+
# - hexrd help
48+
# - hexrd find-orientations -h
49+
# - hexrd help find-orientations
50+
# - hexrd fit-grains -h
51+
# - hexrd help fit-grains
52+
# - hexrd gui -h
53+
# - hexrd help gui
54+
# - hexrd test
5555

5656
about:
5757
license: LGPL

docs/build.rst

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,6 @@ Building
2222
First, the dependencies for building an environment to run hexrd::
2323

2424
- cython
25-
- dask
26-
- distributed
2725
- fabio <pip>
2826
- h5py
2927
- matplotlib
@@ -36,21 +34,26 @@ First, the dependencies for building an environment to run hexrd::
3634
- scikit-image
3735
- scikit-learn
3836
- scipy
39-
- wxpython ==3
37+
- wxpython
4038

4139
If you will be running scripts of you own, I also strongly suggest adding spyder::
4240

4341
- spyder
4442

4543
For example, to buid an environment to run hexrd v0.6.x, do the following::
4644

47-
conda create --name hexrd_0.6 cython dask distributed h5py matplotlib numba numpy=1.15 progressbar=2.3 python=2.7 pyyaml setuptools scikit-image scikit-learn scipy spyder wxpython=3
45+
conda create --name hexrd_0.6 cython h5py matplotlib numba numpy python=2.7 pyyaml setuptools scikit-image scikit-learn scipy spyder
46+
conda install -c anaconda --name hexrd_0.6 wxpython
47+
conda install -c anaconda --name hexrd_0.6 progressbar
48+
conda activate hexrd_0.6
49+
4850

49-
Then install in develop mode using disutils::
51+
Then install using setuptools::
5052
51-
python setup.py develop
53+
python setup.py install
5254
53-
The procedure for building/installing with conda-build is as follows
55+
Note, you will have to install fabio in the same environment using ``setup.py`` as well.
56+
The procedure for building/installing with conda-build is as follows (*this is curently broken*)
5457

5558
First, update conda and conda-build::
5659

@@ -106,4 +109,4 @@ directory) and run::
106109

107110
hexrd --verison
108111

109-
It should currently read ``hexrd 0.6.0``
112+
It should currently read ``hexrd 0.6.5``

hexrd/findorientations.py

Lines changed: 48 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -26,9 +26,7 @@
2626

2727
from hexrd.fitgrains import get_instrument_parameters
2828

29-
logger = logging.getLogger(__name__)
30-
31-
save_as_ascii = False # FIX LATER...
29+
from skimage.feature import blob_dog, blob_log
3230

3331
# just require scikit-learn?
3432
have_sklearn = False
@@ -43,9 +41,20 @@
4341
pass
4442

4543

44+
method = "blob_dog" # !!! have to get this from the config
45+
save_as_ascii = False # FIX LATER...
46+
47+
logger = logging.getLogger(__name__)
48+
49+
50+
# =============================================================================
51+
# FUNCTIONS
52+
# =============================================================================
53+
54+
4655
def generate_orientation_fibers(
4756
eta_ome, chi, threshold, seed_hkl_ids, fiber_ndiv,
48-
filt_stdev=0.8, ncpus=1):
57+
method='blob_dog', filt_stdev=0.8, ncpus=1):
4958
"""
5059
From ome-eta maps and hklid spec, generate list of
5160
quaternions from fibers
@@ -82,21 +91,42 @@ def generate_orientation_fibers(
8291
numSpots = []
8392
coms = []
8493
for i in seed_hkl_ids:
85-
# First apply filter
86-
this_map_f = -ndimage.filters.gaussian_laplace(
87-
eta_ome.dataStore[i], filt_stdev)
88-
89-
labels_t, numSpots_t = ndimage.label(
90-
this_map_f > threshold,
91-
structureNDI_label
92-
)
93-
coms_t = np.atleast_2d(
94-
ndimage.center_of_mass(
95-
this_map_f,
96-
labels=labels_t,
97-
index=np.arange(1, np.amax(labels_t)+1)
94+
if method == 'label':
95+
# First apply filter
96+
this_map_f = -ndimage.filters.gaussian_laplace(
97+
eta_ome.dataStore[i], filt_stdev)
98+
99+
labels_t, numSpots_t = ndimage.label(
100+
this_map_f > threshold,
101+
structureNDI_label
98102
)
99-
)
103+
coms_t = np.atleast_2d(
104+
ndimage.center_of_mass(
105+
this_map_f,
106+
labels=labels_t,
107+
index=np.arange(1, np.amax(labels_t) + 1)
108+
)
109+
)
110+
elif method in ['blob_log', 'blob_dog']:
111+
# must scale map
112+
this_map = eta_ome.dataStore[i]
113+
this_map[np.isnan(this_map)] = 0.
114+
this_map -= np.min(this_map)
115+
scl_map = 2*this_map/np.max(this_map) - 1.
116+
117+
# FIXME: need to expose the parameters to config options.
118+
if method == 'blob_log':
119+
blobs = np.atleast_2d(
120+
blob_log(scl_map, min_sigma=0.5, max_sigma=5,
121+
num_sigma=10, threshold=0.01, overlap=0.1)
122+
)
123+
else:
124+
blobs = np.atleast_2d(
125+
blob_dog(scl_map, min_sigma=0.5, max_sigma=5,
126+
sigma_ratio=1.6, threshold=0.01, overlap=0.1)
127+
)
128+
numSpots_t = len(blobs)
129+
coms_t = blobs[:, :2]
100130
numSpots.append(numSpots_t)
101131
coms.append(coms_t)
102132
pass

hexrd/instrument.py

Lines changed: 17 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@
5555
mapAngle, \
5656
oscillAnglesOfHKLs, \
5757
rowNorm, \
58-
validateAngleRanges
58+
unitRowVector
5959
from hexrd.xrd import xrdutil
6060
from hexrd.xrd.crystallography import PlaneData
6161
from hexrd import constants as ct
@@ -554,10 +554,11 @@ def extract_polar_maps(self, plane_data, imgser_dict,
554554
# remap
555555
retas = mapAngle(retas, new_period)
556556
tmp_bins = mapAngle(eta_edges[reta_idx], new_period)
557-
reta_idx = np.argsort(tmp_bins)
557+
tmp_idx = np.argsort(tmp_bins)
558+
reta_idx = reta_idx[np.argsort(tmp_bins)]
558559
eta_bins = np.hstack(
559-
[tmp_bins[reta_idx],
560-
tmp_bins[reta_idx][-1] + delta_eta]
560+
[tmp_bins[tmp_idx],
561+
tmp_bins[tmp_idx][-1] + delta_eta]
561562
)
562563
pass
563564
pass
@@ -600,7 +601,7 @@ def extract_line_positions(self, plane_data, imgser_dict,
600601
tth_ranges = np.degrees(plane_data.getMergedRanges()[1])
601602
tth_tols = np.vstack([i[1] - i[0] for i in tth_ranges])
602603
else:
603-
tth_tols=np.ones(len(plane_data))*tth_tol
604+
tth_tols = np.ones(len(plane_data))*tth_tol
604605

605606
# =====================================================================
606607
# LOOP OVER DETECTORS
@@ -624,7 +625,8 @@ def extract_line_positions(self, plane_data, imgser_dict,
624625

625626
# make rings
626627
pow_angs, pow_xys = panel.make_powder_rings(
627-
plane_data, merge_hkls=True, delta_tth=tth_tol, delta_eta=eta_tol)
628+
plane_data, merge_hkls=True,
629+
delta_tth=tth_tol, delta_eta=eta_tol)
628630

629631
# =================================================================
630632
# LOOP OVER RING SETS
@@ -681,7 +683,7 @@ def extract_line_positions(self, plane_data, imgser_dict,
681683
ims_data = []
682684
for j_p in np.arange(len(images)):
683685
# catch interpolation type
684-
image=images[j_p]
686+
image = images[j_p]
685687
if do_interpolation:
686688
tmp = panel.interpolate_bilinear(
687689
xy_eval,
@@ -1552,13 +1554,13 @@ def clip_to_panel(self, xy, buffer_edges=True):
15521554
)
15531555
on_panel = np.logical_and(on_panel_x, on_panel_y)
15541556
elif not buffer_edges:
1555-
on_panel_x = np.logical_and(
1556-
xy[:, 0] >= -xlim, xy[:, 0] <= xlim
1557-
)
1558-
on_panel_y = np.logical_and(
1559-
xy[:, 1] >= -ylim, xy[:, 1] <= ylim
1560-
)
1561-
on_panel = np.logical_and(on_panel_x, on_panel_y)
1557+
on_panel_x = np.logical_and(
1558+
xy[:, 0] >= -xlim, xy[:, 0] <= xlim
1559+
)
1560+
on_panel_y = np.logical_and(
1561+
xy[:, 1] >= -ylim, xy[:, 1] <= ylim
1562+
)
1563+
on_panel = np.logical_and(on_panel_x, on_panel_y)
15621564
return xy[on_panel, :], on_panel
15631565

15641566
def cart_to_angles(self, xy_data):
@@ -1743,7 +1745,7 @@ def make_powder_rings(
17431745
eta_centers = eta_edges[:-1] + del_eta
17441746

17451747
# !!! get chi and ome from rmat_s
1746-
chi = np.arctan2(rmat_s[2, 1], rmat_s[1, 1])
1748+
# chi = np.arctan2(rmat_s[2, 1], rmat_s[1, 1])
17471749
ome = np.arctan2(rmat_s[0, 2], rmat_s[0, 0])
17481750

17491751
# make list of angle tuples

hexrd/wx/fitparampanel.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -97,12 +97,12 @@ def __makeObjects(self):
9797
def __makeTitleBar(self, t):
9898
"""Add titlebar"""
9999
self.titlebar = wx.StaticText(self, -1, t,
100-
style=wx.ALIGN_CENTER|wx.SIMPLE_BORDER)
100+
style=wx.ALIGN_CENTER|wx.SIMPLE_BORDER)
101101
self.titlebar.SetBackgroundColour(WP.TITLEBAR_BG_COLOR)
102102
myToolTip = r"""
103-
PANEL FOR managing data for fit parameters
104-
"""
105-
self.titlebar.SetToolTipString(myToolTip)
103+
PANEL FOR managing data for fit parameters
104+
"""
105+
self.titlebar.SetToolTip(myToolTip)
106106

107107
return
108108

hexrd/wx/floatcontrol.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,7 @@ def __init__(self, parent, id, **kwargs):
9898
The spinner increment is shown in the gray
9999
box to the right of the spinner.
100100
"""
101-
self.SetToolTipString(myToolTip)
101+
self.SetToolTip(myToolTip)
102102

103103
self.SetAutoLayout(True)
104104
self.SetSizerAndFit(self.sizer)

hexrd/wx/guiutil.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,7 @@ def makeTitleBar(p, t, **kwargs):
111111
# Keyword args
112112
#
113113
tt = 'tooltip'
114-
if tt in kwargs: titlebar.SetToolTipString(kwargs[tt])
114+
if tt in kwargs: titlebar.SetToolTip(kwargs[tt])
115115

116116
cl = 'color'
117117
if cl in kwargs:

hexrd/wx/indexpanel.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -204,7 +204,7 @@ def __makeObjects(self):
204204

205205
self.friedel_cbox = wx.CheckBox(self, wx.NewId(), 'Friedel Only')
206206
self.friedel_cbox.SetValue(iopts.friedelOnly)
207-
self.claims_cbox = wx.CheckBox(self, wx.NewId(), 'Preserve Claiims')
207+
self.claims_cbox = wx.CheckBox(self, wx.NewId(), 'Preserve Claims')
208208
self.claims_cbox.SetValue(iopts.preserveClaims)
209209
self.refine_cbox = wx.CheckBox(self, wx.NewId(), 'Do Refinement')
210210
self.refine_cbox.SetValue(iopts.doRefinement)

hexrd/wx/listeditor.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,7 @@ def __makeTitleBar(self, t):
101101
myToolTip = r"""
102102
PANEL FOR ...
103103
"""
104-
self.titlebar.SetToolTipString(myToolTip)
104+
self.titlebar.SetToolTip(myToolTip)
105105

106106
return
107107

hexrd/wx/materialspanel.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -189,7 +189,7 @@ def __makeTitleBar(self, t):
189189
myToolTip = r"""
190190
PANEL FOR ...
191191
"""
192-
self.titlebar.SetToolTipString(myToolTip)
192+
self.titlebar.SetToolTip(myToolTip)
193193

194194
return
195195

0 commit comments

Comments
 (0)