Code: Alles auswählen
def mlf_filter(ecz, typ):
import numpy
#Momente der Lastfaelle zur Weiterverarbeitung aufbereiten filtern
if typ == 1:
#Momente der Lastfaelle in Container schreiben
mlf = numpy.array([])
for i in range(0,51,1):
s = ecz[i,2:34:4] #Zeile,von Spalte:bis Spalte, Schritte
mlf = numpy.append(mlf, s)
mlf = numpy.reshape(mlf, (51,2))
elif typ == 2:
#Momente der Lastfaelle in Container schreiben
mlf = numpy.array([])
for i in range(0,102,1):
s = ecz[i,2:34:4] #Zeile,von Spalte:bis Spalte, Schritte
mlf = numpy.append(mlf, s)
mlf = numpy.reshape(mlf, (102,4))
else:
#Momente der Lastfaelle in Container schreiben
mlf = numpy.array([])
for i in range(0,153,1):
s = ecz[i,2:34:4] #Zeile,von Spalte:bis Spalte, Schritte
mlf = numpy.append(mlf, s)
mlf = numpy.reshape(mlf, (153,8))
return mlf
def plot_schnittkraefte(string):
import numpy, json, urllib, random
import matplotlib.pyplot as plt
#Lib fuer Ramdatei
from StringIO import StringIO
import sys
#Json String auspacken
string = urllib.unquote(string)
z = json.loads(string)
typ = z["typ"]
typ = int(typ)
ecz = z["ecz"]
ecz = numpy.array(ecz)
#Momente der Lastfaelle zur Weiterverarbeitung aufbereiten filtern
mlf = mlf_filter(ecz, typ)
#Momenten Minimum bestimmen
min = numpy.amin(mlf,1)
#Momenten Maximum bestimmen
max = numpy.amax(mlf,1)
#Ausgabe als Plot
#Plot x,y
s = StringIO()
plt.figure(figsize=(8.0, 6.)) #breitexhoehe [px]
#Axen reinigen von vorherigen Plot
plt.cla()
#Zeichnen der Lastfaelle
if typ == 1:
plt.plot(ecz[:,0] , mlf[:,0], label= "LF 1", color = '#32cd32')
plt.plot(ecz[:,0] , mlf[:,1], label= "LF 2", color = '#b8860b')
elif typ == 2:
plt.plot(ecz[:,0] , mlf[:,0], label= "LF 1", color = '#32cd32')
plt.plot(ecz[:,0] , mlf[:,1], label= "LF 2", color = '#b8860b')
plt.plot(ecz[:,0] , mlf[:,2], label= "LF 3", color = '#ff69b4')
plt.plot(ecz[:,0] , mlf[:,3], label= "LF 4", color = '#48d1cc')
else:
plt.plot(ecz[:,0] , mlf[:,0], label= "LF 1", color = '#32cd32')
plt.plot(ecz[:,0] , mlf[:,1], label= "LF 2", color = '#b8860b')
plt.plot(ecz[:,0] , mlf[:,2], label= "LF 3", color = '#ff69b4')
plt.plot(ecz[:,0] , mlf[:,3], label= "LF 4", color = '#48d1cc')
plt.plot(ecz[:,0] , mlf[:,4], label= "LF 5", color = '#6a5acd')
plt.plot(ecz[:,0] , mlf[:,5], label= "LF 6", color = '#ffd700')
plt.plot(ecz[:,0] , mlf[:,6], label= "LF 7", color = '#8b0000')
plt.plot(ecz[:,0] , mlf[:,7], label= "LF 8", color = '#bdb76b')
plt.ylim(numpy.amax(max),numpy.amin(min)) # Negativ oben, Bereich einstellen
plt.ylabel('Moment [kN/m]')
plt.xlabel('Laenge [m]')
plt.title('Momentenverlauf')
plt.grid() # Gitternetz zeichnen
plt.legend(ncol=(1), loc=(5))
#return plt.savefig(sys.stdout, format='png')
plt.savefig(s, format='png')
return s.getvalue()
def plot_schnittkraefte_min_max(string):
import numpy, json, urllib
import matplotlib.pyplot as plt
#Lib fuer Ramdatei
from StringIO import StringIO
import sys
#Json String auspacken
string = urllib.unquote(string)
z = json.loads(string)
typ = z["typ"]
typ = int(typ)
ecz = z["ecz"]
ecz = numpy.array(ecz)
#Momente der Lastfaelle zur Weiterverarbeitung aufbereiten filtern
mlf = mlf_filter(ecz, typ)
#Momenten Minimum bestimmen
min = numpy.amin(mlf,1)
#Momenten Maximum bestimmen
max = numpy.amax(mlf,1)
#Ausgabe als Plot
#Plot x,y
s = StringIO()
plt.figure(figsize=(5.0, 3.8)) #breitexhoehe [px]
#Axen reinigen von vorherigen Plot
plt.cla()
# Graphen plotten
plt.plot(ecz[:,0] , min, label='Momenten Minimum', color='k', )
plt.plot(ecz[:,0] , max, label='Momenten Maximum', color='k')
plt.ylim(numpy.amax(max),numpy.amin(min)) # Negativ oben, Bereich einstellen
#Achsen beschriften
plt.ylabel('Moment [kN/m]')
plt.xlabel('Laenge [m]')
plt.title('Momentengrenzlinie')
plt.grid() # Gitternetz zeichnen
#Flaechen fuellen
plt.fill(ecz[:,0] , max, 'r')
plt.fill(ecz[:,0] , min < 0 , 'b')
plt.savefig(s, format='png')
return s.getvalue()