From a361256e962e4b9a14b98647ca37a8dde05d0375 Mon Sep 17 00:00:00 2001
From: Nico Vermaas <vermaas@astron.nl>
Date: Sun, 9 Jun 2019 15:51:55 +0200
Subject: [PATCH] adding functionality to directly read qbx files

---
 atdb_statistics/atdb_plot.py     | 13 ++++++++++---
 atdb_stats.py                    |  4 ++--
 data/ingest_speed_annotated.args | 11 +++++++++++
 data/ingest_speed_imaging.args   |  2 +-
 4 files changed, 24 insertions(+), 6 deletions(-)
 create mode 100644 data/ingest_speed_annotated.args

diff --git a/atdb_statistics/atdb_plot.py b/atdb_statistics/atdb_plot.py
index 2c451c7..a95ce42 100644
--- a/atdb_statistics/atdb_plot.py
+++ b/atdb_statistics/atdb_plot.py
@@ -215,17 +215,19 @@ def do_sky_plot(plot_engine, title, x,y, duration, sizes, output_html,y_axis_tit
         plt.show()
 
 
-def do_speed_plot(title, y_axis_title, subtitle, datapoints):
+def do_speed_plot(title, y_axis_title, subtitle, annotate, datapoints):
     """
-
     :param title: Title of Plot
     :param x: dict with data for x-axis (time)
     :param y: dict with data for y_axix (usage)
     :return:
     """
+
     print('do_speed_plot()')
 
     fig = plt.figure(figsize=(12,6))
+    #fig, ax = plt.subplots()
+
     plt.text(x=0.5, y=0.94, s=title, fontsize=14, ha="center", transform=fig.transFigure)
     plt.text(x=0.5, y=0.90, s='query: '+subtitle, fontsize=10, ha="center", transform=fig.transFigure)
 
@@ -254,6 +256,9 @@ def do_speed_plot(title, y_axis_title, subtitle, datapoints):
             # plot start and end points
             plt.plot(datapoint['timestamp'], datapoint['speed_bps'], 'r.',
                      datapoint['timestamp_end'], datapoint['speed_bps'], 'r.')
+            if annotate is not None:
+                plt.text(datapoint['timestamp'], datapoint['speed_bps'], datapoint[annotate]+'...',
+                         rotation='vertical', fontsize=8)
 
         if datapoint['type']=='ingesting':
             ingesting_x.append(datapoint['timestamp'])
@@ -263,7 +268,9 @@ def do_speed_plot(title, y_axis_title, subtitle, datapoints):
 
             plt.plot(datapoint['timestamp'], datapoint['speed_bps'], 'g.',
                      datapoint['timestamp_end'], datapoint['speed_bps'], 'g.')
-
+            if annotate is not None:
+                plt.text(datapoint['timestamp'], datapoint['speed_bps'], datapoint[annotate]+'...',
+                          rotation='vertical', fontsize=8)
     # plot lines
     # connect a line
     for i in range(0,len(observing_x),2):
diff --git a/atdb_stats.py b/atdb_stats.py
index 0f66765..26e8b6c 100644
--- a/atdb_stats.py
+++ b/atdb_stats.py
@@ -448,11 +448,11 @@ def main():
 
     # --------------------------------------------------------------------------------------------------------
     if (args.version):
-        print('--- atdb_plot.py - version 1.0.0 - 28 mar 2019 ---')
+        print('--- atdb_stats.py - version 1.0.0 - 9 jun 2019 ---')
         print('Copyright (C) 2019 - Nico Vermaas - ASTRON. This program comes with ABSOLUTELY NO WARRANTY;')
         return
 
-    print('--- atdb_plot.py - version 1.0.0 - 28 mar 2019 ---')
+    print('--- atdb_stats.py - version 1.0.0 - 9 jun 2019 ---')
     print('Copyright (C) 2019 - Nico Vermaas - ASTRON. This program comes with ABSOLUTELY NO WARRANTY;')
     if args.starttime != None:
         starttime = datetime.datetime.strptime(args.starttime, TIME_FORMAT)
diff --git a/data/ingest_speed_annotated.args b/data/ingest_speed_annotated.args
new file mode 100644
index 0000000..e94892c
--- /dev/null
+++ b/data/ingest_speed_annotated.args
@@ -0,0 +1,11 @@
+--presentation=ingest_speed
+--atdb_host=http://192.168.22.22/atdb
+--title=I/O speeds on wcudata1 from ATDB
+--observing_mode=imaging
+--y_axis_title=I/O Speed in Gbps
+--starttime=2019-06-08 00:00
+--endtime=2019-06-09 00:00
+--query=taskID__contains=190608
+--query=starttime__gt=2019-06-07T00:00:00Z&starttime__lt=2019-06-10T00:00:00Z
+--annotate=taskid
+--plot_engine=mathplotlib
\ No newline at end of file
diff --git a/data/ingest_speed_imaging.args b/data/ingest_speed_imaging.args
index 7262817..e94892c 100644
--- a/data/ingest_speed_imaging.args
+++ b/data/ingest_speed_imaging.args
@@ -6,6 +6,6 @@
 --starttime=2019-06-08 00:00
 --endtime=2019-06-09 00:00
 --query=taskID__contains=190608
---query=starttime__gt=2019-06-07T00:00:00Z&starttime__lt=2019-06-11T00:00:00Z
+--query=starttime__gt=2019-06-07T00:00:00Z&starttime__lt=2019-06-10T00:00:00Z
 --annotate=taskid
 --plot_engine=mathplotlib
\ No newline at end of file
-- 
GitLab