forked from hep-mirrors/rivet
-
Notifications
You must be signed in to change notification settings - Fork 0
/
plotnanas
executable file
·32 lines (27 loc) · 958 Bytes
/
plotnanas
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
#! /usr/bin/env python
import argparse
ap = argparse.ArgumentParser()
ap.add_argument("DATFILE", metavar="file", default="nanas.dat", help="release/count data file to read")
ap.add_argument("OUTFILE", nargs="?", metavar="file", default=None, help="image file to write")
args = ap.parse_args()
if not args.OUTFILE:
import os
args.OUTFILE = os.path.splitext(os.path.basename(args.DATFILE))[0] + ".pdf"
import datetime
import numpy as np
import matplotlib.pyplot as plt
# import matplotlib.dates as mdates
# import matplotlib.cbook as cbook
tags, dates, nanas = [], [], []
with open(args.DATFILE) as f:
for line in f:
items = line.split()
tags.append(items[0])
ts = float(items[1].replace("-3600", "").replace("-7200", ""))
dates.append(datetime.date.fromtimestamp(ts))
nanas.append(int(items[2]))
plt.plot(dates, nanas)
plt.xlabel("Year")
plt.ylabel("# analyses")
plt.savefig(args.OUTFILE)
# plt.show()