.. DO NOT EDIT. .. THIS FILE WAS AUTOMATICALLY GENERATED BY SPHINX-GALLERY. .. TO MAKE CHANGES, EDIT THE SOURCE PYTHON FILE: .. "_examples/09_file_formats/plot_02_tsert_integer_index.py" .. LINE NUMBERS ARE GIVEN BELOW. .. only:: html .. note:: :class: sphx-glr-download-link-note :ref:`Go to the end ` to download the full example code. .. rst-class:: sphx-glr-example-title .. _sphx_glr__examples_09_file_formats_plot_02_tsert_integer_index.py: TSERT: data with integer indices ================================ Note that timestep keys can have arbitrary types. However, only one type of key is supported at any type. This example uses integers as keys. .. GENERATED FROM PYTHON SOURCE LINES 12-17 .. code-block:: Python import numpy as np import pandas as pd import reda .. GENERATED FROM PYTHON SOURCE LINES 18-19 Export data to the tsert file format .. GENERATED FROM PYTHON SOURCE LINES 19-52 .. code-block:: Python ert = reda.ERT() # set electrode positions electrodes = reda.electrode_manager() electrodes.add_by_position(np.arange(0, 40) * 0.25) ert.electrode_positions = electrodes.electrode_positions # set topograhy topography = pd.DataFrame(columns=['x', 'y', 'z']) topography['x'] = np.arange(0, 40) * 0.25 topography['y'] = 0 topography['z'] = 0 ert.topography = topography # # version 1 ert.import_crtomo_data( 'data/2018-04-13_11-00-25+00-00.dat', timestep=10, ) ert.import_crtomo_data( 'data/2018-06-01_09-00-43+00-00.dat', timestep=11, ) ert.import_crtomo_data( 'data/2018-08-02_09-00-14+00-00.dat', timestep=12 ) ert.export_tsert( 'data_integer_indices.h5', version='base', ) .. rst-class:: sphx-glr-script-out .. code-block:: none TODO: Fix logging format @@@@@@@@@@@@@@@@@@@@@@@ 10 index Empty DataFrame Columns: [value] Index: [] 0 10 Name: value, dtype: int64 --------------------------------- write_index @@@@@@@@@@@@@@@@@@@@@@@ 11 index value 0 10 0 10 1 11 Name: value, dtype: int64 --------------------------------- write_index @@@@@@@@@@@@@@@@@@@@@@@ 12 index value 0 10 1 11 0 10 1 11 2 12 Name: value, dtype: int64 --------------------------------- write_index .. GENERATED FROM PYTHON SOURCE LINES 53-54 Loading data from the tsert file format .. GENERATED FROM PYTHON SOURCE LINES 54-71 .. code-block:: Python # create an ert container ert = reda.ERT() # this is an optional command: it summarises a given file without loading # anything ert.tsert_summary('data_integer_indices.h5', print_index=True) # do the actual import ert.import_tsert( 'data_integer_indices.h5', ) print(ert.data.groupby('timestep').groups.keys()) assert ert.data.shape[0] == 1962, \ "Expected number of data points is {}".format(1962) .. rst-class:: sphx-glr-script-out .. code-block:: none TODO: Fix logging format ################################################################################ Summary of file: data_integer_indices.h5 Format metadata: File format: tsert Format version: 0.1 ------------------------------------------------------------ Number of time steps: 3 1: /ERT_DATA/0 2: /ERT_DATA/1 3: /ERT_DATA/2 Available versions: - Version base is present 3 times ################################################################################ ----------------- Index dataframe: value 0 10 1 11 2 12 ----------------- TODO: Fix logging format loading version: base dict_keys([10, 11, 12]) .. _sphx_glr_download__examples_09_file_formats_plot_02_tsert_integer_index.py: .. only:: html .. container:: sphx-glr-footer sphx-glr-footer-example .. container:: sphx-glr-download sphx-glr-download-jupyter :download:`Download Jupyter notebook: plot_02_tsert_integer_index.ipynb ` .. container:: sphx-glr-download sphx-glr-download-python :download:`Download Python source code: plot_02_tsert_integer_index.py ` .. only:: html .. rst-class:: sphx-glr-signature `Gallery generated by Sphinx-Gallery `_