#!/usr/bin/env python
# (c) Stefan Countryman 2017
# A script for generating a nominal entry for the EVNT log. Note that the text
# below is only true in the event that everything goes right!

with open('graceid.txt', 'r') as f:
    graceid = f.read().strip()

title = 'IRIG-B and DuoTone Timing Checks around {} Passed'.format(graceid)
body = ('Independent CNS-II GPS witness clocks at each end station and '
        'each site show IRIG-B timestamps in agreement with the '
        'timestamps written to frame for the 30 seconds surrounding the '
        '{} event. Note that the decoded Hanford times are 18 seconds '
        'later than the UTC time due to the fact that the Hanford site '
        'outputs its IRIG-B signal in GPS time. All output was as '
        'expected, consistent with a correct absolute timestamp at the '
        'time of {}.\n\n'
        'I also ran a python plotting script translated from Keita\'s '
        'duotone histogram script (found at $CalSVN/aligocalibration'
        '/trunk/Common/MatlabTools/timing/commissioningFrameDuotoneStat). '
        'The delays are within the 1us bounds, as '
        'needed.\n\n').format(graceid, graceid)

with open('event-log.txt', 'w') as f:
    f.write(title)
    f.write('\n\n')
    f.write(body)

@@ -186,16 +186,55 @@
 right!%0A%0A
+import sys%0A%0Aif len(sys.argv) == 1:%0A    
 with ope
@@ -265,16 +265,20 @@
  f:%0A    
+  
+  
 graceid 
@@ -295,16 +295,134 @@
 .strip()
+%0Aelif '-h' in sys.argv:%0A    print('USAGE: %7B%7D GRACEID'.format(sys.argv%5B0%5D))%0A    exit(1)%0Aelse:%0A    graceid = sys.argv%5B1%5D
 %0A%0Atitle 
@@ -1307,16 +1307,533 @@
 ed.%5Cn%5Cn'
+%0A        'Additionally, DuoTone overlay plots (as seen and described in '%0A        'LIGO-T1600161) are attached. These plots show +/- 15 minutes of '%0A        'DuoTone signal surrounding the event with each second worth of data '%0A        'plotted on the same set of axes. The plots are visually '%0A        'indistinguishable from a single second worth of data, indicating that '%0A        'there were no large deviations from periodicity in the DuoTone '%0A        'signal.%5Cn%5Cn'%0A        'In conclusion, timing looks good.%5Cn'
 ).format

add overlay plots to evnt log generator