From 32c34457c28a558a6afefa3b3d8d87e6e07fd78c Mon Sep 17 00:00:00 2001 From: Philip Eisenlohr Date: Wed, 7 Mar 2018 17:45:22 -0500 Subject: [PATCH 1/6] direct selection of valid seed coordinates within subfraction of unit cube instead of check and repeat --- processing/pre/seeds_fromRandom.py | 22 ++++------------------ 1 file changed, 4 insertions(+), 18 deletions(-) diff --git a/processing/pre/seeds_fromRandom.py b/processing/pre/seeds_fromRandom.py index 0df292ed2..3045359ef 100755 --- a/processing/pre/seeds_fromRandom.py +++ b/processing/pre/seeds_fromRandom.py @@ -166,25 +166,11 @@ for name in filenames: grainEuler[2,:] *= 360.0 # phi_2 is uniformly distributed if not options.selective: - seeds = np.array([]) + n = np.array(options.grid * options.fraction,dtype=int) # find valid grid indices within fraction + meshgrid = np.meshgrid(*map(np.arange,n),indexing='ij') # create a meshgrid within fraction - while len(seeds) < options.N: - - theSeeds = np.zeros((options.N,3),dtype=float) # seed positions array - gridpoints = random.sample(range(gridSize),options.N) # choose first N from random permutation of grid positions - - theSeeds[:,0] = (np.mod(gridpoints ,options.grid[0])\ - +np.random.random(options.N)) /options.grid[0] - theSeeds[:,1] = (np.mod(gridpoints// options.grid[0] ,options.grid[1])\ - +np.random.random(options.N)) /options.grid[1] - theSeeds[:,2] = (np.mod(gridpoints//(options.grid[1]*options.grid[0]),options.grid[2])\ - +np.random.random(options.N)) /options.grid[2] - - goodSeeds = theSeeds[np.all(theSeeds<=options.fraction,axis=1)] # pick seeds within threshold fraction - seeds = goodSeeds if len(seeds) == 0 else np.vstack((seeds,goodSeeds)) - if len(seeds) > options.N: seeds = seeds[:min(options.N,len(seeds))] - - seeds = seeds.T # switch layout to point index as last index + coords = np.vstack((meshgrid[0],meshgrid[1],meshgrid[2])).reshape(3,n.prod()).T # assemble list of 3D coordinates + seeds = ((random.sample(coords,options.N)+np.random.random(options.N*3).reshape(options.N,3))/options.grid).T # pick options.N of those and rattle position else: From 2c3eae6bf0b43d6cab68c12ac5430209c67976ce Mon Sep 17 00:00:00 2001 From: Philip Eisenlohr Date: Wed, 7 Mar 2018 18:58:28 -0500 Subject: [PATCH 2/6] fixed tests and bug for very small unit cube fractions when grid is also small --- PRIVATE | 2 +- processing/pre/seeds_fromRandom.py | 11 ++++++----- 2 files changed, 7 insertions(+), 6 deletions(-) diff --git a/PRIVATE b/PRIVATE index 8de4f792a..8546f9bda 160000 --- a/PRIVATE +++ b/PRIVATE @@ -1 +1 @@ -Subproject commit 8de4f792a46d98d98418dbf2d3e621b22c13b18a +Subproject commit 8546f9bda04b58c3b26979048288a8a01f607876 diff --git a/processing/pre/seeds_fromRandom.py b/processing/pre/seeds_fromRandom.py index 3045359ef..77bacdc8e 100755 --- a/processing/pre/seeds_fromRandom.py +++ b/processing/pre/seeds_fromRandom.py @@ -166,14 +166,15 @@ for name in filenames: grainEuler[2,:] *= 360.0 # phi_2 is uniformly distributed if not options.selective: - n = np.array(options.grid * options.fraction,dtype=int) # find valid grid indices within fraction + n = np.maximum(np.ones(3),np.array(options.grid*options.fraction), + dtype=int,casting='unsafe') # find max grid indices within fraction meshgrid = np.meshgrid(*map(np.arange,n),indexing='ij') # create a meshgrid within fraction - coords = np.vstack((meshgrid[0],meshgrid[1],meshgrid[2])).reshape(3,n.prod()).T # assemble list of 3D coordinates - seeds = ((random.sample(coords,options.N)+np.random.random(options.N*3).reshape(options.N,3))/options.grid).T # pick options.N of those and rattle position - + seeds = ((random.sample(coords,options.N)+np.random.random(options.N*3).reshape(options.N,3))\ + / \ + (n/options.fraction)).T # pick options.N of those, rattle position, + # and rescale to fall within fraction else: - seeds = np.zeros((options.N,3),dtype=float) # seed positions array seeds[0] = np.random.random(3)*options.grid/max(options.grid) i = 1 # start out with one given point From 48fce3a49eff13b69936e72c5341325d5f9d5b23 Mon Sep 17 00:00:00 2001 From: Test User Date: Thu, 8 Mar 2018 10:15:17 +0100 Subject: [PATCH 3/6] [skip ci] updated version information after successful test of v2.0.1-1107-g2c3eae6 --- VERSION | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/VERSION b/VERSION index aa98e7d3f..becfecaca 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -v2.0.1-1104-g88c46d5 +v2.0.1-1107-g2c3eae6 From 63c104b3748fadd85f0d78f6aadbb372da2e6a81 Mon Sep 17 00:00:00 2001 From: Pratheek Shanthraj Date: Mon, 12 Mar 2018 17:35:54 +0100 Subject: [PATCH 4/6] more work to get testing to work --- PRIVATE | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/PRIVATE b/PRIVATE index 8546f9bda..1be6a4f1a 160000 --- a/PRIVATE +++ b/PRIVATE @@ -1 +1 @@ -Subproject commit 8546f9bda04b58c3b26979048288a8a01f607876 +Subproject commit 1be6a4f1a313f7e34035b52be67092ddc13db68b From 52c9954ca4dae3c2bfdeb69c9868175bb1bbfe04 Mon Sep 17 00:00:00 2001 From: Pratheek Shanthraj Date: Mon, 12 Mar 2018 17:44:37 +0100 Subject: [PATCH 5/6] Revert "more work to get testing to work" This reverts commit 63c104b3748fadd85f0d78f6aadbb372da2e6a81. --- PRIVATE | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/PRIVATE b/PRIVATE index 1be6a4f1a..8546f9bda 160000 --- a/PRIVATE +++ b/PRIVATE @@ -1 +1 @@ -Subproject commit 1be6a4f1a313f7e34035b52be67092ddc13db68b +Subproject commit 8546f9bda04b58c3b26979048288a8a01f607876 From fb710dda0a6dc621746833b59739586c9d5af2b4 Mon Sep 17 00:00:00 2001 From: Test User Date: Mon, 12 Mar 2018 22:56:52 +0100 Subject: [PATCH 6/6] [skip ci] updated version information after successful test of v2.0.1-1110-g52c9954 --- VERSION | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/VERSION b/VERSION index becfecaca..6cd6d15e3 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -v2.0.1-1107-g2c3eae6 +v2.0.1-1110-g52c9954