Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions defdap/file_readers.py
Original file line number Diff line number Diff line change
Expand Up @@ -984,12 +984,12 @@ def load(self, file_name: pathlib.Path) -> None:
"""
if not file_name.is_file():
raise FileNotFoundError(f"Cannot open file {file_name}")

int_type = 'int32'
double_type = 'double'
data_format = np.dtype([
('x', int_type),
('y', int_type),
('x', double_type),
('y', double_type),
('u', double_type),
('v', double_type),
('displacement_mag', double_type),
Expand Down Expand Up @@ -1026,12 +1026,12 @@ def load(self, file_name: pathlib.Path) -> None:
yx_max = yx_array.max(axis=0)
shape = yx_max - yx_min
assert np.allclose(shape % binning, 0.)
shape = np.rint(shape).astype(int)
shape = tuple((shape // binning + 1).tolist())
self.loaded_metadata['shape'] = shape

self.checkMetadata()

index_array = (yx_array - yx_min) // binning
index_array = np.rint((yx_array - yx_min) / binning).astype(int)
disp_dense = np.zeros(shape + (2,))
disp_dense[index_array[:, 0], index_array[:, 1]] = (
structured_to_unstructured(data[['u', 'v']]))
Expand Down
21 changes: 18 additions & 3 deletions defdap/hrdic.py
Original file line number Diff line number Diff line change
Expand Up @@ -534,12 +534,27 @@ def load_pattern(self):
raise FileNotFoundError("First set path to pattern image.")

img = imread(path)
exp_shape = tuple(v * binning for v in self.original_shape)
if img.shape != exp_shape:

bounds = {
'DaVis': (-1, 0), # Davis rounds up to nearest subwindow
'PyVale': (0, 1), # PyVale rounds down to nearest subwindow
'OpenPIV': (0, 1) # OpenPIV rounds down to nearest subwindow
}
lower, upper = bounds[self.format]

img_shape = np.array(img.shape)
dic_shape = np.array(self.original_shape)

min_shape = np.array((dic_shape + lower) * binning, dtype=int)
max_shape = np.array((dic_shape + upper) * binning, dtype=int)

if not np.all((min_shape <= img_shape) & (img_shape <= max_shape)):
raise ValueError(
f'Incorrect size of pattern image. For binning of {binning} '
f'expected size {exp_shape[::-1]} but got {img.shape[::-1]}'
f'expected size {min_shape[::-1]} to {max_shape[::-1]} '
f'but got {img_shape[::-1]}'
)

return img

def plot_grain_av_max_shear(self, **kwargs):
Expand Down
Loading