Skip to main content

A JSON schema-based framework for mapping and structuring experimental data

Project description

TokaMap

TokaMap is a JSON schema-based framework for mapping and structuring experimental data. It provides a standardized way to define how experimental measurements, calculations, and data transformations should be organized and validated.

The Python package contains the following components:

  • tokamap: A module that provides details about the install, such as the schemas directory
  • tokamap.validator: The validation module for ensuring data consistency and correctness

And the following CLI tools:

  • tokamap: Command-line interface for querying details about the install, such as the schemas directory
  • tokamap-validator: Command-line interface for validating TokaMap mappings

Overview

TokaMap defines a set of JSON schemas that allow researchers and engineers to:

  • Map experimental data using structured configuration files
  • Define data sources with standardized parameters and arguments
  • Create expressions and calculations from mapped data
  • Partition and group data based on experimental attributes
  • Validate mappings to ensure data consistency and correctness

Installation

From PyPI

pip install tokamap

From Source

git clone https://github.com/ukaea/tokamap.git
pip install .

TokaMap CLI

Finding the schemas directory:

tokamap --schemas-dir

Checking the installed version:

tokamap --version

TokaMap library

Finding the schemas directory:

from tokamap import schemas_dir

print(schemas_dir)

Checking the installed version:

from tokamap import __version__

print(__version__)

Validation

TokaMap includes a Python validator tool to ensure your mapping files conform to the schemas.

Usage

Validate a TokaMap mapping directory:

tokamap-validator /path/to/mapping/directory

For verbose output:

tokamap-validator -v /path/to/mapping/directory

Check the installed version:

tokamap-validator --version

The validator will:

  1. Check that the configuration file (mappings.cfg.json) exists and is valid
  2. Validate the top-level globals file
  3. Validate each mapping group's globals and mappings files

Validator Requirements

  • Python >= 3.13
  • jsonschema >= 4.25.0

Architecture

The TokaMap system consists of three main schema components:

1. Mappings Schema (mappings.schema.json)

Defines the structure for mapping experimental data with five main mapping types:

  • DIMENSION: Maps dimensional probe data
  • VALUE: Maps static values (numbers, strings, arrays, objects)
  • DATA_SOURCE: Maps external data sources with configurable arguments, offsets, scaling, and slicing
  • EXPR: Maps mathematical expressions with parameters
  • CUSTOM: Maps custom functions from external libraries

2. Globals Schema (globals.schema.json)

Defines global configuration settings, particularly data source configurations with their associated arguments.

3. Configuration Schema (mappings.cfg.schema.json)

Defines the top-level configuration structure including:

  • Metadata: Experiment information, author, and version
  • Partitions: Data partitioning rules with selectors (max_below, min_above, exact, closest)
  • Groups: Array of group identifiers

Schema Structure

Mapping Types

Each mapping entry can be one of several types:

Dimension Mapping

{
  "MAP_TYPE": "DIMENSION",
  "DIM_PROBE": "probe_identifier",
  "COMMENT": "Optional description"
}

Value Mapping

{
  "MAP_TYPE": "VALUE",
  "VALUE": "any_value_type",
  "COMMENT": "Optional description"
}

Data Source Mapping

{
  "MAP_TYPE": "DATA_SOURCE",
  "DATA_SOURCE": "source_name",
  "ARGS": {
    "arg1": "value1",
    "arg2": true
  },
  "OFFSET": 0,
  "SCALE": 1.0,
  "SLICE": "0:10",
  "COMMENT": "Optional description"
}

Expression Mapping

{
  "MAP_TYPE": "EXPR",
  "EXPR": "mathematical_expression",
  "PARAMETERS": {
    "param1": "value1"
  },
  "COMMENT": "Optional description"
}

Custom Function Mapping

{
  "MAP_TYPE": "CUSTOM",
  "LIBRARY": "library_name",
  "FUNCTION": "function_name",
  "INPUTS": {
    "input1": "value1"
  },
  "PARAMETERS": {},
  "COMMENT": "Optional description"
}

Directory Structure

A typical TokaMap project follows this structure:

mapping_root/
├── mappings.cfg.json          # Main configuration file
├── globals.json               # Global settings
├── mapping_group_1/
│   ├── globals.json          # Group-specific globals
│   └── mappings.json         # Group mappings
└── mapping_group_2/
    ├── globals.json
    └── mappings.json

Getting Started

  1. Create a configuration file (mappings.cfg.json) with your experiment metadata:
{
  "metadata": {
    "experiment": "your_experiment_name",
    "author": "Your Name",
    "version": "1.0.0"
  },
  "partitions": [
    {
      "attribute": "time",
      "selector": "closest"
    }
  ],
  "groups": ["group1", "group2"]
}
  1. Define global settings in globals.json:
{
  "DATA_SOURCE_CONFIG": {
    "your_data_source": {
      "ARGS": {
        "connection_string": "your_connection"
      }
    }
  }
}
  1. Create mapping directories for each group with their respective mappings.json and globals.json files.

  2. Validate your configuration using the TokaMap validator.

Schema Versioning

TokaMap schemas follow semantic versioning. The current version is 1.0 as indicated in the JSON Schema $id fields.

Contributing

TokaMap is developed to support experimental data mapping workflows. The schemas are designed to be extensible while maintaining validation integrity.

License

See the main project LICENSE file for license information.

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

tokamap-0.2.0.tar.gz (8.2 kB view details)

Uploaded Source

Built Distribution

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

tokamap-0.2.0-py3-none-any.whl (7.5 kB view details)

Uploaded Python 3

File details

Details for the file tokamap-0.2.0.tar.gz.

File metadata

  • Download URL: tokamap-0.2.0.tar.gz
  • Upload date:
  • Size: 8.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.14.2

File hashes

Hashes for tokamap-0.2.0.tar.gz
Algorithm Hash digest
SHA256 065a4648457b2ede7ed662a6f12836220160a14e2065c302eaa8bf1303417c48
MD5 829d4161f744e4b385b2f50709c37abe
BLAKE2b-256 77dddb4180406e0562b23bcd7d034f45df712d07180de396bb5fd1ff4447246a

See more details on using hashes here.

File details

Details for the file tokamap-0.2.0-py3-none-any.whl.

File metadata

  • Download URL: tokamap-0.2.0-py3-none-any.whl
  • Upload date:
  • Size: 7.5 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.14.2

File hashes

Hashes for tokamap-0.2.0-py3-none-any.whl
Algorithm Hash digest
SHA256 1636c07b9e3da1da787a0f11614c3ae78cef5486ad960c0cb4259b0c27ed7780
MD5 3e0036e3d1513a012ca3f3a53627f673
BLAKE2b-256 59624b28528630fc9ef5aed3ba829ddc7cd7bce26dfd58d3fcea29bf40a2fc32

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