diff --git a/j2o/__main__.py b/j2o/__main__.py index efca7d7..8444a0b 100644 --- a/j2o/__main__.py +++ b/j2o/__main__.py @@ -139,7 +139,7 @@ def PRINT(*args): # o = {"text": None, "data_file": None, "data_descr": None} if o["text"] is not None: if len(o["text"]) <= ORG_BABEL_MIN_LINES_FOR_BLOCK_OUTPUT: - PRINT("#+RESULTS:" + (f"{i}_{k}" if k > 0 else "")) # add index for several RESULT + PRINT("#+RESULTS:" + (f"{i}_{k}" if k > 0 else "")) # add index if there is several RESULT for one block PRINT("".join([": " + t for t in o["text"]])) # .startswith() PRINT() else: diff --git a/tests/draw-samples.org b/tests/draw-samples.org index 3d1ad4b..7e50552 100644 --- a/tests/draw-samples.org +++ b/tests/draw-samples.org @@ -3,6 +3,8 @@ import h5py import matplotlib.pyplot as plt import numpy as np #+end_src +: #------------------------- + * Чтение файла #+begin_src python :results output :exports both :session s1 with h5py.File('train/2021-01-train.hdf5', mode='r') as dataset: @@ -12,6 +14,8 @@ with h5py.File('train/2021-01-train.hdf5', mode='r') as dataset: : ['1609459200', '1609459800', '1609460400', '1609461000', '1609461600', '1609462200', '1609462800', '1609463400', '1609464000', '1609464600'] +: #------------------------- + #+begin_src python :results output :exports both :session s1 with h5py.File('train/2021-01-train.hdf5', mode='r') as dataset: print(list(dataset['1609459200'].keys())) @@ -20,6 +24,8 @@ with h5py.File('train/2021-01-train.hdf5', mode='r') as dataset: : ['events', 'intensity', 'radial_velocity', 'reflectivity'] +: #------------------------- + #+begin_src python :results output :exports both :session s1 with h5py.File('train/2021-01-train.hdf5', mode='r') as dataset: print(f"events shape: {dataset['1609459200']['events'].shape}") @@ -34,6 +40,8 @@ with h5py.File('train/2021-01-train.hdf5', mode='r') as dataset: : reflectivity shape: (10, 252, 252) +: #------------------------- + * Визуализация #+begin_src python :results output :exports both :session s1 events = [] @@ -63,6 +71,8 @@ radial_velocity[radial_velocity == -1e6] = -1 reflectivity[reflectivity == -2e6] = -2 reflectivity[reflectivity == -1e6] = -1 #+end_src +: #------------------------- + ** Погодные события #+begin_src python :results file graphics :file /tmp/a-a-imgs/8_0.png :exports both :session s1 _, axs = plt.subplots(1, len(events), figsize=(20, 2)) @@ -73,6 +83,8 @@ for index in range(len(events)): #+RESULTS: [[file:/tmp/a-a-imgs/8_0.png]]
+: #------------------------- + ** Интенсивность осадков #+begin_src python :results file graphics :file /tmp/a-a-imgs/10_0.png :exports both :session s1 _, axs = plt.subplots(1, len(intensity), figsize=(20, 2)) @@ -83,6 +95,8 @@ for index in range(len(intensity)): #+RESULTS: [[file:/tmp/a-a-imgs/10_0.png]]
+: #------------------------- + ** Радиальная скорость по высотам #+begin_src python :results file graphics :file /tmp/a-a-imgs/12_0.png :exports both :session s1 _, axs = plt.subplots(10, len(radial_velocity), figsize=(20, 20)) @@ -96,6 +110,8 @@ for index in range(len(radial_velocity)): #+RESULTS: [[file:/tmp/a-a-imgs/12_0.png]]
+: #------------------------- + ** Отражаемость по высотам #+begin_src python :results file graphics :file /tmp/a-a-imgs/14_0.png :exports both :session s1 _, axs = plt.subplots(10, len(reflectivity), figsize=(20, 20)) @@ -109,3 +125,5 @@ for index in range(len(reflectivity)): #+RESULTS: [[file:/tmp/a-a-imgs/14_0.png]]
+: #------------------------- + diff --git a/tests/test_main.py b/tests/test_main.py index bbce39d..93c408e 100644 --- a/tests/test_main.py +++ b/tests/test_main.py @@ -1,3 +1,8 @@ +# steps to fix errors: +# $ python3 -m pytest +# diff /tmp/a.org tests/draw-samples.org +# mv /tmp/a.org tests/draw-samples.org + from filecmp import cmp import os