DIY fertilizer mixer and plant watering machine https://www.xythobuz.de/giessomat.html
Nevar pievienot vairāk kā 25 tēmas Tēmai ir jāsākas ar burtu vai ciparu, tā var saturēt domu zīmes ('-') un var būt līdz 35 simboliem gara.

influx-calibration.py 1.5KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  1. #!/usr/bin/env python
  2. from influxdb import InfluxDBClient
  3. import matplotlib.pyplot as plt
  4. import matplotlib
  5. from datetime import datetime
  6. # config
  7. host = '10.23.42.14'
  8. port = 8086
  9. user = 'root'
  10. password = 'root'
  11. dbname = 'giessomat'
  12. # data
  13. client = InfluxDBClient(host, port, user, password, dbname)
  14. print("Querying DB " + dbname + " on " + host)
  15. result = client.query('SELECT "duration" FROM "calibrated_filling";')
  16. #print("Result: {0}".format(result))
  17. data = list(result.get_points())
  18. print("Got " + str(len(data)) + " datapoints")
  19. #print(data)
  20. times = ([datetime.strptime(d['time'], '%Y-%m-%dT%H:%M:%S.%fZ') for d in data])
  21. durations = ([d['duration'] for d in data])
  22. max_t = max(durations)
  23. min_t = min(durations)
  24. simple_average = min_t + ((max_t - min_t) / 2)
  25. average = 0
  26. for d in durations:
  27. average += d
  28. average /= len(durations)
  29. sorted_durations = sorted(durations)
  30. median = sorted_durations[int(len(sorted_durations) / 2)]
  31. print("Min. Filling Time: " + str(min_t))
  32. print("Max. Filling Time: " + str(max_t))
  33. print("Average Filling Time:")
  34. print(" Simple = " + str(simple_average))
  35. print(" Average = " + str(average))
  36. print(" Median = " + str(median))
  37. # plot results
  38. plt.ioff()
  39. # ---------------------------
  40. fig, ax = plt.subplots()
  41. dates = matplotlib.dates.date2num(times)
  42. ax.plot_date(dates, durations, '-', label='filling')
  43. ax.set_xlabel('Time')
  44. ax.set_ylabel('Duration')
  45. ax.set_title('Filling Durations')
  46. ax.legend()
  47. # ---------------------------
  48. plt.show()