Skip to content

Commit 4b49443

Browse files
committed
Merge branch 'develop_old'
2 parents d8769c9 + c606f4b commit 4b49443

15 files changed

+560
-435
lines changed

CHANGELOG.md

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,20 @@
99
### Fixed
1010

1111

12+
## 0.93.4 (07-03-2022)
13+
14+
### Changed
15+
- Update BCC slip system file and add a separate FCC file with same ordering as in DAMASK
16+
- Refactor boundary lines in `ebsd.map` class and add methods for warping lines to a DIC map
17+
- Refactor `linkEbsdMap` method and pass all arguments to transform estimate method
18+
- Remove IPython and jupyter as requirements
19+
- Move slip systems to `Phase` class and load automatically based on crystal stucture
20+
- Make Oxford bonary loader tolerate of unknown data fields
21+
22+
### Fixed
23+
- Fix ebsd grain linker so it works again
24+
25+
1226
## 0.93.3 (23-08-2021)
1327

1428
### Added

defdap/__init__.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,4 +11,9 @@
1111
'find_grain_report_freq': 100,
1212
# How to find grain in a HRDIC map, either 'floodfill' or 'warp'
1313
'hrdic_grain_finding_method': 'floodfill',
14+
'slip_system_file': {
15+
'FCC': 'cubic_fcc',
16+
'BCC': 'cubic_bcc',
17+
'HCP': 'hexagonal_noca',
18+
},
1419
}

defdap/_version.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
__version__ = '0.93.3'
1+
__version__ = '0.93.4'

defdap/base.py

Lines changed: 111 additions & 88 deletions
Original file line numberDiff line numberDiff line change
@@ -105,8 +105,8 @@ def plotGrainNumbers(self, dilateBoundaries=False, ax=None, **kwargs):
105105
Set to true to dilate boundaries.
106106
ax : matplotlib.axes.Axes, optional
107107
axis to plot on, if not provided the current active axis is used.
108-
kwargs : dict
109-
Keyword arguments to pass to matplotlib.
108+
kwargs : dict, optional
109+
Keyword arguments passed to :func:`defdap.plotting.MapPlot.addGrainNumbers`
110110
111111
Returns
112112
-------
@@ -129,6 +129,8 @@ def locateGrainID(self, clickEvent=None, displaySelected=False, **kwargs):
129129
Click handler to use.
130130
displaySelected : bool, optional
131131
If true, plot slip traces for grain selected by click.
132+
kwargs : dict, optional
133+
Keyword arguments passed to :func:`defdap.base.Map.plotDefault`
132134
133135
"""
134136
# Check that grains have been detected in the map
@@ -157,33 +159,41 @@ def clickGrainID(self, event, plot, displaySelected):
157159
----------
158160
event :
159161
Click event.
160-
plot : defdap.plotting.Plot
162+
plot : defdap.plotting.MapPlot
161163
Plot to capture clicks from.
162164
displaySelected : bool
163165
If true, plot the selected grain alone in pop-out window.
164166
165167
"""
166-
if event.inaxes is plot.ax:
167-
# grain id of selected grain
168-
self.currGrainId = int(self.grains[int(event.ydata), int(event.xdata)] - 1)
169-
print("Grain ID: {}".format(self.currGrainId))
170-
171-
# update the grain highlights layer in the plot
172-
plot.addGrainHighlights([self.currGrainId], alpha=self.highlightAlpha)
173-
174-
if displaySelected:
175-
currGrain = self[self.currGrainId]
176-
if self.grainPlot is None or not self.grainPlot.exists:
177-
self.grainPlot = currGrain.plotDefault(makeInteractive=True)
178-
else:
179-
self.grainPlot.clear()
180-
self.grainPlot.callingGrain = currGrain
181-
currGrain.plotDefault(plot=self.grainPlot)
182-
self.grainPlot.draw()
168+
# check if click was on the map
169+
if event.inaxes is not plot.ax:
170+
return
171+
172+
# grain id of selected grain
173+
self.currGrainId = int(self.grains[int(event.ydata), int(event.xdata)] - 1)
174+
print("Grain ID: {}".format(self.currGrainId))
175+
176+
# update the grain highlights layer in the plot
177+
plot.addGrainHighlights([self.currGrainId], alpha=self.highlightAlpha)
178+
179+
if displaySelected:
180+
currGrain = self[self.currGrainId]
181+
if self.grainPlot is None or not self.grainPlot.exists:
182+
self.grainPlot = currGrain.plotDefault(makeInteractive=True)
183+
else:
184+
self.grainPlot.clear()
185+
self.grainPlot.callingGrain = currGrain
186+
currGrain.plotDefault(plot=self.grainPlot)
187+
self.grainPlot.draw()
183188

184189
def drawLineProfile(self, **kwargs):
185190
"""Interactive plot for drawing a line profile of data.
186191
192+
Parameters
193+
----------
194+
kwargs : dict, optional
195+
Keyword arguments passed to :func:`defdap.base.Map.plotDefault`
196+
187197
"""
188198
plot = self.plotDefault(makeInteractive=True, **kwargs)
189199

@@ -198,21 +208,25 @@ def calcLineProfile(self, plot, startEnd, **kwargs):
198208
199209
Parameters
200210
----------
201-
plot : defdap.plotting.Plot
211+
plot : defdap.plotting.MapPlot
202212
Plot to calculate the line profile for.
203213
startEnd : array_like
204214
Selected points (x0, y0, x1, y1).
215+
kwargs : dict, optional
216+
Keyword arguments passed to :func:`matplotlib.pyplot.plot`
205217
206218
"""
207-
208219
x0, y0 = startEnd[0:2]
209220
x1, y1 = startEnd[2:4]
210221
profile_length = np.sqrt((y1 - y0) ** 2 + (x1 - x0) ** 2)
211222

212223
# Extract the values along the line
213-
zi = profile_line(plot.imgLayers[0].get_array(),
214-
(startEnd[1], startEnd[0]), (startEnd[3], startEnd[2]),
215-
mode='nearest', **kwargs)
224+
zi = profile_line(
225+
plot.imgLayers[0].get_array(),
226+
(startEnd[1], startEnd[0]),
227+
(startEnd[3], startEnd[2]),
228+
mode='nearest'
229+
)
216230
xi = np.linspace(0, profile_length, len(zi))
217231

218232
if self.profilePlot is None or not self.profilePlot.exists:
@@ -237,7 +251,7 @@ def setHomogPoint(self, binSize=1, points=None, **kwargs):
237251
points : numpy.ndarray, optional
238252
Array of (x,y) homologous points to set explicitly.
239253
kwargs : dict, optional
240-
Keyword arguments for matplotlib.
254+
Keyword arguments passed to :func:`defdap.base.Map.plotHomog`
241255
242256
"""
243257
if points is None:
@@ -269,17 +283,20 @@ def clickHomog(self, event, plot):
269283
----------
270284
event :
271285
Click event.
272-
plot : defdap.plotting.Plot
286+
plot : defdap.plotting.MapPlot
273287
Plot to monitor.
274288
275289
"""
276-
if event.inaxes is plot.ax:
277-
# right mouse click or shift + left mouse click
278-
# shift click doesn't work in osx backend
279-
if (event.button == 3 or
280-
(event.button == 1 and event.key == 'shift')):
281-
plot.addPoints([int(event.xdata)], [int(event.ydata)],
282-
updateLayer=1)
290+
# check if click was on the map
291+
if event.inaxes is not plot.ax:
292+
return
293+
294+
# right mouse click or shift + left mouse click
295+
# shift click doesn't work in osx backend
296+
if (event.button == 3 or
297+
(event.button == 1 and event.key == 'shift')):
298+
plot.addPoints([int(event.xdata)], [int(event.ydata)],
299+
updateLayer=1)
283300

284301
def keyHomog(self, event, plot):
285302
"""Event handler for moving position using keyboard after clicking on a map.
@@ -288,7 +305,7 @@ def keyHomog(self, event, plot):
288305
----------
289306
event :
290307
Keypress event.
291-
plot : defdap.plotting.Plot
308+
plot : defdap.plotting.MapPlot
292309
Plot to monitor.
293310
294311
"""
@@ -324,7 +341,7 @@ def clickSaveHomog(self, event, plot, binSize):
324341
----------
325342
event :
326343
Button click event.
327-
plot : defdap.plotting.Plot
344+
plot : defdap.plotting.MapPlot
328345
Plot to monitor.
329346
binSize : int, optional
330347
Binning applied to image, if applicable.
@@ -457,41 +474,43 @@ def clickGrainNeighbours(self, event, plot):
457474
----------
458475
event :
459476
Click event.
460-
plot : defdap.plotting.Plot
477+
plot : defdap.plotting.MapPlot
461478
Plot to monitor.
462479
463480
"""
464-
if event.inaxes is plot.ax:
465-
# grain id of selected grain
466-
grainId = int(self.grains[int(event.ydata), int(event.xdata)] - 1)
467-
if grainId < 0:
468-
return
469-
self.currGrainId = grainId
470-
grain = self[grainId]
481+
# check if click was on the map
482+
if event.inaxes is not plot.ax:
483+
return
471484

472-
# find first and second nearest neighbours
473-
firstNeighbours = list(self.neighbourNetwork.neighbors(grain))
474-
highlightGrains = [grain] + firstNeighbours
475-
476-
secondNeighbours = []
477-
for firstNeighbour in firstNeighbours:
478-
trialSecondNeighbours = list(
479-
self.neighbourNetwork.neighbors(firstNeighbour)
480-
)
481-
for secondNeighbour in trialSecondNeighbours:
482-
if (secondNeighbour not in highlightGrains and
483-
secondNeighbour not in secondNeighbours):
484-
secondNeighbours.append(secondNeighbour)
485-
highlightGrains.extend(secondNeighbours)
486-
487-
highlightGrains = [grain.grainID for grain in highlightGrains]
488-
highlightColours = ['white']
489-
highlightColours.extend(['yellow'] * len(firstNeighbours))
490-
highlightColours.append('green')
491-
492-
# update the grain highlights layer in the plot
493-
plot.addGrainHighlights(highlightGrains,
494-
grainColours=highlightColours)
485+
# grain id of selected grain
486+
grainId = int(self.grains[int(event.ydata), int(event.xdata)] - 1)
487+
if grainId < 0:
488+
return
489+
self.currGrainId = grainId
490+
grain = self[grainId]
491+
492+
# find first and second nearest neighbours
493+
firstNeighbours = list(self.neighbourNetwork.neighbors(grain))
494+
highlightGrains = [grain] + firstNeighbours
495+
496+
secondNeighbours = []
497+
for firstNeighbour in firstNeighbours:
498+
trialSecondNeighbours = list(
499+
self.neighbourNetwork.neighbors(firstNeighbour)
500+
)
501+
for secondNeighbour in trialSecondNeighbours:
502+
if (secondNeighbour not in highlightGrains and
503+
secondNeighbour not in secondNeighbours):
504+
secondNeighbours.append(secondNeighbour)
505+
highlightGrains.extend(secondNeighbours)
506+
507+
highlightGrains = [grain.grainID for grain in highlightGrains]
508+
highlightColours = ['white']
509+
highlightColours.extend(['yellow'] * len(firstNeighbours))
510+
highlightColours.append('green')
511+
512+
# update the grain highlights layer in the plot
513+
plot.addGrainHighlights(highlightGrains, grainColours=highlightColours)
495514

496515
@property
497516
def proxigram(self):
@@ -673,8 +692,8 @@ def plotGrainDataMap(
673692
IDs of grains to plot for. Use -1 for all grains in the map.
674693
bg: int or real, optional
675694
Value to fill the background with.
676-
kwargs:
677-
Other parameters are passed to :func:`defdap.plotting.MapPlot.create`
695+
kwargs : dict, optional
696+
Keyword arguments passed to :func:`defdap.plotting.MapPlot.create`
678697
679698
Returns
680699
-------
@@ -710,18 +729,18 @@ def plotGrainDataIPF(
710729
711730
Parameters
712731
----------
713-
mapData : numpy.ndarray
714-
Array of map data to grain average. This must be cropped!
715732
direction : numpy.ndarray
716733
Vector of reference direction for the IPF.
717-
plotColourBar : bool, optional
718-
Set to False to exclude the colour bar from the plot.
719-
vmin : float, optional
720-
Minimum value of colour scale.
721-
vmax : float, optional
722-
Maximum value for colour scale.
723-
cLabel : str, optional
724-
Colour bar label text.
734+
mapData : numpy.ndarray
735+
Array of map data. This must be cropped! Either mapData or
736+
grainData must be supplied.
737+
grainData : list or np.array, optional
738+
Grain values. This an be a single value per grain or RGB
739+
values. You must supply either mapData or grainData.
740+
grainIds: list of int or int, optional
741+
IDs of grains to plot for. Use -1 for all grains in the map.
742+
kwargs : dict, optional
743+
Keyword arguments passed to :func:`defdap.quat.Quat.plotIPF`
725744
726745
"""
727746
# Set default plot parameters then update with any input
@@ -759,6 +778,16 @@ def plotGrainDataIPF(
759778
class Grain(object):
760779
"""
761780
Base class for a grain.
781+
782+
Attributes
783+
----------
784+
grainID : int
785+
786+
ownerMap : defdap.base.Map
787+
788+
coordList : list of tuples
789+
790+
762791
"""
763792
def __init__(self, grainID, ownerMap):
764793
# list of coords stored as tuples (x, y). These are coords in a
@@ -861,7 +890,7 @@ def plotOutline(self, ax=None, plotScaleBar=False, **kwargs):
861890
plotScaleBar : bool
862891
plots the scale bar on the grain if true.
863892
kwargs : dict
864-
keyword arguments to pass to :func:`defdap.plotting.GrainPlot.addMap`.
893+
keyword arguments passed to :func:`defdap.plotting.GrainPlot.addMap`
865894
866895
Returns
867896
-------
@@ -1014,14 +1043,8 @@ def plotGrainData(self, mapData=None, grainData=None, **kwargs):
10141043
grainData : numpy.ndarray
10151044
List of data at each point in the grain. Either this or
10161045
'mapData' must be supplied and 'grainData' takes precedence.
1017-
vmin : float, optional
1018-
Minimum value of colour scale.
1019-
vmax : float, optional
1020-
Minimum value of colour scale.
1021-
cLabel : str, optional
1022-
Colour bar label text.
1023-
cmap : str, optional
1024-
Colour map to use, default is viridis.
1046+
kwargs : dict, optional
1047+
Keyword arguments passed to :func:`defdap.plotting.GrainPlot.create`
10251048
10261049
"""
10271050
# Set default plot parameters then update with any input

0 commit comments

Comments
 (0)