Skip to content

Add sector mapping CSV, sector_label/use rollout, and validation#3459

Merged
kndehaan merged 14 commits into
emissionsfrom
emissions-mapping
Jul 16, 2026
Merged

Add sector mapping CSV, sector_label/use rollout, and validation#3459
kndehaan merged 14 commits into
emissionsfrom
emissions-mapping

Conversation

@louispt1

@louispt1 louispt1 commented Jul 8, 2026

Copy link
Copy Markdown
Member

Context

  • config/sector_mapping.csv: the canonical mapping from ETM sector labels to external classification schemes (IPCC CRT codes, klimaattafels, national sectors).
  • sector_label attribute added across energy and molecule node files, joined by (sector_label, use); use also added/aligned on molecule nodes. Stale per-node emissions_* groups removed now that mapping supersedes them.
  • spec/sector_mapping_spec.rb: validates every labelled node's (sector_label, use) pair exists in the mapping, the join key (sector_label == slug(sector)_slug(subsector)) hasn't drifted, emissions-store coverage per mapping pair × GHG, scheme names don't collide with emissions-store sector keys, and a static scan of gqueries/inputs for literal SECTOR/MSECTOR/scheme-form EMISSIONS calls against unknown schemes or values.
  • Bumps Atlas to pick up Atlas::SectorMapping.

Note: The spec is failing currently, presumably due to a mismatch with the mock sector_mapping file.

Related

atlas
etengine
etsource

Checklist

  • I have tested these changes
  • I have updated documentation as needed
  • I have tagged the relevant people for review

@kndehaan

kndehaan commented Jul 9, 2026

Copy link
Copy Markdown
Member

Nice work! The mapping seems to generally work well.

I updated the sector_mapping.csv to represent the correct one. An important change here is the removal of the "klimaattafel" mapping, as we want to first implement the ipcc crt code mapping; the klimaattafel mapping will be added in a later increment.

I think now some parts of the ETSource spec don't work as they should anymore. Could you have a look and update this? I think it's best to use the ipcc_crt_code_agg instead. (Sorry for forgetting to tell you that Klimaattafel will be added in a later increment). Perhaps etengine and atlas need to be checked as well?

@kndehaan

kndehaan commented Jul 9, 2026

Copy link
Copy Markdown
Member

I found some issues when a value of the columns contains white spaces:
For example, SECTOR(emissions_subsector, "Steel") works well, but for Electricity and heat production it gives this error:

image

Or another error example:
image

So it's something about handling the blank spaces that needs some fixing. @louispt1 could you look into this?

@kndehaan

Copy link
Copy Markdown
Member

Seems to work well now! I'll make the PR official, and:

Tagging @noracato to review the spec
Tagging @mabijkerk for general review of the changed logic on the nodes and the mapping file

@kndehaan kndehaan requested review from mabijkerk and noracato July 15, 2026 14:01
@kndehaan kndehaan marked this pull request as ready for review July 15, 2026 14:01
Comment thread config/sector_mapping.csv

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why is this query change part of this PR?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

One of the changes meant that whitespaces are properly respected in GQL. It shouldn't matter for the queries, but changing this structure makes the whitespacing consistent across the GQL (same goes for the * 100 changes etc). Without this change queries like: #3459 (comment) would break

Comment thread config/sector_mapping.csv

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In this file, why is for Buildings, Households and Agriculture the aggregated code the same as the non-aggregated code? Shouldn't we use 1A4 there?

More generally, the ipcc_crt_code_agg feels a bit random. Why don't we have a breakdown like crt_code_1st_order, crt_code_2nd_order etc.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This column is needed to get the desired categories for the IPCC chart. We discussed before that it's desired to split out Households, Buildings, Agriculture from category 1.A.4, therefore this has been split the way it is in ipcc_crt_code_agg.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I suggest to discuss this briefly and add the suggested columns in the next increment where we'll be adding the IPCC chart and add IPCC columns to the data export.

Comment thread config/sector_mapping.csv
@kndehaan kndehaan force-pushed the emissions-mapping branch from c2d9fde to bb2976b Compare July 16, 2026 10:02
@kndehaan kndehaan merged commit aeeaa98 into emissions Jul 16, 2026
1 check passed
@kndehaan kndehaan deleted the emissions-mapping branch July 16, 2026 10:05
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants