Skip to main content

Gives functions to help build a mater providing data script.

Project description

MATER data providing

Metabolic Analysis for Transdisciplinary Ecological Research

[TOC]

📋 Requirements

  • Python 3.12 or higher

We recommend using one virtual environment per Python project to manage dependencies and maintain isolation. You can use a package manager like uv to help you with library dependencies and virtual environments.

📦 Install the mater-data-providing Package

Install the mater package via uv:

uv add mater-data-providing

Install the mater package via pip:

pip install mater-data-providing

⚙️ API

metadata_definition

import mater-data-providing as mdp
mdp.metadata_definition("source_link", "my_source", "my_project")

Returns

{"link": "source_link", "source": "my_source", "project": "my_project"}

provider_definition

import mater-data-providing as mdp
mdp.provider_definition("Jon", "Do", "jon.do@mail.com")

Returns

{"first_name": "Jon", "last_name": "Do", "email_address": "jon.do@mail.com"}

to_json

import mater_data_providing as mdp
import pandas as pd

# 1. Build a DataFrame
df = pd.DataFrame([
    {"location": "france", "object": "car", "value": 15, "unit": "year", "time": 2015, "scenario": "historical", "variable": "lifetime_mean_value"},
    {"location": "france", "object": "car", "value": 17, "unit": "year", "time": 2020, "scenario": "historical", "variable": "lifetime_mean_value"},
])

# 2. Write out as "input_data/sample.json"
#    (creates data/input_data/sample.json)
mdp.to_json(
    df,
    folder="input_data",
    name="sample",       # filename will be sample.json
    mode="w"             # write (overwrite) – this is the default
)

Creates data/input_data/sample.json:

[
  {
    "location": "france",
    "object": "car",
    "value": 15,
    "unit": "year",
    "time": 2015,
    "scenario": "historical",
    "variable": "lifetime_mean_value"
  },
  {
    "location": "france",
    "object": "car",
    "value": 17,
    "unit": "year",
    "time": 2020,
    "scenario": "historical",
    "variable": "lifetime_mean_value"
  }
]

replace_equivalence

data\dimension\dimension.json:

[
  {
    "value": "car",
    "equivalence": {
      "short": "PLDV",
      "long": "personal_vehicle"
    }
  },
  {
    "value": "france",
    "equivalence": {
      "ISO3": "FRA"
    }
  }
]

Python scrip at the root of the project:

import mater_data_providing as mdp
import pandas as pd

# 1. Build a DataFrame
df = pd.DataFrame([
    {"location": "FRA", "object": "personal_vehicle", "value": 15, "unit": "year", "time": 2015, "scenario": "historical", "variable": "lifetime_mean_value"},
    {"location": "france", "object": "PLDV", "value": 17, "unit": "year", "time": 2020, "scenario": "historical", "variable": "lifetime_mean_value"},
])

df_uniform = mdp.replace_equivalence(df)
print(df_uniform)
  location object  value  unit  time    scenario             variable
0   france    car     15  year  2015  historical  lifetime_mean_value
1   france    car     17  year  2020  historical  lifetime_mean_value

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

mater_data_providing-0.1.0.tar.gz (43.1 kB view details)

Uploaded Source

Built Distribution

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

mater_data_providing-0.1.0-py3-none-any.whl (29.3 kB view details)

Uploaded Python 3

File details

Details for the file mater_data_providing-0.1.0.tar.gz.

File metadata

File hashes

Hashes for mater_data_providing-0.1.0.tar.gz
Algorithm Hash digest
SHA256 b430d47bcdd6b4d44440ca1029a511f00bf90093cc375a6f14dbaf1de71aa25e
MD5 30cb6ff7d05d534fe3b7b8a125024ebf
BLAKE2b-256 742325b40ee3c07b73cdb31043853a8b9f0a508156bfbe62503d62844dde4a1a

See more details on using hashes here.

File details

Details for the file mater_data_providing-0.1.0-py3-none-any.whl.

File metadata

File hashes

Hashes for mater_data_providing-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 89de4c543a15c2ffb8243d67ae0eded1d9f0a0aed4f14d57cccd4ad135f5ca40
MD5 ba69c3daba41c18dd0514d6cd416ffe8
BLAKE2b-256 a5623884e6f9b51757039f9398c1202fafaa8befc24371686139e7e06d45c952

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