You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
177 lines
4.7 KiB
Python
177 lines
4.7 KiB
Python
|
|
|
|
import toml
|
|
import numpy as np
|
|
import matplotlib.pyplot as plt
|
|
|
|
toml_string = """
|
|
|
|
[kanalplanung]
|
|
|
|
inp_file = "C:/Daten/nc/Ingenieurbüro/20 Projekte/Kanalplanung/kanalplanung.gpkg"
|
|
"""
|
|
|
|
prj = '0122' # Projektnummer als Filter
|
|
|
|
|
|
|
|
#toml.load("config.toml")
|
|
cfg = toml.loads(toml_string)
|
|
|
|
md = QgsProviderRegistry.instance().providerMetadata("ogr")
|
|
gpkg_con = md.createConnection( cfg['kanalplanung']['inp_file'], {})
|
|
#gpkg_con.fields('public','schacht')
|
|
|
|
query = "SELECT * FROM schacht_versickerung"
|
|
|
|
col = ['s.ezg_total_Aum','sv.fz','sv.di','sv.wandst','sv.da','sv.n','sv.r_5','sv.tiefe','sv.r_mas','sv.D_mas','sv.z_v','sv.Q_s','sv.D']
|
|
## col_dict = {j:i for i,j in enumerate(col)}
|
|
|
|
#Ermittle Index von Objekt
|
|
#col.index('sv.di')
|
|
|
|
col_str = ''
|
|
|
|
|
|
query = "UPDATE schacht_versickerung SET d_a = d_i+2*wandst"
|
|
res = gpkg_con.execSql(query)
|
|
|
|
query = """UPDATE schacht_versickerung SET
|
|
k_f = (SELECT
|
|
pr.kf
|
|
FROM schacht s JOIN projekt pr ON pr.nr = s.ibpprj
|
|
WHERE s.fid = schacht_versickerung.schacht_fid) WHERE k_f is NULL
|
|
|
|
|
|
|
|
"""
|
|
res = gpkg_con.execSql(query)
|
|
|
|
query = """SELECT
|
|
s.fid as fid,
|
|
sv.schacht_fid,
|
|
s.ezg_total_Aum,
|
|
sv.f_z,
|
|
sv.d_i,
|
|
sv.wandst,
|
|
sv.d_a,
|
|
sv.n,
|
|
sv.r_5,
|
|
sv.tiefe,
|
|
sv.r_mas,
|
|
sv.D_mas,
|
|
sv.z_v,
|
|
sv.Q_s,
|
|
sv.D,
|
|
sv.k_f
|
|
FROM schacht s
|
|
JOIN schacht_versickerung sv ON s.fid = sv.schacht_fid
|
|
JOIN projekt pr ON pr.nr = s.ibpprj
|
|
"""
|
|
|
|
# Spaltennamen in das Ergebnis-Array integrieren
|
|
dat = []
|
|
|
|
res = gpkg_con.execSql(query)
|
|
for row in res.rows():
|
|
d = {}
|
|
for i,j in enumerate(res.columns()):
|
|
d[j] = row[i]
|
|
dat.append(d)
|
|
|
|
#res = gpkg_con.executeSql(query)
|
|
#res = res[0]
|
|
#res_dict = {j:res[i] for i,j in enumerate(col)}
|
|
#
|
|
#i = res[0]
|
|
#
|
|
#D = i[13]
|
|
#r = i[7].replace("[","").replace("]","").replace("\n","").split(";")
|
|
#z = []
|
|
#
|
|
#
|
|
#
|
|
#def z_v(r, D):
|
|
# (A_u * r - math.pi * d_a**2/4 * k_f/2) / (d_i**2 * math.pi / 4 * D * f_z + d_a * math.pi * k_f/4) * n
|
|
|
|
|
|
for d in dat:
|
|
#via Numpy:
|
|
r = np.fromstring(d['r_5'].replace(',','.'), sep=';')
|
|
D = np.fromstring(d['D'].replace(',','.'), sep=';')
|
|
|
|
z = (d['ezg_total_Aum']*10**-7 * r - math.pi * d['d_a']**2/4 * d['k_f']/2) / (d['d_i']**2 * math.pi / (4 * D * 60 * d['f_z']) + d['d_a'] * math.pi * d['k_f']/4) * d['n']
|
|
|
|
z_max = z.max()
|
|
idx = z.argmax()
|
|
D_z_max = D[idx]
|
|
r_z_max = r[idx]
|
|
Q_s = (math.pi*d['d_i']**2/4+math.pi*d['d_i']*z_max/2)*d['n'] * d['k_f']/2
|
|
|
|
#r = d['r_5'].replace("[","").replace("]","").replace(",",".").replace("\n","").split(";")
|
|
#r = [float(i) for i in r]
|
|
#D = d['D'].replace("[","").replace("]","").replace("\n","").split(";")
|
|
#D = [float(i) for i in D]
|
|
|
|
#z = []
|
|
#
|
|
#for i, j in enumerate(D):
|
|
# #z.append(z_v(r[i], j))
|
|
# z.append(
|
|
# (d['ezg_total_Aum']*10**-7 * r[i] - math.pi * d['da']**2/4 * d['kf']/2) / (d['di']**2 * math.pi / (4 * D[i] * 60 * d['fz']) + d['da'] * math.pi * d['kf']/4) * d['n'])
|
|
|
|
#z_max = max(z)
|
|
#idx = z.index(z_max)
|
|
#D_z_max = D[idx]
|
|
#r_z_max = r[idx]
|
|
|
|
#z_str = np.array2string(r)
|
|
|
|
query = """UPDATE schacht_versickerung SET
|
|
z = '{}',
|
|
z_v = {},
|
|
r_mas = {},
|
|
D_mas = {},
|
|
Q_s = {}
|
|
WHERE schacht_fid = {}""".format(np.array2string(z).replace("[","").replace("]","").replace(" ",";"), z_max, r_z_max, D_z_max, Q_s, d['schacht_fid'])
|
|
print(query)
|
|
gpkg_con.execSql(query)
|
|
|
|
#https://github.com/geopandas/geopandas/issues/2794
|
|
#https://gist.github.com/MaxDragonheart/46445a150aac9d528dadd2ec877203a5
|
|
#https://github.com/geopandas/geopandas/issues/1035
|
|
|
|
|
|
#
|
|
# PLOT-DIAGRAMM
|
|
#
|
|
|
|
|
|
plt.style.use('_mpl-gallery')
|
|
|
|
# make data
|
|
x = D
|
|
x = np.append(0, x)
|
|
y = z
|
|
y = np.append(0, y)
|
|
|
|
# plot
|
|
fig, ax = plt.subplots(facecolor='white', figsize=[8/2.54*1.4, 8/2.54*1.4], dpi=100)
|
|
#fig.subplots_adjust(top=0.15,bottom=0.15,left=0.15,right=0.15)
|
|
|
|
ax.plot(x, y, linewidth=2.0)
|
|
|
|
ax.set_xlim(0, D_z_max+120)
|
|
ax.set_xlabel('Dauerstufe [min]')
|
|
ax.set_ylim(0, z_max+1)
|
|
ax.set_ylabel('Wasserstand [m]')
|
|
ax.set_title('Schachtversickerung')
|
|
|
|
ax
|
|
|
|
#plt.show()
|
|
plt.savefig('C:\\Daten\\nc\\Ingenieurbüro\\20 Projekte\\Kanalplanung\\Grafiken\\berechnet\\a138-schachtversickerung_{}.png'.format(d['schacht_fid']), bbox_inches="tight", transparent=True)
|
|
|
|
|
|
|