IAMconsortium / common-definitions

Repository for definitions and mappings in model comparison projects
Creative Commons Zero v1.0 Universal
9 stars 22 forks source link

Tag in `components` doesn't get expanded by `nomenclature` #101

Closed korsbakken closed 2 months ago

korsbakken commented 3 months ago

This is really an issue with nomenclature and probably should be solved there, but affects a recent addition to this repo. The components property (for aggregation checking) that was added to the Emissions|{Level-1 Species} code in emissions.yaml don't work with nomenclature:

https://github.com/IAMconsortium/common-definitions/blob/013295a0257bf38210febc77a4a9016dcfbc25e4/definitions/variable/emissions/emissions.yaml#L5-L13

The problem is that the tag {Level-1 Species} does not get replaced with the species name when the yaml is parsed by nomenclature. Instead, e.g., the .flattened_dict of Emissions|CO2 looks like this`:

{'name': 'Emissions|CO2',
 'description': 'Emissions of carbon dioxide (CO2)',
 'file': 'variable/emissions/emissions.yaml',
 'unit': 'Mt CO2/yr',
 'components': ['Emissions|{Level-1 Species}|AFOLU',
  'Emissions|{Level-1 Species}|Energy',
  'Emissions|{Level-1 Species}|Industrial Processes',
  'Emissions|{Level-1 Species}|Waste',
  'Emissions|{Level-1 Species}|Other']}

I think the issue here is that nomenclature only expands tags in attributes that are plain str objects. It doesn't descend into list attributes. Which probably should be fixed. I will try to file an issue in the nomenclature repository later today.

danielhuppmann commented 3 months ago

There is already an issue in the nomenclature repo, see https://github.com/IAMconsortium/nomenclature/issues/342. Just too many things on the to-do list, PR to get started would be very much appreciated.

korsbakken commented 3 months ago

I have submitted a PR in the nomenclature repository now, PR 352.

danielhuppmann commented 2 months ago

Closing as implemented in the nomenclature package.