-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathPrepare4API_live.py
More file actions
161 lines (140 loc) · 6.21 KB
/
Prepare4API_live.py
File metadata and controls
161 lines (140 loc) · 6.21 KB
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
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
import numpy as np
import pandas as pd
import os
import sys
datapath_toolbox = os.path.join('W:\\','ESG','DOW_MAQ','MAQ_Archive','loobos_archive','zz_Python')
sys.path.insert(1, datapath_toolbox)
from Loobos_Toolbox_NewTower import *
from Prepare4API_functions import *
import warnings
warnings.filterwarnings("ignore")
# Set datapath for output files (subfolder will be added in function)
datapath = os.path.join('W:\\','ESG','DOW_MAQ','MAQ_Archive','MAQ-Observations.nl','data')
#--- Define the day to process; by default today and for 1 day, but you can also run it for different days and longer periods
RUN_TODAY = True
#if RUN_TODAY: #Run_Today always runs yesterday and today to avoid data loss during day transition (UTC vs local time)
day1 = np.datetime64('today').astype('datetime64[D]') - 1
day2 = day1 + np.timedelta64(2,'D') # exclusive
#else:
# day1 = np.datetime64('2023-11-17').astype('datetime64[D]')
# day2 = np.datetime64('2023-11-20').astype('datetime64[D]') + np.timedelta64(1,'D') # exclusive
#--- Select which streams to process
all_streams = ['Veenkampen_Meteo','Veenkampen_Flux','Veenkampen_BC','Veenkampen_PM','Veenkampen_Teledyne','Veenkampen_BAM','Loobos_BM','Loobos_BM-Backup','Loobos_BM_Soil','Loobos_BM_Precip','Loobos_EC','Loobos_ST','Loobos_LFW','Loobos_BM-MM','Amsterdam_Rad','Amsterdam_Flux'] #'Loobos_AQ',
do_streams = all_streams
do_streams = ['Veenkampen_Meteo','Veenkampen_Flux','Veenkampen_BC','Veenkampen_PM','Veenkampen_Teledyne','Veenkampen_BAM','Loobos_BM','Loobos_BM-Backup','Loobos_BM_Soil','Loobos_BM_Precip','Loobos_EC','Loobos_ST','Loobos_LFW','Loobos_BM-MM','Amsterdam_Rad','Amsterdam_Flux'] #'Loobos_AQ',
#--- Loop over all selected days
days = np.arange(day1,day2,np.timedelta64(1,'D'))
for t1 in days:
t2 = t1+np.timedelta64(1,'D')
#--- Prepare4API_Veenkampen_Meteo
if 'Veenkampen_Meteo' in do_streams:
try:
Prepare4API_Veenkampen_Meteo(t1,t2, datapath)
print('Prepare4API_Veenkampen_Meteo successful')
except:
print('Prepare4API_Veenkampen_Meteo failed')
#--- Prepare4API_Veenkampen_Flux
if 'Veenkampen_Flux' in do_streams:
try:
Prepare4API_Veenkampen_Flux(t1,t2, datapath)
print('Prepare4API_Veenkampen_Flux successful')
except:
print('Prepare4API_Veenkampen_Flux failed')
#--- Prepare4API_Veenkampen_BC
if 'Veenkampen_BC' in do_streams:
try:
Prepare4API_Veenkampen_BC(t1,t2, datapath)
print('Prepare4API_Veenkampen_BC successful')
except:
print('Prepare4API_Veenkampen_BC failed')
#--- Prepare4API_Veenkampen_PM
if 'Veenkampen_PM' in do_streams:
try:
Prepare4API_Veenkampen_PM(t1,t2, datapath)
print('Prepare4API_Veenkampen_PM successful')
except:
print('Prepare4API_Veenkampen_PM failed')
#--- Prepare4API_Veenkampen_Teledyne
if 'Veenkampen_Teledyne' in do_streams:
try:
Prepare4API_Veenkampen_Teledyne(t1,t2, datapath)
print('Prepare4API_Veenkampen_Teledyne successful')
except:
print('Prepare4API_Veenkampen_Teledyne failed')
#--- Prepare4API_Veenkampen_BAM
if 'Veenkampen_BAM' in do_streams:
try:
Prepare4API_Veenkampen_BAM(t1,t2, datapath)
print('Prepare4API_Veenkampen_BAM successful')
except:
print('Prepare4API_Veenkampen_BAM failed')
#--- Loobos BM
if 'Loobos_BM' in do_streams:
try:
Prepare4API_Loobos_BM(t1,t2, datapath)
print('Prepare4API_Loobos_BM successful')
except:
print('Prepare4API_Loobos_BM failed')
#--- Loobos BM-Backup
if 'Loobos_BM-Backup' in do_streams:
try:
Prepare4API_Loobos_BM_Backup(t1,t2, datapath)
print('Prepare4API_Loobos_BM-Backup successful')
except:
print('Prepare4API_Loobos_BM-Backup failed')
#--- Loobos BM_Soil
if 'Loobos_BM_Soil' in do_streams:
try:
Prepare4API_Loobos_BM_Soil(t1,t2, datapath)
print('Loobos_BM_Soil successful')
except:
print('Loobos_BM_Soil failed')
#--- Loobos EC
if 'Loobos_EC' in do_streams:
try:
Prepare4API_Loobos_EC(t1,t2, datapath)
print('Prepare4API_Loobos_EC successful')
except:
print('Prepare4API_Loobos_EC failed')
#--- Loobos BM Precipitation
if 'Loobos_BM_Precip' in do_streams:
try:
Prepare4API_Loobos_BM_Precip(t1,t2, datapath)
print('Prepare4API_Loobos_BM_Precip successful')
except:
print('Prepare4API_Loobos_BM_Precip failed')
#--- Loobos ST
if 'Loobos_ST' in do_streams:
try:
Prepare4API_Loobos_ST_Cal(t1,t2, datapath)
print('Prepare4API_Loobos_ST successful')
except:
print('Prepare4API_Loobos_ST failed')
#--- Loobos LFW
if 'Loobos_LFW' in do_streams:
try:
Prepare4API_Loobos_LFW(t1,t2, datapath)
print('Prepare4API_Loobos_LFW successful')
except:
print('Prepare4API_Loobos_LFW failed')
#--- Loobos BM MM
if 'Loobos_BM-MM' in do_streams:
try:
Prepare4API_Loobos_BM_MM(t1,t2, datapath)
print('Prepare4API_Loobos_BM-MM successful')
except:
print('Prepare4API_Loobos_BM-MM failed')
#--- Prepare4API_Amsterdam_Rad
if 'Amsterdam_Rad' in do_streams:
try:
Prepare4API_Amsterdam_Rad(t1,t2, datapath)
print('Prepare4API_Amsterdam_Rad successful')
except:
print('Prepare4API_Amsterdam_Rad failed')
#--- Prepare4API_Amsterdam_Flux
if 'Amsterdam_Flux' in do_streams:
try:
Prepare4API_Amsterdam_Flux(t1,t2, datapath)
print('Prepare4API_Amsterdam_Flux successful')
except:
print('Prepare4API_Amsterdam_Flux failed')