mirror of
https://github.com/janishutz/BiogasControllerApp.git
synced 2025-11-25 13:54:24 +00:00
Config, Lots of docs, Format
Added a config validator and documented code that was previously undocumented, for the plot_generator scripts, documented them.
This commit is contained in:
@@ -4,29 +4,36 @@ import matplotlib.pyplot as plt
|
||||
import csv
|
||||
import os
|
||||
|
||||
# Get user input for various data
|
||||
path = input("Path to csv-file to be plotted: ")
|
||||
print("For the below, it is recommended to enter data in this format: yyyy-mm-dd-hh-mm")
|
||||
date = input("Date & time at which the measurement was taken (approx.): ")
|
||||
group = input("Group-name: ")
|
||||
saveit = input("Should the graph be saved? (y/n) ").lower()
|
||||
|
||||
imp = open(path, "r")
|
||||
reader = csv.reader(imp, delimiter=',')
|
||||
rohdaten = list(reader)
|
||||
lenght = len(rohdaten)
|
||||
reader = csv.reader(imp, delimiter=",")
|
||||
data = list(reader)
|
||||
x = []
|
||||
y = []
|
||||
for i in range(lenght):
|
||||
extract = rohdaten.pop(0)
|
||||
for i in range(len(data)):
|
||||
# Extract the data
|
||||
extract = data.pop(0)
|
||||
x.append(float(extract.pop(0)))
|
||||
y.append(float(extract.pop(0)))
|
||||
|
||||
# Set up plot
|
||||
plt.plot(x, y, color="MAGENTA")
|
||||
plt.xlabel("Time")
|
||||
plt.ylabel("Voltage")
|
||||
title = f"GC - Biogasanlage {date}"
|
||||
plt.title(title)
|
||||
|
||||
plt.title(f"GC - Biogasanlage {date}")
|
||||
plt.grid(True)
|
||||
if saveit == "y":
|
||||
|
||||
# Check if user wants to save the image
|
||||
if saveit == "n":
|
||||
print("didn't save images")
|
||||
else:
|
||||
pos = 0
|
||||
for letter in path[::-1]:
|
||||
if letter == "/":
|
||||
@@ -40,11 +47,7 @@ if saveit == "y":
|
||||
os.mkdir(save_path)
|
||||
except FileExistsError:
|
||||
pass
|
||||
plt.savefig(save_path)
|
||||
os.rename(f"{save_path}/.png", f"{save_path}/GC-{date}-{group}.png")
|
||||
print(f"saved images to {save_path}")
|
||||
else:
|
||||
print("didn't save images")
|
||||
plt.savefig(f"{save_path}/GC-{date}-{group}.png")
|
||||
|
||||
print(f"Saved images to {save_path}")
|
||||
plt.show()
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user