Skip to content

Commit 28f3b5f

Browse files
authored
Update TurningBands.py
dev new
1 parent c449bd1 commit 28f3b5f

1 file changed

Lines changed: 12 additions & 12 deletions

File tree

afbf/Simulation/TurningBands.py

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -230,7 +230,7 @@ def Weight_TB(q, h, c, ang0, ang1, N):
230230
axis=0)
231231
M = amax(coord.xy, axis=None)
232232
else:
233-
print('Simulate: provide coord as coordinates.')
233+
raise('Simulate: provide coord as coordinates.')
234234

235235
if evaluate:
236236
self.EvaluateTurningBandParameters()
@@ -261,7 +261,7 @@ def Weight_TB(q, h, c, ang0, ang1, N):
261261
# Weight the process on the turning band (based on rectangular
262262
# integral approximation of the variogram).
263263
weig0, weig = Weight_TB(q, H[0, k], C[0, k],
264-
self.tb.Kangle[k-1], kang, N)
264+
self.tb.Kangle[k - 1], kang, N)
265265

266266
# Projection of grid coordinates on the band.
267267
indr = coord.ProjectOnAxis(q, p)
@@ -394,13 +394,13 @@ def rat(x, prec):
394394
if K == 1:
395395
K = 2
396396

397-
Kangle = linspace(-pi/2, pi/2, K)
397+
Kangle = linspace(-pi / 2, pi / 2, K)
398398
K = len(Kangle)
399399
Pangle = zeros(K, dtype=int)
400400
Qangle = zeros(K, dtype=int)
401-
delta = Kangle[1] + pi/2
401+
delta = Kangle[1] + pi / 2
402402

403-
for m in range(1, K-1):
403+
for m in range(1, K - 1):
404404
# Precision.
405405
prec = delta * (1 + pow(tan(Kangle[m]), 2)) * 0.5
406406
# Rational approximation of the slope tan(Kangle(l))
@@ -467,7 +467,7 @@ def OptimalAngles(self, N=500):
467467
# Definition of a set S of possible angles
468468
# and their associated costs.
469469

470-
if N < Nmax/3:
470+
if N < Nmax / 3:
471471
self.QuasiUniformAngles(Nmax)
472472
else:
473473
self.QuasiUniformAngles(10 * N)
@@ -479,16 +479,16 @@ def OptimalAngles(self, N=500):
479479
# Dynamic programming for the selection of an optimal subset
480480
cost = zeros(nvec) # Partial costs.
481481
pos = zeros(nvec, dtype=int)
482-
cost[nvec-1] = Cost[nvec-1]
483-
pos[nvec-1] = nvec-1
484-
ind = range(0, nvec-1)
482+
cost[nvec - 1] = Cost[nvec - 1]
483+
pos[nvec - 1] = nvec - 1
484+
ind = range(0, nvec - 1)
485485
for i in ind[::-1]:
486486
bound = self.Kangle[i] + prec
487487
bestj = i + 1
488488
mini = cost[bestj]
489489
# Seek among upper angles at distance below prec
490490
# of the current angle for the one with a minimal partial cost.
491-
for j in range(i+2, nvec):
491+
for j in range(i + 2, nvec):
492492
if self.Kangle[j] > bound:
493493
break
494494
if cost[j] < mini:
@@ -503,10 +503,10 @@ def OptimalAngles(self, N=500):
503503
# Build the set S' by finding the best path.
504504
i = 0
505505
Select = zeros(nvec)
506-
while i < nvec-1:
506+
while i < nvec - 1:
507507
Select[i] = 1
508508
i = pos[i]
509-
Select[nvec-1] = 1
509+
Select[nvec - 1] = 1
510510

511511
ind = nonzero(Select == 1)
512512
self.Kangle = self.Kangle[ind]

0 commit comments

Comments
 (0)