aboutsummaryrefslogtreecommitdiff
path: root/horizontal.py
diff options
context:
space:
mode:
authorGravatar Jonas Gunz <himself@jonasgunz.de> 2023-09-28 15:24:33 +0200
committerGravatar Jonas Gunz <himself@jonasgunz.de> 2023-09-28 15:24:33 +0200
commit9ed036199f39b5a4f694e44a192dec3129c6d83e (patch)
treedd540f62d0c9f21063e980fc77efecb3a886e983 /horizontal.py
parent02f2fe0096fc2f66bf8d4a5849c1eb6b954d7c0b (diff)
downloadmeteo_toolbox-9ed036199f39b5a4f694e44a192dec3129c6d83e.tar.gz
create index files
Diffstat (limited to 'horizontal.py')
-rwxr-xr-xhorizontal.py14
1 files changed, 14 insertions, 0 deletions
diff --git a/horizontal.py b/horizontal.py
index 02e45b1..a81b372 100755
--- a/horizontal.py
+++ b/horizontal.py
@@ -1,5 +1,6 @@
#!/usr/bin/env python3
import os
+import json
import xarray as xr
@@ -40,6 +41,7 @@ def run(source, plots, output='.'):
_plot(data, output, **plot)
def _plot(data, output, name, layers, area = None):
+ index = []
for step in data.coords['step']:
this_step = data.sel(step=step)
@@ -74,6 +76,18 @@ def _plot(data, output, name, layers, area = None):
outname = f'{name}_{init_for_filename}+{hours_since_init_str}.png'
pc.save(os.path.join(output, outname))
+ index.append(
+ {
+ 'file': outname,
+ 'init': init_str,
+ 'valid': valid_str,
+ 'valid_offset': hours_since_init_str
+ }
+ )
+
+ with open(os.path.join(output, f'{name}.index.json'), 'w') as f:
+ f.write(json.dumps(index, indent=4))
+
def _layer(data, layertype, **kwargs):
layertypes={
'raster': {