mirror of https://gitlab.com/pamhyr/pamhyr2
purge + pep8
parent
5dcbc6b4e1
commit
f6e08f203c
|
|
@ -44,16 +44,18 @@ class InternalMeshing(AMeshingTool):
|
||||||
return reach
|
return reach
|
||||||
|
|
||||||
if limites[0] > limites[1]:
|
if limites[0] > limites[1]:
|
||||||
l = limites[1]
|
lim = limites[1]
|
||||||
limites[1] = limites[0]
|
limites[1] = limites[0]
|
||||||
limites[0] = l
|
limites[0] = lim
|
||||||
elif limites[0] == limites[1]:
|
elif limites[0] == limites[1]:
|
||||||
return reach
|
return reach
|
||||||
|
|
||||||
self.st_to_m(reach, limites)
|
self.st_to_m(reach, limites)
|
||||||
self.interpolate_transversal_step(reach,
|
self.interpolate_transversal_step(reach,
|
||||||
limites,
|
limites,
|
||||||
step)
|
step)
|
||||||
|
self.purge_aligned_points(reach)
|
||||||
|
|
||||||
return reach
|
return reach
|
||||||
|
|
||||||
def st_to_m(self, reach, limites):
|
def st_to_m(self, reach, limites):
|
||||||
|
|
@ -110,11 +112,11 @@ class InternalMeshing(AMeshingTool):
|
||||||
# calcul number of intermediate profiles
|
# calcul number of intermediate profiles
|
||||||
np = []
|
np = []
|
||||||
for i in range(limites[0], limites[1]):
|
for i in range(limites[0], limites[1]):
|
||||||
np.append(int((reach.profiles[i+1].rk - reach.profiles[i].rk)/step) -1)
|
np.append(int((reach.profiles[i+1].rk -
|
||||||
|
reach.profiles[i].rk) / step) - 1)
|
||||||
if np[-1] < 0:
|
if np[-1] < 0:
|
||||||
np[-1] = 0
|
np[-1] = 0
|
||||||
|
|
||||||
|
|
||||||
d = [] # ratios
|
d = [] # ratios
|
||||||
p = [] # new profiles
|
p = [] # new profiles
|
||||||
ptr = int(limites[0])
|
ptr = int(limites[0])
|
||||||
|
|
@ -122,24 +124,23 @@ class InternalMeshing(AMeshingTool):
|
||||||
d = 1.0/float(np[i]+1)
|
d = 1.0/float(np[i]+1)
|
||||||
ptr0 = ptr
|
ptr0 = ptr
|
||||||
for j in range(np[i]):
|
for j in range(np[i]):
|
||||||
#p = reach.profiles[ptr0].copy()
|
|
||||||
p = reach.profiles[ptr0].copy()
|
p = reach.profiles[ptr0].copy()
|
||||||
# RATIO entre les deux sections initiales
|
# RATIO entre les deux sections initiales
|
||||||
dj=float(j+1)*d
|
dj = float(j+1)*d
|
||||||
ptr += 1 # next profile, original
|
ptr += 1 # next profile, original
|
||||||
for k in range(len(reach.profiles[ptr0].points)):
|
for k in range(len(reach.profiles[ptr0].points)):
|
||||||
p.points[k].x = reach.profiles[ptr0].points[k].x + \
|
p.points[k].x = reach.profiles[ptr0].points[k].x + \
|
||||||
dj*(reach.profiles[ptr].points[k].x - \
|
dj*(reach.profiles[ptr].points[k].x -
|
||||||
reach.profiles[ptr0].points[k].x)
|
reach.profiles[ptr0].points[k].x)
|
||||||
p.points[k].y = reach.profiles[ptr0].points[k].y + \
|
p.points[k].y = reach.profiles[ptr0].points[k].y + \
|
||||||
dj*(reach.profiles[ptr].points[k].y - \
|
dj*(reach.profiles[ptr].points[k].y -
|
||||||
reach.profiles[ptr0].points[k].y)
|
reach.profiles[ptr0].points[k].y)
|
||||||
p.points[k].z = reach.profiles[ptr0].points[k].z + \
|
p.points[k].z = reach.profiles[ptr0].points[k].z + \
|
||||||
dj*(reach.profiles[ptr].points[k].z - \
|
dj*(reach.profiles[ptr].points[k].z -
|
||||||
reach.profiles[ptr0].points[k].z)
|
reach.profiles[ptr0].points[k].z)
|
||||||
p.rk = reach.profiles[ptr0].rk + \
|
p.rk = reach.profiles[ptr0].rk + \
|
||||||
dj*(reach.profiles[ptr].rk - \
|
dj*(reach.profiles[ptr].rk -
|
||||||
reach.profiles[ptr0].rk)
|
reach.profiles[ptr0].rk)
|
||||||
p.name = f'interpol{p.rk}'
|
p.name = f'interpol{p.rk}'
|
||||||
reach.insert_profile(ptr, p)
|
reach.insert_profile(ptr, p)
|
||||||
ptr += 1 # next profile, original
|
ptr += 1 # next profile, original
|
||||||
|
|
@ -324,3 +325,7 @@ class InternalMeshing(AMeshingTool):
|
||||||
).dist_2d(reach.profiles[i].named_point(directrices[1]))
|
).dist_2d(reach.profiles[i].named_point(directrices[1]))
|
||||||
reach.profiles[i].rk = reach.profiles[i+1].rk \
|
reach.profiles[i].rk = reach.profiles[i+1].rk \
|
||||||
- (sgn * (d1 + d2) / 2)
|
- (sgn * (d1 + d2) / 2)
|
||||||
|
|
||||||
|
def purge_aligned_points(self, reach):
|
||||||
|
for p in reach.profiles:
|
||||||
|
p.purge_aligned_points()
|
||||||
|
|
|
||||||
|
|
@ -229,6 +229,18 @@ class PointXYZ(Point, SQLSubModel):
|
||||||
s = (a + b + c) / 2
|
s = (a + b + c) / 2
|
||||||
return (s*(s-a) * (s-b)*(s-c)) ** 0.5
|
return (s*(s-a) * (s-b)*(s-c)) ** 0.5
|
||||||
|
|
||||||
|
def dist_from_seg(self, p1, p2):
|
||||||
|
a2 = pow(PointXYZ.distance(self, p1), 2)
|
||||||
|
b2 = pow(PointXYZ.distance(self, p2), 2)
|
||||||
|
c2 = pow(PointXYZ.distance(p1, p2), 2)
|
||||||
|
if c2 < 0.00000001:
|
||||||
|
# si les deux points sont confondus
|
||||||
|
d = 0.0
|
||||||
|
else:
|
||||||
|
d = np.sqrt(abs(a2 - pow((c2 - b2 + a2) / (2*np.sqrt(c2)), 2)))
|
||||||
|
|
||||||
|
return d
|
||||||
|
|
||||||
def copy(self):
|
def copy(self):
|
||||||
p = PointXYZ(self.x,
|
p = PointXYZ(self.x,
|
||||||
self.y,
|
self.y,
|
||||||
|
|
|
||||||
|
|
@ -900,15 +900,28 @@ class ProfileXYZ(Profile, SQLSubModel):
|
||||||
self.point(i+1).z = 0.5 * self.point(i).z + 0.5 * self.point(i+2).z
|
self.point(i+1).z = 0.5 * self.point(i).z + 0.5 * self.point(i+2).z
|
||||||
|
|
||||||
def copy(self):
|
def copy(self):
|
||||||
p=ProfileXYZ(self.id,
|
p = ProfileXYZ(self.id,
|
||||||
self.name,
|
self.name,
|
||||||
self.rk,
|
self.rk,
|
||||||
self.reach,
|
self.reach,
|
||||||
self.num,
|
self.num,
|
||||||
0,
|
0,
|
||||||
0, 0,
|
0, 0,
|
||||||
self._status)
|
self._status)
|
||||||
for i, k in enumerate(self.points):
|
for i, k in enumerate(self.points):
|
||||||
p.insert_point(i, k.copy())
|
p.insert_point(i, k.copy())
|
||||||
|
|
||||||
return p
|
return p
|
||||||
|
|
||||||
|
def purge_aligned_points(self):
|
||||||
|
|
||||||
|
align = True
|
||||||
|
while (align):
|
||||||
|
align = False
|
||||||
|
for i in range(1, self.number_points - 1):
|
||||||
|
d = self.point(i).dist_from_seg(self.point(i-1),
|
||||||
|
self.point(i+1))
|
||||||
|
if d < 0.00001 and self.point(i).name == "":
|
||||||
|
align = True
|
||||||
|
self.delete_i([i])
|
||||||
|
break
|
||||||
|
|
|
||||||
|
|
@ -74,10 +74,10 @@ class Rubar3(CommandLineSolver):
|
||||||
("rubarbe_tf_5", "y"),
|
("rubarbe_tf_5", "y"),
|
||||||
("rubarbe_tf_6", "n"),
|
("rubarbe_tf_6", "n"),
|
||||||
("rubarbe_trased", "y"),
|
("rubarbe_trased", "y"),
|
||||||
#("rubarbe_optfpc", "0"),
|
# ("rubarbe_optfpc", "0"),
|
||||||
#("rubarbe_ros", "2650.0"),
|
# ("rubarbe_ros", "2650.0"),
|
||||||
#("rubarbe_dm", "0.1"),
|
# ("rubarbe_dm", "0.1"),
|
||||||
#("rubarbe_segma", "1.0"),
|
# ("rubarbe_segma", "1.0"),
|
||||||
# Sediment parameters
|
# Sediment parameters
|
||||||
("rubarbe_sediment_ros", "2650.0"),
|
("rubarbe_sediment_ros", "2650.0"),
|
||||||
("rubarbe_sediment_por", "0.4"),
|
("rubarbe_sediment_por", "0.4"),
|
||||||
|
|
|
||||||
|
|
@ -34,7 +34,7 @@ solver_long_name = {
|
||||||
# "mage_fake7": "Mage fake v7",
|
# "mage_fake7": "Mage fake v7",
|
||||||
"adistswc": "Adis-TS_WC",
|
"adistswc": "Adis-TS_WC",
|
||||||
# "rubarbe": "RubarBE",
|
# "rubarbe": "RubarBE",
|
||||||
# "rubar3": "Rubar3",
|
"rubar3": "Rubar3",
|
||||||
}
|
}
|
||||||
|
|
||||||
solver_type_list = {
|
solver_type_list = {
|
||||||
|
|
@ -44,5 +44,5 @@ solver_type_list = {
|
||||||
# "mage_fake7": MageFake7,
|
# "mage_fake7": MageFake7,
|
||||||
"adistswc": AdisTSwc,
|
"adistswc": AdisTSwc,
|
||||||
# "rubarbe": RubarBE,
|
# "rubarbe": RubarBE,
|
||||||
# "rubar3": Rubar3,
|
"rubar3": Rubar3,
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue