.. DO NOT EDIT. .. THIS FILE WAS AUTOMATICALLY GENERATED BY SPHINX-GALLERY. .. TO MAKE CHANGES, EDIT THE SOURCE PYTHON FILE: .. "tutorial-quick/eg_01_quick_read.py" .. LINE NUMBERS ARE GIVEN BELOW. .. only:: html .. note:: :class: sphx-glr-download-link-note Click :ref:`here ` to download the full example code .. rst-class:: sphx-glr-example-title .. _sphx_glr_tutorial-quick_eg_01_quick_read.py: Reading time data ^^^^^^^^^^^^^^^^^ Resistics can quickly read a single continuous recording using the quick reading functionality. This can be useful for inspecting the metadata and having a look at the data when in the field. The dataset in this example has been provided for use by the SAMTEX consortium. For more information, please refer to [Jones2009]_. Additional details about the dataset can be found at https://www.mtnet.info/data/kap03/kap03.html. .. GENERATED FROM PYTHON SOURCE LINES 13-18 .. code-block:: default from pathlib import Path import seedir as sd import plotly import resistics.letsgo as letsgo .. GENERATED FROM PYTHON SOURCE LINES 19-20 Define the data path. This is dependent on where the data is stored. .. GENERATED FROM PYTHON SOURCE LINES 20-23 .. code-block:: default time_data_path = Path("..", "..", "data", "time", "quick", "kap123") sd.seedir(str(time_data_path), style="emoji") .. rst-class:: sphx-glr-script-out Out: .. code-block:: none 📁 kap123/ ├─📄 data.npy └─📄 metadata.json .. GENERATED FROM PYTHON SOURCE LINES 24-25 Quickly read the time series data and inspect the metadata .. GENERATED FROM PYTHON SOURCE LINES 25-28 .. code-block:: default time_data = letsgo.quick_read(time_data_path) time_data.metadata.summary() .. rst-class:: sphx-glr-script-out Out: .. code-block:: none { 'file_info': { 'created_on_local': '2021-07-07T22:25:45.320529', 'created_on_utc': '2021-07-07T21:25:45.320529', 'version': '1.0.0a0' }, 'fs': 0.2, 'chans': ['Hx', 'Hy', 'Hz', 'Ex', 'Ey'], 'n_chans': 5, 'n_samples': 361512, 'first_time': '2003-11-10 15:00:00.000000_000000_000000_000000', 'last_time': '2003-12-01 13:05:55.000000_000000_000000_000000', 'system': '', 'serial': '', 'wgs84_latitude': -999.0, 'wgs84_longitude': -999.0, 'easting': -999.0, 'northing': -999.0, 'elevation': -999.0, 'chans_metadata': { 'Hx': { 'name': 'Hx', 'data_files': ['data.npy'], 'chan_type': 'magnetic', 'chan_source': None, 'sensor': '', 'serial': '', 'gain1': 1.0, 'gain2': 1.0, 'scaling': 1.0, 'chopper': False, 'dipole_dist': 1.0, 'sensor_calibration_file': '', 'instrument_calibration_file': '' }, 'Hy': { 'name': 'Hy', 'data_files': ['data.npy'], 'chan_type': 'magnetic', 'chan_source': None, 'sensor': '', 'serial': '', 'gain1': 1.0, 'gain2': 1.0, 'scaling': 1.0, 'chopper': False, 'dipole_dist': 1.0, 'sensor_calibration_file': '', 'instrument_calibration_file': '' }, 'Hz': { 'name': 'Hz', 'data_files': ['data.npy'], 'chan_type': 'magnetic', 'chan_source': None, 'sensor': '', 'serial': '', 'gain1': 1.0, 'gain2': 1.0, 'scaling': 1.0, 'chopper': False, 'dipole_dist': 1.0, 'sensor_calibration_file': '', 'instrument_calibration_file': '' }, 'Ex': { 'name': 'Ex', 'data_files': ['data.npy'], 'chan_type': 'electric', 'chan_source': None, 'sensor': '', 'serial': '', 'gain1': 1.0, 'gain2': 1.0, 'scaling': 1.0, 'chopper': False, 'dipole_dist': 1.0, 'sensor_calibration_file': '', 'instrument_calibration_file': '' }, 'Ey': { 'name': 'Ey', 'data_files': ['data.npy'], 'chan_type': 'electric', 'chan_source': None, 'sensor': '', 'serial': '', 'gain1': 1.0, 'gain2': 1.0, 'scaling': 1.0, 'chopper': False, 'dipole_dist': 1.0, 'sensor_calibration_file': '', 'instrument_calibration_file': '' } }, 'history': { 'records': [ { 'time_local': '2021-10-14T22:19:02.731137', 'time_utc': '2021-10-14T22:19:02.731136', 'creator': { 'name': 'TimeReaderNumpy', 'apply_scalings': True, 'extension': '.npy' }, 'messages': [ 'Reading raw data from ../../data/time/quick/kap123', 'Sampling frequency 0.2 Hz', 'From sample, time: 0, 2003-11-10 15:00:00', 'To sample, time: 361511, 2003-12-01 13:05:55' ], 'record_type': 'process' } ] } } .. GENERATED FROM PYTHON SOURCE LINES 29-30 Take a subsection of the data and inspect the metadata for the subsection .. GENERATED FROM PYTHON SOURCE LINES 30-33 .. code-block:: default time_data_sub = time_data.subsection("2003-11-20 12:00:00", "2003-11-21 00:00:00") time_data_sub.metadata.summary() .. rst-class:: sphx-glr-script-out Out: .. code-block:: none { 'file_info': { 'created_on_local': '2021-07-07T22:25:45.320529', 'created_on_utc': '2021-07-07T21:25:45.320529', 'version': '1.0.0a0' }, 'fs': 0.2, 'chans': ['Hx', 'Hy', 'Hz', 'Ex', 'Ey'], 'n_chans': 5, 'n_samples': 8641, 'first_time': '2003-11-20 12:00:00.000000_000000_000000_000000', 'last_time': '2003-11-21 00:00:00.000000_000000_000000_000000', 'system': '', 'serial': '', 'wgs84_latitude': -999.0, 'wgs84_longitude': -999.0, 'easting': -999.0, 'northing': -999.0, 'elevation': -999.0, 'chans_metadata': { 'Hx': { 'name': 'Hx', 'data_files': ['data.npy'], 'chan_type': 'magnetic', 'chan_source': None, 'sensor': '', 'serial': '', 'gain1': 1.0, 'gain2': 1.0, 'scaling': 1.0, 'chopper': False, 'dipole_dist': 1.0, 'sensor_calibration_file': '', 'instrument_calibration_file': '' }, 'Hy': { 'name': 'Hy', 'data_files': ['data.npy'], 'chan_type': 'magnetic', 'chan_source': None, 'sensor': '', 'serial': '', 'gain1': 1.0, 'gain2': 1.0, 'scaling': 1.0, 'chopper': False, 'dipole_dist': 1.0, 'sensor_calibration_file': '', 'instrument_calibration_file': '' }, 'Hz': { 'name': 'Hz', 'data_files': ['data.npy'], 'chan_type': 'magnetic', 'chan_source': None, 'sensor': '', 'serial': '', 'gain1': 1.0, 'gain2': 1.0, 'scaling': 1.0, 'chopper': False, 'dipole_dist': 1.0, 'sensor_calibration_file': '', 'instrument_calibration_file': '' }, 'Ex': { 'name': 'Ex', 'data_files': ['data.npy'], 'chan_type': 'electric', 'chan_source': None, 'sensor': '', 'serial': '', 'gain1': 1.0, 'gain2': 1.0, 'scaling': 1.0, 'chopper': False, 'dipole_dist': 1.0, 'sensor_calibration_file': '', 'instrument_calibration_file': '' }, 'Ey': { 'name': 'Ey', 'data_files': ['data.npy'], 'chan_type': 'electric', 'chan_source': None, 'sensor': '', 'serial': '', 'gain1': 1.0, 'gain2': 1.0, 'scaling': 1.0, 'chopper': False, 'dipole_dist': 1.0, 'sensor_calibration_file': '', 'instrument_calibration_file': '' } }, 'history': { 'records': [ { 'time_local': '2021-10-14T22:19:02.731137', 'time_utc': '2021-10-14T22:19:02.731136', 'creator': { 'name': 'TimeReaderNumpy', 'apply_scalings': True, 'extension': '.npy' }, 'messages': [ 'Reading raw data from ../../data/time/quick/kap123', 'Sampling frequency 0.2 Hz', 'From sample, time: 0, 2003-11-10 15:00:00', 'To sample, time: 361511, 2003-12-01 13:05:55' ], 'record_type': 'process' }, { 'time_local': '2021-10-14T22:19:02.748221', 'time_utc': '2021-10-14T22:19:02.748220', 'creator': { 'name': 'Subsection', 'from_time': '2003-11-20 12:00:00', 'to_time': '2003-11-21 00:00:00' }, 'messages': [ 'Subection from sample 170640 to 179280', 'Adjusted times 2003-11-20 12:00:00 to 2003-11-21 00:00:00' ], 'record_type': 'process' } ] } } .. GENERATED FROM PYTHON SOURCE LINES 34-38 Plot the full time data with LTTB downsampling and a subsection without any downsampling. Comparing the downsampled and original data, there is clearly some loss but the LTTB downsampled data does a reasonable job capaturing the main features whilst showing a greater amount of data. .. GENERATED FROM PYTHON SOURCE LINES 38-44 .. code-block:: default fig = time_data.plot(max_pts=1_000) fig = time_data_sub.plot( fig, chans=time_data.metadata.chans, color="red", legend="Subsection", max_pts=None ) fig.update_layout(height=700) plotly.io.show(fig) .. raw:: html :file: images/sphx_glr_eg_01_quick_read_001.html .. rst-class:: sphx-glr-timing **Total running time of the script:** ( 0 minutes 5.855 seconds) .. _sphx_glr_download_tutorial-quick_eg_01_quick_read.py: .. only :: html .. container:: sphx-glr-footer :class: sphx-glr-footer-example .. container:: sphx-glr-download sphx-glr-download-python :download:`Download Python source code: eg_01_quick_read.py ` .. container:: sphx-glr-download sphx-glr-download-jupyter :download:`Download Jupyter notebook: eg_01_quick_read.ipynb ` .. only:: html .. rst-class:: sphx-glr-signature `Gallery generated by Sphinx-Gallery `_