Plot one or multiple jobs.
This commit is contained in:
parent
983bf4ee53
commit
343b77a036
|
@ -0,0 +1,69 @@
|
||||||
|
#!/usr/bin/env python3
|
||||||
|
|
||||||
|
import csv
|
||||||
|
import sys
|
||||||
|
from pandas import DataFrame
|
||||||
|
from pandas import Grouper
|
||||||
|
from matplotlib import pyplot
|
||||||
|
|
||||||
|
jobs = sys.argv[1:]
|
||||||
|
|
||||||
|
print("Analyzing the jobs: " + str(jobs))
|
||||||
|
|
||||||
|
# Plot the timeseries
|
||||||
|
def plot(header, row):
|
||||||
|
x = { h : d for (h, d) in zip(header, row)}
|
||||||
|
jobid = x["jobid"]
|
||||||
|
del x["jobid"]
|
||||||
|
del x["coding_abs"]
|
||||||
|
del x["coding_abs_aggzeros"]
|
||||||
|
|
||||||
|
result = []
|
||||||
|
for k in x:
|
||||||
|
timeseries = x[k].split(":")
|
||||||
|
timeseries = [ float(x) for x in timeseries]
|
||||||
|
if sum(timeseries) == 0:
|
||||||
|
continue
|
||||||
|
timeseries = [ [k, x, s] for (s,x) in zip(timeseries, range(1, len(timeseries))) ]
|
||||||
|
result.extend(timeseries)
|
||||||
|
|
||||||
|
data = DataFrame(result, columns=["metrics", "segment", "value"])
|
||||||
|
groups = data.groupby(["metrics"])
|
||||||
|
metrics = DataFrame()
|
||||||
|
labels = []
|
||||||
|
for name, group in groups:
|
||||||
|
metrics[name] = [x[2] for x in group.values]
|
||||||
|
labels.append(name)
|
||||||
|
|
||||||
|
ax = metrics.plot(subplots=True, legend=False, sharex=True, grid = True, sharey=True, colormap='jet', marker='.', markersize=10)
|
||||||
|
for (i, l) in zip(range(0, len(labels)), labels):
|
||||||
|
ax[i].set_ylabel(l)
|
||||||
|
|
||||||
|
pyplot.xlabel("Segment number")
|
||||||
|
pyplot.savefig("timeseries" + jobid + ".png")
|
||||||
|
|
||||||
|
# Plot first 30 minutes
|
||||||
|
|
||||||
|
ax = metrics.plot(subplots=True, legend=False, sharex=True, grid = True, sharey=True, colormap='jet', marker='.', markersize=10, xlim=(0,30))
|
||||||
|
for (i, l) in zip(range(0, len(labels)), labels):
|
||||||
|
ax[i].set_ylabel(l)
|
||||||
|
|
||||||
|
pyplot.xlabel("Segment number")
|
||||||
|
pyplot.savefig("timeseries" + jobid + "-30.png")
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
with open('job-io-datasets/datasets/job_codings.csv') as csv_file:
|
||||||
|
csv_reader = csv.reader(csv_file, delimiter=',')
|
||||||
|
line_count = 0
|
||||||
|
for row in csv_reader:
|
||||||
|
if line_count == 0:
|
||||||
|
header = row
|
||||||
|
line_count += 1
|
||||||
|
continue
|
||||||
|
|
||||||
|
if not row[0].strip() in jobs:
|
||||||
|
continue
|
||||||
|
else:
|
||||||
|
plot(header, row)
|
Loading…
Reference in New Issue