Skip to content

Commit

Permalink
Reorg
Browse files Browse the repository at this point in the history
  • Loading branch information
cmutel committed Oct 9, 2024
1 parent 4623d3a commit f761925
Show file tree
Hide file tree
Showing 17 changed files with 168 additions and 53 deletions.
2 changes: 1 addition & 1 deletion sentier_vocab/custom_products.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
from rdflib import Graph, Namespace, URIRef
from sentier_vocab.graph_base import GraphBase
from sentier_vocab.data.custom_products import CUSTOM_PRODUCTS_DATA
from sentier_vocab.data.input.custom_products import CUSTOM_PRODUCTS_DATA
from rdflib.namespace import RDFS, SKOS, RDF
import skosify
from loguru import logger
Expand Down
2 changes: 1 addition & 1 deletion sentier_vocab/graph_base.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

from sentier_vocab.utils import DEFAULT_DATA_DIR, GithubZipfileRelease

vocab_data_dir = Path(__file__).parent / "data"
vocab_data_dir = Path(__file__).parent / "output"


class GraphBase:
Expand Down
Empty file added sentier_vocab/input/__init__.py
Empty file.
Original file line number Diff line number Diff line change
Expand Up @@ -104,4 +104,57 @@
SKOS.related,
URIRef("https://en.wikipedia.org/wiki/Solid_oxide_electrolyzer_cell")
),
# Missing from Combined Nomenclature
# tetraflouroethylene, not poly-
(
URIRef(PRODUCTS + "tetrafluoroethylene"),
RDF.type,
SKOS.Concept
),
(
URIRef(PRODUCTS + "tetrafluoroethylene"),
SKOS.broader,
URIRef("http://data.europa.eu/xsp/cn2024/290349000080")
),
(
URIRef(PRODUCTS + "tetrafluoroethylene"),
SKOS.prefLabel,
Literal("Tetrafluoroethylene", lang="en")
),
(
URIRef(PRODUCTS + "tetrafluoroethylene"),
SKOS.related,
URIRef("https://en.wikipedia.org/wiki/Tetrafluoroethylene")
),
(
URIRef(PRODUCTS + "tetrafluoroethylene"),
SKOS.definition,
Literal("Tetrafluoroethylene (TFE) is a fluorocarbon with the chemical formula C2F4. It is the simplest perfluorinated alkene. This gaseous species is used primarily in the industrial preparation of fluoropolymers (from Wikipedia)", lang="en")
),
# Zeolite
(
URIRef(PRODUCTS + "zeolite"),
RDF.type,
SKOS.Concept
),
(
URIRef(PRODUCTS + "zeolite"),
SKOS.broader,
URIRef("http://data.europa.eu/xsp/cn2024/382400000080")
),
(
URIRef(PRODUCTS + "zeolite"),
SKOS.prefLabel,
Literal("Zeolite", lang="en")
),
(
URIRef(PRODUCTS + "zeolite"),
SKOS.related,
URIRef("https://en.wikipedia.org/wiki/Zeolite")
),
(
URIRef(PRODUCTS + "zeolite"),
SKOS.definition,
Literal("Zeolite is a family of several microporous, crystalline aluminosilicate materials commonly used as commercial adsorbents and catalysts (from Wikipedia)", lang="en")
),
]
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,13 @@
qudt:hasQuantityKind <https://vocab.sentier.dev/units/quantity-kind/Time> ;
skos:definition "Product lifetime is the time interval from when a product is sold to when it is discarded."@en .

<https://vocab.sentier.dev/model-terms/electrolyser/capacity_factor> a skos:Concept ;
skos:inScheme <https://vocab.sentier.dev/model-terms/generic> ;
skos:related <https://en.wikipedia.org/wiki/Capacity_factor> ;
skos:prefLabel "Capacity factor"@en ;
qudt:hasQuantityKind <https://vocab.sentier.dev/units/unit/FRACTION> ;
skos:definition "Ratio of actual output to potential output considering availability constraints."@en .

# Energy production and consumption

<https://vocab.sentier.dev/model-terms/energy> a skos:ConceptScheme ;
Expand Down Expand Up @@ -171,6 +178,21 @@
qudt:hasQuantityKind <https://vocab.sentier.dev/units/quantity-kind/Temperature> ;
skos:definition "The maximum allowed temperature in the immediate environment of the electrolyser for successful operation"@en .

<https://vocab.sentier.dev/model-terms/electrolyser/stack> a skos:Concept ;
skos:broader <https://vocab.sentier.dev/products/electrolyzer> ;
skos:inScheme <https://vocab.sentier.dev/model-terms/electrolyzer> ;
skos:prefLabel "Stack (electrolyser)"@en-GB ;
skos:prefLabel "Stack (electrolyzer)"@en-US ;
qudt:hasQuantityKind <https://vocab.sentier.dev/units/quantity-kind/Power> ;
skos:definition "Multiple electrolysis cells connected together form the electrolyser stack"@en .

<https://vocab.sentier.dev/model-terms/electrolyser/balance_of_plant> a skos:Concept ;
skos:broader <https://vocab.sentier.dev/products/electrolyzer> ;
skos:inScheme <https://vocab.sentier.dev/model-terms/electrolyzer> ;
skos:prefLabel "Balance of Plant"@en ;
qudt:hasQuantityKind <https://vocab.sentier.dev/units/quantity-kind/Power> ;
skos:definition "The other components of an electrolyser other than the stack. Usually less costly and has a longer lifetime."@en .

<https://vocab.sentier.dev/model-terms/electrolyser/min_stack_temp> a skos:Concept ;
skos:inScheme <https://vocab.sentier.dev/model-terms/electrolyzer> ;
skos:prefLabel "Minimum stack temperature"@en ;
Expand Down
File renamed without changes.
File renamed without changes.
4 changes: 2 additions & 2 deletions sentier_vocab/model_terms.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
from loguru import logger
from rdflib import Graph

filepath = Path(__file__).parent / "data" / "model-terms.ttl"
filepath = Path(__file__).parent / "input" / "model-terms.ttl"


def ModelTerms():
Expand All @@ -15,7 +15,7 @@ def ModelTerms():
skosify.infer.skos_hierarchical(graph, narrower=True)
skosify.infer.skos_transitive(graph, narrower=True)

output_path = filepath.with_suffix(".reciprocal.ttl")
output_path = Path(__file__).parent / "output" / "model-terms.reciprocal.ttl"
logger.info("Writing output TTL file {}", output_path)
graph.serialize(destination=output_path)
return filepath.with_suffix(".ttl")
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,25 @@
@prefix skos: <http://www.w3.org/2004/02/skos/core#> .

<http://data.europa.eu/xsp/cn2024/290349000080> skos:narrower <https://vocab.sentier.dev/products/tetrafluoroethylene> ;
skos:narrowerTransitive <https://vocab.sentier.dev/products/tetrafluoroethylene> .

<http://data.europa.eu/xsp/cn2024/382400000080> skos:narrower <https://vocab.sentier.dev/products/zeolite> ;
skos:narrowerTransitive <https://vocab.sentier.dev/products/zeolite> .

<https://vocab.sentier.dev/products/tetrafluoroethylene> a skos:Concept ;
skos:broader <http://data.europa.eu/xsp/cn2024/290349000080> ;
skos:broaderTransitive <http://data.europa.eu/xsp/cn2024/290349000080> ;
skos:definition "Tetrafluoroethylene (TFE) is a fluorocarbon with the chemical formula C2F4. It is the simplest perfluorinated alkene. This gaseous species is used primarily in the industrial preparation of fluoropolymers (from Wikipedia)"@en ;
skos:prefLabel "Tetrafluoroethylene"@en ;
skos:related <https://en.wikipedia.org/wiki/Tetrafluoroethylene> .

<https://vocab.sentier.dev/products/zeolite> a skos:Concept ;
skos:broader <http://data.europa.eu/xsp/cn2024/382400000080> ;
skos:broaderTransitive <http://data.europa.eu/xsp/cn2024/382400000080> ;
skos:definition "Zeolite is a family of several microporous, crystalline aluminosilicate materials commonly used as commercial adsorbents and catalysts (from Wikipedia)"@en ;
skos:prefLabel "Zeolite"@en ;
skos:related <https://en.wikipedia.org/wiki/Zeolite> .

<https://vocab.sentier.dev/products/aec-electrolyzer> a skos:Concept ;
skos:broader <https://vocab.sentier.dev/products/electrolyzer> ;
skos:broaderTransitive <http://data.europa.eu/xsp/cn2024/854330700080>,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,13 @@
@prefix skos: <http://www.w3.org/2004/02/skos/core#> .
@prefix xsd: <http://www.w3.org/2001/XMLSchema#> .

<https://vocab.sentier.dev/model-terms/electrolyser/capacity_factor> a skos:Concept ;
qudt:hasQuantityKind <https://vocab.sentier.dev/units/unit/FRACTION> ;
skos:definition "Ratio of actual output to potential output considering availability constraints."@en ;
skos:inScheme <https://vocab.sentier.dev/model-terms/generic> ;
skos:prefLabel "Capacity factor"@en ;
skos:related <https://en.wikipedia.org/wiki/Capacity_factor> .

<https://vocab.sentier.dev/model-terms/electrolyser/h2_pressure> a skos:Concept ;
qudt:hasQuantityKind <https://vocab.sentier.dev/units/quantity-kind/Pressure> ;
skos:definition "The pressure of the hydrogen produced by the electrolyser."@en ;
Expand Down Expand Up @@ -141,6 +148,23 @@
skos:prefLabel "Electrolyser terms"@en-GB,
"Electrolyzer terms"@en-US .

<https://vocab.sentier.dev/model-terms/electrolyser/balance_of_plant> a skos:Concept ;
qudt:hasQuantityKind <https://vocab.sentier.dev/units/quantity-kind/Power> ;
skos:broader <https://vocab.sentier.dev/products/electrolyzer> ;
skos:broaderTransitive <https://vocab.sentier.dev/products/electrolyzer> ;
skos:definition "The other components of an electrolyser other than the stack. Usually less costly and has a longer lifetime."@en ;
skos:inScheme <https://vocab.sentier.dev/model-terms/electrolyzer> ;
skos:prefLabel "Balance of Plant"@en .

<https://vocab.sentier.dev/model-terms/electrolyser/stack> a skos:Concept ;
qudt:hasQuantityKind <https://vocab.sentier.dev/units/quantity-kind/Power> ;
skos:broader <https://vocab.sentier.dev/products/electrolyzer> ;
skos:broaderTransitive <https://vocab.sentier.dev/products/electrolyzer> ;
skos:definition "Multiple electrolysis cells connected together form the electrolyser stack"@en ;
skos:inScheme <https://vocab.sentier.dev/model-terms/electrolyzer> ;
skos:prefLabel "Stack (electrolyser)"@en-GB,
"Stack (electrolyzer)"@en-US .

<https://vocab.sentier.dev/model-terms/energy/elec_energy_serv_dem> a skos:Concept ;
skos:broader <http://openenergy-platform.org/ontology/oeo/OEO_00240024> ;
skos:broaderTransitive <http://openenergy-platform.org/ontology/oeo/OEO_00240024> ;
Expand Down Expand Up @@ -194,6 +218,11 @@
<https://vocab.sentier.dev/model-terms/energy/therm_energy_serv_dem> ;
skos:prefLabel "energy service demand"@en .

<https://vocab.sentier.dev/products/electrolyzer> skos:narrower <https://vocab.sentier.dev/model-terms/electrolyser/balance_of_plant>,
<https://vocab.sentier.dev/model-terms/electrolyser/stack> ;
skos:narrowerTransitive <https://vocab.sentier.dev/model-terms/electrolyser/balance_of_plant>,
<https://vocab.sentier.dev/model-terms/electrolyser/stack> .

<https://vocab.sentier.dev/model-terms/generic> a skos:ConceptScheme ;
dcterms:contributor "Chris Mutel" ;
dcterms:created "2024-10-07"^^xsd:date ;
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
42 changes: 40 additions & 2 deletions sentier_vocab/qudt.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
QK = QUDTV.quantitykind


vocab_data_dir = Path(__file__).parent / "data"
vocab_data_dir = Path(__file__).parent / "input"
selected_fp = vocab_data_dir / "selected-quantity-kinds.json"
extra_concepts_data = vocab_data_dir / "extra-data.ttl"
qudt_patches_data = vocab_data_dir / "qudt-patches.ttl"
Expand Down Expand Up @@ -79,7 +79,7 @@ def write_graph(
if not filename.endswith(".ttl"):
filename += ".ttl"
if not dirpath:
dirpath = vocab_data_dir
dirpath = Path(__file__).parent / "output"
output_fp = Path(dirpath) / filename
self.graph.serialize(destination=output_fp)
return output_fp
Expand Down Expand Up @@ -338,5 +338,43 @@ def add_unit(self, uri: URIRef, unit_graph: Graph, cs: URIRef, qudt_uri: URIRef)
pass


def add_quantity_kinds_to_graph(
input_ttl: Path,
qudt_ttl: Path,
) -> Path:
"""
The `input_ttl` concept scheme was written by hand (!), but we can make it more useful by
positioning each input concept in the QUDT quantity kind hierarchy.
"""
output_ttl = input_ttl.with_suffix(".supplemented" + input_ttl.suffix)
input_graph = Graph().parse(input_ttl)
qudt = Graph().parse(qudt_ttl)

qudt_qk_mapping = {
s: o
for s, v, o in qudt.triples((None, QUDTS.hasQuantityKind, None))
if o.startswith("https://vocab.sentier.dev/units/quantity-kind/")
and s.startswith("https://vocab.sentier.dev/units/unit/")
}
qudt_d_mapping = {
s: o
for s, v, o in qudt.triples((None, QUDTS.hasDimensionVector, None))
if o.startswith("http://qudt.org/vocab/dimensionvector/")
and s.startswith("https://vocab.sentier.dev/units/unit/")
}

for s, v, o in input_graph.triples((None, SKOS.exactMatch, None)):
if o.startswith("https://vocab.sentier.dev/units/unit/"):
input_graph.add((s, QUDTS.hasQuantityKind, qudt_qk_mapping[o]))
input_graph.add((s, QUDTS.hasDimensionVector, qudt_d_mapping[o]))

input_graph.serialize(destination=output_ttl)
return output_ttl


if __name__ == "__main__":
QUDT().write_graph()
add_quantity_kinds_to_graph(
Path(__file__).parent / "input" / "simapro.ttl",
Path(__file__).parent / "output" / "qudt-sentier-dev.ttl"
)
47 changes: 0 additions & 47 deletions sentier_vocab/supplements.py

This file was deleted.

0 comments on commit f761925

Please sign in to comment.