Skip to content

Emissions GQL, load and cache from etsource#1727

Draft
noracato wants to merge 3 commits intomasterfrom
emissions-gql
Draft

Emissions GQL, load and cache from etsource#1727
noracato wants to merge 3 commits intomasterfrom
emissions-gql

Conversation

@noracato
Copy link
Copy Markdown
Member

Introduces a new Qernel::Emissions class, containing hashed keys for getting and setting emissions from the new emissions.csv, for each dataset in ETSource.

It mimicks the behaviour of Qernel::Area in the sense of area_attributes. However, emissions can be queried by a sector scope.

Examples

# Get 1990 emissions
EMISSIONS(households, co2, 1990) => 2506777
# Get start year emissions
EMISSIONS('industry.metal', ghg)     => 20778881

# Set value for ghg for a sector (not possible for 1990)
UPDATE(EMISSION(households), ghg, VALUE )
# Set value for co2 for a sector with a subsector (not possible for 1990)
UPDATE(EMISSION('industry.metal'), co2, VALUE )

Still to do:

  • specs are missing for Qernel::Emissions

@noracato noracato requested a review from louispt1 March 31, 2026 16:02
@louispt1
Copy link
Copy Markdown
Member

louispt1 commented Apr 1, 2026

Based on the altered csv structure, I've updated the branch slightly - I will explain further online @noracato but basically the input csvs were split into two separate csvs and the column structure was altered slightly.

There is a slight functional difference in that you need to now specify energetic/non_energetic as 'type':

# Get 1990 emissions
EMISSIONS(households, energetic, co2, 1990) => 2506777
# Get start year emissions
EMISSIONS('industry.metal', energetic, ghg)     => 20778881

# Set value for ghg for a sector (not possible for 1990)
UPDATE(EMISSION(households), energetic, ghg, VALUE )
# Set value for co2 for a sector with a subsector (not possible for 1990)
UPDATE(EMISSION('industry.metal'), energetic, co2, VALUE )

I also added a lot of spec - there are a couple of TODOs where I wasn't sure whether returning an error or nil was better.

The fixtures have been updated to match the expected input from etsource, and I also tested using those fixtures in etsource and sandboxing results, which worked well. Ideally the fixtures would end up with a few more values and we can adjust the expectations in the spec at that point.

Copy link
Copy Markdown
Member Author

noracato commented Apr 2, 2026

Let's discuss this as well.

Copy link
Copy Markdown
Member

louispt1 commented Apr 2, 2026

Let me know when you have time 👍

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.

2 participants