import datetime
import numpy as np
from irfpy.vels import scidata
def main():
t0 = datetime.datetime(2006, 1, 8)
t1 = datetime.datetime(2014, 12, 2)
fp = open('error.txt', 'w')
t = t0
n = 0
while t < t1:
dt = datetime.timedelta(seconds=1, milliseconds=int(np.random.normal(loc=0.0, scale=0.5) * 1000))
t += dt
if 2 <= t.minute <=58:
continue
n += 1
try:
c = scidata.get_count(t)
c = '{} {} {}'.format(c[1].sum(), c[0], (t - c[0]).total_seconds())
except Exception as e:
c = type(e)
print(n, t, c, file=fp)
fp.flush()
print(n, t, dt.total_seconds(), c)
fp.close()
if __name__ == '__main__':
main()