diff options
author | Jonas Gunz <himself@jonasgunz.de> | 2023-09-29 16:48:26 +0200 |
---|---|---|
committer | Jonas Gunz <himself@jonasgunz.de> | 2023-09-29 16:48:26 +0200 |
commit | 5be351dbe7feb4c8cfd28da883a6904ab7fc57b3 (patch) | |
tree | 761b45b9914679952a66bafc435a48537ce795d7 | |
parent | 09dbbe809ab6a3728e971a29e7704ffa0ecb93a7 (diff) | |
download | meteo_toolbox-5be351dbe7feb4c8cfd28da883a6904ab7fc57b3.tar.gz |
global product index
-rw-r--r-- | config.yaml | 5 | ||||
-rwxr-xr-x | plotter/horizontal.py | 8 | ||||
-rwxr-xr-x | plotter/vertical_from_grib.py | 8 | ||||
-rwxr-xr-x | run.py | 8 |
4 files changed, 24 insertions, 5 deletions
diff --git a/config.yaml b/config.yaml index 5eed3e5..8a882ca 100644 --- a/config.yaml +++ b/config.yaml @@ -1,8 +1,9 @@ --- +index: web/data/index.json plotter: - module: 'plotter.vertical_from_grib' source: dwd_icon-eu/combined.grib2 - output: out + output: web/data plots: - lat: 47.96 lon: 11.99 @@ -10,7 +11,7 @@ plotter: analysis: lcl - module: 'plotter.horizontal' source: dwd_icon-eu/combined.grib2 - output: out + output: web/data plots: - name: t_fi_850 area: null diff --git a/plotter/horizontal.py b/plotter/horizontal.py index a81b372..e83b683 100755 --- a/plotter/horizontal.py +++ b/plotter/horizontal.py @@ -37,8 +37,12 @@ def run(source, plots, output='.'): misc.create_output_dir(output) data = xr.load_dataset(source, engine='cfgrib') + index = [] + for plot in plots: - _plot(data, output, **plot) + index.append(_plot(data, output, **plot)) + + return index def _plot(data, output, name, layers, area = None): index = [] @@ -88,6 +92,8 @@ def _plot(data, output, name, layers, area = None): with open(os.path.join(output, f'{name}.index.json'), 'w') as f: f.write(json.dumps(index, indent=4)) + return { 'name': name, 'indexfile': f'{name}.index.json' } + def _layer(data, layertype, **kwargs): layertypes={ 'raster': { diff --git a/plotter/vertical_from_grib.py b/plotter/vertical_from_grib.py index 8aa851a..929782e 100755 --- a/plotter/vertical_from_grib.py +++ b/plotter/vertical_from_grib.py @@ -29,8 +29,12 @@ def run(source, plots, output='.'): misc.create_output_dir(output) data = xr.load_dataset(source, engine='cfgrib') + index = [] + for plot in plots: - _plot(data, output, **plot) + index.append(_plot(data, output, **plot)) + + return index def _plot(data, output, lat, lon, name, analysis=None): for_temp = data.sel(latitude=lat, longitude = lon, method='nearest') @@ -84,5 +88,7 @@ def _plot(data, output, lat, lon, name, analysis=None): with open(os.path.join(output, f'skewt_{name}.index.json'), 'w') as f: f.write(json.dumps(index, indent=4)) + return {'name': name, 'indexfile': f'skewt_{name}.index.json'} + if __name__ == '__main__': run(**config) @@ -2,6 +2,7 @@ import sys import yaml +import json import matplotlib.pyplot as plt from metpy.units import units @@ -19,11 +20,16 @@ conf = None with open(FILE, 'r') as f: conf = yaml.safe_load(f) +index = [] + for plotter in conf['plotter']: modname = plotter['module'] del plotter['module'] mod = __import__(modname, fromlist=[None]) - mod.run(**plotter) + index.extend(mod.run(**plotter)) plt.close('all') + +with open(conf['index'], 'w') as f: + f.write(json.dumps(index, indent=4)) |