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.

from pathlib import Path
import seedir as sd
import shutil
import plotly
import resistics.letsgo as letsgo

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.

project_path = Path("..", "..", "data", "project", "kap03")
project_info = {
    "ref_time": "2003-10-15 00:00:00",
    "year": 2003,
    "country": "South Africa",
}

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.

letsgo.new(project_path, project_info)
sd.seedir(str(project_path), style="emoji")

Out:

πŸ“ kap03/
β”œβ”€πŸ“ images/
β”œβ”€πŸ“ time/
β”œβ”€πŸ“„ resistics.json
β”œβ”€πŸ“ results/
β”œβ”€πŸ“ calibrate/
β”œβ”€πŸ“ evals/
β”œβ”€πŸ“ masks/
β”œβ”€πŸ“ spectra/
β””β”€πŸ“ features/

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.

resenv = letsgo.load(project_path)
resenv.proj.summary()

Out:

{
    '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': {}
}

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

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")

Out:

πŸ“ 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/

Reload the project and print a new summary.

resenv = letsgo.reload(resenv)
resenv.proj.summary()

Out:

{
    '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'
        }
    }
}

Finally, plot the project timeline.

fig = resenv.proj.plot()
fig.update_layout(height=700)
plotly.io.show(fig)

Total running time of the script: ( 0 minutes 0.302 seconds)

Gallery generated by Sphinx-Gallery