#+begin_src python
import h5py
import matplotlib.pyplot as plt
import numpy as np
#+end_src

* Чтение файла
  :PROPERTIES:
  :CUSTOM_ID: чтение-файла
  :END:

#+begin_src python
with h5py.File('train/2021-01-train.hdf5', mode='r') as dataset:
    print(list(dataset.keys())[:10])
#+end_src

#+begin_example
['1609459200', '1609459800', '1609460400', '1609461000', '1609461600', '1609462200', '1609462800', '1609463400', '1609464000', '1609464600']
#+end_example

#+begin_src python
with h5py.File('train/2021-01-train.hdf5', mode='r') as dataset:
    print(list(dataset['1609459200'].keys()))
#+end_src

#+begin_example
['events', 'intensity', 'radial_velocity', 'reflectivity']
#+end_example

#+begin_src python
with h5py.File('train/2021-01-train.hdf5', mode='r') as dataset:
    print(f"events shape: {dataset['1609459200']['events'].shape}")
    print(f"intensity shape: {dataset['1609459200']['intensity'].shape}")
    print(f"radial_velocity shape: {dataset['1609459200']['radial_velocity'].shape}")
    print(f"reflectivity shape: {dataset['1609459200']['reflectivity'].shape}")
#+end_src

#+begin_example
events shape: (252, 252)
intensity shape: (252, 252)
radial_velocity shape: (10, 252, 252)
reflectivity shape: (10, 252, 252)
#+end_example

* Визуализация
  :PROPERTIES:
  :CUSTOM_ID: визуализация
  :END:

#+begin_src python
events = []
intensity = []
radial_velocity = []
reflectivity = []

with h5py.File('train/2021-01-train.hdf5', mode='r') as dataset:
    timestamps = sorted(dataset.keys())[:6]
    for timestamp in timestamps:
        events.append(np.array(dataset[timestamp]['events']))
        intensity.append(np.array(dataset[timestamp]['intensity']))
        radial_velocity.append(np.array(dataset[timestamp]['radial_velocity']))
        reflectivity.append(np.array(dataset[timestamp]['reflectivity']))

events = np.array(events)
intensity = np.array(intensity)
radial_velocity = np.array(radial_velocity)
reflectivity = np.array(reflectivity)

events[events == -2e6] = -2
events[events == -1e6] = -1
intensity[intensity == -2e6] = -2
intensity[intensity == -1e6] = -1
radial_velocity[radial_velocity == -2e6] = -2
radial_velocity[radial_velocity == -1e6] = -1
reflectivity[reflectivity == -2e6] = -2
reflectivity[reflectivity == -1e6] = -1
#+end_src

** Погодные события
   :PROPERTIES:
   :CUSTOM_ID: погодные-события
   :END:

#+begin_src python
_, axs = plt.subplots(1, len(events), figsize=(20, 2))
for index in range(len(events)):
    axs[index].imshow(events[index])
    axs[index].set_title(timestamps[index])
#+end_src

[[file:c44ee738e3a80a9edf30f2f5a1ce0df0614fecc8.png]]

** Интенсивность осадков
   :PROPERTIES:
   :CUSTOM_ID: интенсивность-осадков
   :END:

#+begin_src python
_, axs = plt.subplots(1, len(intensity), figsize=(20, 2))
for index in range(len(intensity)):
    axs[index].imshow(intensity[index])
    axs[index].set_title(timestamps[index])
#+end_src

[[file:d5e57c6536ba82537a9a0777f644d56cc1cb407b.png]]

** Радиальная скорость по высотам
   :PROPERTIES:
   :CUSTOM_ID: радиальная-скорость-по-высотам
   :END:

#+begin_src python
_, axs = plt.subplots(10, len(radial_velocity), figsize=(20, 20))
for index in range(len(radial_velocity)):
    for row in range(10):
        if index == 0:
            axs[row, index].set_ylabel(f'{row + 1} км')
        axs[row, index].imshow(radial_velocity[index, row])
    axs[0, index].set_title(timestamps[index])
#+end_src

[[file:65ccc1c16abcb43264f79e9edcb738a12be21dda.png]]

** Отражаемость по высотам
   :PROPERTIES:
   :CUSTOM_ID: отражаемость-по-высотам
   :END:

#+begin_src python
_, axs = plt.subplots(10, len(reflectivity), figsize=(20, 20))
for index in range(len(reflectivity)):
    for row in range(10):
        if index == 0:
            axs[row, index].set_ylabel(f'{row + 1} км')
        axs[row, index].imshow(reflectivity[index, row])
    axs[0, index].set_title(timestamps[index])
#+end_src

[[file:6afc9404fd58bc9c1ff750ce6000a65b8331352a.png]]
