From 93ee812d2dba27937bac796a4e7bc1d6e7adf1df Mon Sep 17 00:00:00 2001 From: Dave Rowenhorst <45666721+drowenhorst-nrl@users.noreply.github.com> Date: Fri, 7 Jun 2024 18:29:25 -0400 Subject: [PATCH] NLPAR Chunk Patch ... again (#62) Fixed ----- - This time I think that edge case for NLPAR chunking of scans is really fixed. - Wrote on a chalkboard 100 times, "I will run ALL the unit tests before release." Signed-off by: David Rowenhorst --- CHANGELOG.rst | 9 +++++++++ pyebsdindex/__init__.py | 2 +- pyebsdindex/nlpar_cpu.py | 20 ++++++++++++++++++-- 3 files changed, 28 insertions(+), 3 deletions(-) diff --git a/CHANGELOG.rst b/CHANGELOG.rst index 09c0462..a5a0d15 100644 --- a/CHANGELOG.rst +++ b/CHANGELOG.rst @@ -5,6 +5,15 @@ Changelog All notable changes to PyEBSDIndex will be documented in this file. The format is based on `Keep a Changelog `_. + +0.3.4 (2024-06-07) +================== + +Fixed +----- +- This time I think that edge case for NLPAR chunking of scans is really fixed. +- Wrote on a chalkboard 100 times, "I will run ALL the unit tests before release." + 0.3.3 (2024-06-07) ================== diff --git a/pyebsdindex/__init__.py b/pyebsdindex/__init__.py index 3644248..53da16a 100644 --- a/pyebsdindex/__init__.py +++ b/pyebsdindex/__init__.py @@ -7,7 +7,7 @@ ] __description__ = "Python based tool for Radon based EBSD indexing" __name__ = "pyebsdindex" -__version__ = "0.3.3" +__version__ = "0.3.4" # Try to import only once - also will perform check that at least one GPU is found. diff --git a/pyebsdindex/nlpar_cpu.py b/pyebsdindex/nlpar_cpu.py index 9bec11c..2b00fc3 100644 --- a/pyebsdindex/nlpar_cpu.py +++ b/pyebsdindex/nlpar_cpu.py @@ -390,6 +390,7 @@ def calcnlpar(self, chunksize=0, searchradius=None, lam = None, dthresh = None, nthreadpos = numba.get_num_threads() #numba.set_num_threads(18) + #numba.set_num_threads(18) colstartcount = np.asarray([0,ncols],dtype=np.int64) if verbose >= 1: print("lambda:", self.lam, "search radius:", self.searchradius, "dthresh:", self.dthresh) @@ -776,7 +777,7 @@ def _calcchunks(self, patdim, ncol, nrow, target_bytes=2e9, col_overlap=0, row_o colchunks[-1, 1] = ncol if ncolchunks > 1: - colchunks[-1, 0] = max(0, colchunks[-2, 1] - col_overlap) + colchunks[-1, 0] = max(0, colchunks[-2, 1] - 2*col_overlap-1) colchunks += col_offset @@ -784,6 +785,21 @@ def _calcchunks(self, patdim, ncol, nrow, target_bytes=2e9, col_overlap=0, row_o # if colchunks[i + 1, 0] >= ncol: # colchunks = colchunks[0:i + 1, :] + rowchunks = [] + row_overlap = int(row_overlap) + for r in range(nrowchunks): + rchunk = [int(r * rowstep) - row_overlap, int(r * rowstep + rowstepov) - row_overlap] + rowchunks.append(rchunk) + if rchunk[1] > nrow: + break + + nrowchunks = len(rowchunks) + rowchunks = np.array(rowchunks, dtype=int) + rowchunks[0, 0] = 0 + # for i in range(ncolchunks - 1): + # if colchunks[i + 1, 0] >= ncol: + # colchunks = colchunks[0:i + 1, :] + rowchunks = [] row_overlap = int(row_overlap) for r in range(nrowchunks): @@ -798,7 +814,7 @@ def _calcchunks(self, patdim, ncol, nrow, target_bytes=2e9, col_overlap=0, row_o rowchunks[-1, 1] = nrow if nrowchunks > 1: - rowchunks[-1, 0] = max(0, rowchunks[-2, 1] - row_overlap) + rowchunks[-1, 0] = max(0, rowchunks[-2, 1] - 2*row_overlap-1) rowchunks += row_offset