Skip to content

Commit

Permalink
Remove base.Map.check_grains_detected
Browse files Browse the repository at this point in the history
Grains are generated when accessed with default parameters
  • Loading branch information
mikesmic committed Oct 13, 2023
1 parent f23284f commit 5498b87
Show file tree
Hide file tree
Showing 2 changed files with 0 additions and 61 deletions.
46 changes: 0 additions & 46 deletions defdap/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -68,9 +68,6 @@ def __len__(self):

# allow array like getting of grains
def __getitem__(self, key):
# Check that grains have been detected in the map
# self.check_grains_detected()

return self.grains[key]

@property
Expand All @@ -93,36 +90,6 @@ def crop(self, map_data, **kwargs):
def set_homog_point(self, **kwargs):
self.frame.set_homog_point(self, **kwargs)

def check_grains_detected(self, raise_exc=True):
"""Check if grains have been detected.
Parameters
----------
raise_exc : bool
If True then an exception is raised if grains have not been
detected.
Returns
-------
bool:
True if grains detected, False otherwise.
Raises
-------
Exception
If grains not detected.
"""

if (self._grains is None or
type(self._grains) is not list or
len(self._grains) < 1):
if raise_exc:
raise Exception("No grains detected.")
else:
return False
return True

def plot_grain_numbers(self, dilate_boundaries=False, ax=None, **kwargs):
"""Plot a map with grains numbered.
Expand Down Expand Up @@ -160,9 +127,6 @@ def locate_grain(self, click_event=None, display_grain=False, **kwargs):
Keyword arguments passed to :func:`defdap.base.Map.plot_default`
"""
# Check that grains have been detected in the map
self.check_grains_detected()

# reset current selected grain and plot euler map with click handler
plot = self.plot_default(make_interactive=True, **kwargs)
if click_event is None:
Expand Down Expand Up @@ -627,10 +591,6 @@ def calc_grain_average(self, map_data, grainIds=-1):
Array containing the grain average values.
"""

# Check that grains have been detected in the map
self.check_grains_detected()

if type(grainIds) is int and grainIds == -1:
grainIds = range(len(self))

Expand Down Expand Up @@ -671,9 +631,6 @@ def grain_data_to_map_data(self, grain_data, grainIds=-1, bg=0):
Array filled with grain data values
"""
# Check that grains have been detected in the map
self.check_grains_detected()

if type(grainIds) is int:
if grainIds == -1:
grainIds = range(len(self))
Expand Down Expand Up @@ -780,9 +737,6 @@ def plotGrainDataIPF(
else:
grainData = self.calc_grain_average(mapData, grainIds=grainIds)

# Check that grains have been detected in the map
self.check_grains_detected()

if type(grainIds) is int and grainIds == -1:
grainIds = range(len(self))

Expand Down
15 changes: 0 additions & 15 deletions defdap/ebsd.py
Original file line number Diff line number Diff line change
Expand Up @@ -1042,9 +1042,6 @@ def calc_grain_av_oris(self):
"""Calculate the average orientation of grains.
"""
# Check that grains have been detected in the map
self.check_grains_detected()

numGrains = len(self)
for iGrain, grain in enumerate(self):
grain.calc_average_ori()
Expand All @@ -1062,9 +1059,6 @@ def calc_grain_mis_ori(self, calc_axis=False):
Calculate the misorientation axis if True.
"""
# Check that grains have been detected in the map
self.check_grains_detected()

num_grains = len(self)
for i_grain, grain in enumerate(self):
grain.build_mis_ori_list(calc_axis=calc_axis)
Expand All @@ -1087,9 +1081,6 @@ def plot_mis_ori_map(self, component=0, **kwargs):
defdap.plotting.MapPlot
"""
# Check that grains have been detected in the map
self.check_grains_detected()

if component in [1, 2, 3]:
self.mis_ori = np.zeros(self.shape)
# Calculate misorientation axis if not calculated
Expand Down Expand Up @@ -1141,9 +1132,6 @@ def calc_average_grain_schmid_factors(self, load_vector, slip_systems=None):
planes calculated if not given.
"""
# Check that grains have been detected in the map
self.check_grains_detected()

num_grains = len(self)
for iGrain, grain in enumerate(self):
grain.calc_average_schmid_factors(load_vector, slip_systems=slip_systems)
Expand Down Expand Up @@ -1181,9 +1169,6 @@ def plot_average_grain_schmid_factors_map(self, planes=None, directions=None,
}
plot_params.update(kwargs)

# Check that grains have been detected in the map
self.check_grains_detected()

if self[0].average_schmid_factors is None:
raise Exception("Run 'calc_average_grain_schmid_factors' first")

Expand Down

0 comments on commit 5498b87

Please sign in to comment.