Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,12 +25,14 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- Tests for example and template to be valid frictionless datapackage [(#305)](https://github.com/OpenEnergyPlatform/oemetadata/pull/305)
- Add spatial information to dataset [(#310)](https://github.com/OpenEnergyPlatform/oemetadata/pull/310)
- Add temporal information to dataset [(#310)](https://github.com/OpenEnergyPlatform/oemetadata/pull/310)
- Add a module `Energy Systems` for dataset [(#312)](https://github.com/OpenEnergyPlatform/oemetadata/pull/312)

### Changed
- Update TLDR URL in example sourceLicenses [(#275)](https://github.com/OpenEnergyPlatform/oemetadata/pull/275)
- Scripts in build_source produce same json as provided in repo [(#284)](https://github.com/OpenEnergyPlatform/oemetadata/pull/284)
- Update python env instructions to latest version [(#284)](https://github.com/OpenEnergyPlatform/oemetadata/pull/284)
- Update datapackage logo link [(#311)](https://github.com/OpenEnergyPlatform/oemetadata/pull/311)
- Update `create_example.py` and add `example_modules.json` [(#312)](https://github.com/OpenEnergyPlatform/oemetadata/pull/312)

### Removed

Expand Down
127 changes: 65 additions & 62 deletions docs/oemetadata/metadata_key_description.md

Large diffs are not rendered by default.

67 changes: 67 additions & 0 deletions docs/oemetadata/metadata_key_details.md
Original file line number Diff line number Diff line change
Expand Up @@ -1332,6 +1332,73 @@ If a value is not yet available, use: `ToDo`.
| Ontology Class | [oeo:quality control flag](https://openenergyplatform.org/ontology/oeo/OEO_00140098/) |
| Badge | [0..1] |


## Dataset - Modules

### Dataset - Module - Energy Systems
| | |
|----------------|------------------------------------------------------------------|
| Key | **moduleEnergySystems** |
| Description | An Object that describes the main concepts of an energy system. |
| Example | |
| Ontology Class | |
| Badge | [0..1] |

### Dataset - Module - Energy Systems - supplyTechnologies
| | |
|----------------|----------------------------------------------------------------------------------------------------------------------------|
| Key | **supplyTechnologies** |
| Description | A supply technology describes how specific technical components and processes are combined to generate or provide energy. |
| Example | |
| Ontology Class | |
| Badge | [0..1] |

### Dataset - Module - Energy Systems - storageTechnologies
| | |
|----------------|-----------------------------------------------------------------------------------------------------------------------------------------------------------------|
| Key | **storageTechnologies** |
| Description | An energy storage technology describes how energy storage components and energy carriers are combined to charge, store, and discharge energy for temporary use. |
| Example | |
| Ontology Class | |
| Badge | [0..1] |

### Dataset - Module - Energy Systems - supplyGrid
| | |
|----------------|---------------------------------------------------------------------------------------------------------------------------------|
| Key | **supplyGrid** |
| Description | A supply grid is a system of interconnected technical components that together enable the distribution and delivery of energy. |
| Example | |
| Ontology Class | |
| Badge | [0..1] |

### Dataset - Module - Energy Systems - finalEnergyCarrier
| | |
|----------------|-----------------------------------------------------------------------------------------------------------------------------------------------------------------|
| Key | **finalEnergyCarrier** |
| Description | An energy storage technology describes how energy storage components and energy carriers are combined to charge, store, and discharge energy for temporary use. |
| Example | |
| Ontology Class | |
| Badge | [0..1] |

### Dataset - Module - Energy Systems - demandSectors
| | |
|----------------|-------------------------------------------------------------------------------------------------------------------------------------|
| Key | **demandSectors** |
| Description | An energy demand sector is a sector of the energy system that groups together energy consumers with similar usage characteristics. |
| Example | |
| Ontology Class | |
| Badge | [0..1] |

### Dataset - Module - Energy Systems - moduleDescription
| | |
|----------------|----------------------------------------------------------------------------------------------------------------------------|
| Key | **moduleDescription** |
| Description | A description of the module. It should be usable as summary information for the module that is described by the metadata. |
| Example | |
| Ontology Class | |
| Badge | [0..1] |


### MetaMetadata Keys
| | |
|----------------|--------------------------------------------------------------------------------------|
Expand Down
3 changes: 3 additions & 0 deletions oemetadata/v2/v21/build_source/schema_structure.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,9 @@
"provenance": {
"$ref": "provenance.json#"
},
"moduleEnergySystems": {
"$ref": "module_energy_systems.json#"
},
"datasetLicenses": {
"$ref": "licenses_dataset.json#"
},
Expand Down
217 changes: 217 additions & 0 deletions oemetadata/v2/v21/build_source/schemas/module_energy_systems.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,217 @@
{
"$schema": "https://json-schema.org/draft/2020-12/schema",
"$id": "https://raw.githubusercontent.com/OpenEnergyPlatform/oemetadata/production/oemetadata/v2/v21/build_source/schemas/module_energy_systems.json",
"type": "object",
"properties": {
"moduleEnergySystems": {
"description": "An Object that describes the main concepts of an energy system.",
"type": "object",
"properties": {
"supplyTechnologies": {
"description": "A supply technology describes how specific technical components and processes are combined to generate or provide energy",
"type": "array",
"items": {
"type": "object",
"properties": {
"name": {
"description": "A class label of the ontology term.",
"type": [
"string",
"null"
],
"examples": [
"energy transformation"
],
"badge": "Platinum",
"title": "Subject Name"
},
"@id": {
"description": "A unique identifier (URI/IRI) of the ontology class.",
"type": [
"string",
"null"
],
"examples": [
"https://openenergyplatform.org/ontology/oeo/OEO_00020003"
],
"badge": "Platinum",
"title": "Subject Identifier",
"format": "uri"
}
},
"badge": "Platinum",
"title": "Subject"
},
"badge": "Platinum",
"title": "Subject"
},
"storageTechnologies": {
"description": "An energy storage technology describes how energy storage components and energy carriers are combined to charge, store, and discharge energy for temporary use.",
"type": "array",
"items": {
"type": "object",
"properties": {
"name": {
"description": "A class label of the ontology term.",
"type": [
"string",
"null"
],
"examples": [
"energy storage technology"
],
"badge": "Platinum",
"title": "Subject Name"
},
"@id": {
"description": "A unique identifier (URI/IRI) of the ontology class.",
"type": [
"string",
"null"
],
"examples": [
"https://openenergyplatform.org/ontology/oeo/OEO_00020366"
],
"badge": "Platinum",
"title": "Subject Identifier",
"format": "uri"
}
},
"badge": "Platinum",
"title": "Subject"
},
"badge": "Platinum",
"title": "Subject"
},
"supplyGrid": {
"description": "A supply grid is a system of interconnected technical components that together enable the distribution and delivery of energy.",
"type": "array",
"items": {
"type": "object",
"properties": {
"name": {
"description": "A class label of the ontology term.",
"type": [
"string",
"null"
],
"examples": [
"supply grid"
],
"badge": "Platinum",
"title": "Subject Name"
},
"@id": {
"description": "A unique identifier (URI/IRI) of the ontology class.",
"type": [
"string",
"null"
],
"examples": [
"https://openenergyplatform.org/ontology/oeo/OEO_00000200"
],
"badge": "Platinum",
"title": "Subject Identifier",
"format": "uri"
}
},
"badge": "Platinum",
"title": "Subject"
},
"badge": "Platinum",
"title": "Subject"
},
"finalEnergyCarrier": {
"description": "A final energy carrier is an energy carrier that is delivered to and directly used by end users without further transformation.",
"type": "array",
"items": {
"type": "object",
"properties": {
"name": {
"description": "A class label of the ontology term.",
"type": [
"string",
"null"
],
"examples": [
"final energy carrier"
],
"badge": "Platinum",
"title": "Subject Name"
},
"@id": {
"description": "A unique identifier (URI/IRI) of the ontology class.",
"type": [
"string",
"null"
],
"examples": [
"https://openenergyplatform.org/ontology/oeo/OEO_00140080"
],
"badge": "Platinum",
"title": "Subject Identifier",
"format": "uri"
}
},
"badge": "Platinum",
"title": "Subject"
},
"badge": "Platinum",
"title": "Subject"
},
"demandSectors": {
"description": "An energy demand sector is a sector of the energy system that groups together energy consumers with similar usage characteristics.",
"type": "array",
"items": {
"type": "object",
"properties": {
"name": {
"description": "A class label of the ontology term.",
"type": [
"string",
"null"
],
"examples": [
"energy demand sector"
],
"badge": "Platinum",
"title": "Subject Name"
},
"@id": {
"description": "A unique identifier (URI/IRI) of the ontology class.",
"type": [
"string",
"null"
],
"examples": [
"https://openenergyplatform.org/ontology/oeo/OEO_00000128"
],
"badge": "Platinum",
"title": "Subject Identifier",
"format": "uri"
}
},
"badge": "Platinum",
"title": "Subject"
},
"badge": "Platinum",
"title": "Subject"
},
"moduleDescription": {
"description": "A description of the module. It should be usable as summary information for the module that is described by the metadata.",
"type": [
"string",
"null"
],
"examples": [
"Example module for an energy system dataset"
],
"badge": "Gold",
"title": "Context Title"
}
},
"badge": "Gold",
"title": "Context"
}
}
}
61 changes: 61 additions & 0 deletions oemetadata/v2/v21/build_source/scripts/create_example.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
from typing import Any, Dict, List, Union

from settings import (
EXAMPLE_MODULES_PATH,
EXAMPLE_PATH,
LOG_FORMAT,
RESOLVED_SCHEMA_FILE_NAME,
Expand Down Expand Up @@ -265,6 +266,63 @@ def replace_key_in_json(file_path, target_key, new_value):
logger.info(f"Key '{target_key}' not found in JSON file.")


def copy_example_with_modules(source_path, target_path):
"""
Copies a JSON example file and removes specified module/section keys from the copy.

Args:
source_path: Path to the source example.json
target_path: Path for the output example_module.json
"""
with open(source_path, encoding="utf-8") as file:
data = json.load(file)

with open(target_path, "w", encoding="utf-8") as file:
json.dump(data, file, ensure_ascii=False, indent=2)
file.write("\n")

logger.info(f"Copied '{source_path}' to '{target_path}'")


def remove_keys_from_json(data, keys_to_remove: list):
"""
Recursively removes all occurrences of the given keys from a JSON structure.

Args:
data: The JSON data (dict or list)
keys_to_remove: List of keys to remove
"""
if isinstance(data, dict):
for key in keys_to_remove:
if key in data:
del data[key]
logger.info(f"Removed keys: '{key}'")
for value in data.values():
remove_keys_from_json(value, keys_to_remove)
elif isinstance(data, list):
for item in data:
remove_keys_from_json(item, keys_to_remove)


def remove_modules_from_example(module_keys: list):
"""
Copies a JSON example file and removes specified module/section keys from the copy.

Args:
module_keys: List of top-level (or nested) keys to remove from the copy
"""
with open(EXAMPLE_PATH, encoding="utf-8") as file:
data = json.load(file)

remove_keys_from_json(data, module_keys)

with open(EXAMPLE_PATH, "w", encoding="utf-8") as file:
json.dump(data, file, ensure_ascii=False, indent=2)
file.write("\n")

logger.info(f"Removed modules: {module_keys}")


if __name__ == "__main__":
logger.info("Create OEMetadata Example from Schema.")
schema_filename = RESOLVED_SCHEMA_FILE_NAME
Expand All @@ -276,3 +334,6 @@ def replace_key_in_json(file_path, target_key, new_value):
example_contributors = read_schema(SCHEMA_EXAMPLE_PROV)
replace_key_in_json(EXAMPLE_PATH, "contributors", example_contributors)
test_oemetadata_schema_should_validate_oemetadata_example(json_data)

copy_example_with_modules(EXAMPLE_PATH, EXAMPLE_MODULES_PATH)
remove_modules_from_example(module_keys=["moduleEnergySystems"])
Loading
Loading