Re: Treinwielen
Geplaatst: ma 10 jul 2023, 10:31
Maar het gaat hier natuurlijk om de wielen van de trein waarin je de metingen hebt verricht.
Code: Selecteer alles
import pandas as pd
import matplotlib.pyplot as plt
import matplotlib.mlab as mlab
import numpy as np
# Define layout spectrogram plot and time series
layout = [ ["time","time"], ["time2","time3"], ["freq","freq"], ["spectrum1", "spectrum2"]]
gs_kw = dict(width_ratios=[1,1], height_ratios=[20, 20, 20, 40])
fig, axd = plt.subplot_mosaic(layout, figsize=(10, 9), layout="constrained", gridspec_kw=gs_kw)
def spectogram(signal, fs):
# calcuate the spectrogram, determine perios instead of frequency
spec, freq, t = mlab.specgram(signal, Fs=fs, mode="magnitude", NFFT=256, noverlap=150)
# calculate the period bin limits, omit the zero frequency bin
period = 1. / freq[1:]
return t, freq, period, spec
df = pd.read_csv("treinreis/Retour-calc.csv")[100:-300]
axd["time"].set_title("Retour")
# Plot time signal
axd["time"].plot(df["x"], df["ay"], color="black", linewidth=0.1)
axd["time"].set_xlabel("distance [meters]")
axd["time"].set_ylabel("Acceleration y [m/s²]")
#axd["timepart"].plot(df["x"], df["ay"], color="black", linewidth=0.5)
#axd["timepart"].set_xlabel("distance [meters]")
#xd["timepart"].set_ylabel("Acceleration y [m/s2]")
axd["time2"].plot(df["x"], df["ay"], color="black", linewidth=0.1)
axd["time2"].set_xlabel("distance [meters]")
axd["time2"].set_ylabel("Acceleration y [m/s²]")
axd["time3"].plot(df["x"], df["ay"], color="black", linewidth=0.1)
axd["time3"].set_xlabel("distance [meters]")
axd["time3"].set_ylabel("Acceleration y [m/s²]")
fs = 1/0.75
time, freq, period, spectrum = spectogram(df["ay"], fs)
axd["freq"].pcolormesh(time, (freq), np.log10(spectrum), cmap="coolwarm")
axd["freq"].set_xlabel("distance [meters]")
axd["freq"].set_ylabel("frequency [1/m]")
#axd["period"].pcolormesh(time, (period[::-1]), np.log10(spectrum[:0:-1]), cmap="coolwarm")
#axd["period"].set_xlabel("distance [meters]")
#axd["period"].set_ylabel("period [m]")
#xd["period"].set_ylim([0, 25])
mean = np.mean(spectrum, axis=1)
axd["spectrum1"].plot(freq, (mean), color="black", linewidth=0.1)
axd["spectrum1"].set_xlabel("frequecy [1/m]")
axd["spectrum1"].set_ylabel("magnitude [m/s²]")
#axd["spectrum1"].set_xlim([0, 0.7])
axd["spectrum1"].set_ylim([0, 0.05])
axd["spectrum1"].set_xscale('log')
mean = np.mean(spectrum[:0:-1], axis=1)
axd["spectrum2"].plot(period[::-1], (mean), color="black", linewidth=0.1)
axd["spectrum2"].set_xlabel("period [meters]")
axd["spectrum2"].set_ylabel("magnitude [m/s²]")
axd["spectrum2"].set_xlim([0, 30])
axd["spectrum2"].set_ylim([0, 0.05])
# Annotation
bbox = dict(boxstyle="round", fc="0.8")
arrowprops = dict(
arrowstyle="->",
connectionstyle="angle, angleA = 0, angleB = 90,\
rad = 3")
offset = 10
axd["spectrum2"].annotate('10 [m]',
(10, 0.0147), xytext =(offset, 8*offset),
textcoords ='offset points',
bbox = bbox, arrowprops = arrowprops)
axd["spectrum2"].annotate('27.9 [m]',
(27.9, 0.048), xytext =(offset, 1*offset),
textcoords ='offset points',
bbox = bbox, arrowprops = arrowprops)
axd["spectrum2"].annotate('19.2 [m]',
(19.2, 0.024), xytext =(offset, 4*offset),
textcoords ='offset points',
bbox = bbox, arrowprops = arrowprops)
axd["spectrum2"].annotate('6.8 [m]',
(6.8, 0.0075), xytext =(offset, 6*offset),
textcoords ='offset points',
bbox = bbox, arrowprops = arrowprops)
axd["spectrum2"].annotate('3.48 [m], 0.007 [m/s²]',
(3.48, 0.008), xytext =(offset, 13.5*offset),
textcoords ='offset points',
bbox = bbox, arrowprops = arrowprops)
plt.show()
Waar zit jouw twijfel? De snelheidsgrafieken van jou en mij komen mooi overeen. Dat we allebei dezelfde fout zouden hebben gemaakt lijkt me heel onwaarschijnlijk.OOOVincentOOO schreef: ↑ma 10 jul 2023, 12:24 Er blijft altijd iets knagen. Waar zit mijn fout? Ik heb de snelheid trein in bewegingsrichting toegevoegd.
Het lijkt op plot Xilvo. Maar twijfel nog steeds. Ik dacht dat de grote slinger in versnelling de stop/station was. Is dat het afremmen van de trein?