-
Notifications
You must be signed in to change notification settings - Fork 0
/
correct_lightning_timestamps.py
34 lines (28 loc) · 1.13 KB
/
correct_lightning_timestamps.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
"""Correct Lightning data back to UTC time for strikes before 2011-6-1
HiSPARC stations were using UTC time before that time.
Officially HiSPARC started using GPS time on 2010-3-8.
However, some stations were slower to adapt.
1306886400 2011-6-1 <- vanaf hier gebruikt HiSPARC duidelijk GPS tijd
1268006400 2010-3-8 <- vanaf hier zou HiSPARC GPS moeten gaan gebruiken
"""
import tables
import datetime
import time
with tables.open_file('/Users/reno/HiSPARC/Code/lightning/lightning_10km_120sec.h5', 'a') as data:
data.remove_node('/lightning/corr_timestamps')
t = data.root.lightning.timestamps.read()
corr_t = []
T = time.mktime(datetime.datetime(2011, 6, 1).utctimetuple())
T13 = time.mktime(datetime.datetime(2006, 1, 1).utctimetuple())
T14 = time.mktime(datetime.datetime(2009, 1, 1).utctimetuple())
for u in t:
if u < T:
if u < T13:
corr_t.append(u - 13)
elif u < T14:
corr_t.append(u - 14)
else:
corr_t.append(u - 15)
else:
corr_t.append(u)
data.create_array('/lightning', 'corr_timestamps', corr_t)