Skip to main content

a Python library to work with the echemdb repository

Project description

Binder DOI

This module provides a Python library to interact with a collection of frictionless datapackages. Such datapackages consist of a CSV (data) file which is annotated with a JSON file. This allows storing additional information such as units used in the columns of a CSV or store metadata describing the underlying data. Example datapackages can be found here and a JSON could be structured as follows

{
    "resources": [
        {
            "name": "demo_package",
            "type": "table",
            "path": "demo_package.csv",
            "scheme": "file",
            "format": "csv",
            "mediatype": "text/csv",
            "encoding": "utf-8",
            "schema": {
                "fields": [
                    {
                        "name": "t",
                        "type": "number",
                        "unit": "s"
                    },
                    {
                        "name": "j",
                        "type": "number",
                        "unit": "A / m2"
                    }
                ]
            },
            "metadata": {
                "echemdb": {
                    "description": "Sample data for the unitpackage module.",
                    "curation": {
                        "process": [
                            {
                                "role": "experimentalist",
                                "name": "John Doe",
                                "laboratory": "Institute of Good Scientific Practice",
                                "date": "2021-07-09"
                            }
                        ]
                    }
                }
            }
        }
    ]
}

The metadata of an entries' resource in a collection is accessible from the python API.

>>> from unitpackage.collection import Collection
>>> from unitpackage.local import collect_datapackages
>>> db = Collection(data_packages=collect_datapackages('./doc/files'))
>>> entry = db['demo_package_cv']
>>> entry.description
'Sample data for the unitpackage module.'

From the API also a simple 2D plot can be drawn.

>>> entry.plot()

Ultimately, the unitpackage allows for simple transformation of data within a resource into different units.

>>> entry.get_unit('j')
'A / m2'
>>> entry.df
          t         E        j
0  0.000000	-0.196962 0.043009
1  0.011368	-0.196393 0.051408
...
>>> entry.rescale({'E' : 'mV', 'j' : 'uA / m2'}).df
          t           E             j
0  0.000000 -196.961730  43008.842162
1  0.011368 -196.393321  51408.199892
...

Collections for specific measurement types can be created, which provide additional accessibility to the meatadata or simplify the representation of such data in common plot types. An example of such a collection can be found on echemdb.org, which shows Cyclic Voltammetry data annotated following echemdb's metadata schema, which can be stored in a CVCollection

Collections can be generated from local files or data published in repositories such as on echemdb.org

Detailed installation instructions, description of the modules, advanced usage examples, including local collection creation, are provided in our documentation.

Installation instructions

This package is available on PiPY and can be installed with pip:

pip install unitpackage

The package is also available on conda-forge an can be installed with conda

conda install -c conda-forge unitpackage

or mamba

mamba install -c conda-forge unitpackage

Please consult our documentation for more detailed installation instructions.

License

The contents of this repository are licensed under the GNU General Public License v3.0 or, at your option, any later version.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

unitpackage-0.7.1.tar.gz (28.5 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

unitpackage-0.7.1-py3-none-any.whl (33.8 kB view details)

Uploaded Python 3

File details

Details for the file unitpackage-0.7.1.tar.gz.

File metadata

  • Download URL: unitpackage-0.7.1.tar.gz
  • Upload date:
  • Size: 28.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.10.10

File hashes

Hashes for unitpackage-0.7.1.tar.gz
Algorithm Hash digest
SHA256 5af8a74fc16558abf452e7d02cebd673aacd5a6a90ffb58d60752d700541dac4
MD5 c0a6377ba6b060922963ea21f8df69bb
BLAKE2b-256 bac33c003abd90345cced06684bd98f315e754f66f74862c48f692efbf1f3498

See more details on using hashes here.

File details

Details for the file unitpackage-0.7.1-py3-none-any.whl.

File metadata

  • Download URL: unitpackage-0.7.1-py3-none-any.whl
  • Upload date:
  • Size: 33.8 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.10.10

File hashes

Hashes for unitpackage-0.7.1-py3-none-any.whl
Algorithm Hash digest
SHA256 cff204595c06e848805acdfe1516c4cc68ab5f901b21a1fc2d83e218cc953eb4
MD5 76823882f8ca51e2bfae68516ae54750
BLAKE2b-256 5188426d9e95f12272a40b24d36f259d5d9d54fbce5097d61637d846197d3bc6

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page