Skip to content

Commit 1a8bd1e

Browse files
committed
removing unused resample_distance routine from parametric volumes
1 parent 0047acf commit 1a8bd1e

File tree

2 files changed

+0
-158
lines changed

2 files changed

+0
-158
lines changed

linear_volume.py

Lines changed: 0 additions & 79 deletions
Original file line numberDiff line numberDiff line change
@@ -135,85 +135,6 @@ def _create_vol(self, obs_u, obs_v, obs_l, xyz, **kwargs):
135135
self._vvol = vvol
136136
self._lvol = lvol
137137

138-
def _resample_distance_strategy(self):
139-
from scipy.spatial import cKDTree
140-
141-
u, v, l = self.u, self.v, self.l
142-
um, vm, lm = np.meshgrid(u, v, l, indexing='ij')
143-
uvl = np.array([um.ravel(), vm.ravel(), lm.ravel()]).T
144-
x, y, z = self._xvol(uvl), self._yvol(uvl), self._zvol(uvl)
145-
xyz = np.asarray([x, y, z], dtype='float32').T
146-
tree = cKDTree(xyz)
147-
148-
distance_dictionary = {}
149-
distances = []
150-
N = xyz.shape[0]
151-
min_distance, min_index = 1.0e9, -1
152-
for n in range(N):
153-
d, i = tree.query(xyz[n], k=2)
154-
d, i = d[-1], i[-1]
155-
distance_dictionary[tuple(xyz[n])] = [d, n, i]
156-
distances.append(d)
157-
if d < min_distance:
158-
min_distance, min_index = d, (n, i)
159-
160-
f = open('distances_curv.txt', 'w')
161-
for distance in distances:
162-
f.write(str(distance) + '\n')
163-
f.close()
164-
165-
f = open('add_points.txt', 'w')
166-
for n in range(N):
167-
ndistance, self_index, neighbor_index = distance_dictionary[tuple(xyz[n])]
168-
nearest_neighbor = xyz[neighbor_index]
169-
rel = old_div(np.abs(ndistance - min_distance), min_distance)
170-
points_to_add = 2 ** (rel + 2)
171-
distance_dictionary[tuple(xyz[n])].append(points_to_add)
172-
f.write(str(int(points_to_add)) + '\n')
173-
f.close()
174-
175-
def sample_from_sphere(R, xyz):
176-
phi = np.random.uniform(0, 2. * np.pi)
177-
costheta = np.random.uniform(-1, 1)
178-
u = np.random.uniform(0, 1)
179-
theta = np.arccos(costheta)
180-
r = sphere_radius * (u ** (1. / 3.))
181-
xnew, ynew, znew = xyz[0] + r * np.sin(theta) * np.cos(phi), xyz[1] + r * np.sin(theta) * np.sin(phi), xyz[
182-
2] + r * np.cos(theta)
183-
184-
xyz_new = np.asarray([xnew, ynew, znew], dtype='float32').reshape(1, 3)
185-
u, v, l = self._uvol(xyz_new), self._vvol(xyz_new), self._lvol(xyz_new)
186-
u, v, l = u[0], v[0], l[0]
187-
if (u < np.min(self.u) or u > np.max(self.u)):
188-
return None, None
189-
if (v < np.min(self.v) or v > np.max(self.v)):
190-
return None, None
191-
if (l < np.min(self.l) or l > np.max(self.l)):
192-
return None, None
193-
return xyz_new, np.array([u, v, l], dtype='float32').reshape(1, 3)
194-
195-
for xyz_key in list(distance_dictionary.keys()):
196-
ndistance, _, _, points_to_add = distance_dictionary[xyz_key]
197-
198-
sphere_centroid, sphere_radius = xyz_key, ndistance / 2.
199-
for i in range(int(points_to_add)):
200-
xyz_new = None
201-
while xyz_new is None:
202-
xyz_new, uvl_new = sample_from_sphere(sphere_radius, sphere_centroid)
203-
xyz = np.concatenate((xyz, xyz_new))
204-
uvl = np.concatenate((uvl, uvl_new))
205-
206-
f = open('distance_curv_added.txt', 'w')
207-
tree_added = cKDTree(xyz)
208-
209-
N2 = xyz.shape[0]
210-
for n in range(N2):
211-
d, i = tree_added.query(xyz[n], k=2)
212-
d, i = d[-1], i[-1]
213-
f.write(str(d) + '\n')
214-
f.close()
215-
return xyz, uvl
216-
217138
def _resample_uv(self, ures, vres):
218139
"""Helper function to re-sample to u and v parameters
219140
at the specified resolution

rbf_volume.py

Lines changed: 0 additions & 79 deletions
Original file line numberDiff line numberDiff line change
@@ -140,85 +140,6 @@ def _create_vol(self, obs_u, obs_v, obs_l, xyz, **kwargs):
140140
self._vvol = vvol
141141
self._lvol = lvol
142142

143-
def _resample_distance_strategy(self):
144-
from scipy.spatial import cKDTree
145-
146-
u, v, l = self.u, self.v, self.l
147-
um, vm, lm = np.meshgrid(u, v, l, indexing='ij')
148-
uvl = np.array([um.ravel(), vm.ravel(), lm.ravel()]).T
149-
x, y, z = self._xvol(uvl), self._yvol(uvl), self._zvol(uvl)
150-
xyz = np.asarray([x, y, z], dtype='float32').T
151-
tree = cKDTree(xyz)
152-
153-
distance_dictionary = {}
154-
distances = []
155-
N = xyz.shape[0]
156-
min_distance, min_index = 1.0e9, -1
157-
for n in range(N):
158-
d, i = tree.query(xyz[n], k=2)
159-
d, i = d[-1], i[-1]
160-
distance_dictionary[tuple(xyz[n])] = [d, n, i]
161-
distances.append(d)
162-
if d < min_distance:
163-
min_distance, min_index = d, (n, i)
164-
165-
f = open('distances_curv.txt', 'w')
166-
for distance in distances:
167-
f.write(str(distance) + '\n')
168-
f.close()
169-
170-
f = open('add_points.txt', 'w')
171-
for n in range(N):
172-
ndistance, self_index, neighbor_index = distance_dictionary[tuple(xyz[n])]
173-
nearest_neighbor = xyz[neighbor_index]
174-
rel = np.abs(ndistance - min_distance) / min_distance
175-
points_to_add = 2 ** (rel + 2)
176-
distance_dictionary[tuple(xyz[n])].append(points_to_add)
177-
f.write(str(int(points_to_add)) + '\n')
178-
f.close()
179-
180-
def sample_from_sphere(R, xyz):
181-
phi = np.random.uniform(0, 2. * np.pi)
182-
costheta = np.random.uniform(-1, 1)
183-
u = np.random.uniform(0, 1)
184-
theta = np.arccos(costheta)
185-
r = sphere_radius * (u ** (1. / 3.))
186-
xnew, ynew, znew = xyz[0] + r * np.sin(theta) * np.cos(phi), xyz[1] + r * np.sin(theta) * np.sin(phi), xyz[
187-
2] + r * np.cos(theta)
188-
189-
xyz_new = np.asarray([xnew, ynew, znew], dtype='float32').reshape(1, 3)
190-
u, v, l = self._uvol(xyz_new), self._vvol(xyz_new), self._lvol(xyz_new)
191-
u, v, l = u[0], v[0], l[0]
192-
if (u < np.min(self.u) or u > np.max(self.u)):
193-
return None, None
194-
if (v < np.min(self.v) or v > np.max(self.v)):
195-
return None, None
196-
if (l < np.min(self.l) or l > np.max(self.l)):
197-
return None, None
198-
return xyz_new, np.array([u, v, l], dtype='float32').reshape(1, 3)
199-
200-
for xyz_key in list(distance_dictionary.keys()):
201-
ndistance, _, _, points_to_add = distance_dictionary[xyz_key]
202-
203-
sphere_centroid, sphere_radius = xyz_key, ndistance / 2.
204-
for i in range(int(points_to_add)):
205-
xyz_new = None
206-
while xyz_new is None:
207-
xyz_new, uvl_new = sample_from_sphere(sphere_radius, sphere_centroid)
208-
xyz = np.concatenate((xyz, xyz_new))
209-
uvl = np.concatenate((uvl, uvl_new))
210-
211-
f = open('distance_curv_added.txt', 'w')
212-
tree_added = cKDTree(xyz)
213-
214-
N2 = xyz.shape[0]
215-
for n in range(N2):
216-
d, i = tree_added.query(xyz[n], k=2)
217-
d, i = d[-1], i[-1]
218-
f.write(str(d) + '\n')
219-
f.close()
220-
return xyz, uvl
221-
222143
def _resample_uv(self, ures, vres):
223144
"""Helper function to re-sample to u and v parameters
224145
at the specified resolution

0 commit comments

Comments
 (0)