aboutsummaryrefslogtreecommitdiff
path: root/run.py
diff options
context:
space:
mode:
authorGravatar Jonas Gunz <himself@jonasgunz.de> 2024-10-14 02:23:10 +0200
committerGravatar Jonas Gunz <himself@jonasgunz.de> 2024-10-14 02:23:10 +0200
commit663edde231af9ad4a782c5438027ef7f839806ea (patch)
tree3e0d6745e5b1c633a76e404a56b734caddcf6b37 /run.py
parent9e5f1d17a4b0165bd4a3218ca24a159012ea49bd (diff)
downloadmeteo_toolbox-663edde231af9ad4a782c5438027ef7f839806ea.tar.gz
package with python
Diffstat (limited to 'run.py')
-rwxr-xr-xrun.py106
1 files changed, 0 insertions, 106 deletions
diff --git a/run.py b/run.py
deleted file mode 100755
index 28362d9..0000000
--- a/run.py
+++ /dev/null
@@ -1,106 +0,0 @@
-#!/usr/bin/env python3
-
-import sys
-import yaml
-import json
-import matplotlib.pyplot as plt
-import matplotlib as mpl
-from matplotlib.colors import LinearSegmentedColormap
-
-from metpy.units import units
-
-def create_aggregators(cfg):
- ret = {}
- for aggregator in cfg:
- aggconf = cfg[aggregator]
- classname = aggconf['module']
- del aggconf['module']
-
- module = __import__(classname, fromlist=[None])
-
- ret[aggregator] = module.load_data(name=aggregator, **aggconf)
-
- return ret
-
-def create_modifiers(aggregators, cfg):
- # naming is scuffed
- ret = {}
- for modifier in cfg:
- mod = cfg[modifier]
- modname = mod['module']
- del mod['module']
-
- if 'aggregator' in mod:
- if type(mod['aggregator']) == list:
- mod['data'] = []
- for ag in mod['aggregator']:
- mod['data'].append(aggregators[ag])
-
- del mod['aggregator']
- else:
- mod['data'] = aggregators[mod['aggregator']]
- del mod['aggregator']
-
- pymod = __import__(modname, fromlist=[None])
- ret[modifier] = pymod.run(**mod)
-
- return ret
-
-mpl.use('agg')
-
-# Define custom gpm and gpdm units. The default gpm in metpy is aliased to meter.
-# We need the correct definition
-units.define('_gpm = 9.80665 * J/kg')
-units.define('_gpdm = 10 * _gpm')
-
-# Define custom colormap
-clcov_cmap = {
- 'red': (
- (0.0, 0.0, 0.0),
- (0.1, 0.9, 0.9),
- (1.0, 0.3, 0.3),
- ),
- 'green': (
- (0.0, 0.5, 0.5),
- (0.1, 0.9, 0.9),
- (1.0, 0.3, 0.3),
- ),
- 'blue': (
- (0.0, 0.9, 0.9),
- (0.1, 0.9, 0.9),
- (1.0, 0.3, 0.3),
- ),
-}
-
-mpl.colormaps.register(LinearSegmentedColormap('clcov', clcov_cmap))
-
-FILE = 'config.yaml'
-if len(sys.argv) > 1:
- FILE = sys.argv[1]
-
-conf = None
-with open(FILE, 'r') as f:
- conf = yaml.safe_load(f)
-
-aggregators = create_aggregators(conf['aggregator'])
-
-if 'modifier' in conf:
- aggregators.update(create_modifiers(aggregators, conf['modifier']))
-
-index = []
-
-for plotter in conf['plotter']:
- modname = plotter['module']
- del plotter['module']
-
- if 'aggregator' in plotter:
- plotter['data'] = aggregators[plotter['aggregator']]
- del plotter['aggregator']
-
- mod = __import__(modname, fromlist=[None])
- index.extend(mod.run(**plotter))
-
- plt.close('all')
-
-with open(conf['index'], 'w') as f:
- f.write(json.dumps(index, indent=4))