OSeMOSYS / osemosys2iamc

MIT License
3 stars 11 forks source link

Addressing Emission results conversion and region hard coded extraction #31

Closed genius487 closed 1 year ago

genius487 commented 1 year ago

Good day. Here is a summary of my changes.

My config that I used testing is here

genius487 commented 1 year ago

@willu47 Thanks so much for the feedback. I amended the workflow by using the python package you suggested. Also, this is now a partial solution of the region hard coding as the iso2 or iso3 codes can be located anywhere in the technology or fuel name and converted to the full name of the country. Kindly inform if this is satisfactory.

willu47 commented 1 year ago

@willu47 Thanks so much for the feedback. I amended the workflow by using the Python package you suggested. Also, this is now a partial solution of the region hard coding as the iso2 or iso3 codes can be located anywhere in the technology or fuel name and converted to the full name of the country. Kindly inform if this is satisfactory.

This looks good.

I think you should add some tests for the iso2country method. Take a look in the tests/ folder and create a new test function in test_resultify.py.

I would be interested in a few corner cases such as:

NGNGA2 - natural gas technology in Nigeria (iso2) DENGA2 - natural gas technology in Germany NGKENGX - export of natural gas from Nigeria to Kenya NGANGA - natural gas technology in Nigeria (iso3) ZXNGA - country code does not exist natural gas technology 'strat', 'ned' - misspelt arguments should raise a ValueError() -1, 22 - position number negative or larger than string should raise a ValueError()

You can run the tests with pytest

genius487 commented 1 year ago

@willu47 I've added some tests, and renamed the function to iso_to_country for deeper clarity. A position larger than the string's length isn't intended to raise an error in order to accommodate a list of name with varying name length. Instead, an empty string is returned and a message notifying the failure to find the code is displayed for the user.