Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Universal currency conversion #1319

Open
wants to merge 22 commits into
base: main
Choose a base branch
from

Conversation

danielelerede-oet
Copy link
Contributor

@danielelerede-oet danielelerede-oet commented Jan 23, 2025

Changes proposed in this Pull Request

Hi, @finozzifa and I have been working on universal currency conversion.

In this PR, universal currency conversion is introduced taking advantage of the Currency_Converter package.
Currently, the only allowed conversion adopts a fixed USD to EUR exchange rate for the year 2013. Here, any currency among those in the list at https://github.com/alexprengere/currencyconverter/blob/master/currency_converter/eurofxref.csv may be introduced in the PyPSA-Earth input dataset and converted into the output_currency specified in the config file under costs according to the specified currency_year for each investment, FOM and VOM cost (the adopted conversion factor will correspond to the yearly average for the specified currency_year, according to the get_yearly_currency_exchange_average in _helpers.py).

Additionally, in this way results can be obtained in any currency the user prefers (according to the specification of output_currency) - EUR is set as default as it is in the current PyPSA-Earth.

The only caveat at the moment is that cost units must be specified via code (i.e., USD, EUR, etc. instead of $, €). That is not an issue as the current technology_data output files only contain codes, but a PR will be also raised to technology_data to address the conversion from symbol to code, if necessary (something similar is already there now, but only acts on some input data).

Checklist

  • I consent to the release of this PR's code under the AGPLv3 license and non-code contributions under CC0-1.0 and CC-BY-4.0.
  • I tested my contribution locally and it seems to work fine.
  • Code and workflow changes are sufficiently documented.
  • Newly introduced dependencies are added to envs/environment.yaml and doc/requirements.txt.
  • Changes in configuration options are added in all of config.default.yaml and config.tutorial.yaml.
  • Add a test config or line additions to test/ (note tests are changing the config.tutorial.yaml)
  • Changes in configuration options are also documented in doc/configtables/*.csv and line references are adjusted in doc/configuration.rst and doc/tutorial.rst.
  • A note for the release notes doc/release_notes.rst is amended in the format of previous release notes, including reference to the requested PR.

@danielelerede-oet danielelerede-oet marked this pull request as ready for review January 28, 2025 17:44
Copy link
Member

@ekatef ekatef left a comment

Choose a reason for hiding this comment

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

Hello @danielelerede-oet, thank you for the great contribution!

Looks really nice, and will be definitely very helpful. Have added a couple of quick comments which mainly relate to the maintenance part. Could you please have a look?

Comment on lines 26 to 27
* Introduce universal currency conversion

Copy link
Member

Choose a reason for hiding this comment

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

It would be great to adjust the note formatting to match the format of the others for consistency

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Sure, done! :)

@@ -89,3 +89,4 @@ dependencies:
- git+https://github.com/davide-f/google-drive-downloader@master # google drive with fix for virus scan
- chaospy # lastest version only available on pip
- fake_useragent
- currencyconverter
Copy link
Member

Choose a reason for hiding this comment

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

Have there been any particular reasons to use pip distribution? As discussed, pip can easily lead to the dependencies conflicts and must be avoided

Copy link
Member

Choose a reason for hiding this comment

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

As a follow-up of our discussion, a requirement to have conda installation is by no means ultimative and can be also managed on the maintenance side if there is no other way around 🙂

@@ -575,6 +575,7 @@ dependencies:
- zstd=1.5.6
- pip:
- chaospy==4.3.17
- currencyconverter==0.17.30
Copy link
Member

Choose a reason for hiding this comment

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

Note please that pinned environments are being automatically updated (e.g. #1321 is an example of an automated PR which fixes this issue). So, luckily there is no need for manual changes

@@ -503,6 +503,7 @@ dependencies:
- zstd=1.5.6
- pip:
- chaospy==4.3.17
- currencyconverter==0.17.30
Copy link
Member

Choose a reason for hiding this comment

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

Same comment as above: no need for manual changes

@@ -502,6 +502,7 @@ dependencies:
- zstd=1.5.6
- pip:
- chaospy==4.3.17
- currencyconverter==0.17.30
Copy link
Member

Choose a reason for hiding this comment

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

Same comment as above: no need for manual changes

@danielelerede-oet
Copy link
Contributor Author

The changes in data/costs.csv are needed to align results of the tests with the previous version. I added the "further description" header to uniform with the standard structure of cost files from technology-data while currency_year is set to 2013 as it's only used for the conversion of USD2013 to EUR2013, thus it only acts on hydrogen storage tank, battery inverter and battery storage.

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.

3 participants