forked from dannyjacobs/obs_scripts
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathCampaignStats.py
executable file
·39 lines (32 loc) · 909 Bytes
/
CampaignStats.py
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
33
34
35
36
37
38
39
#! /usr/bin/env python
#CAUTION: This script only works for 'normal operation'
import os,sys,optparse
o = optparse.OptionParser()
opts,args = o.parse_args(sys.argv[1:])
def JDfromFile(FileName):
return float('.'.join(FileName.split('.')[-3:-1]))
MetaD = {}
MetaD['files'] = len(args)
JDmax,JDmin = 1e-10,1e10
for File in args:
_JD = JDfromFile(File)
JDmax = max(JDmax,_JD)
JDmin = min(JDmin,_JD)
MetaD['hours'] = (JDmax - JDmin)*24.
MetaD['days'] = 1.
prefix = '/home/obs/MetaData/N'
suffix = '.eor'
for D in MetaD:
filepath = prefix+D+suffix
print filepath
f = open(filepath,'r')
fileD = f.read()
try:
if fileD.endswith('\n'): fileD = fileD[:-1]
fileD = float(fileD)
fileD += MetaD[D]
except(IOError,ValueError):
print 'Error:',f.read()
fileD = MetaD[D]
f.close()
os.system('echo "%f" > %s' % (fileD,filepath))