TEC Toolkit

Transparent Emissions Calculations (TEC) Toolkit.

Back to main page

Getting started

In this page we provide an overview of the entry points for using the TEC-Toolkit resources. ECFO and PECO ontologies may be used together or separately. For example, the Emissions Conversion Factors KG uses ECFO and can be used as a lookup database of conversion factors (see how below).

PECO may be used to describe the emission calculation process, which typically also involves the conversion factors and hence the combination of PECO and ECFO may be desired. Semantic Machine Learning Impact calculator is a prototype software that demonstrates how PECO and Emissions Conversion Factors KG can be embedded within a web-based application see how can you download a PECO trace.

For further information on ECFO and PECO follow the w3id link that will let you download the ontologies and/or view the online documentation.

Please see the SMLI Calculator for a link to online demo and source code to further explore how the individual components of the TEC toolkit might be integrated in a software application.

Retrieve an Emission Conversion Factor (ECF) Metadata

The simplest way of browsing the metadata of an emission factor is just pasting its URI in a browser. For example, https://w3id.org/ecfkg/i/UK/BEIS/2019/CF_1 will take you to an online page like this one:

RDF explorer

where you can see the units, value and source (among others) of the emission conversion factor. However, how to get to the ECF URI? One way of doing it is using SPARQL queries. We have set up a simple SPARQL query interface where you can create SPARQL queries and retrieve the IDs of the ECFs you may be interested in. For example, to retrieve ECFs related to “CNG” (compressed natural gas) to CO2e (in kg) and within Scope 1, just issue the following query:

PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>
PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>
PREFIX ecfo: <https://w3id.org/ecfo#>
prefix qudt: <http://qudt.org/schema/qudt/>

SELECT ?context ?cf ?s ?t
WHERE {
    ?cf ecfo:hasTag ?tag;
        ecfo:hasEmissionSource ?s;
        ecfo:hasEmissionTarget ?t;
        ecfo:hasTargetUnit ?tu;
    ecfo:hasScope <https://w3id.org/ecfo#Scope1>.
    ?tag rdfs:label "CNG"@en.
    ?t rdfs:label "carbon dioxide equivalent"@en .
    ?tu qudt:abbreviation "kg"@en.
   OPTIONAL {
     ?cf <https://w3id.org/ecfo#hasAdditionalContext> ?context
   }
}

The results will include several ECFs, make sure you read their details before selecting the one of interest. For example two of the results include:

{
    "context": {
        "type": "literal",
        "xml:lang": "en",
        "value": "Energy - Gross CV"
    },
    "cf": {
        "type": "uri",
        "value": "https://w3id.org/ecfkg/i/UK/BEIS/2019/CF_1"
    },
    "s": {
        "type": "uri",
        "value": "https://w3id.org/ecfkg/i/Gaseous_fuels_CNG"
    },
    "t": {
        "type": "uri",
        "value": "http://www.wikidata.org/entity/Q1933140"
    }
}

{
    "context": {
        "type": "literal",
        "xml:lang": "en",
        "value": "Tonnes"
    },
    "cf": {
        "type": "uri",
        "value": "https://w3id.org/ecfkg/i/UK/BEIS/2019/CF_13"
    },
    "s": {
        "type": "uri",
        "value": "https://w3id.org/ecfkg/i/Gaseous_fuels_CNG"
    },
    "t": {
        "type": "uri",
        "value": "http://www.wikidata.org/entity/Q1933140"
    }
}

Note that these include conversion factors as indicated with two different contexts: one includes the Gross Calorific Value, while the other includes the Net Calorific Value.

The following query gets all the ECF values throughout the availbale years (2016-2022):

PREFIX rdf:  <http://www.w3.org/1999/02/22-rdf-syntax-ns#>
PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>
PREFIX ecfo: <https://w3id.org/ecfo#>
PREFIX qudt: <http://qudt.org/schema/qudt/>
PREFIX time: <http://www.w3.org/2006/time#>

SELECT ?cf ?value ?start ?end ?context
WHERE {
    ?cf ecfo:hasTag ?tag;
        ecfo:hasEmissionTarget ?t;
        ecfo:hasTargetUnit ?tu;
        ecfo:hasAdditionalContext ?context;
        rdf:value ?value;
        ecfo:hasScope ecfo:Scope1;
        ecfo:hasApplicablePeriod ?period.
    ?tag rdfs:label "CNG"@en.
    ?t rdfs:label "carbon dioxide equivalent"@en.
    ?tu qudt:abbreviation "kg"@en.
    ?period time:hasBeginning/time:inXSDDate ?start;
            time:hasEnd/time:inXSDDate ?end.
}

Plotting the evolution of an Emission Conversion Factor

Once we have retrieved the values of the ECF of interest, we can easily plot the results. The following image shows the variation for CNG to CO2e from 2016-2022 for both Gross and Net CV. Please note that we have adjusted the axis to show the differences, since the variation of this particular ECF is minimal:

CNG ECF chart

All these queries and plot are available in a Jupyter notebook in our cfkg repository.

PECO trace

For example, this query will retrieve the emission score and the activity for which this score was calculated:

PREFIX peco: <https://w3id.org/peco#>
PREFIX qudt: <http://qudt.org/schema/qudt/>
PREFIX rdf:  <http://www.w3.org/1999/02/22-rdf-syntax-ns#>
PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>

SELECT ?activityL ?score
WHERE {
    ?activity  rdf:type   peco:EmissionGenerationActivity ;
               rdfs:label ?activityL;
               peco:hasEmissionScore/qudt:value ?score.
}

Ontologies

The Emission Conversion Factor Ontology (ECFO)

ECFO Logo

Available at: https://w3id.org/ecfo

Evaluation & Examples: CQs and SPARQL queries

Aims to provide a generic model for describing the values of Emission Conversion Factors and their associated metadata.

ECFO
The main entities of ECFO ontology. Legend: solid ellipse → class in our ontologies, dashed ellipse → class in external ontologies, dashed rectangle → RDFS `Datatype`, arrow → property.

The Provenance of Emission Calculations Ontology (PECO)

PECO Logo

Available at: https://w3id.org/peco

Evaluation & Examples: CQs and SPARQL queries

Defines a vocabulary for describing provenance traces of carbon emissions calculations by capturing the quantifiable measurements of energy estimates (i.e., activity data and emission conversion factors used to estimate the carbon emissions).

PECO
The main entities of PECO ontology. Legend: solid ellipse → class in our ontologies, dashed ellipse → class in external ontologies, dashed rectangle → RDFS `Datatype`, solid arrow → property, dashed arrow → RDFS `subClassOf`.

Emissions Conversion Factors KG

In the following, we outline the Emission Conversion Factors described using ECFO.

BEIS (UK)

Official list of emission conversion factors for use by UK and international organisations to report on greenhouse gas.

Year Number of CFs
2022 6464
2021 6284
2020 6140
2019 6163
2018 6192
2017 6178
2016 4977

MLI

A collection of Scope 2 electricity emission conversion factors from a range of sources.

Year Number of CFs
2002 -2019 81

Software

SMLI Calculator

The Semantic Machine Learning Impact Calculator is an extension of the Machine learning Impact (MLI) calculator with semantic components to perform the emission calculations.

SMLI Demo

An online demo can be found at this link.

(Please note that currently only Chromium-based browsers are supported)

How it works

SMLI Calculator queries the live ECFO KG to retrieve the information about the available conversion factors that match the user input.

An example call to Java-based backend that queries the ECFO KG for corresponding conversion factors:

fetch("/cf_info_all?region=" + region)
    .then((response) =>
      response.json()
    )
    .then((CF_data) =>
      { [...] }
    )

A SPARQL query executed to retrieve conversion factors for a specific region of compute:

PREFIX  ecfo: <https://w3id.org/ecfo#>
PREFIX  geo:   <http://www.opengis.net/ont/geosparql#>
PREFIX  prov: <http://www.w3.org/ns/prov#>
PREFIX  qudt: <http://qudt.org/schema/qudt/>
PREFIX  rdf:   <http://www.w3.org/1999/02/22-rdf-syntax-ns#>
PREFIX  rdfs: <http://www.w3.org/2000/01/rdf-schema#>
PREFIX  time: <http://www.w3.org/2006/time#>

SELECT DISTINCT ?id ?sourceUnit ?targetUnit ?source ?value ?applicableLocation ?applicablePeriodStart ?applicablePeriodEnd ?emissionTargetSymbol
WHERE {
  ?id       rdf:type            ecfo:EmissionConversionFactor ;
              ecfo:hasTargetUnit  ?targetUnitInst .
    ?targetUnitInst
              rdfs:label          "kilogram"@en .
    ?id ecfo:hasEmissionTarget/rdfs:label ?emissionTargetSymbol
      { ?id ecfo:hasApplicableLocation/rdfs:label "europe-west2"@en }
    UNION
      { ?id (ecfo:hasApplicableLocation/geo:ehContains)/rdfs:label "europe-west2"@en .
        ?id  ecfo:hasScope         ecfo:Scope2 ;
             ecfo:hasTag           <https://w3id.org/ecfkg/i/UK%20electricity> ;
             ecfo:hasEmissionTarget  <http://www.wikidata.org/entity/Q1933140>
      }
    OPTIONAL
      { ?id  ecfo:hasSourceUnit  ?sourceUnitInst }
    OPTIONAL
      { ?id  ecfo:hasApplicableLocation  ?location }
    OPTIONAL
      { ?id (ecfo:hasApplicablePeriod/time:hasBeginning)/time:inXSDDate ?applicablePeriodStart }
    OPTIONAL
      { ?id (ecfo:hasApplicablePeriod/time:hasEnd)/time:inXSDDate ?applicablePeriodEnd }
    OPTIONAL
      { ?id  prov:wasDerivedFrom  ?source }
    OPTIONAL
      { ?id  rdf:value  ?value }
    OPTIONAL
      { ?location  rdfs:label  ?applicableLocation }
    OPTIONAL
      { ?targetUnitInst qudt:abbreviation  ?targetUnit }
    OPTIONAL
      { ?sourceUnitInst qudt:abbreviation  ?sourceUnit }
  }
ORDER BY DESC(?applicablePeriodEnd)

The calculator also produces JSON-LD descriptions of provenance traces documenting the individual steps of emissions calculation process. JSON-LD context and set of custom JavaScript Functions are used to query ECFO KG to retrieve the information about the Emission Conversion Factors and to generate portion of the provenance trace.

Together with the calculated emission score, the GUI also shows detailed information about the activities performed during the calculation process, the conversion factor used and other relevant conversion factors that are applicable to the user input:

Result

An example of generating description of activity with a connected input entity in the code that calculates the emissions:

let wattConsumption = createCalculationEntity("Watt Consumption", state.gpus[gpu].watt, "http://www.wikidata.org/entity/Q25236", "http://www.wikidata.org/entity/Q1053879", graphLD, "")

let electricityUseEstimate = createCalculationActivity("https://github.com/TEC-Toolkit/Semantic_Machine_Learning_Impact_Calculator", "Estimate Electricity Use in kW/h", graphLD)

linkInputEntityToActivity(wattConsumption, electricityUseEstimate, graphLD)

The calculator also executes a number of validation queries, for example, to check if the latest available conversion factor is up-to-date:

PREFIX  ecfo: <https://w3id.org/ecfo#>
PREFIX  peco: <https://w3id.org/peco#>
PREFIX  prov: <http://www.w3.org/ns/prov#>
PREFIX  rdf:  <http://www.w3.org/1999/02/22-rdf-syntax-ns#>
PREFIX  time: <http://www.w3.org/2006/time#>

SELECT DISTINCT  ?cf ?cf_value ?time
WHERE {
  ?entity  rdf:type  peco:EmissionScore .
  ?entity prov:wasGeneratedBy/prov:used ?cf .
  ?cf (ecfo:hasApplicablePeriod/time:hasEnd)/time:inXSDDate ?time .
  ?cf  rdf:value  ?cf_value
  FILTER ( ?time < now() )
}

The results are presented in the GUI:

Validation

The provenance trace can be also downloaded by the user:

Download trace

For expanded example of provenance trace and additional queries please see our competency questions.

Data Validation

The Data Validation component runs Datalog rules to detect violations of conditions according to ECFO.

Functionalities

Check if the data are “valid”

  1. Run the data validation module
  2. Check that all queries have 0 answers

Add another validation check

  1. Add a file “check-CUSTOM_NAME-rules” with the rules to check
  2. Add a file “check-CUSTOM_NAME-queries” with the ASK queries
    • Note that the queries must return no answer if the check is passed
  3. Add a new command exec check CUSTOM_NAME in the “validate” file

Back to main page