Skip to content

Commit 1268f07

Browse files
authored
Merge pull request #140 from MechMicroMan/develop
Merge develop into master
2 parents b29ec19 + 10add04 commit 1268f07

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

51 files changed

+7986
-5121
lines changed

.github/workflows/test.yml

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
name: Test DefDAP
2+
3+
on: [push, pull_request]
4+
5+
jobs:
6+
build:
7+
8+
runs-on: ubuntu-latest
9+
strategy:
10+
fail-fast: false
11+
matrix:
12+
python-version: ["3.8", "3.9", "3.10", "3.11"]
13+
14+
steps:
15+
- uses: actions/checkout@v2
16+
- name: Set up Python ${{ matrix.python-version }}
17+
uses: actions/setup-python@v2
18+
with:
19+
python-version: ${{ matrix.python-version }}
20+
- name: Install dependencies
21+
run: |
22+
python -m pip install --upgrade pip
23+
python -m pip install --upgrade pytest
24+
python -m pip install .[testing]
25+
if [ -f requirements.txt ]; then pip install -r requirements.txt; fi
26+
27+
- name: Test with pytest
28+
run: |
29+
pytest

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,3 +33,6 @@ DefDAP.egg-info/
3333

3434
# coverage
3535
.coverage
36+
37+
# vscode
38+
.vscode
File renamed without changes.

.readthedocs.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,4 +10,4 @@ python:
1010
- method: pip
1111
path: .
1212
extra_requirements:
13-
- docs
13+
- docs

.travis.yml

Lines changed: 0 additions & 15 deletions
This file was deleted.

CHANGELOG.md

Lines changed: 43 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,46 @@
11
# Change Log
22

3+
34
## Current
45

56
### Added
7+
- Each grain is assigned a phase and slip systems are automatically loaded
8+
for a given phase based on crystal structure.
9+
- This means that unit cells and slip traces plot correctly for grains
10+
in a multi-phase EBSD map
11+
- Add slip system file for FCC but in same order as DAMASK
12+
- Use example_notebook to generate a 'How To Use' page in the documentation
13+
- Add reader for EDAX .ang EBSD files, pyvale .csv files and openPIV-XL .npx files
14+
- Added a `plot_map` function for grains
15+
- Added more testing
616

717
### Changed
18+
- All functions and arguments are now in snake_case instead of CamelCase
19+
- Cropping and masking are now performed upon access to data
20+
- Changed function names from CamelCase to snake_case
21+
- Overhaul of data storage in the Map classes
22+
- RDR calculation `calcRDR` in grain inspector is faster and more robust
23+
- Improve formatting of grain inspector and RDR plot window
24+
- Refactor boundary lines calculations
25+
- Use GitHub actions to run `pytest` on commit push or pull request
26+
27+
### Fixed
28+
- Fix bug in grain inspector (`None` passed to `corrAngle` inadvertently)
29+
- Fix EBSD grain linker
30+
- Remove `IPython` and `jupyter` as requirements
31+
- Bug in IPF traiangle plotting now fixed with options for `up` triangle (like MTEX) and `down` triangle (like OI)
32+
33+
34+
## 0.93.5 (20-11-2023)
35+
36+
### Added
37+
- Add more options for colouring lines
838

939
### Fixed
40+
- Fix bug with accessing slip systems in grain inspector
41+
- Replace np.float with python float
42+
- Remove in_place argument to skimage.morphology.remove_small_objects
43+
- set_window_title has been moved from figure.canvas to figure.canvas.manager
1044

1145

1246
## 0.93.5 (20-11-2023)
@@ -24,7 +58,7 @@
2458
## 0.93.5 (17-01-2023)
2559

2660
### Added
27-
- Add equality check for Quat
61+
- Add equality check for `Quat`
2862

2963
### Fixed
3064
- Fix bug in boundary line warping
@@ -59,7 +93,7 @@
5993
## 0.93.2 (16-04-2021)
6094

6195
### Added
62-
- Reading of Channel project files that contain EDX data
96+
- Reading of Channel5 project files that contain EDX data
6397

6498
### Fixed
6599
- Plotting unit cells
@@ -75,21 +109,21 @@
75109

76110
### Changed
77111
- Speed up EBSD map data rotation
78-
- Speed up 'warp' grain finding
112+
- Speed up `warp` grain finding
79113
- Store band slope and MAD arrays from EBSD
80-
- Update nCorrToDavis.m script
114+
- Update `nCorrToDavis.m` script
81115
- Better description of how to use the function
82116
- Sub-window size is subset radius * 2, as defined in nCorr
83117
- Subset spacing is subset spacing, as defined in nCorr
84118
- Generate phase boundary points and lines at same time as grain boundaries
85119
- Improve histogram plotting
86-
- Options for scatter (as before), step and bar
87-
- Options for logx, logy, loglog and linear
120+
- Options for scatter (as before), `step` and `bar`
121+
- Options for `logx`, `logy`, `loglog` and `linear`
88122
- Updates to example notebook
89123

90124
### Fixed
91125
- Fixed docstring links
92-
- Fix bug in 'warp' grain finding algorithm
126+
- Fix bug in `warp` grain finding algorithm
93127

94128

95129
## 0.93.0 (20-02-2021)
@@ -108,7 +142,7 @@
108142
- Add misorientation calculation between neighbouring EBSD grains.
109143
- Add a `BoundarySegment` class to represent a section of grain boundary between 2 grain in an EBSD map. Objects of this class are assigned to edges of the neighbour network and contain all the boundary points between the grains.
110144
- Add Kuwahara filter for EBSD map noise reduction.
111-
- Add shape property to maps.
145+
- Add `shape` property to maps.
112146
- Read EBSD phases from file.
113147
- Add classes to represent phases and crystal structures.
114148

@@ -125,7 +159,7 @@
125159
- Change docs over to readthedocs.
126160
- Move version number to own file.
127161
- Update neighbour network to use grains as nodes.
128-
- Store grainID in grain objects.
162+
- Store `grainID` in grain objects.
129163
- Split plotGrainDataMap into separate array construction and plotting function.
130164
- Update neighbour network construction to use new EBSD boundary definition.
131165
- Update flood fill algorithm for grain finding in a EBSD map.

README.md

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717

1818
## How to install
1919
- DefDAP can be installed from PyPI using the command `pip install defdap`
20-
- If you use conda as your package manager (https://www.anaconda.com/), the prerequisite packages that are available from anaconda can be installed using the command `conda install scipy numpy matplotlib scikit-image pandas networkx jupyter ipython` (Anaconda3-2020.02 has been tested)
20+
- If you use conda as your package manager (https://www.anaconda.com/), the prerequisite packages that are available from anaconda can be installed using the command `conda install scipy numpy matplotlib scikit-image pandas networkx` (Anaconda3-2020.02 has been tested)
2121
- For more information, see the [documentation](https://defdap.readthedocs.io/en/latest/installation.html)
2222

2323
## How to use
@@ -43,8 +43,6 @@ The software uses the following open source packages:
4343
- [pandas](http://pandas.pydata.org)
4444
- [peakutils](https://peakutils.readthedocs.io/en/latest/)
4545
- [matplotlib_scalebar](https://pypi.org/project/matplotlib-scalebar/)
46-
- [IPython](https://ipython.org/)
47-
- [jupyter](https://jupyter.org/)
4846

4947
## License
5048
[Apache 2.0 license](https://www.apache.org/licenses/LICENSE-2.0)

defdap/__init__.py

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
from defdap.experiment import Experiment
2+
13
defaults = {
24
# Convention to use when attaching an orthonormal frame to a crystal
35
# structure. 'hkl' or 'tsl'
@@ -14,6 +16,10 @@
1416
'slip_system_file': {
1517
'FCC': 'cubic_fcc',
1618
'BCC': 'cubic_bcc',
17-
'HCP': 'hexagonal_noca',
19+
'HCP': 'hexagonal_withca',
1820
},
21+
# up or down
22+
'ipf_triangle_convention': 'up'
1923
}
24+
25+
anonymous_experiment = Experiment()

defdap/_accelerated.py

Lines changed: 163 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,163 @@
1+
# Copyright 2025 Mechanics of Microstructures Group
2+
# at The University of Manchester
3+
#
4+
# Licensed under the Apache License, Version 2.0 (the "License");
5+
# you may not use this file except in compliance with the License.
6+
# You may obtain a copy of the License at
7+
#
8+
# http://www.apache.org/licenses/LICENSE-2.0
9+
#
10+
# Unless required by applicable law or agreed to in writing, software
11+
# distributed under the License is distributed on an "AS IS" BASIS,
12+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
# See the License for the specific language governing permissions and
14+
# limitations under the License.
15+
16+
from numba import njit
17+
import numpy as np
18+
19+
20+
@njit
21+
def find_first(arr):
22+
for i in range(len(arr)):
23+
if arr[i]:
24+
return i
25+
26+
27+
@njit
28+
def flood_fill(seed, index, points_remaining, grains, boundary_x, boundary_y,
29+
added_coords):
30+
"""Flood fill algorithm that uses the x and y boundary arrays to
31+
fill a connected area around the seed point. The points are inserted
32+
into a grain object and the grain map array is updated.
33+
34+
Parameters
35+
----------
36+
seed : tuple of 2 int
37+
Seed point x for flood fill
38+
index : int
39+
Value to fill in grain map
40+
points_remaining : numpy.ndarray
41+
Boolean map of the points that have not been assigned a grain yet
42+
43+
Returns
44+
-------
45+
grain : defdap.ebsd.Grain
46+
New grain object with points added
47+
"""
48+
x, y = seed
49+
grains[y, x] = index
50+
points_remaining[y, x] = False
51+
edge = [seed]
52+
added_coords[0] = seed
53+
npoints = 1
54+
55+
while edge:
56+
x, y = edge.pop()
57+
moves = [(x+1, y), (x-1, y), (x, y+1), (x, y-1)]
58+
# get rid of any that go out of the map area
59+
if x <= 0:
60+
moves.pop(1)
61+
elif x > grains.shape[1] - 2:
62+
moves.pop(0)
63+
if y <= 0:
64+
moves.pop(-1)
65+
elif y > grains.shape[0] - 2:
66+
moves.pop(-2)
67+
68+
for (s, t) in moves:
69+
if grains[t, s] > 0:
70+
continue
71+
72+
add_point = False
73+
74+
if t == y:
75+
# moving horizontally
76+
if s > x:
77+
# moving right
78+
add_point = not boundary_x[y, x]
79+
else:
80+
# moving left
81+
add_point = not boundary_x[t, s]
82+
else:
83+
# moving vertically
84+
if t > y:
85+
# moving down
86+
add_point = not boundary_y[y, x]
87+
else:
88+
# moving up
89+
add_point = not boundary_y[t, s]
90+
91+
if add_point:
92+
added_coords[npoints] = s, t
93+
grains[t, s] = index
94+
points_remaining[t, s] = False
95+
npoints += 1
96+
edge.append((s, t))
97+
98+
return added_coords[:npoints]
99+
100+
101+
@njit
102+
def flood_fill_dic(seed, index, points_remaining, grains, added_coords):
103+
"""Flood fill algorithm that uses the combined x and y boundary array
104+
to fill a connected area around the seed point. The points are returned and
105+
the grain map array is updated.
106+
107+
Parameters
108+
----------
109+
seed : tuple of 2 int
110+
Seed point x for flood fill
111+
index : int
112+
Value to fill in grain map
113+
points_remaining : numpy.ndarray
114+
Boolean map of the points remaining to assign a grain yet
115+
grains : numpy.ndarray
116+
added_coords : numpy.ndarray
117+
Buffer for points in the grain
118+
119+
Returns
120+
-------
121+
numpy.ndarray
122+
Flooded points (n, 2)
123+
124+
"""
125+
# add first point to the grain
126+
x, y = seed
127+
grains[y, x] = index
128+
points_remaining[y, x] = False
129+
edge = [seed]
130+
added_coords[0] = seed
131+
npoints = 1
132+
133+
while edge:
134+
x, y = edge.pop()
135+
136+
moves = [(x+1, y), (x-1, y), (x, y+1), (x, y-1)]
137+
# get rid of any that go out of the map area
138+
if x <= 0:
139+
moves.pop(1)
140+
elif x >= grains.shape[1] - 1:
141+
moves.pop(0)
142+
if y <= 0:
143+
moves.pop(-1)
144+
elif y >= grains.shape[0] - 1:
145+
moves.pop(-2)
146+
147+
for (s, t) in moves:
148+
add_point = False
149+
150+
if grains[t, s] == 0:
151+
add_point = True
152+
edge.append((s, t))
153+
154+
elif grains[t, s] == -1 and (s > x or t > y):
155+
add_point = True
156+
157+
if add_point:
158+
added_coords[npoints] = (s, t)
159+
grains[t, s] = index
160+
points_remaining[t, s] = False
161+
npoints += 1
162+
163+
return added_coords[:npoints]

defdap/_version.py

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

0 commit comments

Comments
 (0)