.. DO NOT EDIT. .. THIS FILE WAS AUTOMATICALLY GENERATED BY SPHINX-GALLERY. .. TO MAKE CHANGES, EDIT THE SOURCE PYTHON FILE: .. "tutorial-project/eg_01_a_new_project.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-project_eg_01_a_new_project.py: Making a project ^^^^^^^^^^^^^^^^ The quick reading functionality of resistics focuses on analysis of single continuous recordings. When there are multiple recordings at a site or multiple sites, it can be more convenient to use a resistics project. This is generally easier to manage and use, especially when doing remote reference or intersite processing. The data in this example has been provided for use by the SAMTEX consortium. For more information, please refer to [Jones2009]_. Additional details about the data can be found at https://www.mtnet.info/data/kap03/kap03.html. .. GENERATED FROM PYTHON SOURCE LINES 15-21 .. code-block:: default from pathlib import Path import seedir as sd import shutil import plotly import resistics.letsgo as letsgo .. GENERATED FROM PYTHON SOURCE LINES 22-25 Define the path where the project will be created and any extra project metadata. The only required piece of metadata is the reference time but there are other optional fields. .. GENERATED FROM PYTHON SOURCE LINES 25-32 .. code-block:: default project_path = Path("..", "..", "data", "project", "kap03") project_info = { "ref_time": "2003-10-15 00:00:00", "year": 2003, "country": "South Africa", } .. GENERATED FROM PYTHON SOURCE LINES 33-35 Create the new project and look at the directory structure. There are no data files in the project yet, so there is not much to see. .. GENERATED FROM PYTHON SOURCE LINES 35-38 .. code-block:: default letsgo.new(project_path, project_info) sd.seedir(str(project_path), style="emoji") .. rst-class:: sphx-glr-script-out Out: .. code-block:: none 📁 kap03/ ├─📁 images/ ├─📁 time/ ├─📄 resistics.json ├─📁 results/ ├─📁 calibrate/ ├─📁 evals/ ├─📁 masks/ ├─📁 spectra/ └─📁 features/ .. GENERATED FROM PYTHON SOURCE LINES 39-42 Load the project and have a look. When loading a project, a resistics environment is returned. This is a combination of a resistics project and a configuration. .. GENERATED FROM PYTHON SOURCE LINES 42-45 .. code-block:: default resenv = letsgo.load(project_path) resenv.proj.summary() .. rst-class:: sphx-glr-script-out Out: .. code-block:: none { 'dir_path': '../../data/project/kap03', 'begin_time': '2021-10-14 22:19:27.255486_000000_000000_000000', 'end_time': '2021-10-14 22:19:27.255489_000000_000000_000000', 'metadata': { 'file_info': { 'created_on_local': '2021-10-14T22:19:27.253000', 'created_on_utc': '2021-10-14T22:19:27.253006', 'version': '1.0.0a3' }, 'ref_time': '2003-10-15 00:00:00.000000_000000_000000_000000', 'location': '', 'country': 'South Africa', 'year': 2003, 'description': '', 'contributors': [] }, 'sites': {} } .. GENERATED FROM PYTHON SOURCE LINES 46-49 Now let's copy some time series data into the project and look at the directory structure. Copy the data does not have to be done using Python and users can simply copy and paste the time series data into the time folder .. GENERATED FROM PYTHON SOURCE LINES 49-54 .. code-block:: default copy_from = Path("..", "..", "data", "time", "kap03") for site in copy_from.glob("*"): shutil.copytree(site, project_path / "time" / site.stem) sd.seedir(str(project_path), style="emoji") .. rst-class:: sphx-glr-script-out Out: .. code-block:: none 📁 kap03/ ├─📁 images/ ├─📁 time/ │ ├─📁 kap163/ │ │ └─📁 meas01/ │ │ ├─📄 data.npy │ │ └─📄 metadata.json │ ├─📁 kap160/ │ │ └─📁 meas01/ │ │ ├─📄 data.npy │ │ └─📄 metadata.json │ └─📁 kap172/ │ └─📁 meas01/ │ ├─📄 data.npy │ └─📄 metadata.json ├─📄 resistics.json ├─📁 results/ ├─📁 calibrate/ ├─📁 evals/ ├─📁 masks/ ├─📁 spectra/ └─📁 features/ .. GENERATED FROM PYTHON SOURCE LINES 55-56 Reload the project and print a new summary. .. GENERATED FROM PYTHON SOURCE LINES 56-59 .. code-block:: default resenv = letsgo.reload(resenv) resenv.proj.summary() .. rst-class:: sphx-glr-script-out Out: .. code-block:: none { 'dir_path': '../../data/project/kap03', 'begin_time': '2003-10-28 10:00:00.000000_000000_000000_000000', 'end_time': '2003-11-24 15:31:55.000000_000000_000000_000000', 'metadata': { 'file_info': { 'created_on_local': '2021-10-14T22:19:27.253000', 'created_on_utc': '2021-10-14T22:19:27.253006', 'version': '1.0.0a3' }, 'ref_time': '2003-10-15 00:00:00.000000_000000_000000_000000', 'location': '', 'country': 'South Africa', 'year': 2003, 'description': '', 'contributors': [] }, 'sites': { 'kap163': { 'dir_path': '../../data/project/kap03/time/kap163', 'measurements': { 'meas01': { 'site_name': 'kap163', 'dir_path': '../../data/project/kap03/time/kap163/meas01', 'metadata': { 'file_info': { 'created_on_local': '2021-07-07T22:26:52.975361', 'created_on_utc': '2021-07-07T21:26:52.975361', 'version': '1.0.0a0' }, 'fs': 0.2, 'chans': ['Hx', 'Hy', 'Hz', 'Ex', 'Ey'], 'n_chans': 5, 'n_samples': 463807, 'first_time': '2003-10-28 15:30:00.000000_000000_000000_000000', 'last_time': '2003-11-24 11:40:30.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': []} }, 'reader': { 'name': 'TimeReaderNumpy', 'apply_scalings': True, 'extension': '.npy' } } }, 'begin_time': '2003-10-28 15:30:00.000000_000000_000000_000000', 'end_time': '2003-11-24 11:40:30.000000_000000_000000_000000' }, 'kap160': { 'dir_path': '../../data/project/kap03/time/kap160', 'measurements': { 'meas01': { 'site_name': 'kap160', 'dir_path': '../../data/project/kap03/time/kap160/meas01', 'metadata': { 'file_info': { 'created_on_local': '2021-07-07T22:26:48.851498', 'created_on_utc': '2021-07-07T21:26:48.851498', 'version': '1.0.0a0' }, 'fs': 0.2, 'chans': ['Hx', 'Hy', 'Hz', 'Ex', 'Ey'], 'n_chans': 5, 'n_samples': 470544, 'first_time': '2003-10-28 10:00:00.000000_000000_000000_000000', 'last_time': '2003-11-24 15:31: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': []} }, 'reader': { 'name': 'TimeReaderNumpy', 'apply_scalings': True, 'extension': '.npy' } } }, 'begin_time': '2003-10-28 10:00:00.000000_000000_000000_000000', 'end_time': '2003-11-24 15:31:55.000000_000000_000000_000000' }, 'kap172': { 'dir_path': '../../data/project/kap03/time/kap172', 'measurements': { 'meas01': { 'site_name': 'kap172', 'dir_path': '../../data/project/kap03/time/kap172/meas01', 'metadata': { 'file_info': { 'created_on_local': '2021-07-07T22:27:00.395145', 'created_on_utc': '2021-07-07T21:27:00.395145', 'version': '1.0.0a0' }, 'fs': 0.2, 'chans': ['Hx', 'Hy', 'Hz', 'Ex', 'Ey'], 'n_chans': 5, 'n_samples': 414498, 'first_time': '2003-10-30 13:00:00.000000_000000_000000_000000', 'last_time': '2003-11-23 12:41:25.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': []} }, 'reader': { 'name': 'TimeReaderNumpy', 'apply_scalings': True, 'extension': '.npy' } } }, 'begin_time': '2003-10-30 13:00:00.000000_000000_000000_000000', 'end_time': '2003-11-23 12:41:25.000000_000000_000000_000000' } } } .. GENERATED FROM PYTHON SOURCE LINES 60-61 Finally, plot the project timeline. .. GENERATED FROM PYTHON SOURCE LINES 61-64 .. code-block:: default fig = resenv.proj.plot() fig.update_layout(height=700) plotly.io.show(fig) .. raw:: html :file: images/sphx_glr_eg_01_a_new_project_001.html .. rst-class:: sphx-glr-timing **Total running time of the script:** ( 0 minutes 0.302 seconds) .. _sphx_glr_download_tutorial-project_eg_01_a_new_project.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_a_new_project.py ` .. container:: sphx-glr-download sphx-glr-download-jupyter :download:`Download Jupyter notebook: eg_01_a_new_project.ipynb ` .. only:: html .. rst-class:: sphx-glr-signature `Gallery generated by Sphinx-Gallery `_