kujaku11 / mt_metadata

Tools for standardizing metadata, geared towards magnetotelluric (MT) data but is general enough to accommodate "any" type of metadata.
https://mt-metadata.readthedocs.io/en/latest/
MIT License
18 stars 4 forks source link
magnetotellurics metadata-management

mt_metadata version 0.3.7

Standard MT metadata

PyPi version Latest conda|conda-forge version codecov example workflow name License: MIT DOI Binder

Description

MT Metadata is a project led by IRIS-PASSCAL MT Software working group and USGS to develop tools that standardize magnetotelluric metadata, well, at least create tools for standards that are generally accepted. This include the two main types of magnetotelluric data

Most people will be using the transfer functions, but a lot of that metadata comes from the time series metadata. This module supports both and has tried to make them more or less seamless to reduce complication.

Installation

From Source

git clone https://github.com/kujaku11/mt_metadata.git

python setup.py install

You can add the flag -e if you want to change the code.

PIP

pip install mt_metadata

Conda

conda install mt_metadata

Standards

Each metadata keyword has an associated standard that goes with it. These are stored internally in JSON file. The JSON files are read in when the package is loaded to initialize the standards. Each keyword is described by:

All input values are internally validated according to the definition providing a robust way to standardize metadata.

Each metadata object is based on a Base class that has methods:

And each object has a doc string that describes the standard:

Metadata Key Description Example
key description of what the key describes example value
Required: False
Units: None
Type: string
Style: controlled vocabulary

The time series module is more mature than the transfer function module at the moment, and this is still a work in progress.

Example

from mt_metadata import timeseries
x = timeseries.Instrument()

Help

help(x)

+----------------------------------------------+-----------------------------------------------+----------------+
| **Metadata Key**                             | **Description**                               | **Example**    |
+==============================================+===============================================+================+
| **id**                                       | instrument ID number can be serial number or  | mt01           |
|                                              | a designated ID                               |                |
| Required: True                               |                                               |                |
|                                              |                                               |                |
| Units: None                                  |                                               |                |
|                                              |                                               |                |
| Type: string                                 |                                               |                |
|                                              |                                               |                |
| Style: free form                             |                                               |                |
+----------------------------------------------+-----------------------------------------------+----------------+
| **manufacturer**                             | who manufactured the instrument               | mt gurus       |
|                                              |                                               |                |
| Required: True                               |                                               |                |
|                                              |                                               |                |
| Units: None                                  |                                               |                |
|                                              |                                               |                |
| Type: string                                 |                                               |                |
|                                              |                                               |                |
| Style: free form                             |                                               |                |
+----------------------------------------------+-----------------------------------------------+----------------+
| **type**                                     | instrument type                               | broadband      |
|                                              |                                               | 32-bit         |
| Required: True                               |                                               |                |
|                                              |                                               |                |
| Units: None                                  |                                               |                |
|                                              |                                               |                |
| Type: string                                 |                                               |                |
|                                              |                                               |                |
| Style: free form                             |                                               |                |
+----------------------------------------------+-----------------------------------------------+----------------+
| **model**                                    | model version of the instrument               | falcon5        |
|                                              |                                               |                |
| Required: False                              |                                               |                |
|                                              |                                               |                |
| Units: None                                  |                                               |                |
|                                              |                                               |                |
| Type: string                                 |                                               |                |
|                                              |                                               |                |
| Style: free form                             |                                               |                |
+----------------------------------------------+-----------------------------------------------+----------------+

Fill in metadata

x.model = "falcon 5"
x.type = "broadband 32-bit"
x.manufacturer = "MT Gurus"
x.id = "f176"

to JSON

print(x.to_json())
{
    "instrument": {
        "id": "f176",
        "manufacturer": "MT Gurus",
        "model": "falcon 5",
        "type": "broadband 32-bit"
    }
}

to XML

print(x.to_xml(string=True))
<?xml version="1.0" ?>
<instrument>
    <id>f176</id>
    <manufacturer>MT Gurus</manufacturer>
    <model>falcon 5</model>
    <type>broadband 32-bit</type>
</instrument>

Credits

This project is in cooperation with the Incorporated Research Institutes of Seismology, the U.S. Geological Survey, and other collaborators. Facilities of the IRIS Consortium are supported by the National Science Foundation’s Seismological Facilities for the Advancement of Geoscience (SAGE) Award under Cooperative Support Agreement EAR-1851048. USGS is partially funded through the Community for Data Integration and IMAGe through the Minerals Resources Program.