-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathFIX.py
4413 lines (3922 loc) · 171 KB
/
FIX.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
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
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
"""
*** FIX v20.0 ***
- component of REFIR 20.0 -
-control software and GUI for operating REFIR -
Copyright (C) 2020 Tobias Dürig, Fabio Dioguardi
============== ===================
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
at your option any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <https://www.gnu.org/licenses/>.
If you wish to contribute to the development of REFIR or to reports bugs or other problems with
the software, please write an email to me.
Contact: [email protected], [email protected]
RNZ170318FS
"""
from __future__ import division
from __future__ import with_statement
import numpy as np
import matplotlib.pyplot as plt
import matplotlib as mpl
import datetime
import time
import math
from copy import deepcopy
from mpl_toolkits.basemap import Basemap
import os
import sys
if sys.version_info[0] < 3:
from Tkinter import *
else:
from tkinter import *
runtype_weather = Tk()
weather = 1 # Default is automatic weather data retrieval
run_type = 1 # Default is real_time mode
#run_type_original = run_type
quit_refir = IntVar()
#quit_refir.set(0) # FOXI continues until exit_param = 0
exit_param = 0
esps_dur = 0
esps_plh = 0
def calculate_position(self,x, y):
# Function that control the position of the widget in the screen
screen_width = self.winfo_screenwidth()
screen_height = self.winfo_screenheight()
pos_x = x * screen_width
pos_y = y * screen_height
return (pos_x, pos_y)
def first_widget():
global run_type_in, weather_in
run_type_in = IntVar()
weather_in = IntVar()
run_type_in.set(1)
weather_in.set(1)
runtype_weather.title("REFIR Operation Mode")
Label(runtype_weather, text="REFIR Operation Mode", font=("Verdana", 14, "bold"), fg="navy").grid(row=1, column=1,
columnspan=4,
sticky=W)
Label(runtype_weather, text="Mode Selection", font=("Verdana", 10, "bold"), fg="navy").grid(row=2, column=1,
columnspan=2, sticky=W)
Radiobutton(runtype_weather, text="Real Time", variable=run_type_in, value=1).grid(row=4, column=1, columnspan=2,
sticky=W)
Radiobutton(runtype_weather, text="Reanalysis", variable=run_type_in, value=2).grid(row=5, column=1, columnspan=2,
sticky=W)
Label(runtype_weather, text="Weather data", font=("Verdana", 10, "bold"), fg="navy").grid(row=2, column=4,
columnspan=2, sticky=W)
Radiobutton(runtype_weather, text="Automatic Retrieve", variable=weather_in, value=1).grid(row=4, column=4,
columnspan=2, sticky=W)
Radiobutton(runtype_weather, text="Manual entry", variable=weather_in, value=2).grid(row=5, column=4, columnspan=2,
sticky=W)
x_screen_fr = 0.2
y_screen_fr = 0.2
size_x = 300
size_y = 100
pos_x, pos_y = calculate_position(runtype_weather,x_screen_fr, y_screen_fr)
runtype_weather.geometry('%dx%d+%d+%d' % (size_x, size_y, pos_x, pos_y))
runtype_weather.mainloop()
first_widget()
run_type = run_type_in.get()
weather = weather_in.get()
run_type_original = run_type
if run_type == 2:
past_eruption = Tk()
out = StringVar()
def second_widget():
past_eruption.title("Reanalysis mode control")
Label(past_eruption, text="Specify start and end of eruption", \
font="Helvetica 12", fg="blue").grid(row=0, column=0, columnspan=6)
Label(past_eruption, text="Start of eruption: ", \
font="Helvetica 11", fg="green").grid(row=5, column=0, columnspan=2, sticky=W)
Label(past_eruption, text="Year: ", font="Helvetica 10").grid(row=5, column=2)
Label(past_eruption, text="Month: ", font="Helvetica 10").grid(row=6, column=2)
Label(past_eruption, text="Day: ", font="Helvetica 10").grid(row=6, column=0)
Label(past_eruption, text="Hour: ", font="Helvetica 10").grid(row=7, column=0)
Label(past_eruption, text="Minute: ", font="Helvetica 10").grid(row=7, column=2)
Label(past_eruption, text="End of eruption: ", \
font="Helvetica 11", fg="green").grid(row=9, column=0, columnspan=2, sticky=W)
Label(past_eruption, text="Year: ", font="Helvetica 10").grid(row=9, column=2)
Label(past_eruption, text="Month: ", font="Helvetica 10").grid(row=10, column=2)
Label(past_eruption, text="Day: ", font="Helvetica 10").grid(row=10, column=0)
Label(past_eruption, text="Hour: ", font="Helvetica 10").grid(row=11, column=0)
Label(past_eruption, text="Minute: ", font="Helvetica 10").grid(row=11, column=2)
time_ERU_start_y = Entry(past_eruption, width=4)
time_ERU_start_y.grid(row=5, column=3, sticky=W)
time_ERU_start_mo = Entry(past_eruption, width=2)
time_ERU_start_mo.grid(row=6, column=3, sticky=W)
time_ERU_start_d = Entry(past_eruption, width=2)
time_ERU_start_d.grid(row=6, column=1, sticky=W)
time_ERU_start_h = Entry(past_eruption, width=2)
time_ERU_start_h.grid(row=7, column=1, sticky=W)
time_ERU_start_m = Entry(past_eruption, width=2)
time_ERU_start_m.grid(row=7, column=3, sticky=W)
time_ERU_stop_y = Entry(past_eruption, width=4)
time_ERU_stop_y.grid(row=9, column=3, sticky=W)
time_ERU_stop_mo = Entry(past_eruption, width=2)
time_ERU_stop_mo.grid(row=10, column=3, sticky=W)
time_ERU_stop_d = Entry(past_eruption, width=2)
time_ERU_stop_d.grid(row=10, column=1, sticky=W)
time_ERU_stop_h = Entry(past_eruption, width=2)
time_ERU_stop_h.grid(row=11, column=1, sticky=W)
time_ERU_stop_m = Entry(past_eruption, width=2)
time_ERU_stop_m.grid(row=11, column=3, sticky=W)
def on_button():
global time_start, time_stop, eruption_start, eruption_stop
global Y_eru_start_s, MO_eru_start_s, D_eru_start_s
global Y_eru_start, MO_eru_start, D_eru_start, H_eru_start
global Y_eru_stop, MO_eru_stop, D_eru_stop, H_eru_stop
Y_eru_start = int(time_ERU_start_y.get())
MO_eru_start = int(time_ERU_start_mo.get())
D_eru_start = int(time_ERU_start_d.get())
H_eru_start = int(time_ERU_start_h.get())
M_eru_start = int(time_ERU_start_m.get())
Y_eru_stop = int(time_ERU_stop_y.get())
MO_eru_stop = int(time_ERU_stop_mo.get())
D_eru_stop = int(time_ERU_stop_d.get())
H_eru_stop = int(time_ERU_stop_h.get())
M_eru_stop = int(time_ERU_stop_m.get())
Y_eru_start_s = str(Y_eru_start)
if MO_eru_start < 10:
MO_eru_start_s = '0' + str(MO_eru_start)
else:
MO_eru_start_s = str(MO_eru_start)
print(D_eru_start)
if D_eru_start < 10:
D_eru_start_s = '0' + str(D_eru_start)
else:
D_eru_start_s = str(D_eru_start)
if H_eru_start < 10:
H_eru_start_s = '0' + str(H_eru_start)
else:
H_eru_start_s = str(H_eru_start)
Y_eru_stop_s = str(Y_eru_stop)
if MO_eru_stop < 10:
MO_eru_stop_s = '0' + str(MO_eru_stop)
else:
MO_eru_stop_s = str(MO_eru_stop)
if D_eru_stop < 10:
D_eru_stop_s = '0' + str(D_eru_stop)
else:
D_eru_stop_s = str(D_eru_stop)
if H_eru_stop < 10:
H_eru_stop_s = '0' + str(H_eru_stop)
else:
H_eru_stop_s = str(H_eru_stop)
eruption_start = Y_eru_start_s + MO_eru_start_s + D_eru_start_s + H_eru_start_s
eruption_stop = Y_eru_stop_s + MO_eru_stop_s + D_eru_stop_s + H_eru_stop_s
time_start = datetime.datetime(Y_eru_start, MO_eru_start, D_eru_start, H_eru_start, M_eru_start)
time_stop = datetime.datetime(Y_eru_stop, MO_eru_stop, D_eru_stop, H_eru_stop, M_eru_stop)
Button(past_eruption, text="Confirm times", font="Helvetica 11", fg="yellow", bg="red", \
width=24, height=2, command=on_button).grid(row=14, column=0, columnspan=5)
past_eruption.mainloop()
second_widget()
else:
time_start = '00-00-00 00:00:00'
time_stop = '00-00-00 00:00:00'
#dir1 = os.path.dirname(__file__)
dir1 = os.path.dirname(os.path.abspath(__file__))
PlumeRiseFile = "PlumeRise_Foxi"
root = Tk()
x_screen_fr = 0.2
y_screen_fr = 0.2
size_x = 210
size_y = 350
pos_x, pos_y = calculate_position(root,x_screen_fr, y_screen_fr)
root.geometry('%dx%d+%d+%d' % (size_x, size_y, pos_x, pos_y))
root.title("select the volcano")
vulkan = 0
vulk = IntVar()
vulk.set(0) # initializing the choice
try:
label = ['n.a.', 'n.a.', 'n.a.', 'n.a.', 'n.a.', 'n.a.', 'n.a.', 'n.a.', 'n.a.', 'n.a.']
volc_lat = []
volc_lon = []
kurzvulk = []
defsetup = []
fn = os.path.join(dir1 + '/refir_config', 'volcano_list.ini')
with open(fn,encoding="utf-8", errors="surrogateescape") as f:
lines = f.readlines()
Cse = []
for l in lines:
Cse.append(l.strip().split("\t"))
f.close()
N_env = len(Cse) - 1 # number of entries
if N_env < 1:
print("\nNo volcano assigned!\n")
else:
for y in range(0, N_env):
label.append(0)
volc_lat.append(0)
volc_lon.append(0)
defsetup.append(0)
kurzvulk.append("")
for x in range(0, N_env):
label[x] = str(Cse[x + 1][5])
volc_lat[x] = float(Cse[x + 1][1])
volc_lon[x] = float(Cse[x + 1][2])
defsetup[x] = int(Cse[x + 1][4])
kurzvulk[x] = str(Cse[x + 1][0])
# file exists
except EnvironmentError:
# file does not exist yet
print("Error -file volcano_list.ini not found!")
volcanoes = [(label[0], 0), (label[1], 1),
(label[2], 2),
(label[3], 3),
(label[4], 4),
(label[5], 5), (label[6], 6), (label[7], 7), (label[8], 8), (label[9], 9)]
def ShowChoiceVulk():
print (vulk.get())
global vulkan
vulkan = vulk.get()
Label(root,
text="""Select eruption site:""", font="Verdana 12 bold",
justify=LEFT,
padx=20).pack()
for txt, val in volcanoes:
Radiobutton(root,
text=txt, font="Helvetica 12",
indicatoron=0,
width=20,
padx=20,
variable=vulk,
command=ShowChoiceVulk,
value=val).pack(anchor=W)
mainloop()
time_update = datetime.datetime.utcnow()
print("**** REFIR FIX system is booting ****")
print("Selected volcano: ")
print(vulk.get())
ISKEF, ISEGS, ISX1, ISX2, GFZ1, GFZ2, GFZ3 = 0, 0, 0, 0, 0, 0, 0
fndb = os.path.join(dir1 + '/refir_config', 'volc_database.ini')
vent_h, dist_ISKEF, dist_ISEGS, dist_Cband3, dist_Cband4, dist_Cband5, dist_Cband6, \
dist_ISX1, dist_ISX2, dist_Xband3, dist_Xband4, dist_Xband5, dist_Xband6, dist_GFZ1, \
dist_GFZ2, dist_GFZ3, dist_Cam4, dist_Cam5, dist_Cam6 = \
np.loadtxt(fndb, skiprows=2, usecols=(3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21),
unpack=True, delimiter='\t')
try:
defsetup = defsetup[vulkan]
vent_h = vent_h[vulkan]
dist_ISKEF = dist_ISKEF[vulkan]
dist_ISEGS = dist_ISEGS[vulkan]
dist_Cband3, dist_Cband4, dist_Cband5, dist_Cband6, dist_ISX1, dist_ISX2, \
dist_Xband3, dist_Xband4, dist_Xband5, dist_Xband6, dist_GFZ1, \
dist_GFZ2, dist_GFZ3, dist_Cam4, dist_Cam5, dist_Cam6 = \
dist_Cband3[vulkan], dist_Cband4[vulkan], dist_Cband5[vulkan], dist_Cband6[vulkan], dist_ISX1[vulkan], \
dist_ISX2[vulkan], \
dist_Xband3[vulkan], dist_Xband4[vulkan], dist_Xband5[vulkan], dist_Xband6[vulkan], dist_GFZ1[vulkan], \
dist_GFZ2[vulkan], dist_GFZ3[vulkan], dist_Cam4[vulkan], dist_Cam5[vulkan], dist_Cam6[vulkan]
except IndexError:
# only one entry
huj = 0
# Note: if the automatic weather data option is chosen, some of these data will be overwritten at runtime (when using
# Degruyter&Bonadonna or Woodhouse model. The automatic weather data retrieval package will be called from these
# functions
P0 = 101325
P_0_in_default = P0 * math.exp(-vent_h / 7990)
P_0 = P_0_in_default
theta0_default = 1323
alpha_default = 0.1
beta_default = 0.5
theta_a0_default = 278
H1_default = 12000
H2_default = 20000
tempGrad_1_default = -0.0065
tempGrad_2_default = 0
tempGrad_3_default = 0.002
wfac_mod4_default = [1.0, 1.0, 1.0, 1.0, 1.0, 1.0]
rho_dre_default = 2600
Vmax_default = 10
ki_default = 1.6
def safe_exit():
global exit_param
exit_param = 1
save_default_file()
print("Aborting FIX")
print("FOXI will stop at next iteration")
sys.exit()
return(exit_param)
def automatic_weather():
sys.path.insert(0, './weather')
from weather import retrieve_data
#from retrieve_data import era_interim_retrieve
from retrieve_data import era5_retrieve
from retrieve_data import gfs_forecast_retrieve
from retrieve_data import gfs_past_forecast_retrieve
import os
from datetime import datetime, date, timedelta
from shutil import move
if run_type == 1:
print('Retrieving GFS forecasts for the ongoing eruption')
now = str(datetime.utcnow())
year = now[0:4]
month = now[5:7]
day = now[8:10]
nfcst = 6
gfs_forecast_retrieve(volc_lon[vulkan], volc_lat[vulkan], nfcst, 999)
folder = 'raw_forecast_weather_data_' + year + month + day
elif run_type == 2:
print('Retrieving past GFS forecasts for the eruption interval')
eruption_start_datetime = datetime(Y_eru_start, MO_eru_start, D_eru_start, H_eru_start)
eruption_stop_datetime = datetime(Y_eru_stop, MO_eru_stop, D_eru_stop, H_eru_stop)
response = gfs_past_forecast_retrieve(volc_lon[vulkan], volc_lat[vulkan], eruption_start_datetime,
eruption_stop_datetime)
if response == True:
folder = 'raw_reanalysis_weather_data_' + Y_eru_start_s + MO_eru_start_s + D_eru_start_s
else:
print('GFS data not available')
print('Retrieving ERA5 data')
era5_retrieve(volc_lon[vulkan], volc_lat[vulkan], eruption_start, eruption_stop)
folder = 'raw_reanalysis_weather_data_' + Y_eru_start_s + MO_eru_start_s + D_eru_start_s
if not os.path.isdir(folder):
os.makedirs(folder)
current = os.getcwd()
files = os.listdir(current)
for file in files:
if file.startswith('weather_') or file.startswith('profile_') or file.startswith('pressure_level'):
move(os.path.join(current,file),os.path.join(folder,file))
if weather == 1:
automatic_weather()
qf_OBS = 4
#timebase = -1
ID = ["n.a.", "n.a.", "n.a.", "n.a.", "n.a.", "n.a.", "n.a.", "n.a.", "n.a.", "n.a.", "n.a.", "n.a.", "n.a.", "n.a.",
"n.a.", "n.a.", "n.a.", "n.a."]
sens_file = ["", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", ""]
sens_IP = ["", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", ""]
sens_dir = ["", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", ""]
sens_url = ["", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", ""]
N_en, N_en1, N_en2 = 0, 0, 0
loc_ISKEF = 0
loc_ISEGS = 0
loc_Cband4 = 0
loc_Cband5 = 0
loc_Cband6 = 0
loc_ISX1 = 0
loc_ISX2 = 0
loc_Xband3 = 0
loc_Xband4 = 0
loc_Xband5 = 0
loc_Xband6 = 0
loc_GFZ1 = 0
loc_GFZ2 = 0
loc_GFZ3 = 0
loc_Cam4 = 0
loc_Cam5 = 0
loc_Cam6 = 0
def read_sensors():
"""reads IDs and GPS coordinates from *.ini files"""
global ID, sens_file, N_en, N_en1, N_en2, sens_url, sens_IP, sens_dir, Ase, sens_bwidth
sens_bwidth = [9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9]
try:
# C-band
fnCb = os.path.join(dir1 + '/refir_config', 'Cband.ini')
with open(fnCb, encoding="utf-8", errors="surrogateescape") as f:
lines = f.readlines()
Cse = []
for l in lines:
Cse.append(l.strip().split("\t"))
f.close()
N_en = len(Cse) - 1 # number of entries
if N_en < 1:
print("\nNo C-band radar sensors assigned!\n")
else:
for x in range(0, N_en):
ID[x] = str(Cse[x + 1][0])
sens_bwidth[x] = str(Cse[x + 1][5])
sens_file[x] = str(Cse[x + 1][6])
sens_url[x] = str(Cse[x + 1][7])
if sens_url[x] == "":
sens_IP[x] = str(Cse[x + 1][8])
sens_dir[x] = str(Cse[x + 1][9])
else:
sens_IP[x] = ""
sens_dir[x] = ""
except EnvironmentError:
print("Warning - \".ini\" C-band radar sensor file not found!\n")
try:
# X-band
fnXb = os.path.join(dir1 + '/refir_config', 'Xband.ini')
with open(fnXb,encoding="utf-8", errors="surrogateescape") as f:
lines = f.readlines()
Dse = []
for l in lines:
Dse.append(l.strip().split("\t"))
f.close()
N_en2 = len(Dse) - 1 # number of entries
if N_en2 < 1:
print("\nNo X-band radar sensors assigned!\n")
else:
for x in range(0, N_en2):
ID[x + 6] = str(Dse[x + 1][0])
sens_bwidth[x + 6] = str(Dse[x + 1][5])
sens_file[x + 6] = str(Dse[x + 1][6])
sens_url[x + 6] = str(Dse[x + 1][7])
if sens_url[x + 6] == "":
sens_IP[x + 6] = str(Dse[x + 1][8])
sens_dir[x + 6] = str(Dse[x + 1][9])
else:
sens_IP[x + 6] = ""
sens_dir[x + 6] = ""
except EnvironmentError:
print("Warning - \".ini\" X-band radar sensor file not found!\n")
try:
# Cams
fnCam = os.path.join(dir1 + '/refir_config', 'Cam.ini')
with open(fnCam,encoding="utf-8", errors="surrogateescape") as f:
lines = f.readlines()
Ase = []
for l in lines:
Ase.append(l.strip().split("\t"))
f.close()
N_en1 = len(Ase) - 1 # number of entries
if N_en1 < 1:
print("\nNo webcams assigned!\n")
else:
for x in range(0, N_en1):
ID[x + 12] = str(Ase[x + 1][0])
sens_file[x + 12] = str(Ase[x + 1][6])
sens_url[x + 12] = str(Ase[x + 1][7])
if sens_url[x + 12] == "":
sens_IP[x + 12] = str(Ase[x + 1][8])
sens_dir[x + 12] = str(Ase[x + 1][9])
else:
sens_IP[x + 12] = ""
sens_dir[x + 12] = ""
except EnvironmentError:
print("Warning - \".ini\" Webcam sensor file not found!\n")
read_sensors() # ID: array with sensor IDs [0-5]:Cband, [6-11]:Xband, [12-17]Cam
def get_last_time():
global time_OBS
try:
config2file = open("fix_config.txt", "r",encoding="utf-8", errors="surrogateescape")
config2lines = config2file.readlines()
config2file.close()
time_OBS_str0 = config2lines[2]
time_OBS_str = time_OBS_str0[0:19]
time_OBS = datetime.datetime.strptime(time_OBS_str, "%Y-%m-%d %H:%M:%S")
checkfile = 11
except EnvironmentError:
checkfile = 10
time_OBS = datetime.datetime(1979, 4, 30)
Hmin_obs_in = 0
Hmax_obs_in = 0
def defaultvalues(venth):
"""attributes default values to input parameters"""
global P_0_in_default
global theta_0
global alpha
global beta
global theta_a0
global H1
global H2
global tempGrad_1
global tempGrad_2
global tempGrad_3
global wfac_mod4_default
global wtf_wil
global wtf_spa
global wtf_mas
global wtf_mtg
global wtf_deg
global wtf_wood0d
global rho_dre
global Vmax
global ki
global Hmin_obs
global Hmax_obs
global qf_OBS
global time_OBS
global analysis
global timebase
global ISKEF_on
global ISEGS_on
global ISX1_on
global ISX2_on
global ISKEFm_on
global ISEGSm_on
global ISX1m_on
global ISX2m_on
global GFZ1_on
global GFZ2_on
global GFZ3_on
global OBS_on
global oo_exp
global oo_con
global wtf_exp
global wtf_con
global oo_manual
global wtf_manual
global min_manMER
global max_manMER
global oo_wood
global oo_RMER
global wtf_wood
global wtf_RMER
global oo_isound
global wtf_isound
global oo_esens
global wtf_esens
global oo_pulsan
global wtf_pulsan
global oo_scatter
global wtf_scatter
global cal_ISKEF_a
global cal_ISKEF_b
global cal_ISEGS_a
global cal_ISEGS_b
global cal_ISX1_a
global cal_ISX1_b
global cal_ISX2_a
global cal_ISX2_b
global Hmin_obs_in
global Hmax_obs_in
global qf_obs
global OBS1
global P_0
global PM_Nplot, PM_PHplot, PM_MERplot, PM_TME, PM_FMERplot, PM_FTME, PM_TAV, StatusR_oo, NAME_out_on, PI_THRESH
global Min_DiaOBS, Max_DiaOBS, pl_width_min, pl_width_max
global Cband3_on, Cband4_on, Cband5_on, Cband6_on, Xband3_on, Xband4_on, \
Xband5_on, Xband6_on, Cam4_on, Cam5_on, Cam6_on
global Cband3m_on, Cband4m_on, Cband5m_on, Cband6m_on, Xband3m_on, Xband4m_on, \
Xband5m_on, Xband6m_on, Cam4m_on, Cam5m_on, Cam6m_on
global cal_Cband3a, cal_Cband3b, cal_Cband4a, cal_Cband4b, cal_Cband5a, cal_Cband5b, \
cal_Cband6a, cal_Cband6b, cal_Xband3a, cal_Xband3b, cal_Xband4a, cal_Xband4b, \
cal_Xband5a, cal_Xband5b, cal_Xband6a, cal_Xband6b
global ESPs_data_on, ESPs_duration_read, oo_satellite, qf_satellite
P0 = 101325 # default ambient pressure at sea level
P_0_in_default = P0 * math.exp(-venth / 7990) # def. ambient pressure at vent
P_0 = P_0_in_default
theta_0 = 1323 # default magmatic temperature (K)
alpha = 0.1 # def. radial entrainment coeff
beta = 0.5 # def. wind entrainment coeff
theta_a0 = 278 # default ambient temperature (K)
H1 = 12000 # def. height tropopause a.s.l. (m)
H2 = 20000 # def. height stratosphere a.s.l. (m)
tempGrad_1 = -0.0065 # def. temp. grad. troposphere (K/m)
tempGrad_2 = 0 # def. temp. grad. between tropo & stratosphere (K/m)
tempGrad_3 = 0.002 # def. temp. grad. stratosphere (K/m)
wfac_mod4_default = [1.0, 1.0, 1.0, 1.0, 1.0, 1.0] # def. model weight factors
wtf_wil = wfac_mod4_default[0]
wtf_spa = wfac_mod4_default[1]
wtf_mas = wfac_mod4_default[2]
wtf_mtg = wfac_mod4_default[3]
wtf_deg = wfac_mod4_default[4]
wtf_wood0d = wfac_mod4_default[5]
ki = 1.6 # default scale factor
rho_dre = 2600 # default rock density
Vmax = 10 # default max windspeed at tropopause (m/s)
Hmin_obs = 0
Hmax_obs = 0
Min_DiaOBS = 0
Max_DiaOBS = 0
time_OBS = datetime.datetime(1979, 4, 30)
analysis = 0
timebase = 30 #-1
ISKEF_on = 0
ISEGS_on = 0
ISX1_on = 0
ISX2_on = 0
ISKEFm_on = 0
ISEGSm_on = 0
ISX1m_on = 0
ISX2m_on = 0
GFZ1_on = 0
GFZ2_on = 0
GFZ3_on = 0
OBS_on = 1
oo_exp = 0
oo_con = 1
wtf_exp = 0
wtf_con = 1
oo_manual = 0
wtf_manual = 0
min_manMER = 0
max_manMER = 0
oo_wood = 0
oo_RMER = 1
wtf_wood = 0
wtf_RMER = 1
oo_isound = 0
wtf_isound = 0
oo_esens = 0
wtf_esens = 0
oo_pulsan = 0
wtf_pulsan = 0
oo_scatter = 0
wtf_scatter = 0
oo_satellite = 0
qf_satellite = 1
cal_ISKEF_a = 0
cal_ISKEF_b = 1
cal_ISEGS_a = 0
cal_ISEGS_b = 1
cal_ISX1_a = 0
cal_ISX1_b = 1
cal_ISX2_a = 0
cal_ISX2_b = 1
Hmin_obs_in = 0
Hmax_obs_in = 0
qf_obs = 0
OBS1 = 1
PM_Nplot = 1
PM_PHplot = 1
PM_MERplot = 1
PM_TME = 1
PM_FMERplot = 1
PM_FTME = 1
PM_TAV = 0
StatusR_oo = 1
NAME_out_on = 0
PI_THRESH = 5.0
ESPs_data_on = 0
ESPs_duration_read = 0
Cband3_on, Cband4_on, Cband5_on, Cband6_on, Xband3_on, Xband4_on, \
Xband5_on, Xband6_on, Cam4_on, Cam5_on, Cam6_on, Cband3m_on, Cband4m_on, Cband5m_on, \
Cband6m_on, Xband3m_on, Xband4m_on, Xband5m_on, Xband6m_on, Cam4m_on, Cam5m_on, Cam6m_on \
= -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1
cal_Cband3a, cal_Cband3b, cal_Cband4a, cal_Cband4b, cal_Cband5a, cal_Cband5b, \
cal_Cband6a, cal_Cband6b, cal_Xband3a, cal_Xband3b, cal_Xband4a, cal_Xband4b, \
cal_Xband5a, cal_Xband5b, cal_Xband6a, cal_Xband6b = 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1
V = vulkan + 1
IDC = []
LatC = []
LonC = []
try:
fnCb = os.path.join(dir1 + '/refir_config', 'Cband.ini')
with open(fnCb,encoding="utf-8", errors="surrogateescape") as f:
lines = f.readlines()
Cse = []
for l in lines:
Cse.append(l.strip().split("\t"))
f.close()
N_enc = len(Cse) - 1 # number of entries
if N_enc < 1:
print("\nNo C-band radar sensors assigned!\n")
else:
for y in range(0, N_enc):
IDC.append(0)
LatC.append(0)
LonC.append(0)
for x in range(0, N_enc):
IDC[x] = str(Cse[x + 1][0])
LatC[x] = float(Cse[x + 1][1])
LonC[x] = float(Cse[x + 1][2])
# file exists
except EnvironmentError:
# file does not exist yet
print("\nCband.ini file not found!\n")
IDX = []
LatX = []
LonX = []
try:
fnXb = os.path.join(dir1 + '/refir_config', 'Xband.ini')
with open(fnXb,encoding="utf-8", errors="surrogateescape") as f:
lines = f.readlines()
Cse = []
for l in lines:
Cse.append(l.strip().split("\t"))
f.close()
N_enx = len(Cse) - 1 # number of entries
if N_enx < 1:
print("\nNo X-band radar sensors assigned!\n")
else:
for y in range(0, N_enx):
IDX.append(0)
LatX.append(0)
LonX.append(0)
for x in range(0, N_enx):
IDX[x] = str(Cse[x + 1][0])
LatX[x] = float(Cse[x + 1][1])
LonX[x] = float(Cse[x + 1][2])
# file exists
except EnvironmentError:
# file does not exist yet
print("\nXband.ini file not found!\n")
IDCam = []
LatCam = []
LonCam = []
try:
fnCam = os.path.join(dir1 + '/refir_config', 'Cam.ini')
with open(fnCam,encoding="utf-8", errors="surrogateescape") as f:
lines = f.readlines()
Cse = []
for l in lines:
Cse.append(l.strip().split("\t"))
f.close()
N_enca = len(Cse) - 1 # number of entries
if N_enca < 1:
print("\nNo webcams assigned!\n")
else:
for y in range(0, N_enca):
IDCam.append(0)
LatCam.append(0)
LonCam.append(0)
for x in range(0, N_enca):
IDCam[x] = str(Cse[x + 1][0])
LatCam[x] = float(Cse[x + 1][1])
LonCam[x] = float(Cse[x + 1][2])
# file exists
except EnvironmentError:
# file does not exist yet
print("\nCam.ini file not found!\n")
minlat = min(min(LatC or volc_lat), min(LatX or volc_lat), min(LatCam or volc_lat), min(volc_lat)) - 0.5
maxlat = max(max(LatC or volc_lat), max(LatX or volc_lat), max(LatCam or volc_lat), max(volc_lat)) + 0.5
minlon = min(min(LonC or volc_lon), min(LonX or volc_lon), min(LonCam or volc_lon), min(volc_lon)) - 0.5
maxlon = max(max(LonC or volc_lon), max(LonX or volc_lon), max(LonCam or volc_lon), max(volc_lon)) + 0.5
def checkbox_oo(oo_var):
"""returns True or False when called by an on/off switch"""
if oo_var == 1:
return True
else:
return False
def get_last_data():
"""reads default values from fix_config file if existing"""
global P_0
global theta_0
global alpha
global beta
global theta_a0
global H1
global H2
global tempGrad_1
global tempGrad_2
global tempGrad_3
global wfac_mod4_default
global rho_dre
global Vmax, Vmax_default
global ki
global wtf_wil
global wtf_spa
global wtf_mas
global wtf_mtg
global wtf_deg
global qf_OBS
global time_OBS
global analysis
global timebase
global ISKEF_on
global ISEGS_on
global ISX1_on
global ISX2_on
global ISKEFm_on
global ISEGSm_on
global ISX1m_on
global ISX2m_on
global GFZ1_on
global GFZ2_on
global GFZ3_on
global OBS_on
global oo_exp
global oo_con
global wtf_exp
global wtf_con
global oo_manual
global wtf_manual
global min_manMER
global max_manMER
global oo_wood
global oo_RMER
global wtf_wood
global wtf_RMER
global oo_isound
global wtf_isound
global oo_esens
global wtf_esens
global oo_pulsan
global wtf_pulsan
global oo_scatter
global wtf_scatter
global cal_ISKEF_a
global cal_ISKEF_b
global cal_ISEGS_a
global cal_ISEGS_b
global cal_ISX1_a
global cal_ISX1_b
global cal_ISX2_a
global cal_ISX2_b
global qf_obs
global OBS1
global PM_Nplot, PM_PHplot, PM_MERplot, PM_TME, PM_FMERplot, PM_FTME, PM_TAV, StatusR_oo, NAME_out_on
global pl_minw_default, pl_maxw_default
global qfak_Cband3
global qfak_Cband4, qfak_Cband5, qfak_Cband6, qfak_Xband3, qfak_Xband4, \
qfak_Xband5, qfak_Xband6, qfak_Cam4, qfak_Cam5, qfak_Cam6, unc_Cband3, \
unc_Cband4, unc_Cband5, unc_Cband6, unc_Xband3, unc_Xband4, unc_Xband5, unc_Xband6
global Cband3_on, Cband4_on, Cband5_on, Cband6_on, Xband3_on, Xband4_on, \
Xband5_on, Xband6_on, Cam4_on, Cam5_on, Cam6_on
global Cband3m_on, Cband4m_on, Cband5m_on, Cband6m_on, Xband3m_on, Xband4m_on, \
Xband5m_on, Xband6m_on, Cam4m_on, Cam5m_on, Cam6m_on
global cal_Cband3a, cal_Cband3b, cal_Cband4a, cal_Cband4b, cal_Cband5a, cal_Cband5b, \
cal_Cband6a, cal_Cband6b, cal_Xband3a, cal_Xband3b, cal_Xband4a, cal_Xband4b, \
cal_Xband5a, cal_Xband5b, cal_Xband6a, cal_Xband6b
global wtf_wood0d
global time_start, time_stop
global loc_ISKEF, loc_ISEGS, loc_Cband3, loc_Cband5, loc_Cband6, loc_ISX1, loc_ISX2, loc_Xband3, loc_Xband4, \
loc_Xband5, loc_Xband6, loc_GFZ1, loc_GFZ2, loc_GFZ3, loc_Cam4, loc_Cam5, loc_Cam6
global defsetup, run_type, weather, exit_param, PI_THRESH
global oo_satellite, qf_satellite
try:
configfile = open("fix_config.txt", "r",encoding="utf-8", errors="surrogateescape")
configlines3 = configfile.readlines()
configfile.close()
checkfile = 1
P_0 = float(configlines3[8])
theta_0 = float(configlines3[9])
alpha = float(configlines3[11])
beta = float(configlines3[12])
theta_a0 = float(configlines3[7])
H1 = float(configlines3[18])
H2 = float(configlines3[19])
tempGrad_1 = float(configlines3[20])
tempGrad_2 = float(configlines3[21])
tempGrad_3 = float(configlines3[22])
wfac_mod4_default[0] = float(configlines3[13])
wfac_mod4_default[1] = float(configlines3[14])
wfac_mod4_default[2] = float(configlines3[15])
wfac_mod4_default[3] = float(configlines3[16])
wfac_mod4_default[4] = float(configlines3[17])
wfac_mod4_default[5] = float(configlines3[165])
wtf_wil = wfac_mod4_default[0]
wtf_spa = wfac_mod4_default[1]
wtf_mas = wfac_mod4_default[2]
wtf_mtg = wfac_mod4_default[3]
wtf_deg = wfac_mod4_default[4]
wtf_wood0d = wfac_mod4_default[5]
rho_dre = float(configlines3[10])
Vmax = float(configlines3[23])
Vmax_default = Vmax
ki = float(configlines3[24])
qf_OBS = int(configlines3[6])
ISKEF_on = int(configlines3[37])
ISEGS_on = int(configlines3[38])
ISX1_on = int(configlines3[39])
ISX2_on = int(configlines3[40])
GFZ1_on = int(configlines3[41])
GFZ2_on = int(configlines3[42])
GFZ3_on = int(configlines3[43])
analysis = int(configlines3[44])
timebase = int(configlines3[45])
cal_ISKEF_a = float(configlines3[66])
cal_ISKEF_b = float(configlines3[67])
cal_ISEGS_a = float(configlines3[68])
cal_ISEGS_b = float(configlines3[69])
cal_ISX1_a = float(configlines3[70])
cal_ISX1_b = float(configlines3[71])
cal_ISX2_a = float(configlines3[72])
cal_ISX2_b = float(configlines3[73])
ISKEFm_on = int(configlines3[74])
ISEGSm_on = int(configlines3[75])
ISX1m_on = int(configlines3[76])
ISX2m_on = int(configlines3[77])
OBS_on = int(configlines3[5])
oo_exp = int(configlines3[46])
oo_con = int(configlines3[47])
wtf_exp = float(configlines3[48])
wtf_con = float(configlines3[49])
oo_manual = int(configlines3[50])
wtf_manual = float(configlines3[51])
min_manMER = float(configlines3[52])
max_manMER = float(configlines3[53])
oo_wood = int(configlines3[54])
oo_RMER = int(configlines3[55])
wtf_wood = float(configlines3[56])
wtf_RMER = float(configlines3[57])
oo_isound = int(configlines3[58])
wtf_isound = float(configlines3[59])
oo_esens = int(configlines3[60])
wtf_esens = float(configlines3[61])
oo_pulsan = int(configlines3[62])
wtf_pulsan = float(configlines3[63])
oo_scatter = int(configlines3[64])
wtf_scatter = float(configlines3[65])
PM_Nplot = int(configlines3[78])
PM_PHplot = int(configlines3[79])
PM_MERplot = int(configlines3[80])
PM_TME = int(configlines3[81])
PM_FMERplot = int(configlines3[82])
PM_FTME = int(configlines3[83])
StatusR_oo = int(configlines3[84])
pl_minw_default = float(configlines3[85])