-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathgenmaps.py
More file actions
executable file
·145 lines (128 loc) · 4.45 KB
/
genmaps.py
File metadata and controls
executable file
·145 lines (128 loc) · 4.45 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
#!/usr/bin/env python
# -*- coding: utf-8 -*-
"""genmaps
.. module:: genmaps
:platform: Unix
:synopis:
.. moduleauther: CEMAC (UoL)
.. description: This module was developed by CEMAC as part of the UNRESP
Project. This Script plots CALPUFF concrec data on a map.
:copyright: © 2019 University of Leeds.
:license: BSD-2 Clause.
Example:
To use::
./genemaps.py <date>
<date> - Date string, format YYYYMMDD, of the current CALPUFF run.
Used to locate directory containing the SO2 output files
(with assumed naming convention 'concrec0100**.dat',
where '**' goes from '01' through to '48')
.. CEMAC_UNRESPForcastingSystem:
https://github.com/cemac/UNRESPForcastingSystem
"""
from __future__ import print_function
import argparse
from dateutil.parser import parse
import maptoolkit as mtk
import sys
# Set everything to off
TopoMaps = False
SatelliteMaps = False
GoogleMaps = False
SO2 = False
SO4 = False
# READ IN COMMAND LINE ARGUMENTS
dstring = ("Used to generate a series (48hrs) of static and interactive" +
"(google) maps \n showing SO2 concentrations around the Masaya " +
"volcano, as predicted by the CALPUFF dispersion model")
hstring = ("Date string, format YYYYMMDD, of the current CALPUFF run. Used " +
"to + locate \n directory containing the SO2 output files (with " +
"assumed naming convention 'concrec0100**.dat', \n where '**' " +
" goes from '01' through to '48'")
hstring = ("number of concrec files e.g. 24 or 48")
parser = argparse.ArgumentParser(description=dstring)
parser.add_argument("date", help=hstring, type=str)
parser.add_argument("--conc", help=hstring, type=str)
# Switches
parser.add_argument('--all', help='Plots all types of maps',
action='store_true')
parser.add_argument('--SO2', help=r'Plot SO$_2$',
action='store_true')
parser.add_argument('--SO4', help=r'Plot SO$_4$',
action='store_true')
parser.add_argument('--topo', help='Turn on basic maps',
action='store_true')
parser.add_argument('--satellite', help='Turn on satellite maps',
action='store_true')
parser.add_argument('--google', help='Turn on googlemaps',
action='store_true')
args = parser.parse_args()
if args.SO2:
SO2 = True
if args.SO4:
SO4 = True
if args.satellite:
SatelliteMaps = True
if args.topo:
TopoMaps = True
if args.google:
GoogleMaps = True
if args.all:
SO2 = True
SO4 = True
GoogleMaps = True
TopoMaps = True
SatelliteMaps = True
# echo what is being done
print('Generating Maps with following settings:')
print(r"SO$_2$ = ", SO2)
print(r"SO$_4$ = ", SO4)
print("Basic Maps =", TopoMaps)
print("Satallite Maps =", SatelliteMaps)
print("Gooogle Maps =", GoogleMaps)
# %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
date = args.date
if args.conc:
nconc = args.conc
else:
nconc = 48
try:
mpt = mtk.MasayaMaps(date, n_conc_files=int(nconc))
except AssertionError:
print('CALPUFF output directory does not exist for' + date)
print('Stopping, please check output exists for ' + date)
if TopoMaps:
if SO2 and SO4:
mpt.plot_staticmaps('topo', SOX='SO2')
mpt.plot_staticmaps('topo', SOX='SO4')
elif SO4:
mpt.plot_staticmaps('topo', SOX='SO4')
elif SO2:
mpt.plot_staticmaps('topo', SOX='SO2')
else:
print(r'Conc must be set to SO$_2$ or SO$_4$ or both (default)')
print(r'most likely the --custom flag has been used with out:')
print(' --SO2', 'or --SO4',)
if SatelliteMaps:
if SO2 and SO4:
mpt.plot_staticmaps('satellite', SOX='SO2')
mpt.plot_staticmaps('satellite', SOX='SO4')
elif SO2:
mpt.plot_staticmaps('satellite', SOX='SO2')
elif SO4:
mpt.plot_staticmaps('satellite', SOX='SO4')
else:
print(r'Conc must be set to SO$_2$ or SO$_4$ or both (default)')
print(r'most likely the --custom flag has been used with out:')
print(' --SO24', ' --SO2', 'or --SO4',)
if GoogleMaps:
if SO2 and SO4:
mpt.plot_google(SOX='SO2')
mpt.plot_google(SOX='SO4')
elif SO2:
mpt.plot_google(SOX='SO2')
elif SO4:
mpt.plot_google(SOX='SO4')
else:
print(r'Conc must be set to SO$_2$ and/or SO$_4$ ')
print(r'most likely the --custom flag has been used with out:')
print('--SO2', 'or --SO4',)