Skip to content

Commit e7d325d

Browse files
committed
Correction import rtree
1 parent 65e1d5c commit e7d325d

File tree

3 files changed

+21
-9
lines changed

3 files changed

+21
-9
lines changed

tracklib/algo/stochastics.py

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -320,7 +320,6 @@ def noise(
320320
:param force: force definite-positive matrix with removal of negative eigen values
321321
:param control: control points (list of coords) for conditional simulations
322322
:param N: number of tracks to generate (returns track collection if N > 1)"""
323-
324323
if n == 1:
325324
return __noise(track, sigma, kernel, distribution, mode, force, cycle, control, direction)
326325
else:
@@ -386,7 +385,7 @@ def __noise(
386385
# Zero-amplitude case
387386
if (sigma[ik] == 0):
388387
continue
389-
388+
390389
# Building covariance matrix
391390
SIGMA_S = makeCovarianceMatrixFromKernel(kernel[ik], noised_track, force=force, mode=mode, control=control)
392391
SIGMA_S += np.identity(SIGMA_S.shape[0]) * 1e-12
@@ -410,7 +409,7 @@ def __noise(
410409
Yy = np.matmul(L22, __randomSampler(N, distribution)) + np.matmul(L12, np.linalg.solve(L11, Yc))
411410
if (direction in [MODE_DIRECTION_Z, MODE_DIRECTION_YZ, MODE_DIRECTION_XZ, MODE_DIRECTION_XYZ, MODE_DIRECTION_ORTHO]):
412411
Yz = np.matmul(L22, __randomSampler(N, distribution)) + np.matmul(L12, np.linalg.solve(L11, Zc))
413-
412+
414413
# Building noised track
415414
if (direction == MODE_DIRECTION_ORTHO):
416415
for i in range(N-1):
@@ -422,12 +421,18 @@ def __noise(
422421
else:
423422
for i in range(N):
424423
noised_track.getObs(i).position.translate(Yx[i], Yy[i], Yz[i])
425-
424+
426425
if mode == 'circular':
427426
noised_track.loop()
428427

428+
# Cast to real float
429+
for p in noised_track:
430+
p.position.E = p.position.E.real
431+
p.position.N = p.position.N.real
432+
p.position.U = p.position.U.real
433+
429434
noised_track.removeAnalyticalFeature("abs_curv")
430-
435+
431436
return noised_track
432437

433438
def randomizer(input, f, sigma=[7], kernel=[GaussianKernel(650)], N=10):

tracklib/core/utils.py

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,12 @@
6262
import itertools
6363
import matplotlib.pyplot as plt
6464

65-
from rtree import index
65+
try:
66+
from rtree import index
67+
except ImportError:
68+
print ('Code running in a no rtree environment')
69+
70+
6671

6772
try:
6873
import shapely
@@ -630,7 +635,8 @@ def co_median(tarray):
630635
# covariogram of standard deviation h
631636
# ---------------------------------------------------------------------------------
632637
def conflateOnNetwork(geom, network, threshold=1e300, h=30, verbose=True):
633-
638+
639+
from tracklib.core import ENUCoords
634640
from tracklib.core import TrackCollection
635641
from tracklib.algo.interpolation import conflate
636642
from tracklib.algo.comparison import compare, MODE_COMPARISON_POINTWISE
@@ -646,13 +652,14 @@ def conflateOnNetwork(geom, network, threshold=1e300, h=30, verbose=True):
646652

647653
for segment in geom:
648654
edge = network.getEdge(segment.tid)
655+
649656
p1 = edge.source.coord
650657
p2 = edge.target.coord
651658

652659
h11 = p1.distance2DTo(segment[ 0].position); h12 = p2.distance2DTo(segment[-1].position); h1 = (h11**2+h12**2)**0.5/1.414
653660
h21 = p1.distance2DTo(segment[-1].position); h22 = p2.distance2DTo(segment[ 0].position); h2 = (h21**2+h22**2)**0.5/1.141
654661
HMIN = min(h1, h2)
655-
662+
656663
if (h2 < h1):
657664
ptemp = p1; p1 = p2; p2 = ptemp
658665

tracklib/util/centerline.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -207,7 +207,7 @@ def run(self):
207207

208208
for key in self.dct_polygons.keys():
209209
poly_geom = self.dct_polygons[key]
210-
centerlineObj = CenterlineCenterline(poly_geom, self.dist, self.clean_dist)
210+
centerlineObj = Centerline(poly_geom, self.dist, self.clean_dist)
211211

212212
self.dct_centerlines[key] = centerlineObj.createCenterline()
213213

0 commit comments

Comments
 (0)